Code:
mob
verb
Kill_Everyone(mob/M as mob in world)
switch(alert("Are you sure you want to kill everyone in the world?",,"Yes","No"))
if("Yes")
var/numkilled = 0
while(M.Alive == 1)
world << "Please stand by for an important update to your character."
sleep(100)
if(M.key == usr.key) continue
else if(M.Alive == 0) continue
else
world << "Targeting... [M]"
sleep(100)
numkilled += 1
M << "HA I GOT YAH!"
world << "[M] was the [numkilled]\th killed in the world!"
del M
if(!Alive)
sleep(100)
world << "Now, the final person will die!"
world << "Targeting [usr]"
sleep(100)
usr.Die()
sleep(10)
world << "The death is finally over!"
Problem description: It works fine around compile-time, but when it initiates, I get this run-time error. Also, it does go farther than that, and the rest works fine, it's just that part.
runtime error: Cannot read null.Alive
proc name: Kill Everyone (/mob/Admin/verb/Kill_Everyone)
usr: (/mob)
src: (/mob)
call stack:
(/mob): Kill Everyone(null)
Also, no matter how long I wait, it never moves on from the while(M.Alive == 1) to killing the user, I'm really not sure why.
Thus, M in your argument is null as no argument has been passed on. You can read more of Procedures in Chapter 6 of the DM Guide
Note that alert()'s default reference (see the DM Reference entry) is usr, which you want to avoid in most procedures... not to mention that the reference is M not usr... and you are calling usr.Die() near the end, not M.Die()
In addition, you may want to read the usr unfriendly article, warning you the dangerous of abusing usr (per say). You may want to read up the Green Programming article to make your project more efficient, such as using boolean checks.