Added vehicle indicators
This commit is contained in:
@@ -54,3 +54,4 @@ require('./Tuning/sirensilence.js');
|
|||||||
|
|
||||||
require('./vehiclesync/vehiclesync.js');
|
require('./vehiclesync/vehiclesync.js');
|
||||||
require('./vehiclesync/smoothtrottle.js');
|
require('./vehiclesync/smoothtrottle.js');
|
||||||
|
require('./vehiclesync/vehicleindicators.js');
|
||||||
33
ReallifeGamemode.Client/vehiclesync/vehicleindicators.js
Normal file
33
ReallifeGamemode.Client/vehiclesync/vehicleindicators.js
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
var player = mp.players.local;
|
||||||
|
|
||||||
|
mp.keys.bind(0x64, true, function () {
|
||||||
|
if (!player.vehicle) return;
|
||||||
|
mp.events.callRemote("CLIENT:toggleLeftIndicator");
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.keys.bind(0x66, true, function () {
|
||||||
|
if (!player.vehicle) return;
|
||||||
|
mp.events.callRemote("CLIENT:toggleRightIndicator");
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.keys.bind(0x65, true, function () {
|
||||||
|
if (!player.vehicle) return;
|
||||||
|
mp.events.callRemote("CLIENT:toggleWarningIndicator");
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add("SERVER:setIndicatorStatus", (vehicle, left, right) => {
|
||||||
|
var veh = mp.vehicles.atRemoteId(vehicle);
|
||||||
|
|
||||||
|
veh.setIndicatorLights(0, right);
|
||||||
|
veh.setIndicatorLights(1, left);
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add("entityStreamIn", entity => {
|
||||||
|
if (entity === undefined || entity === null || !entity.isAVehicle()) return;
|
||||||
|
|
||||||
|
var data = entity.getVariable("indicatorData");
|
||||||
|
if (data) {
|
||||||
|
entity.setIndicatorLights(0, data.Right);
|
||||||
|
entity.setIndicatorLights(1, data.Left);
|
||||||
|
}
|
||||||
|
});
|
||||||
8
ReallifeGamemode.Server/Util/IndicatorData.cs
Normal file
8
ReallifeGamemode.Server/Util/IndicatorData.cs
Normal file
@@ -0,0 +1,8 @@
|
|||||||
|
namespace ReallifeGamemode.Server.Util
|
||||||
|
{
|
||||||
|
public class IndicatorData
|
||||||
|
{
|
||||||
|
public bool Left { get; set; } = false;
|
||||||
|
public bool Right { get; set; } = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,28 +1,6 @@
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using Newtonsoft.Json.Linq;
|
using Newtonsoft.Json.Linq;
|
||||||
|
|
||||||
//Disapproved by god himself
|
|
||||||
|
|
||||||
//Just use the API functions, you have nothing else to worry about
|
|
||||||
|
|
||||||
//Things to note
|
|
||||||
//More things like vehicle mods will be added in the next version
|
|
||||||
|
|
||||||
/* API FUNCTIONS:
|
|
||||||
public static void SetVehicleWindowState(Vehicle veh, WindowID window, WindowState state)
|
|
||||||
public static WindowState GetVehicleWindowState(Vehicle veh, WindowID window)
|
|
||||||
public static void SetVehicleWheelState(Vehicle veh, WheelID wheel, WheelState state)
|
|
||||||
public static WheelState GetVehicleWheelState(Vehicle veh, WheelID wheel)
|
|
||||||
public static void SetVehicleDirt(Vehicle veh, float dirt)
|
|
||||||
public static float GetVehicleDirt(Vehicle veh)
|
|
||||||
public static void SetDoorState(Vehicle veh, DoorID door, DoorState state)
|
|
||||||
public static DoorState GetDoorState(Vehicle veh, DoorID door)
|
|
||||||
public static void SetEngineState(Vehicle veh, bool status)
|
|
||||||
public static bool GetEngineState(Vehicle veh)
|
|
||||||
public static void SetLockStatus(Vehicle veh, bool status)
|
|
||||||
public static bool GetLockState(Vehicle veh)
|
|
||||||
*/
|
|
||||||
|
|
||||||
namespace ReallifeGamemode.Server.Util
|
namespace ReallifeGamemode.Server.Util
|
||||||
{
|
{
|
||||||
//Enums for ease of use
|
//Enums for ease of use
|
||||||
@@ -448,5 +426,72 @@ namespace ReallifeGamemode.Server.Util
|
|||||||
|
|
||||||
NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDoorStatus", veh.Handle, data.Door[0], data.Door[1], data.Door[2], data.Door[3], data.Door[4], data.Door[5], data.Door[6], data.Door[7]);
|
NAPI.ClientEvent.TriggerClientEventInDimension(veh.Dimension, "VehStream_SetVehicleDoorStatus", veh.Handle, data.Door[0], data.Door[1], data.Door[2], data.Door[3], data.Door[4], data.Door[5], data.Door[6], data.Door[7]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// INDICATORS
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:toggleLeftIndicator")]
|
||||||
|
public void ToggleLeftIndicator(Client player)
|
||||||
|
{
|
||||||
|
if (!player.IsInVehicle || player.VehicleSeat != -1) return;
|
||||||
|
Vehicle veh = player.Vehicle;
|
||||||
|
|
||||||
|
if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData();
|
||||||
|
|
||||||
|
if (data.Left && data.Right)
|
||||||
|
{
|
||||||
|
data.Right = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.Left = !data.Left;
|
||||||
|
}
|
||||||
|
|
||||||
|
veh.SetData("indicatorData", data);
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:toggleRightIndicator")]
|
||||||
|
public void ToggleRightIndicator(Client player)
|
||||||
|
{
|
||||||
|
if (!player.IsInVehicle || player.VehicleSeat != -1) return;
|
||||||
|
Vehicle veh = player.Vehicle;
|
||||||
|
|
||||||
|
if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData();
|
||||||
|
|
||||||
|
if (data.Left && data.Right)
|
||||||
|
{
|
||||||
|
data.Left = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.Right = !data.Right;
|
||||||
|
}
|
||||||
|
|
||||||
|
veh.SetData("indicatorData", data);
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:toggleWarningIndicator")]
|
||||||
|
public void ToggleWarningIndicator(Client player)
|
||||||
|
{
|
||||||
|
if (!player.IsInVehicle || player.VehicleSeat != -1) return;
|
||||||
|
Vehicle veh = player.Vehicle;
|
||||||
|
|
||||||
|
if (!(veh.GetData("indicatorData") is IndicatorData data)) data = new IndicatorData();
|
||||||
|
|
||||||
|
if (data.Right && data.Left)
|
||||||
|
{
|
||||||
|
data.Right = false;
|
||||||
|
data.Left = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
data.Right = true;
|
||||||
|
data.Left = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
veh.SetData("indicatorData", data);
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("SERVER:setIndicatorStatus", veh.Handle.Value, data.Left, data.Right);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user