ID:270729
 
I've seen in some games that people use a whisper verb that uses a link to reply to the whisper. I've tried doing this, but I can't really get it to work. I've also tried looking up more on Topic() but can't seem to find what I'm looking for. So any help will be appreciated.
This code in un-tested but it might work. Either way you can sort of learn form it maybe?

client/Topic(href)
if(href=="Whisper")
for(var/mob/m as mob in world)
if(m.name==h["whisper"])
call(/mob/verb/whisper)(m)
.=..()

mob/verb/whisper(mob/m in world)
var/p=input("What would you like to tell them?","Whisper")as null|text
if(!p)return
m<<"<a href=?Whisper;whisper=[m.name]>[src]</a> whispers to you: [p]"
In response to Evidence
Thank you and sorry... I should've tried more because I was close to getting that :P

EDIT:
Yeah, it didn't work but I fixed it. Thanks.
In response to Evidence
Evidence wrote:
This code in un-tested but it might work. Either way you can sort of learn form it maybe?

> client/Topic(href)
> if(href=="Whisper")
> for(var/mob/m as mob in world)
> if(m.name==h["whisper"])
> call(/mob/verb/whisper)(m)
> .=..()
>
> mob/verb/whisper(mob/m in world)
> var/p=input("What would you like to tell them?","Whisper")as null|text
> if(!p)return
> m<<"<a href=?Whisper;whisper=[m.name]>[src]</a> whispers to you: [p]"
>


You're doing a pointless loop. Here's the way to do it:

client/Topic(href, h[])
switch(h["action"])
if("whisper")
var/client/whisperwho = locate(h["whisperwho"])
if(whisperwho)
var/msg = input("msg as text") as null|text
if(msg) whisper(msg, whisperwho)


client/proc/whisper(msg, mob/target)
target << "<a href=?action=whisper&whisperwho=\ref[mob]>[mob.name]</a> \
whispers, '
[copytext(html_encode(msg), 1, 350)]'" //a safe text is a good text! :p