SA-MP Forums Archive
pstats cmd bugged - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: pstats cmd bugged (/showthread.php?tid=153758)



pstats cmd bugged - iStarzz - 10.06.2010

When i type /pstats 1 it's showing wrong stats.. :S then i type /pstats 2 and it will be showing /pstats 1 stats.. :S
pawn Код:
dcmd_pstats(playerid,params[])
{
    new statid;
    new string[256];
  new Float:ratio=floatdiv(UserUD[statid][kills], UserUD[statid][deaths]);

    if(sscanf(params, "u", statid)) return SendClientMessage(playerid,green,"Error: /pstats <playerid/name>");
    if(!IsPlayerConnected(statid) || statid == INVALID_PLAYER_ID || statid == playerid) return SendClientMessage(playerid,green,"Error: Player is not connected or it is yourself, For your own stats use /stats");

  format(string,sizeof(string),"Duty-Stats: Kills: %d | Deaths: %d | KD Ratio: %.2f | Admin Level: %d | Duty-ViP: %d | Duty-Cash: %d",UserUD[statid][kills],UserUD[statid][deaths],ratio,UserUD[statid][admin],UserUD[statid][vip],UserUD[statid][money]);
    SendClientMessage(playerid,green,string);
  format(string,sizeof(string),"Duty-Special-Stats: cookies: %d",UserUD[statid][cookies]);
    SendClientMessage(playerid,green,string);
    return 1;
}
I hope somebody is able to help.


Re: pstats cmd bugged - PotH3Ad - 10.06.2010

This line "new Float:ratio=floatdiv(UserUD[statid][kills], UserUD[statid][deaths]);" should be under "if(sscanf...". Everything else looks correct...

pawn Код:
dcmd_pstats(playerid,params[])
{
    new statid;
    new string[256];

    if(sscanf(params, "u", statid)) return SendClientMessage(playerid,green,"Error: /pstats <playerid/name>");
    if(!IsPlayerConnected(statid) || statid == INVALID_PLAYER_ID || statid == playerid) return SendClientMessage(playerid,green,"Error: Player is not connected or it is yourself, For your own stats use /stats");
  new Float:ratio=floatdiv(UserUD[statid][kills], UserUD[statid][deaths]);

  format(string,sizeof(string),"Duty-Stats: Kills: %d | Deaths: %d | KD Ratio: %.2f | Admin Level: %d | Duty-ViP: %d | Duty-Cash: %d",UserUD[statid][kills],UserUD[statid][deaths],ratio,UserUD[statid][admin],UserUD[statid][vip],UserUD[statid][money]);
    SendClientMessage(playerid,green,string);
  format(string,sizeof(string),"Duty-Special-Stats: cookies: %d",UserUD[statid][cookies]);
    SendClientMessage(playerid,green,string);
    return 1;
}



Re: pstats cmd bugged - iStarzz - 10.06.2010

k thanks


Re: pstats cmd bugged - Sergei - 10.06.2010

Код:
!IsPlayerConnected(statid) || statid == INVALID_PLAYER_ID
Useless. Use only second option.
Код:
statid == INVALID_PLAYER_ID