SA-MP Forums Archive
zcmd stats [id] - 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)
+--- Thread: zcmd stats [id] (/showthread.php?tid=347381)



zcmd stats [id] - sanrock - 01.06.2012

So I made stats for my own player but how do i get it to view other people stats like

/stats [id]

my stats:
pawn Code:
CMD:stats(playerid, params[])
{
new string[200];

format(string, sizeof(string), "Name: %s | ID: %d | Team: %s | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d", PlayerName(playerid), playerid, GetTeamName(playerid), GetPlayerScore(playerid), PlayerInfo[playerid][Kills], PlayerInfo[playerid][Deaths], GetPlayerMoney(playerid), AdminLevel[playerid]);
SendClientMessage(playerid ,COLOR_BROWN, string);
return 1;
}
cheers


Re: zcmd stats [id] - Niko_boy - 01.06.2012

if you can use sscanf it will be better

make it like

pawn Code:
CMD:stats(playerid, params[])
{
   new string[200],pID;
   if(sscanf(params,"i",pID)) return SendClientMessage(playerid,-1,"/stats <id>");

   format(string, sizeof(string), "Name: %s | ID: %d | Team: %s | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d", PlayerName(pID),   pID, GetTeamName(pID), GetPlayerScore(pID), PlayerInfo[pID][Kills], PlayerInfo[pID][Deaths], GetPlayerMoney(pID), AdminLevel[pID]); // all playerid replaced by pID since pID = player  whose stats we gonna get but playerid is player who use command
   SendClientMessage(playerid ,COLOR_BROWN, string);
   return 1;
}



Re: zcmd stats [id] - [ABK]Antonio - 01.06.2012

pawn Code:
CMD:stats(playerid, params[])
{
    new target=playerid; //default our target var as playerid
    if(!isnull(params)) sscanf(params, "r", target); //if the params aren't null, we sscanf the params
   
    new string[200];
    format(string, sizeof(string), "Name: %s | ID: %d | Team: %s | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d", PlayerName(target), target, GetTeamName(target), GetPlayerScore(target), PlayerInfo[target][Kills], PlayerInfo[target][Deaths], GetPlayerMoney(target), AdminLevel[target]);
    SendClientMessage(playerid ,COLOR_BROWN, string);
    return 1;
}
This might work, if you have sscanf that is (might not with it, I'll experiment some with the optional R specifier if it doesn't). Without sscanf we can do;

pawn Code:
CMD:stats(playerid, params[])
{
    new target=playerid;
    if(!isnull(params)) target=strval(params);
   
    if(!IsPlayerConnected(target)) return SendClientMessage(playerid, COLOR_RED, "That player isn't connected!");

    new string[200];
    format(string, sizeof(string), "Name: %s | ID: %d | Team: %s | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d", PlayerName(target), target, GetTeamName(target), GetPlayerScore(target), PlayerInfo[target][Kills], PlayerInfo[target][Deaths], GetPlayerMoney(target), AdminLevel[target]);
    SendClientMessage(playerid ,COLOR_BROWN, string);
    return 1;
}



Re: zcmd stats [id] - Skaizo - 01.06.2012

like it,it can create comand exemple /stats Skaizo and /stats 1
pawn Code:
CMD:stats(playerid, params[])
{
   new string[200], pID;
   if(sscanf(params,"u",pID)) return SendClientMessage(playerid,-1,"/stats <playerid>");

   format(string, sizeof(string), "Name: %s | ID: %d | Team: %s | Score: %d | Kills: %i | Deaths: %i | Money: %d | Adminlevel: %d", PlayerName(pID),   pID, GetTeamName(pID), GetPlayerScore(pID), PlayerInfo[pID][Kills], PlayerInfo[pID][Deaths], GetPlayerMoney(pID), AdminLevel[pID]); // all playerid replaced by pID since pID = player  whose stats we gonna get but playerid is player who use command
   SendClientMessage(playerid ,COLOR_BROWN, string);
   return 1;
}
how create it?
using sscanf
Code:
Specifier(s)			Name				Example values
	i, d			Integer				1, 42, -10
	c			Character			a, o, *
	l			Logical				true, false
	b			Binary				01001, 0b1100
	h, x			Hex				1A, 0x23
	o			Octal				045 12
	n			Number				42, 0b010, 0xAC, 045
	f			Float				0.7, -99.5
	g			IEEE Float			0.7, -99.5, INFINITY, -INFINITY, NAN, NAN_E
	u			User name/id (bots and players)	******, 0
	q			Bot name/id			ShopBot, 27
	r			Player name/id			******, 42



Re: zcmd stats [id] - sanrock - 01.06.2012

Cheers
+repped