/GetPlayerStats :) - 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: /GetPlayerStats :) (
/showthread.php?tid=371085)
/GetPlayerStats :) -
Guitar - 22.08.2012
Hello guys,
Sorry, It's me again XD -- Anyway, I scripted this cmd:
pawn Код:
CMD:getplayerstats(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_RED, "Error Occured: This command is only for Admins.");
new str[256], TargetName[MAX_PLAYER_NAME], IP[16], targetid;
new Money = GetPlayerMoney(targetid);
PlayerNameGet(targetid, TargetName, 24);
GetPlayerIp(targetid,IP,sizeof IP);
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, 0xFFFFFFF, "[ADMIN]/getplayerstats [playerid/name]");
format(str, 256, ""#COL_WHITE"=======================[%s statistics]=======================", TargetName);
SendClientMessage(playerid,COLOR_WHITE,str);
format(str,128, ">"#COL_WHITE"%s: IP[%s] - Money[$%i] - Kills[%i] - Deaths[%i] - Admin[%i] - Skin[%i]", TargetName, IP, Money, PlayerInfo[targetid][pKills], PlayerInfo[targetid][pDeaths], PlayerInfo[targetid][pAdmin], GetPlayerSkin(targetid));
SendClientMessage(playerid,COLOR_WHITE,str);
return 1;
}
But it doesn't give me the player's name and the right numbers, can you re-script it for me again? Thanks <3
Re: /GetPlayerStats :) -
Calgon - 22.08.2012
You need to let the sscanf code execute first before you get the details about the player. 'targetid' is 0 until the sscanf code detects who the player is you're using the command on.
pawn Код:
CMD:getplayerstats(playerid, params[])
{
if(PlayerInfo[playerid][pAdmin] <= 2) return SendClientMessage(playerid, COLOR_RED, "Error Occured: This command is only for Admins.");
new str[128], TargetName[MAX_PLAYER_NAME], IP[16], targetid;
if(sscanf(params,"u", targetid)) return SendClientMessage(playerid, 0xFFFFFFF, "[ADMIN]/getplayerstats [playerid/name]");
new Money = GetPlayerMoney(targetid);
PlayerNameGet(targetid, TargetName, 24);
GetPlayerIp(targetid,IP,sizeof IP);
format(str, 128, ""#COL_WHITE"=======================[%s statistics]=======================", TargetName);
SendClientMessage(playerid,COLOR_WHITE,str);
format(str,128, ">"#COL_WHITE"%s: IP[%s] - Money[$%i] - Kills[%i] - Deaths[%i] - Admin[%i] - Skin[%i]", TargetName, IP, Money, PlayerInfo[targetid][pKills], PlayerInfo[targetid][pDeaths], PlayerInfo[targetid][pAdmin], GetPlayerSkin(targetid));
SendClientMessage(playerid,COLOR_WHITE,str);
return 1;
}
Re: /GetPlayerStats :) -
Guitar - 22.08.2012
Oh, thank you I will study your cmd and my cmd and see what's the difference between them and learn from my mistake
.
Re: /GetPlayerStats :) -
Calgon - 22.08.2012
All I did was move the 3 lines of code for the money, name and IP down below the sscanf line.
Re: /GetPlayerStats :) -
[MM]RoXoR[FS] - 22.08.2012
EDIT : late
Re: /GetPlayerStats :) -
Guitar - 22.08.2012
Oh, so my code was right? I actually stopped believing in myself :S
Re: /GetPlayerStats :) -
Calgon - 22.08.2012
Read what I wrote, it explains everything...