Skip to content

Commit

Permalink
Wasted event arguments (#3568)
Browse files Browse the repository at this point in the history
Addendum to 27a24b5 (fixes a bug that enabled cheaters to use "Crash any player" exploit)
  • Loading branch information
Nico8340 authored Jul 15, 2024
1 parent 5cdc04d commit ecd6ed9
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 4 deletions.
4 changes: 3 additions & 1 deletion Client/mods/deathmatch/logic/CClientGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2638,7 +2638,7 @@ void CClientGame::AddBuiltInEvents()
m_Events.AddEvent("onClientPlayerRadioSwitch", "", NULL, false);
m_Events.AddEvent("onClientPlayerDamage", "attacker, weapon, bodypart", NULL, false);
m_Events.AddEvent("onClientPlayerWeaponFire", "weapon, ammo, ammoInClip, hitX, hitY, hitZ, hitElement", NULL, false);
m_Events.AddEvent("onClientPlayerWasted", "", NULL, false);
m_Events.AddEvent("onClientPlayerWasted", "ammo, killer, weapon, bodypart, isStealth, animGroup, animID", nullptr, false);
m_Events.AddEvent("onClientPlayerChoke", "", NULL, false);
m_Events.AddEvent("onClientPlayerVoiceStart", "", NULL, false);
m_Events.AddEvent("onClientPlayerVoiceStop", "", NULL, false);
Expand Down Expand Up @@ -5665,6 +5665,8 @@ void CClientGame::DoWastedCheck(ElementID damagerID, unsigned char ucWeapon, uns
else
Arguments.PushBoolean(false);
Arguments.PushBoolean(false);
Arguments.PushNumber(animGroup);
Arguments.PushNumber(animID);
m_pLocalPlayer->CallEvent("onClientPlayerWasted", Arguments, true);

// Write some death info
Expand Down
2 changes: 2 additions & 0 deletions Client/mods/deathmatch/logic/CPacketHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1226,6 +1226,8 @@ void CPacketHandler::Packet_PlayerWasted(NetBitStreamInterface& bitStream)
else
Arguments.PushBoolean(false);
Arguments.PushBoolean(bStealth);
Arguments.PushNumber(animGroup);
Arguments.PushNumber(animID);
if (IS_PLAYER(pPed))
pPed->CallEvent("onClientPlayerWasted", Arguments, true);
else
Expand Down
3 changes: 2 additions & 1 deletion Client/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2153,7 +2153,8 @@ bool CStaticFunctionDefinitions::KillPed(CClientEntity& Entity, CClientEntity* p
else
Arguments.PushBoolean(false);
Arguments.PushBoolean(bStealth);

Arguments.PushBoolean(false);
Arguments.PushBoolean(false);
pPed.CallEvent("onClientPedWasted", Arguments, false);
pPed.RemoveAllWeapons();

Expand Down
8 changes: 6 additions & 2 deletions Server/mods/deathmatch/logic/CGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1570,7 +1570,7 @@ void CGame::AddBuiltInEvents()
m_Events.AddEvent("onPlayerQuit", "reason", NULL, false);
m_Events.AddEvent("onPlayerSpawn", "spawnpoint, team", NULL, false);
m_Events.AddEvent("onPlayerTarget", "target", NULL, false);
m_Events.AddEvent("onPlayerWasted", "ammo, killer, weapon, bodypart", NULL, false);
m_Events.AddEvent("onPlayerWasted", "ammo, killer, weapon, bodypart, isStealth, animGroup, animID", nullptr, false);
m_Events.AddEvent("onPlayerWeaponSwitch", "previous, current", NULL, false);
m_Events.AddEvent("onPlayerMarkerHit", "marker, matchingDimension", NULL, false);
m_Events.AddEvent("onPlayerMarkerLeave", "marker, matchingDimension", NULL, false);
Expand Down Expand Up @@ -1602,7 +1602,7 @@ void CGame::AddBuiltInEvents()
// Ped events
m_Events.AddEvent("onPedVehicleEnter", "vehicle, seat, jacked", NULL, false);
m_Events.AddEvent("onPedVehicleExit", "vehicle, reason, jacker", NULL, false);
m_Events.AddEvent("onPedWasted", "ammo, killer, weapon, bodypart", NULL, false);
m_Events.AddEvent("onPedWasted", "ammo, killer, weapon, bodypart, isStealth, animGroup, animID", nullptr, false);
m_Events.AddEvent("onPedWeaponSwitch", "previous, current", NULL, false);
m_Events.AddEvent("onPedDamage", "loss", NULL, false);

Expand Down Expand Up @@ -2045,6 +2045,8 @@ void CGame::Packet_PedWasted(CPedWastedPacket& Packet)
else
Arguments.PushBoolean(false);
Arguments.PushBoolean(false);
Arguments.PushNumber(Packet.m_AnimGroup);
Arguments.PushNumber(Packet.m_AnimID);
pPed->CallEvent("onPedWasted", Arguments);

// Reset the weapons list, because a ped loses his weapons on death
Expand Down Expand Up @@ -2105,6 +2107,8 @@ void CGame::Packet_PlayerWasted(CPlayerWastedPacket& Packet)
else
Arguments.PushBoolean(false);
Arguments.PushBoolean(false);
Arguments.PushNumber(Packet.m_AnimGroup);
Arguments.PushNumber(Packet.m_AnimID);
pPlayer->CallEvent("onPlayerWasted", Arguments);

// Reset the weapons list, because a player loses his weapons on death
Expand Down
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3753,6 +3753,8 @@ bool CStaticFunctionDefinitions::KillPed(CElement* pElement, CElement* pKiller,
else
Arguments.PushBoolean(false);
Arguments.PushBoolean(bStealth);
Arguments.PushBoolean(false);
Arguments.PushBoolean(false);
// TODO: change to onPedWasted
if (IS_PLAYER(pPed))
{
Expand Down

0 comments on commit ecd6ed9

Please sign in to comment.