08.09.2014, 10:36
Hello there,
I made a /stats command which displays amount of cash of a certain player, admin level, kills and deaths. This is my player information enum and array:
My user path stock:
My /stats command:
Whenever a player dies, this is what happens:
The above code should increment the deaths then update the user file, so when I type /stats, I get the values. The problem is, it's not updating, despite the code above. All I see is 0 deaths even though I /kill'd myself a few times.
Please help me
I made a /stats command which displays amount of cash of a certain player, admin level, kills and deaths. This is my player information enum and array:
pawn Код:
enum pInfo
{
pPass,
pCash,
pAdmin,
pKills,
pDeaths
}
new PlayerInfo[MAX_PLAYERS][pInfo];
pawn Код:
stock UserPath(playerid)
{
new string[128], playername[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, playername, sizeof(playername));
format(string, sizeof(string), PATH, playername);
return string;
}
pawn Код:
if (strcmp("/stats", cmdtext, true, 6) == 0)
{
new cash = PlayerInfo[playerid][pCash];
new admin = PlayerInfo[playerid][pAdmin];
new kills = PlayerInfo[playerid][pKills];
new deaths = PlayerInfo[playerid][pDeaths];
new string[128], playerName[MAX_PLAYER_NAME+1];
GetPlayerName(playerid, playerName, sizeof(playerName));
format(string, sizeof(string), "%s's statistics: \n Amount of cash: %i \n Admin level: %i \n Kills: %i \n Deaths: %i \n", playerName, cash, admin, kills, deaths);
SendClientMessage(playerid, -1, string);
return 1;
}
pawn Код:
public OnPlayerDeath(playerid, killerid, reason)
{
// Increment killer's kills and dead's deaths
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
GivePlayerMoney(killerid, 1000);
SendClientMessage(killerid, -1, "Nicely done, you have received 1000 dollars for the kill!");
new INI:File = INI_Open(UserPath(playerid));
INI_SetTag(File, "data");
INI_WriteInt(File, "Deaths", PlayerInfo[playerid][pDeaths]);
INI_Close(File);
return 1;
}
Please help me