#define PATH "mainfs/%s.ini"
new Kills[MAX_PLAYERS], Deaths[MAX_PLAYERS], DerbyWon[MAX_PLAYERS], DuelWon[MAX_PLAYERS], DuelsAllow[MAX_PLAYERS];
stock UserPath(playerid)
{
new file[40];
format(file, sizeof(file), PATH, GetName(playerid));
return file;
}
stock GetName(playerid)
{
new Name[24];
GetPlayerName(playerid, Name, sizeof(Name));
return Name;
}
public OnPlayerConnect(playerid)
{
new string[40];
format(string, sizeof(string), "JLadmin/Users/%s.ini", GetName(playerid));
if(fexist(string))
{
if(!fexist(UserPath(playerid)))
{
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File, "Kills", 0);
INI_WriteInt(File, "Deaths", 0);
INI_WriteInt(File, "Derby Won", 0);
INI_WriteInt(File, "DuelWon", 0);
INI_WriteInt(File, "DuelsAllow", 0);
INI_Close(File);
SetTimerEx("SaveData", 1000, 1, "i", playerid);
}
else
{
INI_ParseFile(UserPath(playerid),"loadaccount_%s", .bExtra = true, .extra = playerid);
}
}
}
stock SavePlayerData(playerid)
{
new INI:File = INI_Open(UserPath(playerid));
INI_WriteInt(File, "Kills", Kills[playerid]);
INI_WriteInt(File, "Deaths", Deaths[playerid]);
INI_WriteInt(File, "DerbyWon", DerbyWon[playerid]);
INI_WriteInt(File, "DuelWon", DuelWon[playerid]);
INI_WriteInt(File, "DuelsAllow", DuelsAllow[playerid]);
INI_Close(File);
return 1;
}
forward loadaccount_user(playerid, name[], value[]);
public loadaccount_user(playerid, name[], value[])
{
INI_Int("Kills", Kills[playerid]);
INI_Int("Deaths", Deaths[playerid]);
INI_Int("Derby Won", DerbyWon[playerid]);
INI_Int("DuelWon", DuelWon[playerid]);
INI_Int("DuelsAllow", DuelsAllow[playerid]);
return 1;
}
CMD:pstats(playerid, params[])
{
new id;
if(sscanf(params, "u", id)) return SendClientMessage(playerid, -1,"{ff0000}Error: {ffffff}Correct usage: /stats (playerid)");
if(!IsPlayerConnected(id)) return SendClientMessage(playerid, -1, "{ff0000}Error: {ffffff}Player Is Not Connected");
new string[201];
format(string, sizeof(string), "{f7ea00}~~~~~~~~%s(%d)~~~~~~~ \n {ff0000}Kills: {00ff19}%d \n {ff0000}Deaths: {00ff19}%d \n {ff0000}Death Racing Won: {00ff19}%d \n {ff0000}Duels Won: {00ff19}%d \n {ff0000}Kill/Death Ratio: {00ff19}%d", GetName(id), id, Kills[id], Deaths[id], DerbyWon[id], DuelWon[id], Kills[id]/Deaths[id]);
ShowPlayerDialog(playerid, 25, DIALOG_STYLE_MSGBOX, "{f7ea00}Player Statistics:", string, "Okay", "");
return 1;
}
Kills[id]/Deaths[id]
floatdiv(Kills[id], Deaths[id])
The problem is more likely here:
pawn Код:
You should do this instead: pawn Код:
|
NaN
Be aware that, if the number of deaths are 0, it will return:
Код:
NaN http://en.wikipedia.org/wiki/NaN |
if(sscanf(params, "i", id))