Raised This Month: $ Target: $400
 0% 

Call function to get 4 random players?!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
padilha007
Senior Member
Join Date: Jul 2008
Old 07-22-2008 , 16:08   Call function to get 4 random players?!
Reply With Quote #1

how i can do that?
padilha007 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-22-2008 , 16:21   Re: Call function to get 4 random players?!
Reply With Quote #2

Code:
stock get_random_players(iArray[4]) {  new iPlayers[32], iNum;  get_players(iPlayers, iNum, "ch");    for(new i = 0 ; i < 4 ; i++)  {   iArray[i] = iPlayers[random(iNum)];  } }
iArray[4] (from 0 to 3) will be filled with random indexes of players that are connected on server. E.g

Code:
client_print(iArray[0], print_chat, "Hey there!");
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
padilha007
Senior Member
Join Date: Jul 2008
Old 07-22-2008 , 16:38   Re: Call function to get 4 random players?!
Reply With Quote #3

how i get the name?

client_print(iArray[0], print_chat, "Hey there!");
client_print(iArray[1], print_chat, "Hey there!");
client_print(iArray[2], print_chat, "Hey there!");
client_print(iArray[3], print_chat, "Hey there!");

iArray[2] send msg to random player3?

i need exec a commands:

server_cmd(
iArray[2]," my command ")

correct?


Last edited by padilha007; 07-22-2008 at 16:42.
padilha007 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-22-2008 , 16:44   Re: Call function to get 4 random players?!
Reply With Quote #4

Code:
new szName[32]; get_user_name(iArray[0], szName, sizeof szName - 1);   client_print(iArray[0], print_chat, "Hey there %s!", szName);
Yes, iArray[2] is random player 3.
To exec a command on a client use:
Code:
client_cmd(iArray[2], "say Yo!");
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
padilha007
Senior Member
Join Date: Jul 2008
Old 07-22-2008 , 17:05   Re: Call function to get 4 random players?!
Reply With Quote #5

tnx +karma
padilha007 is offline
dekken
Veteran Member
Join Date: Jul 2007
Old 07-22-2008 , 17:37   Re: Call function to get 4 random players?!
Reply With Quote #6

hey i got a question about this too..
how do you do this:
If the it got same ID Twice or more, how to Detect it and fill the one of the same ID's with 0 or NULL or w/e
__________________
Signature Goes Here
dekken is offline
12345
Senior Member
Join Date: Dec 2004
Old 07-22-2008 , 17:53   Re: Call function to get 4 random players?!
Reply With Quote #7

GREAT!

how i can put this to work on start round?
anyone can make one plugin to me?
12345 is offline
Alka
AMX Mod X Plugin Approver
Join Date: Dec 2006
Location: malloc(null)
Old 07-22-2008 , 18:11   Re: Call function to get 4 random players?!
Reply With Quote #8

Quote:
Originally Posted by dekken View Post
hey i got a question about this too..
how do you do this:
If the it got same ID Twice or more, how to Detect it and fill the one of the same ID's with 0 or NULL or w/e
Somehting like
Code:
 for(new i = 0 ; i < 4 ; i++)  {   for(new j = 0 ; j < 4 ; j++)   {    if((iArray[i] == iArray[j]) && (i != j))     iArray[j] = 0;   }  }
__________________
Still...lovin' . Connor noob! Hello
Alka is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-22-2008 , 18:31   Re: Call function to get 4 random players?!
Reply With Quote #9

http://forums.alliedmods.net/showthread.php?t=74666
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
12345
Senior Member
Join Date: Dec 2004
Old 07-22-2008 , 21:37   Re: Call function to get 4 random players?!
Reply With Quote #10

Quote:
Originally Posted by 12345 View Post
GREAT!

how i can put this to work on start round?
anyone can make one plugin to me?
12345 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 05:29.


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