How to see others stats? -
Champ - 02.07.2013
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;
}
Re: How to see others stats? -
Luis- - 02.07.2013
Copy it change the command name and use sscanf?
Re: How to see others stats? -
Scottas - 02.07.2013
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;
}
Re: How to see others stats? -
Champ - 02.07.2013
checking
Re: How to see others stats? -
Scottas - 02.07.2013
my code does what you want.
Re: How to see others stats? -
Champ - 02.07.2013
is this posible when player is not connected a message appears "player is not connected'.
Re: How to see others stats? -
Scottas - 02.07.2013
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;
}
Re: How to see others stats? -
drichie - 02.07.2013
pawn Код:
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,("Player is not connected");
Re: How to see others stats? -
Goldilox - 02.07.2013
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;
}
Re: How to see others stats? -
Scottas - 02.07.2013
there is no need to use sscanf, when you only need one param.