Skip to content

Commit 5820085

Browse files
Synchronize changes from 1.6 master branch [ci skip]
38e550f Add `onClientPlayerWeaponReload` and `onClientPedWeaponReload` events (#4373)
2 parents 6d3c595 + 38e550f commit 5820085

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

Client/mods/deathmatch/logic/CClientGame.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,7 @@ void CClientGame::AddBuiltInEvents()
26482648
m_Events.AddEvent("onClientPlayerRadioSwitch", "", NULL, false);
26492649
m_Events.AddEvent("onClientPlayerDamage", "attacker, weapon, bodypart", NULL, false);
26502650
m_Events.AddEvent("onClientPlayerWeaponFire", "weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement", NULL, false);
2651+
m_Events.AddEvent("onClientPlayerWeaponReload", "weapon, clip, ammo", nullptr, false);
26512652
m_Events.AddEvent("onClientPlayerWasted", "ammo, killer, weapon, bodypart, isStealth, animGroup, animID", nullptr, false);
26522653
m_Events.AddEvent("onClientPlayerChoke", "", NULL, false);
26532654
m_Events.AddEvent("onClientPlayerVoiceStart", "", NULL, false);
@@ -2666,6 +2667,7 @@ void CClientGame::AddBuiltInEvents()
26662667
m_Events.AddEvent("onClientPedVehicleEnter", "vehicle, seat", NULL, false);
26672668
m_Events.AddEvent("onClientPedVehicleExit", "vehicle, seat", NULL, false);
26682669
m_Events.AddEvent("onClientPedWeaponFire", "weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement", NULL, false);
2670+
m_Events.AddEvent("onClientPedWeaponReload", "weapon, clip, ammo", nullptr, false);
26692671
m_Events.AddEvent("onClientPedWasted", "", NULL, false);
26702672
m_Events.AddEvent("onClientPedChoke", "", NULL, false);
26712673
m_Events.AddEvent("onClientPedHeliKilled", "heli", NULL, false);

Client/mods/deathmatch/logic/CClientPed.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6119,6 +6119,21 @@ bool CClientPed::ReloadWeapon() noexcept
61196119
if (!CanReloadWeapon() || (task && task->GetTaskType() == TASK_SIMPLE_USE_GUN))
61206120
return false;
61216121

6122+
CLuaArguments args;
6123+
args.PushNumber(weapon->GetType());
6124+
args.PushNumber(weapon->GetAmmoInClip());
6125+
args.PushNumber(weapon->GetAmmoTotal());
6126+
6127+
bool result = false;
6128+
6129+
if (IS_PLAYER(this))
6130+
result = CallEvent("onClientPlayerWeaponReload", args, true);
6131+
else
6132+
result = CallEvent("onClientPedWeaponReload", args, true);
6133+
6134+
if (!result)
6135+
return false;
6136+
61226137
weapon->SetState(WEAPONSTATE_RELOADING);
61236138
return true;
61246139
}

0 commit comments

Comments
 (0)