ID:160462
 
Just wondering how I would go about making it so a var could save a mob and then later I could switch the client over to this variable. Thanks.

EDIT: Ignore the indentation errors.



            mob
global
playerone
playertwo





                        playerone=src
playertwo=m


    proc
game_end(mob/a,mob/b)
a.inmatch=0
a.inmatchs=0
b.inmatch=0
b.inmatchs=0
matchstarted=0
//a.client=playerone
b.client=playertwo
//a.loc=locate(rand(2,9),rand(2,9),2)
b.loc=locate(rand(2,9),rand(2,9),2)
b<<"test."
for(var/mob/soldiers/n)
if(istype(n))
del n //switch clients before deleting N...
mob
verb
that()
game_end(playerone,playertwo)
check()
world<<"[playerone] is player 1, [playertwo] is player 2."



You mean, mob switching ?
In response to Andre-g1
Like for example if I log on it saves a variable of my mob (playerone=usr) then later if I ever switch clients so maybe I'm a mob called 'Giant idiot' now, I can switch back by using that playerone variable. I was thinking it would work like: 'src.client.mob=playerone', but that doesn't work.
In response to Speedro
var/mob/world_mob //note how we don't say global/world_mob
//var/ is the same as global/var/ just easier

mob/verb/Change_Mob()
if(src != world_mob && ismob(world_mob)) //if they aren't the world mob
client.mob = world_mob //make them it
world_mob = src
else
client.mob = new /mob //give them a new mob


It's a screwy example, but it shows how it should work in a way.
In response to Jeff8500
It's still not working.


    proc
game_end(mob/a,mob/b)
a.inmatch=0
a.inmatchs=0
b.inmatch=0
b.inmatchs=0
matchstarted=0
a.client.mob=playerone
b.client.mob=playertwo
a.loc=locate(rand(2,9),rand(2,9),2)
b.loc=locate(rand(2,9),rand(2,9),2)
b<<"test."
for(var/mob/soldiers/n)
if(istype(n))
del n //switch clients before deleting N...


The idea is to switch clients before deleting all the soldiers. So as you can see by the above code, I'm attempting to switch both a and b's client to the variable of player one or two. I defined when they were saved in this snippet:
mob
verb
Challenge(mob/m)
/*if(!m.client||m.key==src.key)
src<<"You cannot challenge yourself!"
return*/

if(matchstarted)
src<<"<b>\red Only one game per server is allowed."
src<<"<b>\red Another game is already in progress."
return
var/c=m.loc.z
var/d=src.loc.z
if(c==1&&d==1)
switch(input(m,"[src] has challenged you. Do you accept their challenge?","Accept?")in list("Yes","No"))
if("Yes")
playerone= src.client.mob
playertwo= m.client.mob

alert("[m] has accepted your challenge!")
switch(input("Which map would you like to go to?","Map")in list("Grasslands","Erm, nevermind"))
if("Grasslands")
worldmap="grassland"
src.team=1
m.team=2
src.checkmap()
m.checkmap()
src.inmatchs=1
m.inmatchs=1
matchstarted=1
spawn() turnswitch()
if("No")
..()
In this code, after both the challenger and challengee have agreed to battle, it assigns both their mob's to either 'playerone' or 'playertwo' (at least, that's what I'm attempting to do. So we switch clients using click and then later when we're done the game, you want to delete all the soldiers but we might just be a soldier. That's why I want it to return to the original mob you were using.

Furthermore, I would prefer it if it really did just return them to their original mob, as I don't want to make a new mob/player type because that would take a lot to run through all the code to fix that up.
Does anyone have any ideas?
In response to Speedro
Yeah. Please wait patiently and don't bump your topic until at least 24 hours have passed since the last reply. =P It was also still on the front page so a bump was really useless and extraneous. This is not a chatroom, after all, people will see your topic regardless of whether you write every few minutes or not. It just takes varying time.
In response to Kaioken
Okay, I'll keep that in mind. Thanks for the advice. Seriously though, does anyone know?