Raised This Month: $ Target: $400
 0% 

Array of ID's + Random


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
GalegO
Member
Join Date: May 2010
Location: Brazil
Old 11-05-2011 , 16:49   Array of ID's + Random
Reply With Quote #1

Hi guys, is possible to make a array with the Players ID and after read this array and run the random to catch one of them?

Ex: read all CT's ID, storage and after catch just one randomly.

Thanks!
__________________
Sou brasileiro e não desisto NUNCA!
I'm Brazilian and NEVER give up!

Loucademia de CZ (lcz # GalegO)
CZ CrazyAcademy
189.1.164.85:27017


Last edited by GalegO; 11-05-2011 at 16:49.
GalegO is offline
TheArmagedon
Senior Member
Join Date: Sep 2010
Location: Unknown Source
Old 11-05-2011 , 16:57   Re: Array of ID's + Random
Reply With Quote #2

@BP - Assim deve funcionar...
@US - This code should work...

PHP Code:
new playerss[32], num;
get_players(playerssnum"c""COUNTER-TERRORIST");


if(
num)
{
    new 
playerrandom playerss[random(num)];

    
anything(playerrandom); // exec the command for the random player


Last edited by TheArmagedon; 11-05-2011 at 17:10.
TheArmagedon is offline
Emp`
AMX Mod X Plugin Approver
Join Date: Aug 2005
Location: Decapod 10
Old 11-05-2011 , 16:59   Re: Array of ID's + Random
Reply With Quote #3

Use get_players but note:
Quote:
Originally Posted by ConnorMcLeod View Post
Flags are ok, except for "e" flag when "a" flag is not used.
If you don't want to use the "e" flag, then you can do something along the lines of:

Code:
new iPlayers[32], iPnum;
get_players( iPlayers, iPnum )

for ( new i; i < iPnum; i++ )
{
     if ( cs_get_user_team( iPlayers[i] ) != CS_TEAM_CT )
          iPlayers[ i-- ] = iPlayers[ iPnum-- ];
}

if ( iPnum > 0 )
{
     new iRandomPlayer = iPlayers[ random( iPnum ) ];
}
edit:

Quote:
Originally Posted by TheArmagedon View Post
@BP - Assim deve funcionar...
@US - This code should work...

PHP Code:
new playerss[33], num;
get_players(playerssnum"c""CS_TEAM_CT");


if(
num)
{
    new 
playerrandom playerss[random(num)];

    
anything(playerrandom); // exec the command for the random player

You need to use team names for get_players, not the CS_TEAM_* constants.

Last edited by Emp`; 11-05-2011 at 17:03.
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`
GalegO
Member
Join Date: May 2010
Location: Brazil
Old 11-05-2011 , 17:09   Re: Array of ID's + Random
Reply With Quote #4

Thanks Again Emp`, I tried some logicals, but not make sense or dosen't worked.

I just can't find the correct logical.

EDIT: Sorry, Thanks tou too TheArmageddon
__________________
Sou brasileiro e não desisto NUNCA!
I'm Brazilian and NEVER give up!

Loucademia de CZ (lcz # GalegO)
CZ CrazyAcademy
189.1.164.85:27017


Last edited by GalegO; 11-06-2011 at 01:09.
GalegO is offline
TheArmagedon
Senior Member
Join Date: Sep 2010
Location: Unknown Source
Old 11-05-2011 , 17:10   Re: Array of ID's + Random
Reply With Quote #5

@emp
oh, thank you, fixed!

Last edited by TheArmagedon; 11-05-2011 at 17:10.
TheArmagedon is offline
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 14:27.


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