heal 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: heal command (
/showthread.php?tid=292697)
heal command -
Michael[NBK] - 24.10.2011
Hey,
i have this code:
pawn Код:
CMD:heal(playerid,params[])
{
new pID;
if(gTeam[playerid] == Medic) return SendClientMessage(playerid,COLOR_RED,"You must be a medic to use this command");
else if(sscanf(params, "u", pID)) SendClientMessage(playerid,COLOR_YELLOW,"Please use /heal [playerid]");
else if(GetPlayerHealth(pID) == 100) SendClientMessage(playerid,COLOR_YELLOW,"This player is already full health");
else if(PlayerFromPlayer(playerid,pID,4)) SendClientMessage(playerid,COLOR_YELLOW,"%s is not close enough to heal");
else if(!IsPlayerConnected(playerid)) SendClientMessage(playerid,COLOR_YELLOW,"That player is not connected!");
else if(pID == playerid) SendClientMessage(playerid,COLOR_YELLOW,"You cannot use this command to heal your self");
else
{
SetPlayerHealth(pID,100);
GivePlayerMoney(playerid,1000);
GivePlayerMoney(pID,-1000);
SendClientMessage(playerid,COLOR_YELLOW,"You have healed %s");
SendClientMessage(pID,COLOR_YELLOW,"You have been healed by %s for $1000");
}
return 1;
}
but for some reason the GetPlayerHealth isn't right as i get this:
Код:
C:\Users\Admin\Desktop\SAMP\Midnight Drifts\pawno\MaddMikesCNR.pwn(88) : warning 202: number of arguments does not match definition
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
Re: heal command -
[HiC]TheKiller - 24.10.2011
GetPlayerHealth has 2 arguments. Use the following stock if you want to make it easier.
pawn Код:
stock Float:GetPlayerHealthEx(playerid)
{
new Float:HealthX;
GetPlayerHealth(playerid, HealthX);
return HealthX;
}
Also, I found another error
pawn Код:
else if(!IsPlayerConnected(playerid)) SendClientMessage(playerid,COLOR_YELLOW,"That player is not connected!");
That should be
pawn Код:
else if(!IsPlayerConnected(pID)) SendClientMessage(playerid,COLOR_YELLOW,"That player is not connected!");
Re: heal command -
Michael[NBK] - 24.10.2011
on the return HealthEx;
C:\Users\Admin\Desktop\SAMP\Midnight Drifts\pawno\MaddMikesCNR.pwn(86) : warning 213: tag mismatch
Pawn compiler 3.2.3664 Copyright © 1997-2006, ITB CompuPhase
1 Warning.
Re: heal command -
[HiC]TheKiller - 24.10.2011
Sorry, I was missing the float at the start of the function, try now.
Re: heal command -
Michael[NBK] - 24.10.2011
perfect thank you