Raised This Month: $51 Target: $400
 12% 

Get Random TerroristId via get_players()


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 11-07-2010 , 10:51   Get Random TerroristId via get_players()
Reply With Quote #1

Huh Alliedmods,

Im trying to get a random T so my code:

PHP Code:
public getRandomCt()
{
    new 
players[32], pnum
    get_players
(playerspnum"ae""TERRORIST")
    
    new 
randomT players[random_num(1pnum)]

shoudnt that work?
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
Old 11-07-2010, 11:01
SaM.ThE.MaN
This message has been deleted by SaM.ThE.MaN. Reason: wrong ..
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 11-07-2010 , 11:06   Re: Get Random TerroristId via get_players()
Reply With Quote #2

this isnt a random T...
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 11-07-2010 , 12:05   Re: Get Random TerroristId via get_players()
Reply With Quote #3

Quote:
Originally Posted by mottzi View Post
shoudnt that work?
Test and/or search before posting a new topic.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
hleV
Veteran Member
Join Date: Mar 2007
Location: Lithuania
Old 11-07-2010 , 12:09   Re: Get Random TerroristId via get_players()
Reply With Quote #4

Code:
random_num(1, pnum)
change to
Code:
random(pnum)
__________________
hleV is offline
Voi
Veteran Member
Join Date: Sep 2006
Location: Gdansk, Poland
Old 11-07-2010 , 19:40   Re: Get Random TerroristId via get_players()
Reply With Quote #5

Quote:
Originally Posted by hleV View Post
Code:
random_num(1, pnum)

change to
Code:
random(pnum)

This is doing the same, yet random() is faster ?
__________________
Voi is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-07-2010 , 19:44   Re: Get Random TerroristId via get_players()
Reply With Quote #6

Quote:
Originally Posted by Voi View Post
This is doing the same, yet random() is faster ?
No, those are not the same.

PHP Code:
random_num(0pnum 1
and

PHP Code:
random(pnum
are the same.
__________________
fysiks is online now
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 11-08-2010 , 05:19   Re: Get Random TerroristId via get_players()
Reply With Quote #7

So this could also return 0.. but 0 isnt a valid player... what can i do?
PHP Code:
public getRandomCt()
{
    new 
players[32], pnum
    get_players
(playerspnum"ae""TERRORIST")
    
    new 
randomT players[random(pnum)]

__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers

Last edited by mottzi; 11-08-2010 at 05:22.
mottzi is offline
Send a message via MSN to mottzi
reinert
Veteran Member
Join Date: Feb 2007
Old 11-08-2010 , 05:25   Re: Get Random TerroristId via get_players()
Reply With Quote #8

PHP Code:
static players[32], pnum
    get_players
(playerspnum"ae""TERRORIST")
    if(
pnum>0)
        
random_t(playersrandom(pnum) ])

public 
random_t(id){
    
client_print(idprint_center"You are the chosen one!")
    
set_user_health(id get_pcvar_num(hp))
    
cs_set_user_armor(idget_pcvar_num(ap), CS_ARMOR_VESTHELM)   

I'm useing something like that :S
reinert is offline
fysiks
Veteran Member
Join Date: Sep 2007
Location: Flatland, USA
Old 11-08-2010 , 12:03   Re: Get Random TerroristId via get_players()
Reply With Quote #9

Quote:
Originally Posted by mottzi View Post
So this could also return 0.. but 0 isnt a valid player... what can i do?
PHP Code:
public getRandomCt()
{
    new 
players[32], pnum
    get_players
(playerspnum"ae""TERRORIST")
    
    new 
randomT players[random(pnum)]

That will always return 0 because it doesn't return anything.
__________________
fysiks is online now
mottzi
Veteran Member
Join Date: May 2010
Location: Switzerland
Old 11-08-2010 , 12:51   Re: Get Random TerroristId via get_players()
Reply With Quote #10

sry, im talking about the random() funcion, not about the getRandomCt call itselfes...

thanks reinert and all others <3
__________________
Quote:
#define true ((rand() % 2)? true: false) //Happy debugging suckers
mottzi is offline
Send a message via MSN to mottzi
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 03:21.


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