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



/gethp - DerickClark - 06.03.2013

Код:
(5037) : warning 219: local variable "PName" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
in dis command:

Код:
CMD:gethp(playerid, params[])
{
   new string[128], ID, Float:health; //Define string, ID & health float.
   if(sscanf(params, "u", ID)) return SendClientMessage(playerid, -1, "Correct usage: /gethp <playerid/name>"); //Show a message with correct usage of the command, if inputted wrong.
   if(!IsPlayerConnected(ID)) return SendClientMessage(playerid, -1, "That player is not online."); //Output if ID is not online.
   GetPlayerHealth(ID, health); //Store health in health float.
   format(string,sizeof(string), "%s health:%f.", PName(ID),health); //String to store the output (Health will output as eg. 100.0000, as it is a float)
   SendClientMessage(playerid, -1, string); //Output string to the client.
   return 1;
}



Re: /gethp - rangerxxll - 06.03.2013

Is pName a stock or a global variable?


Re: /gethp - DerickClark - 06.03.2013

Код:
stock PName(playerid)
{
new name[MAX_PLAYER_NAME];
GetPlayerName(playerid, name, sizeof(name));
return name;
}



Re: /gethp - rangerxxll - 06.03.2013

Try this.

pawn Код:
stock PName(playerid)
{
    new Name[MAX_PLAYER_NAME];
    if(IsPlayerConnected(playerid))
    {
        GetPlayerName(playerid, Name, sizeof(Name));
    }
    return Name;
}



Re: /gethp - DerickClark - 06.03.2013

still say dis:
Код:
(5037) : warning 219: local variable "PName" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.



Re: /gethp - rangerxxll - 06.03.2013

Make sure your stock is outside of any callback.

EDIT: Also make sure you don't have a variable named PName.


Re: /gethp - DerickClark - 06.03.2013

i guss it's the command.

Код:
format(string,sizeof(string), "%s health:%f.", PName(ID),health); //String to store the output (Health will output as eg. 100.0000, as it is a float)



Re: /gethp - rangerxxll - 06.03.2013

I really don't know. It looks perfectly fine to me.

Sorry I couldn't assist you.


Respuesta: /gethp - Strier - 07.03.2013

Replace the defining of (PName) with (pPName) or something, exampl..

pawn Код:
new PName[MAX_PLAYERS_NAME]; /*to*/ new pPname[MAX_PLAYERS_NAME]



Re: /gethp - DerickClark - 07.03.2013

Can you give me the full cmd?