diff --git a/Client/mods/deathmatch/logic/rpc/CElementRPCs.cpp b/Client/mods/deathmatch/logic/rpc/CElementRPCs.cpp index 3213d8192a..3d30ddc6c9 100644 --- a/Client/mods/deathmatch/logic/rpc/CElementRPCs.cpp +++ b/Client/mods/deathmatch/logic/rpc/CElementRPCs.cpp @@ -50,6 +50,7 @@ void CElementRPCs::LoadFunctions() AddHandler(SET_PROPAGATE_CALLS_ENABLED, SetCallPropagationEnabled, "setCallPropagationEnabled"); AddHandler(SET_COLPOLYGON_HEIGHT, SetColPolygonHeight, "setColShapePolygonHeight"); AddHandler(SET_ELEMENT_ON_FIRE, SetElementOnFire, "setElementOnFire"); + AddHandler(SET_ELEMENT_COLLIDABLE_WITH, SetElementCollidableWith, "setElementCollidableWith"); } #define RUN_CHILDREN_SERVER(func) \ @@ -765,3 +766,19 @@ void CElementRPCs::SetElementOnFire(CClientEntity* pSource, NetBitStreamInterfac { pSource->SetOnFire(bitStream.ReadBit()); } + +void CElementRPCs::SetElementCollidableWith(CClientEntity* pSource, NetBitStreamInterface& bitStream) +{ + ElementID ElementID; + + if (!bitStream.Can(eBitStreamVersion::SetElementCollidableWith_Serverside)) + return; + + bitStream.Read(ElementID); + + CClientEntity* collidableWith = CElementIDs::GetElement(ElementID); + + if (collidableWith == nullptr) // validity check + return; + pSource->SetCollidableWith(collidableWith, bitStream.ReadBit()); +} diff --git a/Client/mods/deathmatch/logic/rpc/CElementRPCs.h b/Client/mods/deathmatch/logic/rpc/CElementRPCs.h index 2800d239fb..de328b68f4 100644 --- a/Client/mods/deathmatch/logic/rpc/CElementRPCs.h +++ b/Client/mods/deathmatch/logic/rpc/CElementRPCs.h @@ -51,4 +51,5 @@ class CElementRPCs : public CRPCFunctions DECLARE_ELEMENT_RPC(SetCallPropagationEnabled); DECLARE_ELEMENT_RPC(SetColPolygonHeight); DECLARE_ELEMENT_RPC(SetElementOnFire); + DECLARE_ELEMENT_RPC(SetElementCollidableWith); }; diff --git a/Server/mods/deathmatch/logic/CPerfStat.RPCPacketUsage.cpp b/Server/mods/deathmatch/logic/CPerfStat.RPCPacketUsage.cpp index cdebcedcc2..66a29568ce 100644 --- a/Server/mods/deathmatch/logic/CPerfStat.RPCPacketUsage.cpp +++ b/Server/mods/deathmatch/logic/CPerfStat.RPCPacketUsage.cpp @@ -232,6 +232,7 @@ ADD_ENUM1(TOGGLE_OBJECT_RESPAWN) ADD_ENUM1(RESET_WORLD_PROPERTIES) ADD_ENUM1(SPAWN_VEHICLE_FLYING_COMPONENT) ADD_ENUM1(SET_ELEMENT_ON_FIRE) +ADD_ENUM1(SET_ELEMENT_COLLIDABLE_WITH) IMPLEMENT_ENUM_END("eElementRPCFunctions") DECLARE_ENUM(CRPCFunctions::eRPCFunctions); diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp index 85963144ab..8e0ba012cf 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp @@ -64,7 +64,6 @@ #include "packets/CChatEchoPacket.h" #include "packets/CConsoleEchoPacket.h" #include "packets/CChatClearPacket.h" -#include "packets/CElementRPCPacket.h" #include "version.h" #include @@ -12566,3 +12565,38 @@ bool CStaticFunctionDefinitions::SpawnVehicleFlyingComponent(CVehicle* const veh return true; } + +bool CStaticFunctionDefinitions::SetElementCollidableWith(CElement* element, CElement* withElement, bool canCollide) +{ + switch (element->GetType()) + { + case EElementType::PLAYER: + case EElementType::PED: + case EElementType::OBJECT: + case EElementType::WEAPON: + case EElementType::VEHICLE: + { + switch (withElement->GetType()) + { + case EElementType::PLAYER: + case EElementType::PED: + case EElementType::OBJECT: + case EElementType::WEAPON: + case EElementType::VEHICLE: + { + CBitStream BitStream; + BitStream.pBitStream->Write(withElement->GetID()); + BitStream.pBitStream->WriteBit(canCollide); + m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(element, SET_ELEMENT_COLLIDABLE_WITH, *BitStream.pBitStream)); + return true; + } + default: + break; + } + break; + } + default: + break; + } + return false; +} diff --git a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h index d41ac650f1..77e8c6e0e6 100644 --- a/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h +++ b/Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h @@ -770,4 +770,5 @@ class CStaticFunctionDefinitions static const char* GetOperatingSystemName(); static const char* GetVersionBuildTag(); static CMtaVersion GetVersionSortable(); + static bool SetElementCollidableWith(CElement* element, CElement* withElement, bool canCollide); }; diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp b/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp index 81fec44882..f1cff98b14 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp +++ b/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.cpp @@ -104,6 +104,7 @@ void CLuaElementDefs::LoadFunctions() {"setElementFrozen", setElementFrozen}, {"setLowLODElement", setLowLODElement}, {"setElementOnFire", ArgumentParser}, + {"setElementCollidableWith", ArgumentParser}, }; // Add functions @@ -2460,3 +2461,8 @@ bool CLuaElementDefs::SetElementOnFire(CElement* element, bool onFire) noexcept { return CStaticFunctionDefinitions::SetElementOnFire(element, onFire); } + + bool CLuaElementDefs::SetElementCollidableWith(CElement* element, CElement* withElement, bool canCollide) +{ + return CStaticFunctionDefinitions::SetElementCollidableWith(element, withElement, canCollide); +} diff --git a/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h b/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h index 89745b5a3f..71efcc479a 100644 --- a/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h +++ b/Server/mods/deathmatch/logic/luadefs/CLuaElementDefs.h @@ -108,4 +108,5 @@ class CLuaElementDefs : public CLuaDefs LUA_DECLARE(setLowLODElement); LUA_DECLARE(setElementCallPropagationEnabled); static bool SetElementOnFire(CElement* element, bool onFire) noexcept; + static bool SetElementCollidableWith(CElement* element, CElement* withElement, bool canCollide); }; diff --git a/Shared/sdk/net/bitstream.h b/Shared/sdk/net/bitstream.h index fece5cf4de..a8210fcbee 100644 --- a/Shared/sdk/net/bitstream.h +++ b/Shared/sdk/net/bitstream.h @@ -612,6 +612,10 @@ enum class eBitStreamVersion : unsigned short // 2025-01-29 PedSync_CameraRotation, + //Add setElementCollidableWith serverside + // 2025-03-14 + SetElementCollidableWith_Serverside, + // This allows us to automatically increment the BitStreamVersion when things are added to this enum. // Make sure you only add things above this comment. Next, diff --git a/Shared/sdk/net/rpc_enums.h b/Shared/sdk/net/rpc_enums.h index 84c7518bc4..db0f2cb0be 100644 --- a/Shared/sdk/net/rpc_enums.h +++ b/Shared/sdk/net/rpc_enums.h @@ -293,5 +293,7 @@ enum eElementRPCFunctions SET_ELEMENT_ON_FIRE, + SET_ELEMENT_COLLIDABLE_WITH, + NUM_RPC_FUNCS // Add above this line };