Raised This Month: $ Target: $400
 0% 

random() function won't work


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
shadow.hk
Senior Member
Join Date: Dec 2008
Location: WA, Australia
Old 07-30-2009 , 10:32   random() function won't work
Reply With Quote #1

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");

shadow.hk is offline
Send a message via MSN to shadow.hk
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 07-30-2009 , 10:34   Re: random() function won't work
Reply With Quote #2

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.
__________________
Bugsy is offline
shadow.hk
Senior Member
Join Date: Dec 2008
Location: WA, Australia
Old 07-30-2009 , 10:36   Re: random() function won't work
Reply With Quote #3

ok, thanks for the info.
shadow.hk is offline
Send a message via MSN to shadow.hk
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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