09.03.2016, 20:53
I am facing a problem with INI_ParseFile, whenever I use it within a CMD.
The problem is, the stats of the [playername] are transferring to me. It's kinda hard to explain...
----
For example: Michael is admin level 3 and Sarah is admin level 0.
Michael uses the CMD: /giveoffmoney Sarah 500
after committing this, Michael receives the STATS of Sarah, so Michael's admin level is 0 now.
+rep.
PHP код:
CMD:giveoffmoney(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] < 1) return 0;
if(PlayerInfo[playerid][pAdmin] < 4) return SendClientMessage(playerid, COLOR_YELLOWGREEN, "Error: You are not authorized to use this command.");
new string[128], user[50], amount;
if(sscanf(params, "s[50]i", user, amount)) return SendClientMessage(playerid, COLOR_ORANGE, "Usage: /giveoffmoney [playername] [amount]");
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);
new INI:File = INI_Open(string);
INI_SetTag(File, "PlayerData");
INI_WriteInt(File, "Money", PlayerInfo[playerid][pMoney] + amount);
INI_Close(File);
format(string, sizeof string, "You have given '%s' $%i. Player '%s' has now $%i dollars.", user, amount, user, PlayerInfo[playerid][pMoney] + amount);
SendClientMessage(playerid, -1, string);
return 1;
}
----
For example: Michael is admin level 3 and Sarah is admin level 0.
Michael uses the CMD: /giveoffmoney Sarah 500
after committing this, Michael receives the STATS of Sarah, so Michael's admin level is 0 now.
+rep.