AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Call function to get 4 random players?! (https://forums.alliedmods.net/showthread.php?t=74651)

padilha007 07-22-2008 16:08

Call function to get 4 random players?!
 
how i can do that?

Alka 07-22-2008 16:21

Re: Call function to get 4 random players?!
 
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!");

padilha007 07-22-2008 16:38

Re: Call function to get 4 random players?!
 
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?


Alka 07-22-2008 16:44

Re: Call function to get 4 random players?!
 
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!");

padilha007 07-22-2008 17:05

Re: Call function to get 4 random players?!
 
tnx +karma

dekken 07-22-2008 17:37

Re: Call function to get 4 random players?!
 
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

12345 07-22-2008 17:53

Re: Call function to get 4 random players?!
 
GREAT!

how i can put this to work on start round?
anyone can make one plugin to me?

Alka 07-22-2008 18:11

Re: Call function to get 4 random players?!
 
Quote:

Originally Posted by dekken (Post 656834)
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;   }  }

Exolent[jNr] 07-22-2008 18:31

Re: Call function to get 4 random players?!
 
http://forums.alliedmods.net/showthread.php?t=74666

12345 07-22-2008 21:37

Re: Call function to get 4 random players?!
 
Quote:

Originally Posted by 12345 (Post 656845)
GREAT!

how i can put this to work on start round?
anyone can make one plugin to me?



All times are GMT -4. The time now is 05:29.

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