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
}