SA-MP Forums Archive
/info command - 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: /info command (/showthread.php?tid=369076)



/info command - nogh445 - 15.08.2012

So I'm trying to make an command that will show you a players statistics but when I press compile the pawno compiler crashes and comes up with a popup saying that it is not responding. Anyone have any ideas? Here is the code:
pawn Код:
CMD:info(playerid, params[])
{
    new targetid, string[128];
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /info[id]");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage, COLOR_RED, "Only Administrators have access to this command.");
    if( targetid != INVALID_PLAYER_ID )
    {
        format(string, sizeof(string),"Health: %d  Armor: %d  Score: %d  Cash: %d",GetPlayerHealth(targetid),GetPlayerArmor(targetid),
        GetPlayerScore(targetid),GetPlayerMoney(targetid);
        SendClientMessage(playerid,COLOR_RED,string);
    }
    return 1;
}
I am using another script as an reference but I don't know if i'm messing up completely or not.


Re: /info command - SaYrOn - 15.08.2012

Well, maybe it's just a typo here, but when you are checking if player is admin you forgot to add bracket and playerid on SendClientMessage :/


Re: /info command - nogh445 - 15.08.2012

Quote:
Originally Posted by SaYrOn
Посмотреть сообщение
Well, maybe it's just a typo here, but when you are checking if player is admin you forgot to add bracket and playerid on SendClientMessage :/
Oh wow... I completely missed "(playerid," But now I put it in so lets see if it works :\


Edit: The command still doesn't seem to work In game. I do get two warnings.
This the the pawn code I have now:
pawn Код:
CMD:info(playerid, params[])
{
    new targetid, string[128];
    if(sscanf(params, "u", targetid)) return SendClientMessage(playerid, COLOR_RED, "USAGE: /info[id]");
    if(!IsPlayerAdmin(playerid)) return SendClientMessage(playerid, COLOR_RED, "Only Administrators have access to this command.");
    if( targetid != INVALID_PLAYER_ID )
    {
        format(string, sizeof(string),"Health: %d  Armor: %d  Score: %d  Cash: %d",GetPlayerHealth(targetid),GetPlayerArmour(targetid), GetPlayerScore(targetid),GetPlayerMoney(targetid));//line 349
        SendClientMessage(playerid,COLOR_RED,string);
    }
    return 1;
}

And these are the warnings I get:
Код:
C:\Users\user\Desktop\h\gamemodes\new.pwn(349) : warning 202: number of arguments does not match definition
C:\Users\user\Desktop\h\gamemodes\new.pwn(349) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


2 Warnings.



Re: /info command - SaYrOn - 15.08.2012

Write line 349 please


Re: /info command - Jessyy - 15.08.2012

Line 349:
Код:
format(string, sizeof(string),"Health: %d  Armor: %d  Score: %d  Cash: %d",GetPlayerHealth(targetid),GetPlayerArmour(targetid), GetPlayerScore(targetid),GetPlayerMoney(targetid));//line 349



Re: /info command - SaYrOn - 15.08.2012

Oh, thing is that GetPlayerHealth and GetPlayerArmour work with float, just add in the top of the command:
Код:
new Float:Health, Float:Armour;
Then lower:
Код:
 GetPlayerHealth(targetid, Health);
GetPlayerArmour(targetid, Armour);
and make format line look like this:
Код:
format(string, sizeof(string),"Health: %d  Armor: %d  Score: %d  Cash: %d",Health,Armour, GetPlayerScore(targetid),GetPlayerMoney(targetid));



Re: /info command - nogh445 - 15.08.2012

Quote:
Originally Posted by SaYrOn
Посмотреть сообщение
Oh, thing is that GetPlayerHealth and GetPlayerArmour work with float, just add in the top of the command:
Код:
new Float:Health, Float:Armour;
Then lower:
Код:
 GetPlayerHealth(targetid, Health);
GetPlayerArmour(targetid, Armour);
and make format line look like this:
Код:
format(string, sizeof(string),"Health: %d  Armor: %d  Score: %d  Cash: %d",Health,Armour, GetPlayerScore(targetid),GetPlayerMoney(targetid));
Thanks this worked


Re: /info command - SaYrOn - 15.08.2012

You're welcome