Question
#2

Under OnPlayerPickupPickUp, if they pick up the health then you would set a repeating timer of however many seconds you want their health to increase. You would then setup a public function. In this function you would get the player's health using a float and set their health, but add 5 to it. You would then add an if statement if their health reaches 50 then kill the timer. I will provide you an example.

pawn Код:
new
    healthpickup, // The variable for the pickup.
    timer; // The var for the timer.
public OnGameModeInit()
{
    healthpickup = CreatePickup(/*your pickup params go here*/); // This assigns our healthpickup variable to the CreatePickup
    return 1;
}
public OnPlayerPickupPickUp(playerid,pickupid)
{
    if(pickupid == healthpickup) // If they pickup the health pickup.
    {
        timer = SetTimer("Health",3000,true); // Assigns the car "timer" to this,and sets a repeating timer of 3 seconds.
        return 1;
    }
    return 1;
}
forward Health(playerid);
public Health(playerid) // every three seconds
{
    new Float:hp; // A new float that will store their health.
    GetPlayerHealth(playerid,hp); // Stores their health to the float.
    SetPlayerhealth(playerid,hp+5) // Increases their health by five
    if(GetPlayerHealth(playerid) >= 50)  // If they have more than 50 health
    {
        KillTimer(HealthTimer); // then kill the timer.
        return 1;
    }
    return 1;
}
goodluck
Reply


Messages In This Thread
Question [+rep] - by lordturhan - 09.03.2012, 21:05
Re: Question - by ReneG - 10.03.2012, 00:13

Forum Jump:


Users browsing this thread: 2 Guest(s)