Yini ParseFile bug -
saffierr - 29.02.2016
As soon as I commit any command having 'INI_ParseFile' included in it I get a strange bug, namely; for example: /getip player1, I get the stats of the 'player1' player.
Code:
PHP Code:
new string[75], pName[MAX_PLAYER_NAME], option[25], user[50], pName2[MAX_PLAYER_NAME], targetplayer;
if(sscanf(params, "s[50]", user)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /getip [playername]");
format(string, sizeof string, "/Users/%s.txt", user);
if(!fexist(string)) return SendClientMessage(playerid, COLOR_RED, "Error: The player has not been found in our database!");
INI_ParseFile(string, "LoadPlayerData_user", .bExtra = true, .extra = playerid);
GetPlayerIp(playerid, string, sizeof string);
format(string, sizeof string, "The IP of '%s' is: %s", user, string);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
Whenever restarting the server I get my old stats back.
Re: Yini ParseFile bug -
saffierr - 01.03.2016
Anyone?
Re: Yini ParseFile bug -
Stev - 01.03.2016
Quote:
Originally Posted by saffierr
GetPlayerIp(playerid, string, sizeof string);
format(string, sizeof string, "The IP of '%s' is: %s", user, string);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);[/PHP]
|
GetPlayerIp(playerid, string, sizeof(string));
Re: Yini ParseFile bug -
saffierr - 01.03.2016
Quote:
Originally Posted by Stev
GetPlayerIp(playerid, string, sizeof(string));
|
For real? that doesn't make any difference...?
Re: Yini ParseFile bug -
[NWA]Hannes - 01.03.2016
In your LoadPlayerData function, save the IP to a declaration in a string, then use this in your /getip command.
Example:
pawn Code:
//Somewhere
new PlayerIP[32];
//LoadPlayerData
GetPlayerIp(playerid, PlayerIP, sizeof(PlayerIP));
//Command for getting IP
INI_ParseFile(string, "LoadPlayerData_user", .bExtra = true, .extra = CHANGEME); //Here put the id of the player you're retrieving the IP from
new str[64];
format(str, sizeof(str), "Players IP is %s", PlayerIP);
SendClientMessage(playerid, -1, str);
Or you could simply save the IP for each player to the file itself
Re: Yini ParseFile bug -
saffierr - 01.03.2016
Thank you, but it still gives me the strange bug...
Re: Yini ParseFile bug -
SyS - 02.03.2016
Quote:
Originally Posted by saffierr
Thank you, but it still gives me the strange bug...
|
What is the bug??
Re: Yini ParseFile bug -
saffierr - 02.03.2016
The bug is: if an Player1 does /getip [Saffierr] (from a offline player) the admin gets the stats of Saffierr. For example:
Saffierr Admin Level = 2
Saffierr VIP = 1
The Player1 Admin Level = 4
The Player1 VIP = 2
If Player1 does /getip Saffierr, all the stats of Player1 changes to the stats of Saffierr.
NOTE: But when restarting Player1 gets his old stats back.
Re: Yini ParseFile bug -
Threshold - 02.03.2016
pawn Code:
INI_ParseFile(string, "LoadPlayerData_user", .bExtra = true, .extra = playerid);
That line is going to replace all of YOUR variables with the information loaded from "/Users/user.txt"... so you will be replacing all your stats with that line. I have a feeling that you won't understand my full explanation, so show me your LoadPlayerData and I will make a new function for you and explain it from there...
Re: Yini ParseFile bug -
SyS - 02.03.2016
U may not cleared variables after parse use close ini
Re: Yini ParseFile bug -
saffierr - 02.03.2016
edit is below
Re: Yini ParseFile bug -
Threshold - 02.03.2016
Okay, so you don't even save the IP in the user's file... so why are you using INI_ParseFile in the first place?
Re: Yini ParseFile bug -
saffierr - 02.03.2016
Edit is below
Re: Yini ParseFile bug -
Threshold - 03.03.2016
IP is a string, not an integer.
Re: Yini ParseFile bug -
saffierr - 03.03.2016
Fixed it, see below.
Re: Yini ParseFile bug -
saffierr - 03.03.2016
#Threshold, I have fixed it in a other way, the cmd looks now like this:
PHP Code:
new user[50];
if(sscanf(params, "s[25]s[50]", option, user)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /getip [playername]");
format(string, sizeof string, "/Users/%s.txt", user);
if(!fexist(string)) return SendClientMessage(playerid, COLOR_RED, "Error: The player has not been found in our database!");
format(string, sizeof string, "The IP of '%s' is: %s", user, PlayerInfo[playerid][pIP]);
SendClientMessage(playerid, COLOR_LIGHTBLUE, string);
I have reffered GetPlayerIp(); to PlayerInfo[][pIP] whenever they register.
----
But still I'd like to know how to fix the bug I had as I have other cmds which uses INI_ParseFile and faces the same bug.
We possibly could discuss this through PMs or skype if you want.