Auto Health Not Working
#1

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"
Reply
#2

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;
}
Reply
#3

Its working Thnx
Cant give rep at the moment :P
Reply
#4

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..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)