ID:261565
![]() Jul 12 2002, 8:13 pm
|
|
i cant get it to pick a random #
|
![]() Jul 12 2002, 8:20 pm
|
|
rand(1,100000000000000000)
|
usr.gold -= pick(-5,5)
or... if(pick(0,1)) usr << "you win!" usr.gold += 5 else usr << "you lose!" usr.gold -= 5 |
Nunugi wrote:
rand(1,2) It looks like you are trying to copy the structure of a switch. You would need to include the switch statement for it to work and modify the ifs a bit: switch(rand(1,2)) if(2) usr:gold-=5 if(1) usr:gold-=5 That is the structure of a switch but there are still some potential problems. I don't think you want to subtract gold in both cases (assuming one case is wining, and the other is losing). This also isn't a very efficient setup for the simple task it accomplishes but if you want to add complexity then it isn't necessarily a bad way to go. |
You can do it like this too
var/gain = rand(-5,5) //Define a var called gain pick-5to5 if(gain <= 0) //if the number is 0 or less.. usr.gold -= gain //subtract the amount if(gain > 0) //if the number is greater than 0 usr.gold += gain //add the gold |