diff --git a/Server/mods/deathmatch/logic/CGame.cpp b/Server/mods/deathmatch/logic/CGame.cpp index 06794d7ce4..407cc95592 100644 --- a/Server/mods/deathmatch/logic/CGame.cpp +++ b/Server/mods/deathmatch/logic/CGame.cpp @@ -1583,6 +1583,8 @@ void CGame::AddBuiltInEvents() m_Events.AddEvent("onPlayerNetworkStatus", "type, ticks", NULL, false); m_Events.AddEvent("onPlayerScreenShot", "resource, status, file_data, timestamp, tag", NULL, false); m_Events.AddEvent("onPlayerResourceStart", "resource", NULL, false); + m_Events.AddEvent("onPlayerProjectileCreation", "weaponType, posX, posY, posZ, force, target, rotX, rotY, rotZ, velX, velY, velZ", nullptr, false); + m_Events.AddEvent("onPlayerDetonateSatchels", "", nullptr, false); // Ped events m_Events.AddEvent("onPedVehicleEnter", "vehicle, seat, jacked", NULL, false); @@ -2624,6 +2626,11 @@ void CGame::Packet_DetonateSatchels(CDetonateSatchelsPacket& Packet) CPlayer* pPlayer = Packet.GetSourcePlayer(); if (pPlayer && pPlayer->IsJoined()) { + // Trigger Lua event and see if we are allowed to continue + CLuaArguments arguments; + if (!pPlayer->CallEvent("onPlayerDetonateSatchels", arguments)) + return; + // Tell everyone to blow up this guy's satchels m_pPlayerManager->BroadcastOnlyJoined(Packet); // Take away their detonator @@ -2777,6 +2784,29 @@ void CGame::Packet_ProjectileSync(CProjectileSyncPacket& Packet) vecPosition += pOriginSource->GetPosition(); } + CLuaArguments arguments; + arguments.PushNumber(Packet.m_ucWeaponType); // "weaponType" + arguments.PushNumber(vecPosition.fX); // "posX" + arguments.PushNumber(vecPosition.fY); // "posY" + arguments.PushNumber(vecPosition.fZ); // "posZ" + arguments.PushNumber(Packet.m_fForce); // "force" + + CElement* pTarget = nullptr; + if (Packet.m_bHasTarget && Packet.m_TargetID != INVALID_ELEMENT_ID) + pTarget = CElementIDs::GetElement(Packet.m_TargetID); + + arguments.PushElement(pTarget); // "target" + arguments.PushNumber(Packet.m_vecRotation.fX); // "rotX" + arguments.PushNumber(Packet.m_vecRotation.fY); // "rotY" + arguments.PushNumber(Packet.m_vecRotation.fZ); // "rotZ" + arguments.PushNumber(Packet.m_vecMoveSpeed.fX); // "velX" + arguments.PushNumber(Packet.m_vecMoveSpeed.fY); // "velY" + arguments.PushNumber(Packet.m_vecMoveSpeed.fZ); // "velZ" + + // Trigger Lua event and see if we are allowed to continue + if (!pPlayer->CallEvent("onPlayerProjectileCreation", arguments)) + return; + // Make a list of players to send this packet to CSendList sendList; diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 81462c8377..0542dce5fd 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -2079,6 +2079,11 @@ bool CStaticFunctionDefinitions::DetonateSatchels(CElement* pElement) CPlayer* pPlayer = static_cast(pElement); if (pPlayer->IsJoined()) { + // Trigger Lua event and see if we are allowed to continue + CLuaArguments arguments; + if (!pPlayer->CallEvent("onPlayerDetonateSatchels", arguments)) + return false; + CDetonateSatchelsPacket Packet; Packet.SetSourceElement(pPlayer); m_pPlayerManager->BroadcastOnlyJoined(Packet); diff --git a/Server/mods/deathmatch/logic/packets/CProjectileSyncPacket.cpp b/Server/mods/deathmatch/logic/packets/CProjectileSyncPacket.cpp index 1444ea11e3..4d6975a442 100644 --- a/Server/mods/deathmatch/logic/packets/CProjectileSyncPacket.cpp +++ b/Server/mods/deathmatch/logic/packets/CProjectileSyncPacket.cpp @@ -39,11 +39,8 @@ bool CProjectileSyncPacket::Read(NetBitStreamInterface& BitStream) return false; m_ucWeaponType = weaponType.data.ucWeaponType; - if (BitStream.Version() >= 0x4F) - { - if (!BitStream.Read(m_usModel)) - return false; - } + if (!BitStream.Read(m_usModel)) + return false; switch (m_ucWeaponType) { @@ -67,12 +64,11 @@ bool CProjectileSyncPacket::Read(NetBitStreamInterface& BitStream) case 19: // WEAPONTYPE_ROCKET case 20: // WEAPONTYPE_ROCKET_HS { - bool bHasTarget; - if (!BitStream.ReadBit(bHasTarget)) + if (!BitStream.ReadBit(m_bHasTarget)) return false; m_TargetID = INVALID_ELEMENT_ID; - if (bHasTarget && !BitStream.Read(m_TargetID)) + if (m_bHasTarget && !BitStream.Read(m_TargetID)) return false; SVelocitySync velocity; @@ -127,10 +123,7 @@ bool CProjectileSyncPacket::Write(NetBitStreamInterface& BitStream) const weaponType.data.ucWeaponType = m_ucWeaponType; BitStream.Write(&weaponType); - if (BitStream.Version() >= 0x4F) - { - BitStream.Write(m_usModel); - } + BitStream.Write(m_usModel); switch (m_ucWeaponType) { diff --git a/Server/mods/deathmatch/logic/packets/CProjectileSyncPacket.h b/Server/mods/deathmatch/logic/packets/CProjectileSyncPacket.h index 2cad54cfe5..22e97a0953 100644 --- a/Server/mods/deathmatch/logic/packets/CProjectileSyncPacket.h +++ b/Server/mods/deathmatch/logic/packets/CProjectileSyncPacket.h @@ -29,7 +29,7 @@ class CProjectileSyncPacket final : public CPacket ElementID m_OriginID; CVector m_vecOrigin; float m_fForce; - unsigned char m_ucHasTarget; + bool m_bHasTarget; ElementID m_TargetID; CVector m_vecTarget; CVector m_vecRotation;