Quote:
Originally Posted by AmigaBlizzard
PHP Code:
enum TPlayerData
{
UserID,
Name[25],
Password[130],
IP[16],
GPCI[130],
PasswordAttempts,
bool:LoggedIn,
bool:InClassSelection,
// Player data
Money,
Score,
AdminLevel,
Speed
}
new APlayerData[MAX_PLAYERS][TPlayerData];
Consider this enum structure.
Most people do this when clearing all data in a player's account when a player disconnects or connects (to be sure the new player won't get data from the previous player):
PHP Code:
APlayerData[playerid][UserID] = 0;
APlayerData[playerid][Name][0] = 0;
APlayerData[playerid][Password][0] = 0;
APlayerData[playerid][IP][0] = 0;
APlayerData[playerid][GPCI][0] = 0;
APlayerData[playerid][PasswordAttempts] = 0;
APlayerData[playerid][LoggedIn] = false;
APlayerData[playerid][InClassSelection] = false;
APlayerData[playerid][Money] = 0;
APlayerData[playerid][Score] = 0;
APlayerData[playerid][AdminLevel] = 0;
APlayerData[playerid][Speed] = 0;
While it's alot easier to do this:
PHP Code:
new temp[TPlayerData];
APlayerData[playerid] = temp;
No need for hundreds of lines of code to reset your entire structure one variable at a time and no risk about forgetting to reset one of them.
Just reset them all at once.
I have no idea if it's faster and if it is, how much faster.
I never tested the speed of it, but it surely is less code and less risk to clear all your vars.
|
This is a proper way of doing it
pawn Code:
public OnPlayerDisconnect(playerid, reason)
{
for(new i = 0; i < sizeof(Players[]); i++) {
Players[playerid][pInfo:i] = 0; // or whatever ur player array is
}
return 1;
}
Of course if you use that make sure that you have your saving above it so you don't clear the players data entirely.
But for this thread this is completely unnecessary just for the minimal performance difference, it's not worth changing or doing in your current or future game modes. Eh I could see someone using it if they just found out about this way, and want to use it for the nano second differences, but not changes to already made GM's unless their that hungry for the performance.