How to see others stats?
#1

i have a cmd /stats in which player only see his own stats. I want /stats [id] cmd in which he can see others stats too.

here is the cmd ↓

pawn Код:
CMD:stats(playerid,params[])
{
    new money = PlayerInfo[playerid][pCash];
    new deaths = PlayerInfo[playerid][pDeaths];
    new kills = PlayerInfo[playerid][pKills];
    new vip = PlayerInfo[playerid][pVip];
    new warn = PlayerInfo[playerid][pWarns];
    new string[200];
    format(string,sizeof(string),"| Money: %d | Kills: %d | Deaths: %d | Ratio: %0.2f | VIP: %d | Warns: %d| ",money,kills,deaths,Float:kills/Float:deaths,vip,warn);
    SendClientMessage(playerid,COLOR_WHITE,string);
    return 1;
}
Reply
#2

Copy it change the command name and use sscanf?
Reply
#3

pawn Код:
CMD:stats(playerid,params[])
{
    new id = playerid;
   
    if(!isnull(params))
        id = strval(params);
   
    new money = PlayerInfo[id][pCash];
    new deaths = PlayerInfo[id][pDeaths];
    new kills = PlayerInfo[id][pKills];
    new vip = PlayerInfo[id][pVip];
    new warn = PlayerInfo[id][pWarns];
    new string[200];
    format(string,sizeof(string),"| Money: %d | Kills: %d | Deaths: %d | Ratio: %0.2f | VIP: %d | Warns: %d| ",money,kills,deaths,Float:kills/Float:deaths,vip,warn);
    SendClientMessage(playerid,COLOR_WHITE,string);
    return 1;
}
Reply
#4

checking
Reply
#5

my code does what you want.
Reply
#6

is this posible when player is not connected a message appears "player is not connected'.
Reply
#7

pawn Код:
CMD:stats(playerid,params[])
{
    new id = playerid;
   
    if(!isnull(params))
    {
        id = strval(params);
        if(!IsPlayerConnected(id))
            return SendClientMessage(playerid, 0xFFFFFFFF, "Player is not connected");
    }
   
    new money = PlayerInfo[id][pCash];
    new deaths = PlayerInfo[id][pDeaths];
    new kills = PlayerInfo[id][pKills];
    new vip = PlayerInfo[id][pVip];
    new warn = PlayerInfo[id][pWarns];
    new string[200];
    format(string,sizeof(string),"| Money: %d | Kills: %d | Deaths: %d | Ratio: %0.2f | VIP: %d | Warns: %d| ",money,kills,deaths,Float:kills/Float:deaths,vip,warn);
    SendClientMessage(playerid,COLOR_WHITE,string);
    return 1;
}
Reply
#8

pawn Код:
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,("Player is not connected");
Reply
#9

pawn Код:
CMD:stats(playerid,params[])
{
    new money = PlayerInfo[pID][pCash];
    new deaths = PlayerInfo[pID][pDeaths];
    new kills = PlayerInfo[pID][pKills];
    new vip = PlayerInfo[pID][pVip];
    new warn = PlayerInfo[pID][pWarns];
    new string[200];
    new name[MAX_PLAYER_NAME],pID;
   if(sscanf(params,"u",pID)) return SendClientMessage(playerid,0xCCCCCCAA,"/stats [id]");
   if(!IsPlayerConnected(pID)) return SendClientMessage(playerid,COLOR_WHITE,"Player not connected.");
   if(pID == INVALID_PLAYER_ID) return SendClientMessage(playerid,COLOR_WHITE,"Invalid Player ID");
   GetPlayerName(pID,name,sizeof(name));
   format(string,sizeof(string),"%s's Stats",name);
    format(string,sizeof(string),"| Money: %d | Kills: %d | Deaths: %d | Ratio: %0.2f | VIP: %d | Warns: %d| ",money,kills,deaths,Float:kills/Float:deaths,vip,warn);
    SendClientMessage(playerid,COLOR_WHITE,string);
    return 1;
}
Reply
#10

there is no need to use sscanf, when you only need one param.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)