Player files - 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: Player files (
/showthread.php?tid=605581)
Player files -
CROSS_Hunter - 21.04.2016
Basically I coded this INI user file system and these are the variables it creates/saves
Password
Cash
Admin
VIP Level
Took Tutorial
But the thing is , everytime a player disconnects the user file repeats the VIP Level and Took Tutorial variables and saves them so the files looks like
[data]
Password = 199754503
Cash = 0
Admin = 0
V.I.P Level = 0
Took Tutorial = 0
Score = 0
V.I.P Level = 0
Took Tutorial = 1
V.I.P Level = 0
Took Tutorial = 1
it says took tutorial = 1 because after registration you enter tutorial so after that it stays as 1 but the thing is about spamming it, why does it do that
Re: Player files -
introzen - 21.04.2016
Show us OnPlayerDisconnect and all associated functions.
Re: Player files -
CROSS_Hunter - 21.04.2016
Quote:
Originally Posted by introzen
Show us OnPlayerDisconnect and all associated functions.
|
Код:
public OnPlayerDisconnect(playerid, reason)
{
new str[128];
new PlayerName[MAX_PLAYER_NAME];
GetPlayerName(playerid, PlayerName, MAX_PLAYER_NAME);
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(playerid));
INI_WriteInt(File,"Admin",PlayerInfo[playerid][pAdmin]);
INI_WriteInt(File,"Score",PlayerInfo[playerid][pScore]);
INI_WriteInt(File,"V.I.P Level",PlayerInfo[playerid][pVIP]);
INI_WriteInt(File,"Took Tutorial",PlayerInfo[playerid][pTakenTUT]);
INI_Close(File);
switch (reason)
{
case 0:
format(str, sizeof(str), "* Player %s (Id:%d) has left the Server (Timeout)", PlayerName, playerid);
case 1:
format(str, sizeof(str), "* Player %s (Id:%d) has left the Server (Leaving)", PlayerName, playerid);
case 2:
format(str, sizeof(str), "* Player %s (Id:%d) has left the Server (Kicked/Banned)", PlayerName, playerid);
}
SendClientMessageToAll(COLOR_GREY, str);
if(BallHolder == playerid)
RecreateBall();
return 1;
}
Re: Player files -
introzen - 21.04.2016
Search your script for "V.I.P Level". I bet you have it elsewhere.
Re: Player files -
CROSS_Hunter - 21.04.2016
Quote:
Originally Posted by introzen
Search your script for "V.I.P Level". I bet you have it elsewhere.
|
The thing is, it doesn't write to the main variable it creates new ones everytime the player logs off with the correct values like:
[data]
Password = 199754503
Cash = 0
Admin = 0
V.I.P Level = 0
Took Tutorial = 0
Score = 0
V.I.P Level = 0
Took Tutorial = 1
It saves this but does NOT overwrite the original one which makes it duplicate it every time he logs off with the correct value
Re: Player files -
introzen - 21.04.2016
Try adding this to OnPlayerDisconnect and see if it adds a duplicate of those too.
PHP код:
INI_WriteInt(File,"V.I.P",PlayerInfo[playerid][pVIP]);
INI_WriteInt(File,"Taken Tutorial",PlayerInfo[playerid][pTakenTUT]);
Do not remove the ones you already have.
Re: Player files -
CROSS_Hunter - 21.04.2016
Quote:
Originally Posted by introzen
Try adding this to OnPlayerDisconnect and see if it adds a duplicate of those too.
PHP код:
INI_WriteInt(File,"V.I.P",PlayerInfo[playerid][pVIP]);
INI_WriteInt(File,"Taken Tutorial",PlayerInfo[playerid][pTakenTUT]);
Do not remove the ones you already have.
|
That was the result
[data]
Password = 199754503
Cash = 0
Admin = 0
V.I.P = 0
Took Tutorial = 0
Score = 0
V.I.P Level = 0
Took Tutorial = 1
Taken Tutorial = 1
V.I.P Level = 0
Took Tutorial = 1
Taken Tutorial = 1
Re: Player files -
introzen - 22.04.2016
Then try removing all the spaces.
Use VIPLevel and Takentutorial as entries. Seems it adds duplicates of any entries containing spaces.