SA-MP Forums Archive
Yini ParseFile bug - 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: Yini ParseFile bug (/showthread.php?tid=602001)



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(playeridCOLOR_ORANGE"Usage: /getip [playername]");
        
format(stringsizeof string"/Users/%s.txt"user);
        if(!
fexist(string)) return SendClientMessage(playeridCOLOR_RED"Error: The player has not been found in our database!");
        
INI_ParseFile(string"LoadPlayerData_user", .bExtra true, .extra playerid);
        
GetPlayerIp(playeridstringsizeof string);
        
format(stringsizeof string"The IP of '%s' is: %s"userstring);
        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring); 
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
View Post
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
View Post
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
View Post
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]"optionuser)) return SendClientMessage(playeridCOLOR_ORANGE"Usage: /getip [playername]");
        
format(stringsizeof string"/Users/%s.txt"user);
        if(!
fexist(string)) return SendClientMessage(playeridCOLOR_RED"Error: The player has not been found in our database!");
        
format(stringsizeof string"The IP of '%s' is: %s"userPlayerInfo[playerid][pIP]);
        
SendClientMessage(playeridCOLOR_LIGHTBLUEstring); 
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.