Yini ParseFile bug
#1

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

Anyone?
Reply
#3

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

Quote:
Originally Posted by Stev
View Post
GetPlayerIp(playerid, string, sizeof(string));
For real? that doesn't make any difference...?
Reply
#5

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

Thank you, but it still gives me the strange bug...
Reply
#7

Quote:
Originally Posted by saffierr
View Post
Thank you, but it still gives me the strange bug...
What is the bug??
Reply
#8

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

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

U may not cleared variables after parse use close ini
Reply
#11

edit is below
Reply
#12

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?
Reply
#13

Edit is below
Reply
#14

IP is a string, not an integer.
Reply
#15

Fixed it, see below.
Reply
#16

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


Forum Jump:


Users browsing this thread: 2 Guest(s)