AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   random() function won't work (https://forums.alliedmods.net/showthread.php?t=98879)

shadow.hk 07-30-2009 10:32

random() function won't work
 
Been trying to use a simple chance function, however, it doesn't seem to work. It ALWAYS slays. So... am I doing this wrong?

PHP Code:

if(random(get_pcvar_num(p_Amount_Gamble)) == 1)
{
    
give_item(id"weapon_glock");
            
    
jb_print(id"Congratulations, you just won a !tglock!n!");
}
else
{
    
slay_lightning(id);
        
    
jb_print(id"Wow... bad luck");



Bugsy 07-30-2009 10:34

Re: random() function won't work
 
It works:

Code:

random() - Returns a pseudo-random number in the range of 0 to max-1.

random( 5 ) will return random of 0 through 4.

Code:

random_num() - Generates random integer from a to b.

random_num( 1 , 5 ) will return a random of 1 through 5.


shadow.hk 07-30-2009 10:36

Re: random() function won't work
 
ok, thanks for the info.


All times are GMT -4. The time now is 18:27.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.