add option to park vehicles in vehicle menu
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
using GTANetworkAPI;
|
||||
using ReallifeGamemode.Server.Entities;
|
||||
using ReallifeGamemode.Server.Extensions;
|
||||
using ReallifeGamemode.Server.Models;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -37,8 +38,17 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
else if (sV is FactionVehicle fV)
|
||||
{
|
||||
if (fV.FactionId != u.FactionId && !state)
|
||||
if (fV.FactionId != u.FactionId && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (sV is GroupVehicle gV)
|
||||
{
|
||||
if(gV.GroupId != u.Group.Id && !state && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
{
|
||||
player.SendNotification("~r~Du hast keinen Schlüssel.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -76,20 +86,75 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
else if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id && !u.IsAdmin(AdminLevel.ADMIN3))
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
VehicleStreaming.SetLockStatus(v, !state);
|
||||
state = !state;
|
||||
VehicleStreaming.SetLockStatus(v, state);
|
||||
string msg = "Fahrzeug ";
|
||||
msg += state ? "~g~abgeschlossen" : "~r~aufgeschlossen";
|
||||
player.SendNotification(msg);
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("CLIENT:VehicleMenu_ParkCar")]
|
||||
public void VehicleMenuParkCarEvent(Client player)
|
||||
{
|
||||
if (player.IsInVehicle && player.VehicleSeat == -1)
|
||||
{
|
||||
Vehicle v = player.Vehicle;
|
||||
|
||||
User u = player.GetUser();
|
||||
if (u == null) return;
|
||||
|
||||
using (var dbContext = new DatabaseContext())
|
||||
{
|
||||
ServerVehicle sV = v.GetServerVehicle(dbContext);
|
||||
|
||||
if (sV == null) return;
|
||||
|
||||
if (sV is UserVehicle uV)
|
||||
{
|
||||
if (uV.UserId != u.Id)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sV is FactionVehicle fV)
|
||||
{
|
||||
if(fV.FactionId != u.FactionId || !u.FactionLeader)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if(sV is GroupVehicle gV)
|
||||
{
|
||||
if (gV.GroupId != u.Group.Id || u.GroupRank < GroupRank.MANAGER)
|
||||
{
|
||||
player.SendNotification("~r~Du darfst dieses Fahrzeug nicht parken.");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
Vector3 pos = v.Position;
|
||||
|
||||
sV.PositionX = pos.X;
|
||||
sV.PositionY = pos.Y;
|
||||
sV.PositionZ = pos.Z;
|
||||
sV.Heading = v.Heading;
|
||||
|
||||
player.SendNotification("~g~Das Fahrzeug wurde geparkt.");
|
||||
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("VehicleMenu_ToggleSingleDoor")]
|
||||
public void VehicleMenuToggleSingleDoorEvent(Client player, int door)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user