PDA

View Full Version : Does these two loops do the same thing?


Cowboy
01/09/2011, 10:39 AM
for (new i = 0; i < MAX_PLAYERS; i++)

and

for(new i; i != MAX_PLAYERS; i++)

Lorenc_
01/09/2011, 10:41 AM
yes

( 1234 )

Cowboy
01/09/2011, 10:46 AM
Hi Lorenc, thanks for your answer.

Btw, from your tutorial, this

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

Babul
01/09/2011, 11:16 AM
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.

=WoR=Varth
01/09/2011, 11:28 AM
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.php?t=268499&highlight=PVar

AndreT
01/09/2011, 11:46 AM
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.

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.

=WoR=Varth
01/09/2011, 11:56 AM
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.

Cowboy
01/09/2011, 11:58 AM
I tried that code, but it doesn't save when I gmx, why?

=WoR=Varth
01/09/2011, 12:08 PM
Create costum gmx command.
Do the saving thinghy then run gmx.

Cowboy
01/09/2011, 12:17 PM
No other way? I would really like to use the gmx from rcon window

=WoR=Varth
01/09/2011, 12:37 PM
There's no difference with costum gmx (Except the saving thinghy).
Just put IsPlayerAdmin in it.