Raised This Month: $32 Target: $400
 8% 

[(probably not)USEFUL FUNCTION] Find Next/Previous Player


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
pRED*
Join Date: Dec 2006
Old 06-30-2007 , 22:16   [(probably not)USEFUL FUNCTION] Find Next/Previous Player
Reply With Quote #1

Two stocks I made for my rate checker plugin.
Find a Next or Previous player (based on their id num).

I used it for the next and previous buttons on the rate menu, you, probably wont use it at all, but I posted it anyway.

Code:
/**  * Finds the Next Non bot connected player (based on id number)  *  * @param player        Id number of the current player  * @return        Id of next player or -1 for failure  */ stock FindNextPlayer(player) {     new maxclients=GetMaxClients()     new temp=player         do     {         temp++         if (temp>maxclients)             temp=1                 //been all the way around without finding.         //quit with an error to prevent infinite loop         if (temp==player)             return -1     }     while (!(IsClientInGame(temp) && !IsFakeClient(temp)))         return temp } /**  * Finds the Previous Non bot connected player (based on id number)  *  * @param player        Id number of the current player  * @return        Id of previous player or -1 for failure  */ stock FindPrevPlayer(player) {     new maxclients=GetMaxClients()     new temp=player         do     {         temp--         if (temp<1)             temp=maxclients         //been all the way around without finding.         //quit with an error to prevent infinite loop         if (temp==player)             return -1     }     while (!(IsClientInGame(temp) && !IsFakeClient(temp)))         return temp }
pRED* 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 04:03.


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