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=420458)



/gethp - DerickClark - 05.03.2013

Код:
CMD:gethp(playerid, params[])
{
    new string[128], ID, Float:health; //Define string, ID & health float.
	if(sscanf(params, "u", ID)) SendClientMessage(playerid, -1, "Correct usage: /gethp <playerid/name>"); //Show a message with correct usage of the command, if inputted wrong.
	else if(!IsPlayerConnected(ID)) SendClientMessage(playerid, -1, "That player is not online."); //Output if ID is not online.
    else //If everything has gone fine, do this.
    {
        GetPlayerHealth(ID, health); //Store health in health float.
        format(string,sizeof(string), "%s health:%f.", PlayerName(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;
}
Код:
pawno\include\PPC_PlayerCommands.inc(5336) : error 012: invalid function call, not a valid address
include\PPC_PlayerCommands.inc(5336) : warning 215: expression has no effect
include\PPC_PlayerCommands.inc(5336) : error 001: expected token: ";", but found ")"
\include\PPC_PlayerCommands.inc(5336) : error 029: invalid expression, assumed zero
\pawno\include\PPC_PlayerCommands.inc(5336) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Respuesta: /gethp - Strier - 05.03.2013

Could you show us or highlight line 5336?

pawn Код:
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:%d.", PlayerName(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;
}
EDIT: This has to work..


Re: /gethp - DerickClark - 05.03.2013

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



Respuesta: /gethp - Strier - 05.03.2013

Read my edit, it has to work..


Re: /gethp - DerickClark - 05.03.2013

Код:
(5334) : error 012: invalid function call, not a valid address
(5334) : warning 215: expression has no effect
(5334) : error 001: expected token: ";", but found ")"
(5334) : error 029: invalid expression, assumed zero
(5334) : fatal error 107: too many error messages on one line

Compilation aborted.Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


4 Errors.



Re : /gethp - DaTa[X] - 05.03.2013

Change this

Код:
if(!IsPlayerConnected(ID) return SendClientMessage(playerid, -1, "That player is not online.");



Re: /gethp - Glad2BeHere - 05.03.2013

pawn Код:
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;
}

stock PName(playerid)
{
    new name[MAX_PLAYER_NAME];
    GetPlayerName(playerid, name, sizeof(name));
    return name;
}
No problem right


Re: /gethp - DerickClark - 05.03.2013

Код:
C:\Users\pawno\include\PPC_PlayerCommands.inc(5018) : 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 - L.Hudson - 05.03.2013

Quote:
Originally Posted by DerickClark
Посмотреть сообщение
Код:
C:\Users\pawno\include\PPC_PlayerCommands.inc(5018) : warning 219: local variable "PName" shadows a variable at a preceding level
Pawn compiler 3.2.3664	 	 	Copyright © 1997-2006, ITB CompuPhase


1 Warning.
It means that you have the value
pawn Код:
new pName[...
writen two or so times in or out of the CMD lines... But showing which line is 5018 would help us... help you


Re: /gethp - DerickClark - 05.03.2013

Still give me alots of errors