SA-MP Forums Archive
Does these two loops do the same thing? - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Does these two loops do the same thing? (/showthread.php?tid=280470)



Does these two loops do the same thing? - Cowboy - 01.09.2011

pawn Code:
for (new i = 0; i < MAX_PLAYERS; i++)
and

pawn Code:
for(new i; i != MAX_PLAYERS; i++)



Re: Does these two loops do the same thing? - Lorenc_ - 01.09.2011

yes

( 1234 )


Re: Does these two loops do the same thing? - Cowboy - 01.09.2011

Hi Lorenc, thanks for your answer.

Btw, from your tutorial, this

pawn Code:
public OnGameModeExit()
{
    for(new i; i != MAX_PLAYERS; i++) OnPlayerDisconnect(i, 1);
    db_close(Database);
    return 1;
}
Doesn't it need a IsPlayerConnected check?

EDIT:

I gotta another question.

Example:

PlayerInfo[playerid][pAdminLevel] = 0;

Where is it best to put this? OnPlayerConnect or OnPlayerDisconnect? Or maybe both?

Thanks


Re: Does these two loops do the same thing? - Babul - 01.09.2011

the PlayerInfo[playerid][pAdminLevel] is a global variable, it wont get erased in case a level 3 admin logs out. so adding the level=0 into the disconnect, is a good idea.
to set admin level to 0 when connecting, is not the best idea (its value is set to 0 at initializing, also got set to 0 from a recently playing admin on that slot).
i suggest you to use PVars to store such "important" variables, so any of your filterscript can access it aswell. PVars gets deleted when a player disconnects, so no worry about resetting the player-arrays.


Re: Does these two loops do the same thing? - =WoR=Varth - 01.09.2011

Quote:
Originally Posted by Babul
View Post
the PlayerInfo[playerid][pAdminLevel] is a global variable, it wont get erased in case a level 3 admin logs out. so adding the level=0 into the disconnect, is a good idea.
to set admin level to 0 when connecting, is not the best idea (its value is set to 0 at initializing, also got set to 0 from a recently playing admin on that slot).
i suggest you to use PVars to store such "important" variables, so any of your filterscript can access it aswell. PVars gets deleted when a player disconnects, so no worry about resetting the player-arrays.
I suggest you to read this:
http://forum.sa-mp.com/showthread.ph...highlight=PVar


Re: Does these two loops do the same thing? - AndreT - 01.09.2011

Quote:
Originally Posted by Cowboy
View Post
pawn Code:
public OnGameModeExit()
{
    for(new i; i != MAX_PLAYERS; i++) OnPlayerDisconnect(i, 1);
    db_close(Database);
    return 1;
}
Why would there be anything like that at all is what I'm wondering. OnPlayerDisconnect is called for every player upon a controlled server restart anyways.
Quote:
Originally Posted by Cowboy
View Post
I gotta another question.

Example:

PlayerInfo[playerid][pAdminLevel] = 0;

Where is it best to put this? OnPlayerConnect or OnPlayerDisconnect? Or maybe both?
Both would be a waste. Resetting it under OnPlayerDisconnect is a good idea.


Re: Does these two loops do the same thing? - =WoR=Varth - 01.09.2011

Quote:
Originally Posted by AndreT
View Post
Why would there be anything like that at all is what I'm wondering. OnPlayerDisconnect is called for every player upon a controlled server restart anyways.
It's bugged with gmx.


Re: Does these two loops do the same thing? - Cowboy - 01.09.2011

I tried that code, but it doesn't save when I gmx, why?


Re: Does these two loops do the same thing? - =WoR=Varth - 01.09.2011

Create costum gmx command.
Do the saving thinghy then run gmx.


Re: Does these two loops do the same thing? - Cowboy - 01.09.2011

No other way? I would really like to use the gmx from rcon window