AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   pick random, then loop (https://forums.alliedmods.net/showthread.php?t=16842)

Obbin 08-21-2005 09:34

pick random, then loop
 
can someone give me an code snippet @ how to pick an random player and then make an loop that affects everybody but that person?

example:
everybody affected says "i was affected"

Code:
client_cmd(id,"I was affected by the loop")

v3x 08-21-2005 09:38

Code:
public MyFunc(id) {     new iRand = random_num(1,get_maxplayers())     if( is_user_connected(iRand) )     {         client_print(iRand,print_chat,"I was affected by teh func")     }     else     {         MyFunc(id)     } }
Bah, that's how I would do it. :P

Obbin 08-21-2005 10:02

thx v3x but i wanted to make the opposit!
everybody exept one!

example:

players: 4/4 (george, bill, john, richard)
---> Function satrts and radndomly picks jhon!
bill: I was affected
richard: I was affected
george: I was affected
jhon: I was not affected

XxAvalanchexX 08-21-2005 15:08

shame shame, v3x, that could take forever when the game is running 3 / 32 players.

Code:
new players[32], num, i; get_players(players,num); new free = players[random_num(0,num-1)]; for(i=0;i<num;i++) {    if(players[i] != free) {       client_cmd(players[i],"say ^"Anais Anais smells so good!^"");    } }

v3x 08-21-2005 19:29

Ah yes, shame upon me. :P


All times are GMT -4. The time now is 14:35.

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