ID:145447
 
Code: Racing code for a Text Based.
mob
verb
Race()
for(var/mob/M in world)
if(!M.key) continue //skip NPCs
if(M.racing == 1) continue
var/race = input("Race who?") in list(M.name)
if(race == M.name)
switch(input(M,"[src] wants to race you. Accept?","Challenge!") in list("Yes","No"))
if("Yes")
world << "<b>[src.name] is now racing [M.name]!"
src.StartRace(M)
else
src << "[M] declined."
return

proc
StartRace(mob/M,mob/C)
C.distance = 0
M.distance = 0
sleep(5)
//And so on...

runtime error: Cannot modify null.distance.
proc name: StartRace (/mob/proc/StartRace)
usr: the haha (/mob)
src: the haha (/mob)
call stack:
the haha (/mob): StartRace(the haha (/mob), null)
the haha (/mob): Race()
Problem description: "The Haha" is just a test name for me :P. I'm currently racing myself, but I can't because of this. If I can't start races, then the whole game has collapsed in one.

You need 2 arguments for your proc, though you only passed 1.
Also, if(var==1) should be if(var).
In response to Mysame
...And where?
RedlineM203 wrote:
if(M.racing == 1) continue // BOOLEAN! Should be if(M.racing)
src.StartRace(M)// src.StartRace(M) ? You need 2 arguments, check!:
>mob
> proc
> StartRace(mob/M,mob/C) // See? Who the hell is C? you didn't pass him. Use src and forget about C.
> C.distance = 0
> M.distance = 0
> sleep(5)
>