• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Not receiving damage when player fell onto the ground
#8
it doesn't work in game bro, what should I do to this

Code:
forward OnPlayerFall(playerid);
forward CalculateDamage(Float:fall_height);

public OnPlayerFall(playerid) {
new Float:fall_height = GetPlayerDistanceFromPoint(playerid, 2.0, 2.0, 2.0);

    new damage = CalculateDamage(fall_height);

    // Apply damage to the player
    SetPlayerHealth(playerid, GetPlayerHealth(playerid) - damage);

    // You can also send a message to the player informing them about the damage
    SendClientMessage(playerid, COLOR_RED, "You took damage from the fall!");
    return 1;
}

// Function to calculate damage based on fall height
public CalculateDamage(Float:fall_height) {
    if (fall_height <= 0.0) return 0;
    if (fall_height <= 2.0) return 5; // Minimum damage if fall height is less than or equal to 2 meters
    return floatround((fall_height - 2.0) * 2 + 5); // Damage increases linearly with fall height beyond 2 meters
}
  Reply


Messages In This Thread
RE: Not receiving damage when player fell onto the ground - by Sizy - 2024-05-05, 10:56 AM

Forum Jump: