ID:268225
 
Well I ran across a problem, or atleast I think it's a problem and that was using var/mob/t as mob and assigning it to usr.client.mob...


of one of the many things I have people do in my game is click on screen objects which activates the proc Click() which is usr friendly (meaning you can only use usr).

anyways

the problem I'm running into is when I try to create a new mob, and have usr.client.mob= new mob in order to switch clients, the problem comes when I want to delete the old mob... what is the best way to do this?

Should I have the deletion of the mob and the transfer of client to new mob in a proc by declaring usr.TransferChar() and then do all the crap in TransferChar?

or is it safe to do a transfer in Click() and then just declare a variable var/mob/t as mob, and then have t=usr.client.mob BEFORE the transfer of client, then at the end have a del(t)?

Any help would be appreciated...
Jon Snow wrote:
or is it safe to do a transfer in Click() and then just declare a variable var/mob/t as mob, and then have t=usr.client.mob BEFORE the transfer of client, then at the end have a del(t)?
Well, if you're setting usr.client.mob, you're obviously setting the client to that mob, but - besides that good, it'll work, except more along these lines...

var/mob/player/P=new //define a new mob variable
usr.client.mob=P //set the client to the new mob
del(usr) //delete the old mob
In response to Goku72
Don't forget to give 'new' it's location paramiter.
In response to Yota
I was afraid about using del(usr) because usr is refering to the client, isn't it?
In response to Jon Snow
'usr' is a mob varibable. 'src' would be the client if it was 'client.Click()'.