Skip to content

Commit

Permalink
Fix No Shooting Allowed in planes
Browse files Browse the repository at this point in the history
Fixes #187
  • Loading branch information
Lordmau5 committed Jan 4, 2023
1 parent 97be099 commit 8728df8
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions src/gtasa/effects/custom/player/NoShootingAllowedEffect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,19 @@ class NoShootingAllowedEffect : public EffectBase
HOOK_METHOD_ARGS (inst, Hooked_CTaskSimpleGangDriveBy_FireGun,
char (CTaskSimpleGangDriveBy *, CPed * ped), 0x51A3FD,
0x62D60D);

HOOK_METHOD_ARGS (inst, Hooked_CVehicle_FirePlaneGuns,
void (CVehicle *), 0x6E3A17);

HOOK_METHOD_ARGS (inst,
Hooked_CVehicle_PossiblyDropFreeFallBombForPlayer,
char (CVehicle *, int, bool), 0x6E3A27);

HOOK_METHOD_ARGS (inst, Hooked_CVehicle_FireHeatSeakingMissile,
char (CVehicle *, CEntity *, bool), 0x6E3A72);

HOOK_METHOD_ARGS (inst, Hooked_CVehicle_FireUnguidedMissile,
char (CVehicle *, int, bool), 0x6E3A82);
}

static char
Expand Down Expand Up @@ -64,6 +77,56 @@ class NoShootingAllowedEffect : public EffectBase

return cb ();
}

static void
Hooked_CVehicle_FirePlaneGuns (auto &&cb, CVehicle *vehicle)
{
CPed *driver = vehicle->m_pDriver;

if (driver && driver->IsPlayer ())
Command<eScriptCommands::COMMAND_SET_CHAR_HEALTH> (driver, 0);

cb ();
}

static char
Hooked_CVehicle_PossiblyDropFreeFallBombForPlayer (auto &&cb,
CVehicle *vehicle,
int positionType,
bool checkTime)
{
CPed *driver = vehicle->m_pDriver;

if (driver && driver->IsPlayer ())
Command<eScriptCommands::COMMAND_SET_CHAR_HEALTH> (driver, 0);

return cb ();
}

static char
Hooked_CVehicle_FireHeatSeakingMissile (auto &&cb, CVehicle *vehicle,
CEntity *targetEntity,
bool checkTime)
{
CPed *driver = vehicle->m_pDriver;

if (driver && driver->IsPlayer ())
Command<eScriptCommands::COMMAND_SET_CHAR_HEALTH> (driver, 0);

return cb ();
}

static char
Hooked_CVehicle_FireUnguidedMissile (auto &&cb, CVehicle *vehicle,
int positionType, bool checkTime)
{
CPed *driver = vehicle->m_pDriver;

if (driver && driver->IsPlayer ())
Command<eScriptCommands::COMMAND_SET_CHAR_HEALTH> (driver, 0);

return cb ();
}
};

DEFINE_EFFECT (NoShootingAllowedEffect, "effect_no_shooting_allowed",
Expand Down

0 comments on commit 8728df8

Please sign in to comment.