Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding setVehicleNitroActivated server-side #3706

Open
wants to merge 12 commits into
base: master
Choose a base branch
from
Next Next commit
adding setVehicleNitroActivated server side
Proxy-99 committed Sep 8, 2024
commit 6aefef1647dfe099dc5dd8595401e42a5250d319
23 changes: 23 additions & 0 deletions Client/mods/deathmatch/logic/rpc/CVehicleRPCs.cpp
Original file line number Diff line number Diff line change
@@ -52,6 +52,7 @@ void CVehicleRPCs::LoadFunctions()
AddHandler(REMOVE_VEHICLE_SIRENS, RemoveVehicleSirens, "removeVehicleSirens");
AddHandler(SET_VEHICLE_SIRENS, SetVehicleSirens, "setVehicleSirens");
AddHandler(SET_VEHICLE_PLATE_TEXT, SetVehiclePlateText, "setVehiclePlateText");
AddHandler(SET_VEHICLE_NITRO_ACTIVATED, SetVehicleNitroActivated, "SetVehicleNitroActivated");
}

void CVehicleRPCs::DestroyAllVehicles(NetBitStreamInterface& bitStream)
@@ -653,3 +654,25 @@ void CVehicleRPCs::SetVehiclePlateText(CClientEntity* pSourceEntity, NetBitStrea
}
}
}


void CVehicleRPCs::SetVehicleNitroActivated(CClientEntity* pSourceEntity, NetBitStreamInterface& bitStream)
{
bool state;
if (bitStream.ReadBit(state))
{
CClientVehicle* pVehicle = m_pVehicleManager->Get(pSourceEntity->GetID());
if (pVehicle)
{
if (pVehicle->IsNitroInstalled())
{
if (state)
pVehicle->SetNitroLevel(pVehicle->GetNitroLevel() - 1.0001f);
else
pVehicle->SetNitroLevel(pVehicle->GetNitroLevel() + 1.0001f);

}
}
}
Proxy-99 marked this conversation as resolved.
Show resolved Hide resolved

Proxy-99 marked this conversation as resolved.
Show resolved Hide resolved
Proxy-99 marked this conversation as resolved.
Show resolved Hide resolved
}
1 change: 1 addition & 0 deletions Client/mods/deathmatch/logic/rpc/CVehicleRPCs.h
Original file line number Diff line number Diff line change
@@ -57,4 +57,5 @@ class CVehicleRPCs : public CRPCFunctions
DECLARE_ELEMENT_RPC(RemoveVehicleSirens);
DECLARE_ELEMENT_RPC(SetVehicleSirens);
DECLARE_ELEMENT_RPC(SetVehiclePlateText);
DECLARE_ELEMENT_RPC(SetVehicleNitroActivated);
};
11 changes: 11 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.cpp
Original file line number Diff line number Diff line change
@@ -126,6 +126,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"getVehicleSirens", GetVehicleSirens},
{"getVehicleSirenParams", GetVehicleSirenParams},
{"setVehiclePlateText", SetVehiclePlateText},
{"setVehicleNitroActivated", ArgumentParser <SetVehicleNitroActivated>},
Proxy-99 marked this conversation as resolved.
Show resolved Hide resolved
};

// Add functions
@@ -2982,3 +2983,13 @@ int CLuaVehicleDefs::SetVehiclePlateText(lua_State* luaVM)
lua_pushboolean(luaVM, false);
return 1;
}


bool CLuaVehicleDefs::SetVehicleNitroActivated(CVehicle* pVehicle, bool state)
{
CBitStream BitStream;
BitStream.pBitStream->WriteBit(state);

m_pPlayerManager->BroadcastOnlyJoined(CElementRPCPacket(pVehicle, SET_VEHICLE_NITRO_ACTIVATED, *BitStream.pBitStream));
return true;
}
Proxy-99 marked this conversation as resolved.
Show resolved Hide resolved
2 changes: 2 additions & 0 deletions Server/mods/deathmatch/logic/luadefs/CLuaVehicleDefs.h
Original file line number Diff line number Diff line change
@@ -125,4 +125,6 @@ class CLuaVehicleDefs : public CLuaDefs
LUA_DECLARE(GetVehicleSirens);
LUA_DECLARE(GetVehicleSirenParams);
LUA_DECLARE(SetVehiclePlateText);

static bool SetVehicleNitroActivated(CVehicle* pVehicle, bool state);
};
2 changes: 2 additions & 0 deletions Shared/sdk/net/rpc_enums.h
Original file line number Diff line number Diff line change
@@ -286,5 +286,7 @@ enum eElementRPCFunctions
RESPAWN_OBJECT,
TOGGLE_OBJECT_RESPAWN,

SET_VEHICLE_NITRO_ACTIVATED,

NUM_RPC_FUNCS // Add above this line
};