Statistic's arent updating. (Y_ini) -
rangerxxll - 16.03.2013
Hi. So I have a few commands that just aren't working. The first one is /stats which shows the players statistics, and the second is /check, which will get the selected players statistics. Kills, Deaths, any of that, that required PlayerInfo is not updating for some reason. I'm really confused.
Here's my current enumerator.
pawn Код:
enum pInfo
{
pPass,
pCash,
pAdmin,
pVip,
pKills,
pDeaths,
pBan,
pScore,
pTalent
}
new PlayerInfo[MAX_PLAYERS][pInfo];
And my /check command for administrators.
pawn Код:
CMD:check(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=1 )
{
new target;
if(sscanf(params, "u",target)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /check [ID].");
if(!IsPlayerConnected(target)) return SendClientMessage(playerid,COLOR_RED, "Player is not connected.");
new Float:health;
GetPlayerHealth(target, health);
new Float:armour;
GetPlayerArmour(target, armour);
new money;
money = GetPlayerMoney(target);
new score;
score = GetPlayerScore(target);
new stats[1280];
format(stats, sizeof(stats), "{44A1D0}Score: %d\nHealth: %f\nArmour: %f\nMoney: %d\nVIP: %s\nAdmin Level: %s\nKills: %d\nDeaths: %d\n",
score, health, armour, money, GetVipLvlName(target), GetAdminLvlName(target), PlayerInfo[target][pKills], PlayerInfo[target][pDeaths]);
ShowPlayerDialog(playerid,0,DIALOG_STYLE_MSGBOX,"Information",stats,"Ok","");
}
else return SendClientMessage(playerid,COLOR_GREY, ERROR);
return 1;
Do I need to add a timer or something, that will re-read the stats, or what? I completely have no idea.
I also have this under onplayerdeath.
pawn Код:
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
Any help would be appreciated. Thank you.
Re: Statistic's arent updating. (Y_ini) -
Mystique - 16.03.2013
Does it return any errors? Because in my eyes that looks exactly as it should be.
Re: Statistic's arent updating. (Y_ini) -
rangerxxll - 16.03.2013
It doesn't.
Re: Statistic's arent updating. (Y_ini) -
Da_Noob - 16.03.2013
Are you sure that everytime your person dies, PlayerInfo[playerid][pDeaths] goes op? Or when he gets a kill, PlayerInfo[playerid][pKills] gets up? Everytime his cash, deaths, kills, viplevel, adminlevel changes, you'll need to change PlayerInfo too.
Re: Statistic's arent updating. (Y_ini) -
rangerxxll - 16.03.2013
I'm positive.
OnPlayerDeath:
pawn Код:
PlayerInfo[killerid][pKills]++;
PlayerInfo[playerid][pDeaths]++;
My /setadmin command.
pawn Код:
PlayerInfo[target][pAdmin] = 1;
<-- Just a example of what I have under it.
I also implemented a /savestats command, which still doesn't save there kills/deaths.
pawn Код:
CMD:savestats(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] >=4)
{
new string[128], reason[75];
if(sscanf(params, "s[75]",reason)) return SendClientMessage(playerid,COLOR_WHITE, "USAGE: /savestats [reason]");
{
foreach (Player, i)
{
new INI:File = INI_Open(UserPath(i));
INI_SetTag(File,"data");
INI_WriteInt(File,"Cash",GetPlayerMoney(i));
INI_WriteInt(File,"Admin",PlayerInfo[i][pAdmin]);
INI_WriteInt(File,"Vip",PlayerInfo[i][pVip]);
INI_WriteInt(File,"Kills",PlayerInfo[i][pKills]);
INI_WriteInt(File,"Deaths",PlayerInfo[i][pDeaths]);
INI_WriteInt(File,"Ban",PlayerInfo[i][pBan]);
INI_WriteInt(File,"Score",PlayerInfo[i][pScore]);
INI_WriteInt(File,"Talent",PlayerInfo[i][pTalent]);
INI_Close(File);
}
format(string,sizeof(string), "AdmCmd: %s %s has Saved everyones stats. Reason: %s",GetAdminLvlName(playerid),GetName(playerid),reason);
SendClientMessageToAll(COLOR_ORANGE, string);
}
}
else return SendClientMessage(playerid, COLOR_GREY, ERROR);
return 1;
}