pInfo[playerid][Admin] = 0;
ResetVariables(playerid)
{
PlayerTemp[playerid][OnDuty] = 0;
PlayerTemp[playerid][OnhDuty] = 0;
PlayerTemp[playerid][Spawned] = 0;
PlayerTemp[playerid][isevent] = 0;
PlayerTemp[playerid][MaxRcon] = 0;
PlayerTemp[playerid][Jetpack] = 0;
PlayerTemp[playerid][LastShot] = 0;
PlayerTemp[playerid][LastShotTick] = 0;
PlayerTemp[playerid][dSpawnedCars] = 0;
PlayerTemp[playerid][pSpawnFreeze] = 0;
PlayerTemp[playerid][LoginAttempts] = 0;
//these are all that reset to 0 below
pInfo[playerid][Score] = 0;
pInfo[playerid][Kills] = 0;
pInfo[playerid][Deaths] = 0;
pInfo[playerid][Banned] = 0;
pInfo[playerid][Admin] = 0;
/*^^^^^^^^^^^^^^^^^^^^^^^^^*/
NeedsHelp[playerid] = 0;
ReportTime[playerid] = 0;
Delete3DTextLabel(afklabel[playerid]);
Delete3DTextLabel(adminlabel[playerid]);
}
else
{
ShowPlayerDialog(playerid, DIALOG_REGISTER, DIALOG_STYLE_INPUT,""COL_WHITE"Registering...",""COL_WHITE"Type your password below to register a new account.","Register","Quit");
GivePlayerMoney(playerid, 25000);
PlayerInfo[playerid][pKills] = 0;
PlayerInfo[playerid][pDeaths] = 0;
PlayerInfo[playerid][pScore] = 0;
OMG this register system i made it right, and then if i set player A to be an admin it will set and it will save, good.. Now if player B comes online and register he will get the stats of player A, resulting in him also being admin, anyways i then made a resetvariable(playerid);, which is called when the players (dis)connect, now i place this coding under the resetvariable function
PHP код:
PHP код:
|
OnRegister(playerid) { pInfo[playerid][Score] = 0; pInfo[playerid][Kills] = 0; pInfo[playerid][Deaths] = 0; pInfo[playerid][Banned] = 0; pInfo[playerid][Admin] = 0; }
ResetVariables(playerid)
{
PlayerTemp[playerid][OnDuty] = 0;
PlayerTemp[playerid][OnhDuty] = 0;
PlayerTemp[playerid][Spawned] = 0;
PlayerTemp[playerid][isevent] = 0;
PlayerTemp[playerid][MaxRcon] = 0;
PlayerTemp[playerid][Jetpack] = 0;
PlayerTemp[playerid][LastShot] = 0;
PlayerTemp[playerid][LastShotTick] = 0;
PlayerTemp[playerid][dSpawnedCars] = 0;
PlayerTemp[playerid][pSpawnFreeze] = 0;
PlayerTemp[playerid][LoginAttempts] = 0;
//these are all that reset to 0 below
pInfo[playerid][Score] = 0;
pInfo[playerid][Kills] = 0;
pInfo[playerid][Deaths] = 0;
pInfo[playerid][Banned] = 0;
pInfo[playerid][Admin] = 0;
/*^^^^^^^^^^^^^^^^^^^^^^^^^*/
NeedsHelp[playerid] = 0;
ReportTime[playerid] = 0;
Delete3DTextLabel(afklabel[playerid]);
Delete3DTextLabel(adminlabel[playerid]);
}
ResetVariables(playerid)
{
memcpy(pInfo[playerid], pInfo[MAX_PLAYERS], 0, sizeof(pInfo[])*4, sizeof(pInfo[]));
memcpy(PlayerTemp[playerid], PlayerTemp[MAX_PLAYERS], 0, sizeof(PlayerTemp[])*4, sizeof(PlayerTemp[]));
NeedsHelp[playerid] = 0;
ReportTime[playerid] = 0;
Delete3DTextLabel(afklabel[playerid]);
Delete3DTextLabel(adminlabel[playerid]);
}
Not the TS but working on a similar system: is resetting these stats absolutely needed? Why can't the '[playerinfo][][admin]' integer be null instead of 0?
I don't question your knowledge on this subject, I am just curious. |
Resetting the stats is needed.
Suppose, you're ID 0 and you've data in your variables, and you leave the server, your variables aren't reset to zero and another new player joins with ID 0 ( which was same as yours ), so he'll get the same data as yours which aren't saved/loaded. |