27.03.2016, 19:49
You can also use functions from foreach/y_iterate if you already use it since there are Iter_Next and Iter_Prev in it.
PHP код:
GetNextPlayerID(id)
{
new
next_id;
if ((next_id = Iter_Next(Player, id)) != MAX_PLAYERS) return next_id;
return ((next_id = Iter_First(Player)) == id) ? INVALID_PLAYER_ID : next_id;
}
GetPreviousPlayerID(id)
{
new
previous_id;
if ((previous_id = Iter_Prev(Player, id)) != MAX_PLAYERS) return previous_id;
return ((previous_id = Iter_Last(Player)) == id) ? INVALID_PLAYER_ID : previous_id;
}