Skip to content
Permalink
Browse files

Add areVehicleLightsOn function (#938)

* Add areVehicleLightsOn function

This function gets the vehicle lights state (on/off)

* Add OOP definitions of areVehicleLightsOn

* Hard error

* Update make_uname.bat
  • Loading branch information...
StrixG authored and patrikjuvonen committed Sep 2, 2019
1 parent c1053ee commit 4dc23350c619ed4b275c78e154d2810c2e24b17a
@@ -1582,6 +1582,16 @@ void CClientVehicle::SetLightStatus(unsigned char ucLight, unsigned char ucStatu
}
}

bool CClientVehicle::AreLightsOn()
{
if (m_pVehicle)
{
return m_pVehicle->GetLightsOn();
}

return false;
}

float CClientVehicle::GetHeliRotorSpeed()
{
if (m_pVehicle && m_eVehicleType == CLIENTVEHICLE_HELI)
@@ -261,6 +261,8 @@ class CClientVehicle : public CClientStreamElement
unsigned char GetPanelStatus(unsigned char ucPanel);
unsigned char GetLightStatus(unsigned char ucLight);

bool AreLightsOn();

void SetDoorStatus(unsigned char ucDoor, unsigned char ucStatus);
void SetWheelStatus(unsigned char ucWheel, unsigned char ucStatus, bool bSilent = true);
void SetPanelStatus(unsigned char ucPanel, unsigned char ucStatus);
@@ -36,6 +36,7 @@ void CLuaVehicleDefs::LoadFunctions()
{"getVehicleDoorState", GetVehicleDoorState},
{"getVehicleLightState", GetVehicleLightState},
{"getVehiclePanelState", GetVehiclePanelState},
{"areVehicleLightsOn", AreVehicleLightsOn},
{"getVehicleOverrideLights", GetVehicleOverrideLights},
{"getVehicleTowedByVehicle", GetVehicleTowedByVehicle},
{"getVehicleTowingVehicle", GetVehicleTowingVehicle},
@@ -200,6 +201,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classfunction(luaVM, "getEngineState", "getVehicleEngineState");
lua_classfunction(luaVM, "getLightState", "getVehicleLightState");
lua_classfunction(luaVM, "getAdjustableProperty", "getVehicleAdjustableProperty");
lua_classfunction(luaVM, "areLightsOn", "areVehicleLightsOn");
lua_classfunction(luaVM, "getOverrideLights", "getVehicleOverrideLights");
lua_classfunction(luaVM, "getPanelState", "getVehiclePanelState");
lua_classfunction(luaVM, "getTurnVelocity", OOP_GetVehicleTurnVelocity);
@@ -298,6 +300,7 @@ void CLuaVehicleDefs::AddClass(lua_State* luaVM)
lua_classvariable(luaVM, "fuelTankExplodable", "setVehicleFuelTankExplodable", "isVehicleFuelTankExplodable");
lua_classvariable(luaVM, "engineState", "setVehicleEngineState", "getVehicleEngineState");
lua_classvariable(luaVM, "landingGearDown", "setVehicleLandingGearDown", "getVehicleLandingGearDown");
lua_classvariable(luaVM, "lightsOn", NULL, "areVehicleLightsOn");
lua_classvariable(luaVM, "overrideLights", "setVehicleOverrideLights", "getVehicleOverrideLights");
lua_classvariable(luaVM, "undamageableDoors", "setVehicleDoorsUndamageable", NULL);
lua_classvariable(luaVM, "taxiLight", "setVehicleTaxiLightOn", "isVehicleTaxiLightOn");
@@ -1008,6 +1011,20 @@ int CLuaVehicleDefs::GetVehiclePanelState(lua_State* luaVM)
return 1;
}

int CLuaVehicleDefs::AreVehicleLightsOn(lua_State* luaVM)
{
CClientVehicle* pVehicle;
CScriptArgReader argStream(luaVM);
argStream.ReadUserData(pVehicle);

if (argStream.HasErrors())
return luaL_error(luaVM, argStream.GetFullErrorMessage());

bool bLightsOn = (pVehicle->AreLightsOn() || pVehicle->GetOverrideLights() == 2);
lua_pushboolean(luaVM, bLightsOn);
return 1;
}

int CLuaVehicleDefs::GetVehicleOverrideLights(lua_State* luaVM)
{
CClientVehicle* pVehicle = NULL;
@@ -44,6 +44,7 @@ class CLuaVehicleDefs : public CLuaDefs
LUA_DECLARE(GetVehicleDoorState);
LUA_DECLARE(GetVehicleLightState);
LUA_DECLARE(GetVehiclePanelState);
LUA_DECLARE(AreVehicleLightsOn);
LUA_DECLARE(GetVehicleOverrideLights);
LUA_DECLARE(GetVehicleTowedByVehicle);
LUA_DECLARE(GetVehicleTowingVehicle);

0 comments on commit 4dc2335

Please sign in to comment.
You can’t perform that action at this time.