[Help] Stats
#1

Hey all i made stats command and it work fine but problem is when player e.g. id 0 left server,and other player join server and get id 0, when i do /stats 0 it still showing stats for player who left with id 0?

Anyone know how to fix that?

Here is command if you need something else from code tell me:
pawn Код:
CMD:stats(playerid,params[])
{
    new name[MAX_PLAYER_NAME];
    new id;
    if(sscanf(params,"d",id)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /stats <ID>");
    if (!IsPlayerConnected(id)) return SendClientMessage(playerid, COLOR_RED, "ERROR: Player is not connected.");
    new string[128];
    GetPlayerName(id, name, sizeof(name));
    new Float:ratio=floatdiv(PlayerInfo[id][pKills], PlayerInfo[id][pDeaths]);
    format(string, 128, "%d %d %.2f", PlayerInfo[id][pKills], PlayerInfo[id][pDeaths], ratio);
    format(string, sizeof(string), "Name: %s (ID:%d)\nKills : %d\nDeaths : %d\nKill/Death Ratio: %.2f\nScore: %d\nTime Played: %d Hours, %d Minutes, %d Seconds",name, id, PlayerInfo[id][pKills], PlayerInfo[id][pDeaths], ratio,PlayerInfo[id][pScore],PlayerInfo[id][pHour],PlayerInfo[id][pMin],PlayerInfo[id][pSec]);
    ShowPlayerDialog(playerid,DIALOG_STATS,DIALOG_STYLE_MSGBOX,"Player Stats",string,"Close","");
    return 1;
}
Reply
#2

Reset the stats when a player disconnects. When a new player (who has no stat records joins) the stats from the old player are now written to the new one.

PHP код:
public OnPlayerDisconnect(playeridreason)
{
PlayerInfo[playerid][pKills] = 0;
//etc...
    
return 1;

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)