[Tutorial] How to lock your gamemode whilst ingame
#10

Quote:
Originally Posted by Inverse
Посмотреть сообщение
Change "if(!IsPlayerAdmin(i))" to if(IsPlayerConnected(i) && !IsPlayerAdmin(i))

- More efficient this way...
Quote:
Originally Posted by sammp
Посмотреть сообщение
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);
}
That would be the best way -excluding foreach off course-.

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.

Hehehe. And the time you saved was entirely spilled to that comment haha
Reply


Messages In This Thread
How to lock your gamemode whilst ingame - by sammp - 30.06.2014, 23:44
Re: How to lock your gamemode whilst ingame - by SHE790 - 02.07.2014, 23:33
Re: How to lock your gamemode whilst ingame - by NewerthRoleplay - 02.07.2014, 23:37
Re: How to lock your gamemode whilst ingame - by Wilbert - 02.07.2014, 23:47
Re: How to lock your gamemode whilst ingame - by sammp - 04.07.2014, 01:08
Re: How to lock your gamemode whilst ingame - by Snipa - 04.07.2014, 01:19
Re: How to lock your gamemode whilst ingame - by sammp - 04.07.2014, 12:27
Re: How to lock your gamemode whilst ingame - by Inverse - 04.07.2014, 12:37
Re: How to lock your gamemode whilst ingame - by sammp - 11.07.2014, 20:37
Re: How to lock your gamemode whilst ingame - by Kwarde - 14.11.2014, 19:15

Forum Jump:


Users browsing this thread: 2 Guest(s)