Raised This Month: $ Target: $400
 0% 

Help with random bool:[id]


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
dstopgunner
Senior Member
Join Date: Oct 2007
Old 05-23-2009 , 21:50   Help with random bool:[id]
Reply With Quote #1

Im trying to give random people chainsaws to people when they spawned.
Somehow my random num's like not working becuase none of us got a chainsaw. HelpZ?

PHP Code:
public spawned(id)
{
chainsaw[id] = false
 
if(is_user_alive(id))
{
new 
rand random_num(1,2)
switch(
rand)
{
case 
1: (chainsaw[id] = true)
case 
2: (chainsaw[id] = false)
}
}
return 
PLUGIN_HANDLED

dstopgunner is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 05-23-2009 , 22:36   Re: Help with random bool:[id]
Reply With Quote #2

Make sure your spawn hook is post spawn (so it will detect they are alive).
Emp` is offline
Send a message via AIM to Emp` Send a message via MSN to Emp` Send a message via Yahoo to Emp` Send a message via Skype™ to Emp`
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-23-2009 , 23:18   Re: Help with random bool:[id]
Reply With Quote #3

Once you have checked what Emp` said, you can make this easy code optimization:
PHP Code:
public spawned(id)
{
chainsaw[id] = false
 
if(is_user_alive(id))
{
chainsaw[id] = bool:random(2)
}

__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
--kml--
Senior Member
Join Date: Jan 2009
Old 05-29-2009 , 09:59   Re: Help with random bool:[id]
Reply With Quote #4

so
is a random num is an operator?
or i can do like this
ZOMG(1,2)?
__________________
wooT now is asking season
will ask you plenty of things for learning
--kml-- is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-29-2009 , 10:07   Re: Help with random bool:[id]
Reply With Quote #5

It's not an operator, it's a native function.

random : http://www.amxmodx.org/funcwiki.php?go=func&id=41
random_float: http://www.amxmodx.org/funcwiki.php?go=func&id=285
random_num: http://www.amxmodx.org/funcwiki.php?go=func&id=286
__________________
Bugsy is offline
AntiBots
Veteran Member
Join Date: May 2008
Location: Brazil
Old 05-29-2009 , 12:45   Re: Help with random bool:[id]
Reply With Quote #6

Someone know with random(0) return 145345 something like that.
__________________
AntiBots is offline
Send a message via ICQ to AntiBots Send a message via MSN to AntiBots Send a message via Skype™ to AntiBots
--kml--
Senior Member
Join Date: Jan 2009
Old 05-29-2009 , 20:43   Re: Help with random bool:[id]
Reply With Quote #7

ooo
i c
so it is only a too b?
cannot do a b c?
or 1 , 2 , 3?

and yet are there an alternative to random num O.O
__________________
wooT now is asking season
will ask you plenty of things for learning
--kml-- is offline
SnoW
Veteran Member
Join Date: Oct 2008
Location: Finland WisdomNuggets: 8
Old 05-30-2009 , 03:33   Re: Help with random bool:[id]
Reply With Quote #8

Quote:
Originally Posted by --kml-- View Post
ooo
i c
so it is only a too b?
cannot do a b c?
or 1 , 2 , 3?

and yet are there an alternative to random num O.O
If you read the link what bugsy specified, you should now that it returns a random number between the two parameters. So I don't understand what random_num(1, 2, 3) could return? If you want a random number from 1, 2, 3 you would obviously use random_num(1, 3).
SnoW is offline
Send a message via MSN to SnoW
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 01:25.


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