• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
[Pawn] Not receiving damage when player fell onto the ground
#10
Created code, what you can try for falling detection
Code:
// indicates if player is falling or not
new bool:IsPlayerFalling[MAX_PLAYERS] = {false, ...};

// checks if it's falling animation, https://www.open.mp/docs/scripting/resources/animations
IsFallingAnim(index) {
    return index == 1128 || index == 1130 || index == 1131;
}

public OnPlayerUpdate(playerid) {
    // checks that player isn't inside anything or special mode etc
    if (GetPlayerState(playerid) == PLAYER_STATE_ONFOOT) {
        new animIndex = GetPlayerAnimationIndex(playerid);
        // current player animation
        new hasFallingAnim = IsFallingAnim(animIndex);
        // player started falling, but not stored yet
        if (hasFallingAnim && !IsPlayerFalling[playerid]) {
            IsPlayerFalling[playerid] = true;
            SendClientMessage(playerid, -1, "You started falling!");
        }
        // player stopped falling, but not stored yet
        else if(!hasFallingAnim && IsPlayerFalling[playerid]) {
            IsPlayerFalling[playerid] = false;
            SendClientMessage(playerid, -1, "You stopped falling!");
        }
    }
    return 1;
}
  Reply


Messages In This Thread
RE: Not receiving damage when player fell onto the ground - by carl_anderson - 2024-05-05, 09:12 PM

Forum Jump: