Health returns 100.. - 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)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Health returns 100.. (
/showthread.php?tid=97016)
Health returns 100.. -
CJ101 - 12.09.2009
Код:
dcmd_farton(playerid,params[])
{
new tmp2[300],tmp[300], Index;
tmp = strtok(params,Index), tmp2 = strtok(params,Index);
new id = strval(tmp);
if(IsPlayerAdminLevel(playerid,2))
{
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"That Player Is Not Connected");
new string2[156], pname[24], pname2[24];
GetPlayerName(playerid, pname, 24);
GetPlayerName(id, pname2, 24);
new Float:health;
GetPlayerHealth(id,health);
SetPlayerHealth(id,health - 5);
format(string2, sizeof(string2), "Admin %s farted on %s (%d Health Left)",pname,pname2,floatround(health));
SendClientMessageToAll(COLOR_RED,string2);
}
else
{
SendClientMessage(playerid,COLOR_RED,"You must be Admin Level 2 to do this.");
}
return 1;
}
the first time an admin uses this command, it always shows 100 health.. then the second time it starts taking away health.
Re: Health returns 100.. -
[HiC]TheKiller - 12.09.2009
Try getting the health value afterwards or making a different variable.
Re: Health returns 100.. -
[nl]daplayer - 12.09.2009
Try This:
pawn Код:
dcmd_farton(playerid,params[])
{
new tmp2[300],tmp[300], Index;
tmp = strtok(params,Index), tmp2 = strtok(params,Index);
new id = strval(tmp);
if(IsPlayerAdminLevel(playerid,2))
{
if(!IsPlayerConnected(id)) return SendClientMessage(playerid,COLOR_RED,"That Player Is Not Connected");
new string2[156], pname[24], pname2[24];
GetPlayerName(playerid, pname, 24);
GetPlayerName(id, pname2, 24);
new Float:health;
GetPlayerHealth(id,health);
health -= 5; // Put this, so the variable will change. And not only return the new variable value if you do -5.
SetPlayerHealth(id,health);
format(string2, sizeof(string2), "Admin %s farted on %s (%d Health Left)",pname,pname2,floatround(health));
SendClientMessageToAll(COLOR_RED,string2);
}
else
{
SendClientMessage(playerid,COLOR_RED,"You must be Admin Level 2 to do this.");
}
return 1;
}