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
}