ID:158496
 
Battle_Invite(mob/Character/M as mob in view(10))
set category="Communication"
if(Talk==1)
switch(alert(M, "[usr] wants to battle you.","Battle","Yes","No"))
if("Yes")
usr << output("[M] accepts your battle request.", "chat")
for(var/turf/B in world)
if(name=="Battle1")
if(B:desc==0)
usr.loc= locate(B:loc)
B:desc=1
M.loc=locate(usr.x,usr.y+2,usr.z)
return..()

if("No")
usr << output("[M] rejects your battle request.", "chat")


I hope you can understand what I am trying to do here. I want the M and usr to be located to one of the empty Battle1 turfs in the world but at runtime it relocates me to a all black area what am I doing wrong???

</<></<>
Bhill1 wrote:
Battle_Invite(mob/Character/M as mob in view(10))
set category="Communication"
if(Talk==1)
switch(alert(M, "[usr] wants to battle you.","Battle","Yes","No"))
if("Yes")
usr << output("[M] accepts your battle request.", "chat")
for(var/turf/B in world)
if(name=="Battle1")
if(B:desc==0)
usr.loc= locate(B:loc)
B:desc=1
M.loc=locate(usr.x,usr.y+2,usr.z)
return..()

if("No")
usr << output("[M] rejects your battle request.", "chat")


I hope you can understand what I am trying to do here. I want the M and usr to be located to one of the empty Battle1 turfs in the world but at runtime it relocates me to a all black area what am I doing wrong???


1. Use DM tags

2. Close your HTML tags

3. Post in Code Problems next time

4. Don't use the : operator unless in a very rare situation. It is bad practice.

5. You might want to try something akin to this:

for(var/turf/battle1/B in world)
if(B.empty)
usr.loc = B.loc
M.loc = locate(B.x, B.y + 2, B.z)
B.empty = 0
return ..()


Of course you'll need to define battle1, setup empty and make sure it's set properly when the battle is over, and other silly things.

I might've made a mistake, forgive me.
In response to ANiChowy
Battle_Invite(mob/Character/M as mob in oview(10))
set category="Communication"
if(Talk==1)
switch(alert(M, "[usr] wants to battle you.","Battle","Yes","No"))
if("Yes")
for(var/turf/Battle1/B in world)
if(B.empty)
usr << output("
[M] accepts your battle request.", "chat")
usr.loc = B.loc
M.loc = locate(B.x,B.y+2,B.z)
B.empty = 0
return ..()
if("No")
usr << output("[M] rejects your battle request.", "chat")
else
usr << output("
You can't invite people to battle yet. You can only accept battles from other players.", "chat")



Ok, I used the code you gave me ANichowy. It some what worked it warped the usr to the destination 1 time and the M to a way different M.z I haven't changed any code around and now it wont even teleport either one (usr or M) there are no errors in the DM this is insane the code looks just fine but I'm doing something wrong I hope someone can help with this.