ID:2692544
 
(See the best response by Kaiochao.)
Okay so Im trying to make it so when someone clicks on a persons name in the chat, it brings up that users profile.

Here is my code for defining the topic.
client
Topic(href,href_list[],hsrc)
switch(href_list["action"])
if("showprofile")
usr.ShowNewProfile(M)


and here is the code to display it in the chat

world << {"<b>\icon[new/obj/active]([time2text(world.realtime,"hh:mm")]) <font color =#F6F613><a href='?src=\ref[m];action=showprofile;var=[m]'>@[m.nickname]</a></font> >> [t]</b>"}


The more specific part of the code is
<a href='?src=\ref[m];action=showprofile;var=[m]'>@[m.nickname]</a>


What actually happens when I click it though, is my own profile appears and not the person I am clicking. I am losing my mind trying to figure this out so any help would be greatly appreciated.


You left out the part where you define M in client Topic. I'd assume it's set to hsrc, but then you probably wouldn't have this issue.

For simplicity, instead of overriding client's Topic(), you could override the mob's, showing src's profile to usr.

Just in case, can you confirm that ShowNewProfile is actually capable of showing profiles of mobs other than src?
In response to Kaiochao
Yeah, the code I have for showing the profile is this at the moment

    verb
ShowNewProfile()

var/list/players = list()
for(var/mob/M in world)
players += M
var/mob/M = input("Which player's info would you like to view?","View Player Info") as null|anything in players
if(!M) return
else
var/html = {"HTML STUFF GOES HERE"}
winshow(src,"profilepop",1)
//winset(src, "profilepop.profilename", "text=[M.nickname]");
usr<<browse(html,"window=profilepop.profile,size=650x440")


Edit: Obviously the HTML displays the variables for M. which in this case would be whoever we want to see the profile of. (The person who sent the message)
In response to Stargate_Offic
ShowNewProfile doesn't take any arguments. It can't be passed a mob to have that mob's profile displayed, which client Topic is trying to do. I suggest making a new proc from the "else" branch where there's an actual reference to the profile owner, taking that reference as an argument, and call that in client Topic instead.
Also, it doesn't look like you'd be able to view the profile of someone that doesn't exist anymore, like if you're deleting mobs as they log out, or the world has rebooted, after the link was created.

I think it would work better if profile data was saved and loaded by ckey, and the ckey is used in the links instead of a ref, instead of requiring a mob at all.
In response to Kaiochao
Sorry, Im not super adept to DM, could you give a code example of how to achieve this? I can work from there.
In response to Stargate_Offic
Best response
Viewing profiles:
client
proc/ViewProfile(profile/profile)
// HTML STUFF GOES HERE, but with profile vars instead of mob vars

verb/ShowNewProfile()
// input() some player mob M to view the profile of
ViewProfile(new/profile(M))

Topic(href, list/params, datum/hsrc)
..()
if(params["action"] == "ViewProfile")
var/profile/profile = Profiles.Get(params["ckey"])
if(profile)
ViewProfile(profile)
else
// profile never existed, handle this somehow

Profile linking:
mob
proc/ProfileLink(text)
return "<a href=?action=ViewProfile;ckey=[ckey]>[text]</a>"

verb/say(text as text) // example
world << "<b>[ProfileLink(name)]</b>: [text]"

Profile:
profile
// define variables needed for client ViewProfile
var/name // example

New(mob/mob)
if(mob)
// set from mob the above variables
name = mob.name // example

Saving profiles by mob, and finding from existing clients or loading profiles by ckey:
var/profile_manager/Profiles = new

profile_manager
proc/Path(ckey)
return "data/profile/[ckey].sav" // example

proc/Save(mob/mob)
new/savefile(Path(mob.ckey))["profile"] << new/profile(mob)

proc/Load(ckey)
var/profile/loaded = null
if(fexists(Path(ckey)))
new/savefile(Path(ckey))["profile"] >> loaded
return loaded

proc/Get(ckey)
return Find(ckey) || Load(ckey)

proc/Find(ckey)
for(var/client/client)
if(client.ckey == ckey)
return new/profile(client.mob)
return null

Updating the offline-viewed profile as the mob logs out:
// example
mob
Logout()
..()
if(ckey)
Profiles.Save(src)

Any questions, ask away.
Wow, this is perfect, thank you so much for the assistance. Ill be sure to credit you on the hub :)