HP Regen
#1

I Was Wondering If i could make hp regeneraton
1hp point every 2500ms
Код:
SetTimer("HPregen",2500,1); // on gamemodeinit

forward HPregen(playerid);
public HPregen(playerid)
{
SetPlayerHealth(playerid, +1);
}
but + sign makes 4 errors ... can anyone help me with that ?

Those Errors
Код:
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : error 029: invalid expression, assumed zero
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : warning 215: expression has no effect
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : error 001: expected token: ";", but found ")"
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : error 029: invalid expression, assumed zero
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : fatal error 107: too many error messages on one line

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


4 Errors.
Reply
#2

Код:
public HPregen(playerid)
{

new PlayerHP;
PlayerHP = GetPlayerHealth(playerid,/*1 What Supposed To Be Here ?*/);
if PlayerHP <= 100 *then
{
SetPlayerHealth(playerid, /* What Supposed To Be Here to Make +1?*/);
}
}
I Made This ... (read comments and help me)

But If im doing something wrong to make hp regeneration and you can do it or have better idea plz help me ..
Reply
#3

Quote:
Originally Posted by Nekrus2
Посмотреть сообщение
I Was Wondering If i could make hp regeneraton
1hp point every 2500ms
Код:
SetTimer("HPregen",2500,1); // on gamemodeinit

forward HPregen(playerid);
public HPregen(playerid)
{
SetPlayerHealth(playerid, +1);
}
but + sign makes 4 errors ... can anyone help me with that ?

Those Errors
Код:
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : error 029: invalid expression, assumed zero
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : warning 215: expression has no effect
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : error 001: expected token: ";", but found ")"
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : error 029: invalid expression, assumed zero
C:\DOCUME~1\TRUST\Pulpit\RPGSER~1\GAMEMO~1\RPG.pwn(252) : fatal error 107: too many error messages on one line

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


4 Errors.
Try this:
pawn Код:
SetTimer("HPregen",2500,1); // on gamemodeinit

forward HPregen(playerid);
public HPregen(playerid)
{
SetPlayerHealth(playerid, GetPlayerHealth(playerid)+1);
return 1;
}
You need to get their health, and add 1, because if you do +1 only, the script will think you want to set the player's health to 1.
Reply
#4

Here you go
pawn Код:
public OnPlayerSpawn(playerid)
{
    SetTimerEx("RegHP", 2500, true, "%i", playerid); //Should be at OnPlayerSpawn
    return 1;
}

forward RegHP(playerid);
public RegHP(playerid)
{
    new Float:Health;
    GetPlayerHealth(playerid, Health);
    if(Health < 100) //To stop regernating if the player has 100 health or more
    {
        SetPlayerHealth(playerid, Health+1);
    }
}
Reply
#5

Thanks Very Much
Reply
#6

Just Tested Though And When I Die I Respawn With Same Amout of HP ( i killed myself with amout of 95 health and when i respawned i seen still 95...)

Should i just put SetPlayerHealth(playerid,100); onplayerspawn ? or something else ?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)