ID:147936
 
I made a challenge verb for my game, everything works just fine except for the finish line turf. Sometimes it'll say both racers won, or that both racers got second, and sometimes it works just fine. Whenever I race it says both me and my car won, sometimes it says the winner got second, just does a bunch of crazy stuff. I dunno if I can be helped by just pasting the following code but, tell me if you need more.

Finish_Line
Entered(mob/M)
if(finished == 0)
world << "INFO: [M] has won the race!"
finished = 1
sleep(50)
M.loc = locate(2,2,1)
else
world << "INFO: [M] has placed second!"
finished = 0
sleep(50)
M.loc = locate(2,2,1)
I'm not too sure on this, but maybe you should use Enter() instead of Entered() ??

~cam
In response to Camaro (#1)
Nah, that don't help my situation any.
In response to Enigmaster2002 (#2)
I fixed it up a bit, so now it ignores the car mobs, but it still seems to randomly announce which place each racer gets. Help please?

turf/var
finished = 0

turf
Finish_Line
Entered(mob/M)
if(istype(M,/mob/Car))
return
if(finished == 0)
world << "<font color=red>INFO:</font><font color=white> [M] has won the race!</font>"
finished = 1
sleep(50)
M.loc = locate(2,2,1)
return
if(finished == 1)
world << "<font color=red>INFO:</font><font color=white> [M] has placed second!</font>"
finished = 0
sleep(50)
M.loc = locate(2,2,1)
return
In response to Enigmaster2002 (#3)
Are you setting finished=0 for all Finish_Line turfs at the beginning of the race? Is it possible that another mob might be interfering, by stepping on the finish line when they're not in the race?
In response to Crispy (#4)
The drag track is on the second Z level, and I have a "safety" that makes sure no one else can use the track until the second racer finishes. I used Hanns' car system, so the car is defined as a mob as well, but I fixed that in the code snippet I had in my last post. It only reports the driver as the winner now, but it still likes to mess up by saying both racers won or whatnot. I use the same turf for the finish line on both tracks, but I think somehow it's assigning the finished var to the player, because I went back over the finish line after I initially finished, and the first time it said I placed first and when I went back over it it said I got second. And when the server first starts, the finished var is set to zero by default.
In response to Enigmaster2002 (#5)
Remember that EACH Finish_Line turf has a SEPARATE "finished" var. Setting it to 1 for one Finish_Line turf won't set it to 1 on all other Finish_Line turfs.

When starting the race, try something like this:

for(var/turf/Finish_Line/F)
F.finished=0

And instead of just setting finished=1 for the current turf, do this:

for(var/turf/Finish_Line/F)
F.finished=1
In response to Crispy (#6)
Yes! My finish line turf finally works! Crispy, you are the best!
In response to Enigmaster2002 (#7)
One tries. =)
In response to Enigmaster2002 (#7)
If this is a car racing game (which it sounds like), please let me know when this is done, I'm DYING for an original car game. The only car games I've seen on byond is the FAF rips. AIM(CamDivX), post the publication in the 'Creations' section, pager, anyway. Just please let me know :).

~Cam
In response to Camaro (#9)