ID:142192
 
Code: Ok so i have this instant messenger code but i cant find a way to have the input on the window output to the output on the window for the two users talking,
mob/verb
Instant_Message()
var/varPeople = list()
for(var/mob/T in world)
if(T.key)
varPeople += T
var/mob/M=input("Who would you like to whisper to?","") in varPeople +list("Cancel")
if(M=="Cancel")
return
else
var/msg=input("") as text
if(winget(M,"[usr][M]","id")||winget(usr,"[usr][M]","id"))
winclone(M, "Messager","[usr][M]")
winclone(usr, "Messager","[usr][M]")
M << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "[usr][M].IMout")
usr << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "[usr][M].IMout")
winshow(M, "[usr][M]",1)
winshow(usr, "[usr][M]",1)
usr.sender=M
M.sender=usr
else
winclone(M, "Messager","[M][usr]")
winclone(usr, "Messager","[M][usr]")
M << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "[M][usr].IMout")
usr << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "[M][usr].IMout")
winshow(M, "[M][usr]",1)
winshow(usr, "[M][usr]",1)
usr.sender=M
M.sender=usr

Right now im using this for the verb in the input on the windows but it requires me to assign sender variables and you can only talk to one person and if someone else sends a message you get auto set to that person.
send(msg as text)
set hidden=1
if(usr.sender)
var/mob/M=usr.sender
M << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "IMout")
usr << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "IMout")
winshow(M, "Messager",1)
winshow(usr, "Messager",1)

Problem description:

Just send the output to the newly cloned output, not the IMout output.
In response to Jeff8500
well thats what im asking how to do, cause the window name changes based on whos sending it so i dont know how to get the right winid there.
In response to NightJumper88
Then you should change it so that all outputs have the ID of the mob you're sending it to + IMout, then just use [M] IMout as the output ID.
In response to Jeff8500
the only problem with that is theres two people involved so you would have a conflict if two people sent you a message it would go to the same window
In response to NightJumper88
...not really, unless I'm misunderstanding you.
In response to Jeff8500
well there are actually a couple things wrong with doing it that way, It works for the person sending it in the first place, but not for the person to respond back, its a two way chat system. So if say a guy named Bob sent a message to someone named Jim (his IM window would be Jim.IMout) then some other guy named Jack sent to jim (his window would also be Jim.IMout).

Also How do i know who im sending it to in the send command without having to select the person everytime (that is the root of my problem)
In response to NightJumper88
No, No, No. I told you already, always name it otherperson.IMout. For example, for Jim you would name it Bob.IMout, and for Bob it would would Jim.IMout. Just set it so the ID for usr of the verb's window is M and the ID of M's window is usr of the verb. Also, I said usr of the verb because I can't remember if it was a proc or a verb haha.
In response to Jeff8500
ok i see how you would send it to the other person, however there would be a new problem and if you were talking to more than one person there would be more than one person with name.IMout. So if i did it your way again lets use an example
If Bob IMs jim, Bob would have a Jim.IMout and Jim would have a Bob.IMout, and then say Jack IMs Jim, then Jack would have a Jim.IMout and Jim would have a Jack.IMout. so anything Jim would send would go to both Jack and Bob if i tried to send it to Jim.IMout. Unless im missing something in what your saying
In response to NightJumper88
No, your just lacking a fundamental knowledge of how skins work. Each client has his/her own skin. If a player really wanted, they could create a custom skin for a game (which I have done). If you say M << output("Text","randomwindow") it won't output it to the whole world, only M. Or if you say winset(M,"window","is-maximized=true") it would only maximize M's window, not everyone elses.

You're sending messages to mobs, which then sends it to the client's output. Remember that.
In response to Jeff8500
Actually i think i figured it out, what i was having problems with was figuring out how to output to M and get M defined as the right mob, but if the window in the users window is named after the Mob i should be able to get the id and use that

edit:
Ok I was wrong I understand what your saying but how do i make the verb for the input and define M heres modified IM code to remind you of what we have been talking about

mob/verb
Instant_Message()
var/varPeople = list()
for(var/mob/T in world)
if(T.key)
varPeople += T
var/mob/M=input("Who would you like to whisper to?","") in varPeople +list("Cancel")
if(M=="Cancel")
return
else
var/msg=input("") as text
winclone(M, "Messager","[usr]")
winclone(usr, "Messager","[M]")
M << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "[usr].IMout")
usr << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "[M].IMout")
winshow(M, "[usr]",1)
winshow(usr, "[M]",1)
In response to NightJumper88
This is easy. Just make a verb with an argument that identifies the recipient of the message.

For example:
mob/verb
IM(var/mob/M,var/txt as text)
M << output(text,"[M].out")


Once you cloned the "Messenger" window, set the clone's input command as 'IM <recipient>'. This can be done using the winset() proc. If you are talking with me, set the command of "Jemai1.input" to "IM Jemai1 " (don't forget the spaces). That way, if you entered "Hi" in "Jemai1.input" the whole command will be "IM Jemai1 Hi". IM is the command; Jemai1 and Hi are the arguments (M and txt).
In response to Jemai1
Ok i understand but i cant get it to work this is what i have for both the intial sending of the IM and the command
mob/verb
Instant_Message()
var/varPeople = list()
for(var/mob/T in world)
if(T.key)
varPeople += T
var/mob/M=input("Who would you like to whisper to?","") in varPeople +list("Cancel")
if(M=="Cancel")
return
else
var/msg=input("") as text
winclone(M, "Messager","[usr]")
winclone(usr, "Messager","[M]")
winset(usr, "[M].IMout", "command=send [M] ")
winset(M, "[usr].IMout", "command=send [usr] ")
M << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "[usr].IMout")
usr << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(msg)]", "[M].IMout")
winshow(M, "[usr]",1)
winshow(usr, "[M]",1)

and for the command line verb
send(var/mob/M,var/txt as text)
M << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(txt)]", "[usr].IMout")
usr << output("\blue([usr.Nation])</FONT>--[usr.name]: [html_encode(txt)]", "[M].IMout")
winshow(M, "[usr]",1)
winshow(usr, "[M]",1)


But the send command doesnt work
In response to NightJumper88
            winset(usr, "[M].IMout", "command=\"send [M] \"")
winset(M, "[usr].IMout", "command=\"send [usr] \"")
In response to Jemai1
Thank you it works now this has been bugging me for a long time.
In response to NightJumper88
No problem.