Player files
#1

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
Reply
#2

Show us OnPlayerDisconnect and all associated functions.
Reply
#3

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;
}
Reply
#4

Search your script for "V.I.P Level". I bet you have it elsewhere.
Reply
#5

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


Код:
Took Tutorial = 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
Reply
#6

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.
Reply
#7

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
Reply
#8

Then try removing all the spaces.

Use VIPLevel and Takentutorial as entries. Seems it adds duplicates of any entries containing spaces.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)