Function "random_int"

FOR DEVS ONLY!! This adds the ability to generate random numbers with your script with or without a seed!
Version1.00
AuthorDarkKiritoV
Publish DateSun, 6 Nov 2022 - 22:08
Last UpdateSun, 6 Nov 2022 - 22:08
Downloads41
RATE


0

0

Release Notes: :]
Code: Select all
/*
Function Made By DarkKiritoV
function_random_int.gpc
 
Intructions:
 
Paste the function into any script you want to!
 
random_int(min, max, seed)
Use FALSE for the seed if you want the function to generate one for you.
 
Ex:
random_int(10, 20, -9)
random_int(1, 30, FALSE)
 
Extra info:
I dont require credit but it would be nice!
 
IMPORTANT!!:
FOR SCRIPT DEVELOPERS ONLY NOT FOR CONSUMER USE!!
*/

 
 
//This line is for the demo you do not need it
int currentlyheld;
main {
    //This is for the demo you do not need it
    if(get_val(XB1_RB)&& currentlyheld == FALSE) {
        currentlyheld = TRUE;
        set_val(TRACE_1, random_int(10, 20, -9));
        set_val(TRACE_2, random_int(0, 30, FALSE));
    }
    if (!get_val(XB1_RB)) currentlyheld = FALSE;
}
 
//Function Made By DarkKiritoV
function random_int (min, max, seed) {
    if (seed == FALSE) {
        seed = 0;
        seed = seed + (get_val(0) + get_val(1) + get_val(2) + get_val(3) + get_val(4) + get_val(5) + get_val(6) + get_val(7) + get_val(8) + get_val(9) + get_val(10) + get_val(11) + get_val(12) + get_val(13) + get_val(14) + get_val(15) + get_val(16) + get_val(17) + get_val(18) + get_val(19) + get_val(20) + get_val(21) + get_val(22) + get_val(23) + get_val(24) + get_val(25) + get_val(26) + get_val(27) + get_val(28) + get_val(29) + get_val(30) + get_val(31) + get_val(32) + get_val(33) + get_val(34) + get_val(35) + get_rtime() + get_rumble(RUMBLE_A) + get_rumble(RUMBLE_B) + get_rumble(RUMBLE_LT) + get_rumble(RUMBLE_RT) + get_ptime(get_val(0)) + get_ptime(get_val(1)) + get_ptime(get_val(2)) + get_ptime(get_val(3)) + get_ptime(get_val(4)) + get_ptime(get_val(5)) + get_ptime(get_val(6)) + get_ptime(get_val(7)) + get_ptime(get_val(8)) + get_ptime(get_val(9)) + get_ptime(get_val(10)) + get_ptime(get_val(11)) + get_ptime(get_val(12)) + get_ptime(get_val(13)) + get_ptime(get_val(14)) + get_ptime(get_val(15)) + get_ptime(get_val(16)) + get_ptime(get_val(17)) + get_ptime(get_val(18)) + get_ptime(get_val(19)) + get_ptime(get_val(20)) + get_ptime(get_val(21)) + get_ptime(get_val(22)) + get_ptime(get_val(23)) + get_ptime(get_val(24)) + get_ptime(get_val(25)) + get_ptime(get_val(26)) + get_ptime(get_val(27)) + get_ptime(get_val(28)) + get_ptime(get_val(29)) + get_ptime(get_val(30)) + get_ptime(get_val(31)) + get_ptime(get_val(32)) + get_ptime(get_val(33)) + get_ptime(get_val(34)) + get_ptime(get_val(35)) + get_battery() + get_slot());
    }
    while (seed > max || seed < min) {
    while (seed > max) seed = seed - max - 7;
    while (seed < min) seed = seed + min + 7;
    }
    return seed;
}