Hp drain ??
#1

ok can anyone tell me how to script this i has no idea! PLs
okay so when the peson gets hungry the hp slowly drains out maybe after every 5 hours (game time) the hp starts to drain? please help
im using ravens roleplay
Reply
#2

I dont know how you make the person hungry but I suspect you use a timer

Just use that timer for decreasing, too
pawn Код:
new Float:health;
GetPlayerHealth(playerid, health);
SetPlayerHealth(playerid, health - 1.0);
Reply
#3

i dont understand so i add this 2 times?
please make an example
Reply
#4

this should work
pawn Код:
forward EatTimer(playerid);

public OnGameModeInit()
{
    SetTimer("EatTimer",timeyouwant in miliseconds,true);
    return 1;
}

public EatTimer(playerid)
{
    new Float:health;
    GetPlayerHealth(playerid, health);
    SetPlayerHealth(playerid, health - 1.0); // you can change 1.0 to like 5.0 to lose more hp
    return 1;
}
Reply
#5

make something like this:

pawn Код:
#define HUNGER_BEFORE_DRAIN 5
#define DRAIN_HEALTH_AMOUNT 3
#define DRAIN_HEALTH_TIME 10000

new
    Hunger[MAX_PLAYERS],
    IsDraining[MAX_PLAYERS];


public OnPlayerConnect(playerid)
{
    Hunger[playerid] = HUNGER_BEFORE_DRAIN;
    DrainTimer[playerid] = SetTimerEx("DrainHealth", DRAIN_HEALTH_TIME, "i", playerid); // Needs an timer id so you could kill it on player DC
}

public DrainHealth(playerid)
{
    if(Hunger[playerid] == 0)
    {
        SetPlayerHealth(playerid, GetHealth(playerid) - DRAIN_HEALTH_AMOUNT);
    }
    else
    {
        Hunger[playerid]--;
    }
}

stock GetHealth(playerid)
{
    new Float: pHealth;
    GetPlayerHealth(playerid, pHealth);
    return pHealth;
}
should work, scripted in a hurry though..
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)