Question
#1

Ok here is the deal i dont know so many about floats so that i need to ask here.

So here is the deal i want like when you pickup a "pickup" that your health will start to increase +5 but it will stop untill your health is 50 and when you leave pickup it will stop giving health.(I think it wont need code but just saying)

Anyways help would be lovely

EDIT:

Started to think you didnt understand

I want health to increase slowly.
Reply
#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


Forum Jump:


Users browsing this thread: 3 Guest(s)