93 lines
3.0 KiB
C#
93 lines
3.0 KiB
C#
using GTANetworkAPI;
|
|
using reallife_gamemode.Server.Entities;
|
|
using reallife_gamemode.Server.Extensions;
|
|
using reallife_gamemode.Server.Util;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
|
|
namespace reallife_gamemode.Server.Events
|
|
{
|
|
public class VehicleMenu : Script
|
|
{
|
|
[RemoteEvent("VehicleMenu_ToggleEngine")]
|
|
public void VehicleMenuToggleEngineEvent(Client player)
|
|
{
|
|
if (player.IsInVehicle && player.VehicleSeat == -1)
|
|
{
|
|
Vehicle v = player.Vehicle;
|
|
|
|
User u = player.GetUser();
|
|
if (u == null) return;
|
|
|
|
if (NAPI.Entity.GetEntityVelocity(v).Length() > 1)
|
|
{
|
|
player.SendNotification("~r~Der Motor kann nur im Stand betätigt werden.", true);
|
|
return;
|
|
}
|
|
|
|
bool state = VehicleStreaming.GetEngineState(v);
|
|
ServerVehicle sV = v.GetServerVehicle();
|
|
if (sV != null)
|
|
{
|
|
if (sV is ShopVehicle)
|
|
{
|
|
VehicleStreaming.SetEngineState(v, false);
|
|
return;
|
|
}
|
|
else if (sV is FactionVehicle fV)
|
|
{
|
|
if (fV.FactionId != u.FactionId && !state)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
VehicleStreaming.SetEngineState(v, !state);
|
|
}
|
|
}
|
|
|
|
[RemoteEvent("VehicleMenu_LockCar")]
|
|
public void VehicleMenuLockCarEvent(Client player)
|
|
{
|
|
if (player.IsInVehicle && player.VehicleSeat == -1)
|
|
{
|
|
Vehicle v = player.Vehicle;
|
|
|
|
User u = player.GetUser();
|
|
if (u == null) return;
|
|
|
|
bool state = VehicleStreaming.GetLockState(v);
|
|
ServerVehicle sV = v.GetServerVehicle();
|
|
|
|
if (sV != null)
|
|
{
|
|
if (sV is ShopVehicle)
|
|
{
|
|
VehicleStreaming.SetEngineState(v, false);
|
|
return;
|
|
}
|
|
else if (sV is FactionVehicle fV)
|
|
{
|
|
if (fV.FactionId != u.FactionId)
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
else if(sV is UserVehicle uV)
|
|
{
|
|
if(uV.UserId != u.Id && !u.IsAdmin(AdminLevel.ADMIN3))
|
|
{
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
VehicleStreaming.SetLockStatus(v, !state);
|
|
string msg = "Fahrzeug ";
|
|
msg += !state ? "~r~abgeschlossen" : "~g~abgeschlossen";
|
|
player.SendNotification(msg);
|
|
}
|
|
}
|
|
}
|
|
}
|