/info command
#1

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.
Reply
#2

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 :/
Reply
#3

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.
Reply
#4

Write line 349 please
Reply
#5

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

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));
Reply
#7

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
Reply
#8

You're welcome
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)