Skip to content
14 changes: 14 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ void CVehicleRPCs::LoadFunctions()
AddHandler(SET_VEHICLE_PLATE_TEXT, SetVehiclePlateText, "setVehiclePlateText");
AddHandler(SPAWN_VEHICLE_FLYING_COMPONENT, SpawnVehicleFlyingComponent, "spawnVehicleFlyingComponent");
AddHandler(SET_VEHICLE_NITRO_ACTIVATED, SetVehicleNitroActivated, "SetVehicleNitroActivated");
AddHandler(SET_VEHICLE_SMOKE_TRAIL_ENABLED, SetVehicleSmokeTrailEnabled, "SetVehicleSmokeTrailEnabled");
}

void CVehicleRPCs::DestroyAllVehicles(NetBitStreamInterface& bitStream)
Expand Down Expand Up @@ -693,3 +694,16 @@ void CVehicleRPCs::SetVehicleNitroActivated(CClientEntity* pSourceEntity, NetBit
vehicle->SetNitroLevel(vehicle->GetNitroLevel() + 1.0001f);
}

void CVehicleRPCs::SetVehicleSmokeTrailEnabled(CClientEntity* pSourceEntity, NetBitStreamInterface& bitStream)
{
bool state = bitStream.ReadBit();
CClientVehicle* vehicle = m_pVehicleManager->Get(pSourceEntity->GetID());
if (!vehicle)
return;

std::uint16_t model = vehicle->GetModel();
if (model != 512 && model != 513)
return;

vehicle->SetSmokeTrailEnabled(state);
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,4 +59,5 @@ class CVehicleRPCs : public CRPCFunctions
DECLARE_ELEMENT_RPC(SetVehiclePlateText);
DECLARE_ELEMENT_RPC(SpawnVehicleFlyingComponent);
DECLARE_ELEMENT_RPC(SetVehicleNitroActivated);
DECLARE_ELEMENT_RPC(SetVehicleSmokeTrailEnabled);
};
5 changes: 5 additions & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12668,3 +12668,8 @@ bool CStaticFunctionDefinitions::SpawnVehicleFlyingComponent(CVehicle* const veh

return true;
}

bool CStaticFunctionDefinitions::IsVehicleSmokeTrailEnabled(CVehicle* const vehicle)
{
return vehicle->IsSmokeTrailEnabled();
}
1 change: 1 addition & 0 deletions Server/mods/deathmatch/logic/CStaticFunctionDefinitions.h
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,7 @@ class CStaticFunctionDefinitions
static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, std::string& strValue);
static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, unsigned int& uiValue);
static bool GetEntryHandling(const CHandlingEntry* pEntry, eHandlingProperty eProperty, unsigned char& ucValue);
static bool IsVehicleSmokeTrailEnabled(CVehicle* const vehicle);

// Vehicle set functions
static bool FixVehicle(CElement* pElement);
Expand Down
31 changes: 30 additions & 1 deletion Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"isVehicleBlown", ArgumentParserWarn<false, IsVehicleBlown>},
{"getVehicleHeadLightColor", GetVehicleHeadLightColor},
{"getVehicleDoorOpenRatio", GetVehicleDoorOpenRatio},
{"isVehicleSmokeTrailEnabled", IsVehicleSmokeTrailEnabled},

// Vehicle set funcs
{"fixVehicle", FixVehicle},
Expand Down Expand Up @@ -128,6 +129,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"getVehicleSirenParams", GetVehicleSirenParams},
{"setVehiclePlateText", SetVehiclePlateText},
{"setVehicleNitroActivated", ArgumentParser<SetVehicleNitroActivated>},
{"setVehicleSmokeTrailEnabled", ArgumentParser<SetVehicleSmokeTrailEnabled>},
};

// Add functions
Expand Down Expand Up @@ -209,6 +211,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "isRespawnable", "isVehicleRespawnable");
lua_classfunction(luaVM, "getRespawnDelay", "getVehicleRespawnDelay");
lua_classfunction(luaVM, "getIdleRespawnDelay", "getVehicleIdleRespawnDelay");
lua_classfunction(luaVM, "isSmokeTrailEnabled", "isVehicleSmokeTrailEnabled");

lua_classfunction(luaVM, "setColor", "setVehicleColor");
lua_classfunction(luaVM, "setDamageProof", "setVehicleDamageProof");
Expand Down Expand Up @@ -244,6 +247,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "setTrainPosition", "setTrainPosition");
lua_classfunction(luaVM, "setTrainSpeed", "setTrainSpeed"); // Reduce confusion
lua_classfunction(luaVM, "spawnFlyingComponent", "spawnVehicleFlyingComponent");
lua_classfunction(luaVM, "setSmokeTrailEnabled", "setVehicleSmokeTrailEnabled");

lua_classvariable(luaVM, "damageProof", "setVehicleDamageProof", "isVehicleDamageProof");
lua_classvariable(luaVM, "locked", "setVehicleLocked", "isVehicleLocked");
Expand Down Expand Up @@ -3059,4 +3063,29 @@ bool CLuaVehicleDefs::SetVehicleNitroActivated(CVehicle* vehicle, bool state) no

m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(vehicle, SET_VEHICLE_NITRO_ACTIVATED, *BitStream.pBitStream));
return true;
}
}

bool CLuaVehicleDefs::SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept
{
CBitStream BitStream;
BitStream.pBitStream->WriteBit(state);

m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(vehicle, SET_VEHICLE_SMOKE_TRAIL_ENABLED, *BitStream.pBitStream));
return true;
}

int CLuaVehicleDefs::IsVehicleSmokeTrailEnabled(lua_State* luaVM)
{
CVehicle* pVehicle;
CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pVehicle);
if (!argStream.HasErrors())
{
lua_pushboolean(luaVM, CStaticFunctionDefinitions::IsVehicleSmokeTrailEnabled(pVehicle));
return 1;
}
else
m_pScriptDebugging->LogCustom(luaVM, argStream.GetFullErrorMessage());
lua_pushboolean(luaVM, false);
return 1;
}
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ class CLuaVehicleDefs : public CLuaDefs
static bool IsVehicleBlown(CVehicle* vehicle);
LUA_DECLARE(GetVehicleHeadLightColor);
LUA_DECLARE(GetVehicleDoorOpenRatio);
LUA_DECLARE(IsVehicleSmokeTrailEnabled);

// Vehicle set functions
LUA_DECLARE(FixVehicle);
Expand Down Expand Up @@ -128,4 +129,5 @@ class CLuaVehicleDefs : public CLuaDefs

static bool SpawnVehicleFlyingComponent(CVehicle* const vehicle, std::uint8_t nodeIndex, std::optional<std::uint8_t> componentCollisionType, std::optional<std::uint32_t> removalTime);
static bool SetVehicleNitroActivated(CVehicle* vehicle, bool state) noexcept;
static bool SetVehicleSmokeTrailEnabled(CVehicle* vehicle, bool state) noexcept;
};
2 changes: 2 additions & 0 deletions Shared/sdk/net/rpc_enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,8 @@ enum eElementRPCFunctions
SPAWN_VEHICLE_FLYING_COMPONENT,

SET_VEHICLE_NITRO_ACTIVATED,

SET_VEHICLE_SMOKE_TRAIL_ENABLED,

SET_ELEMENT_ON_FIRE,

Expand Down