Auto Health Not Working - 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: Auto Health Not Working (
/showthread.php?tid=441319)
Auto Health Not Working -
GreTex - 02.06.2013
Code:
pawn Код:
public autohealth()
{
new Float:health;
GetPlayerHealth(playerid,health);
if (health < 99.0)
{
SetPlayerHealth(playerid, 100.0);
}
return 1;
}
pawn Код:
C:\Documents and Settings\dx\Desktop\New Folder (3)\gamemodes\GM.pwn(6190) : error 017: undefined symbol "playerid"
C:\Documents and Settings\dx\Desktop\New Folder (3)\gamemodes\GM.pwn(6193) : error 017: undefined symbol "playerid"
Re: Auto Health Not Working -
Konstantinos - 02.06.2013
There's not such as parameter 'playerid'. You've to loop through the players, use either foreach (recommended) or normal for loop.
pawn Код:
// Foreach
public autohealth()
{
new Float:health;
foreach(playerid : Player)
{
GetPlayerHealth(playerid,health);
if (health < 99.0)
{
SetPlayerHealth(playerid, 100.0);
}
}
return 1;
}
pawn Код:
// Normal For Loop
public autohealth()
{
new Float:health;
for(new playerid = 0; playerid < MAX_PLAYERS; playerid++)
{
GetPlayerHealth(playerid,health);
if (health < 99.0)
{
SetPlayerHealth(playerid, 100.0);
}
}
return 1;
}
Re: Auto Health Not Working -
GreTex - 02.06.2013
Its working Thnx
Cant give rep at the moment :P
Re: Auto Health Not Working -
MP2 - 02.06.2013
Or you could just set their health very high instead of wasting resources on a timer. Set their health to 98303 (no higher) if you don't want the health bar to flash (any higher and it will). Same for vehicle health. I can't believe nobody thinks of these obvious things..