14.11.2014, 19:15
Quote:
Change "if(!IsPlayerAdmin(i))" to if(IsPlayerConnected(i) && !IsPlayerAdmin(i))
- More efficient this way... |
Quote:
No it isn't. The player has to be connected in order for the script to kick them, therefore including that function would be useless.
Your method is inefficient. |
pawn Код:
for (new i = 0; i < MAX_PLAYERS; i++)
{
if (!IsPlayerConnected(i))
continue; //'i' not connected - Break current 'round' and start the next 'round' of the loop (i++)
if (!IsPlayerAdmin(i)) Kick(i);
}
What if you have 2 players online (and MAX_PLAYERS is defined as 500). It will try to kick atleast 498 players (if not connected, a player also isn't a RCON admin). By using 'continue', you will break the current 'round' of the loop and continue futher with the statement (which is 'i++').
Also, the if (IsPlayerConnected(i) && !IsPlayerAdmin(i)) is not ineffecient, because the server now won't try to kick a player whom is offline. Yet, my way would be the best way.
Quote:
if(!IsPlayerAdmin(i)) Kick(playerid); // you can use KickWithMessage if you want, I'm just using Kick() for the sake of time. |