AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get players, then select (https://forums.alliedmods.net/showthread.php?t=11582)

DiscoBBQ 03-23-2005 19:14

get players, then select
 
Well.. I need to have it so it gets all the players in servers. then randomly selects someone.
Help?
Like heres what i need. I need it so when you talk to one of my npc's itll randomly select someone in the server and display it in a client_print.

xeroblood 03-23-2005 19:48

Code:
new iPlayers[32], iNum // For alive players only..   get_players( iPlayers, iNum, "a" ) // For dead players only..   get_players( iPlayers, iNum, "b" ) // For all players get_players( iPlayers, iNum ) // now to loop through them all: new id, i for( i = 0; i < iNum; i++ ) {     id = iPlayers[i]     // do something with id }

Note: only use one of the get_players() listed above, and there are more possibilites, like specific teams and stuff.. look up the function in amxmodx.inc

:D

Twilight Suzuka 03-23-2005 20:23

or random_num(0,32), since a player index is 0-32.

xeroblood 03-23-2005 22:24

:oops: Ahh.. i forgot the random part!! :p lol

Thx Mel, i slipped up!! :P

Instead of:
Code:
// instead of this: new id, i for( i = 0; i < iNum; i++ ) {     id = iPlayers[i]     // do something with id } // put this: id = iPlayers[ random_num(0, iNum-1) ]

v3x 03-23-2005 22:37

Thought you were missing that.. :roll:


All times are GMT -4. The time now is 09:50.

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