ID:273762
 
I have never used the Topic proc until now. It is mainly used for hyperlinks that call verbs, correct? How would I use it to send private messages to other players when I click on a player's name in the output element?

For example:
When a player submit's a chat message, it will be output to whatever output element that displays the player's name and the message, except that the name will be "hyperlinked" so that other players who see the message may click on this player's name and send him/her a private message.
The first thing you'd look at is the datum/Topic() proc, and not the client/Topic() proc -- this version of Topic() gets called if you provide a proper reference to the 'src' parameter of your hyperlink.

mob
Topic(href,href_list[])
..()
if(!href||!href_list) return
if(href_list["whisper"])
var/mob/sender = locate(href_list["sender"])
if(sender)
var/message = input(sender,"Send a private message to [src.name]","Private Message") as null}text
if(!message) return
src << "[M.name] (private): [message]"
M << "[src.name] (private): [message]"


Of course that doesn't make the hyperlink (didn't want to type it out inside of a code block, just typing this off the top of my head), but the link would look something like this:

<a href="byond://?whisper=1&src=\ref[who_to_send_it_to]&sender=\ref[who_its_from]">[name]</a>


The important things you'll notice are the \ref lines, this will create a reference number pointing to the mob embedded after it, which will allow you to locate() the mob based on that number. The 'src' parameter is what tells BYOND to call the Topic() proc for that datum, this can be done for any datum. So you don't have all kinds of clutter inside of client/Topic() and all that.

I'm sure you can figure out how to adapt this to your needs, as I said, I typed it off the top of my head so I imagine there's some goof-ups here and there. Good luck :)
In response to Nadrew
Thank you very much! This helped me to understand it a lot better. :)
Spunky_Girl wrote:
I have never used the Topic proc until now. It is mainly used for hyperlinks that call verbs, correct? How would I use it to send private messages to other players when I click on a player's name in the output element?

For example:
When a player submit's a chat message, it will be output to whatever output element that displays the player's name and the message, except that the name will be "hyperlinked" so that other players who see the message may click on this player's name and send him/her a private message.

In addition to Nadrew's post, you should check out Unknown Person's Dream Maker Article on Browser controls and forms. The spot I linked to deals with datum/Topic() and client/Topic().