ID:166790
 
In this bit of script, our hero passes his hat to the public.
If he has not played any music first, he is punished for begging. otherwise he gets paid a random amount depending on where he is:

mob/proc/Pass_hat(mob/M in oview(hat_distance))
if (busked == 0)
usr << "you have not busked. STOP BEGGING!"
crimes += 1
return..()


if(M.class == "joe_public" && istype(loc.loc,/area/pitch))
var/amount = (rand(1,(M.gold/2))-1)
M.gold -= amount
usr.gold += amount
world << "[usr] hats [M] , getting [amount] Euros!"
busked = 0
return..()

if(istype(loc.loc,/area/police))
usr << "[M] calls the police!"
world << "[usr] is wanted by the police for hatting in a police station"
wanted = "YES"
busked = 0
crimes += 2
return..()


The problem is when he passes the hat there is a box which asks which person to hat. I want him to hat EVERYONE in the distance defined by the hat distance and not just one person. What must I do?
instead of
mob/proc/PAss_hat(mob/M in oview(hat_distance))


Look up for()

And on a side note;
//For checking TRUE/FALSE values.
if(var==1) // WRONG.
if(var) // RIGHT!

if(var==0) WRONG!
if(!var) RIGHT!


Non-robust code ftw.

And besides THAT;

No put usr in proc, ungh.
In response to Mysame
thanks for the side note, that I understand, Im having a little trouble getting my head around the for loop thing, can someone either solve the thing or give me an example I can use as a base?