diff --git a/code/components/citizen-server-impl/include/state/ServerGameState.h b/code/components/citizen-server-impl/include/state/ServerGameState.h index cca6864df6..c944484dec 100644 --- a/code/components/citizen-server-impl/include/state/ServerGameState.h +++ b/code/components/citizen-server-impl/include/state/ServerGameState.h @@ -490,7 +490,7 @@ struct CVehicleGameStateNodeData bool sirenOn; int lockStatus; int doorsOpen; - int doorPositions[1 << 7]; + int doorPositions[7]; bool isStationary; bool lightsOn; bool highbeamsOn; diff --git a/code/components/citizen-server-impl/src/state/ServerGameState_Scripting.cpp b/code/components/citizen-server-impl/src/state/ServerGameState_Scripting.cpp index 619d155541..b5116e76d5 100644 --- a/code/components/citizen-server-impl/src/state/ServerGameState_Scripting.cpp +++ b/code/components/citizen-server-impl/src/state/ServerGameState_Scripting.cpp @@ -652,7 +652,13 @@ static void Init() if (context.GetArgumentCount() > 1 && doorsOpen) { - doorStatus = vn->doorPositions[context.GetArgument(1)]; + const int index = context.GetArgument(1); + if (index < 0 || index > 6) + { + return doorStatus; + } + + doorStatus = vn->doorPositions[index]; } return doorStatus; @@ -718,7 +724,12 @@ static void Init() if (!wheelsFine && context.GetArgumentCount() > 1) { - int tyreID = context.GetArgument(1); + const int tyreID = context.GetArgument(1); + if (tyreID < 0 || tyreID > 15) + { + return tyreBurst; + } + bool completely = context.GetArgument(2); int tyreStatus = vn->tyreStatus[tyreID]; @@ -1219,7 +1230,11 @@ static void Init() { auto vn = entity->syncTree->GetVehicleGameState(); - int seatArg = context.GetArgument(1) + 2; + const int seatArg = context.GetArgument(1) + 2; + if (seatArg < 0 || seatArg > 31) + { + return 0; + } // get the current resource manager auto resourceManager = fx::ResourceManager::GetCurrent(); @@ -1248,7 +1263,11 @@ static void Init() { auto vn = entity->syncTree->GetVehicleGameState(); - int seatArg = context.GetArgument(1) + 2; + const int seatArg = context.GetArgument(1) + 2; + if (seatArg < 0 || seatArg > 31) + { + return 0; + } // get the current resource manager auto resourceManager = fx::ResourceManager::GetCurrent(); diff --git a/ext/native-decls/GetVehicleDoorStatus.md b/ext/native-decls/GetVehicleDoorStatus.md index 6e2828c237..3b6ed492ba 100644 --- a/ext/native-decls/GetVehicleDoorStatus.md +++ b/ext/native-decls/GetVehicleDoorStatus.md @@ -5,12 +5,14 @@ apiset: server ## GET_VEHICLE_DOOR_STATUS ```c -int GET_VEHICLE_DOOR_STATUS(Vehicle vehicle); +int GET_VEHICLE_DOOR_STATUS(Vehicle vehicle, int doorIndex); ``` +Returns the open position of the specified door on the target vehicle. ## Parameters -* **vehicle**: +- **vehicle**: The target vehicle. +- **doorIndex**: Index of door to check (0-6). ## Return value A number from 0 to 7. \ No newline at end of file