Generating a random number?

Hey everyone,
I was wondering if anyone new of a script call for generating a random number? I need to use it with Hime's 'Event Wrapping' script to produce the chance of an event occurring, however it seems that the normal 'rand(n)' doesn't work. I've searched and searched, and I can't seem to get anything to work! D:

Thanks in advance for any help you guys can give!

Regards,
David.
I think you can use the variable function for that?

Make a new event and select the variable operation and you will see the "Random" down there. Select two numbers and the variable generate random numbers

between those two number you input.

If you want to use it in a script call, $game_variables[x] where x is the variable number of the one you have made.

Sorry if it's not quite understandable but I hope I helped you.
Thanks for that senpoRiot, normally that's what I WOULD use, but the script I'm using (Hime's Event Wrapper) doesn't use the editor, instead events are fully scripted, hence my problem / issue. At the moment the script for the even I am using is 
 

event.build { add_comment("<parallel page>") cond_if("self_variable('c_date')!=$game_variables[2]") { call_script("self_variable('c_chance',rand(60))")#~ cond_else{} cond_if("self_variable('c_chance')==3"){ call_script("self_variable('c_date', $game_variables[2])") call_script("self_switch('c_water',false)") control_self_switch("B",0)} cond_else{#~ cond_if("self_variable('c_chance')==2"){ control_self_switch("A",0) } cond_else {} } }but for some reason it seems to 'skip' the randomisation or checking of the self_variable...
I've moved this thread to RGSSx Script Support. Please be sure to post your threads in the correct forum next time. Thank you.
Sorry Shaz! I wasn't sure whether I should put it here because I wasn't sure whether it was a problem with the script or a problem with my logic. Thank you for you help though! 

As a side note, I found and fixed the problem myself, (creating others in the process), but that's beside the point.
 

Thanks everyone!
I put it here more due to the fact that you have to format it a specific way because of the script you're using.


Looking again at the logic, it looks as if the c_chance variable is only going to be set IF the condition on the line above it is true. Maybe that should be moved a line higher, so it's set regardless of any other conditions? I don't know - it may be in the perfect place, depending on your requirements.


So do your other issues have to do with the same script, and do you need assistance with them, or shall we close this topic up since you solved that first issue?


Edit: never mind - I see you've started a new thread for it 🙂


This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

Original thread: https://forums.rpgmakerweb.com/threads/generating-a-random-number.19657/