Raised This Month: $ Target: $400
 0% 

Random player/s.


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Lee
AlliedModders Donor
Join Date: Feb 2006
Old 05-09-2009 , 15:53   Re: Random player/s.
Reply With Quote #17

Indeed (depending on what approach to collecting valid players is taken). Here's an efficient and simple solution to a simple problem.

Code:
#include <amxmodx> new bool:isConnected[33]; public client_putinserver(id)     isConnected[id] = true;     public client_disconnect(id)     isConnected[id] = false; getRandomPlayer() {     //returns player index or 0 if no players are found         static playerList[32];     new playerCount;         for(new i = 1; i < 33; i++)     {         if(!isConnected[i])             continue;                     if(1 < get_user_team(i) < 4)             playerList[playerCount++] = i;     }             return playerCount ? playerList[random_num(0, playerCount - 1)] : 0; }

Edit: this doesn't meet the request because I was following what the the other three did. :/
__________________
No support via PM.

Last edited by Lee; 05-09-2009 at 16:07.
Lee is offline
 


Thread Tools
Display Modes

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 23:13.


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