Finish DoorManager
This commit is contained in:
@@ -1,7 +1,11 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using GTANetworkAPI;
|
||||
using reallife_gamemode.Model;
|
||||
using reallife_gamemode.Server.Entities;
|
||||
using reallife_gamemode.Server.Extensions;
|
||||
/**
|
||||
* @overview Life of German Reallife - Managers BankManager (BankManager.cs)
|
||||
* @author VegaZ
|
||||
@@ -15,24 +19,75 @@ namespace reallife_gamemode.Server.Managers
|
||||
[RemoteEvent("ChangeDoorState")]
|
||||
public void ChangeDoorState(Client player)
|
||||
{
|
||||
var isNearDoor = NAPI.ColShape.IsPointWithinColshape(LoadManager.policeDoors, player.Position);
|
||||
List<Door> NearDoors = new List<Door>();
|
||||
var user = player.GetUser();
|
||||
|
||||
if (isNearDoor)
|
||||
using (var saveDoor = new DatabaseContext())
|
||||
{
|
||||
if (NAPI.Data.GetWorldData("policeDoors") == false)
|
||||
NearDoors = saveDoor.Doors.ToList().FindAll(d => new Vector3(d.X, d.Y, d.Z).DistanceTo(player.Position) <= 2);
|
||||
foreach (Door d in NearDoors)
|
||||
{
|
||||
player.SendNotification("Polizeitüren ~r~abgeschlossen", false);
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", 320433149, 434.7479f, -983.2151f, 30.83926f, 1, 0.0f, 0.0f, 0.0f));
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", -1215222675, 434.7479f, -980.6184f, 30.83926f, 1, 0.0f, 0.0f, 0.0f));
|
||||
NAPI.Data.SetWorldData("policeDoors", true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("Polizeitüren ~g~aufgeschlossen", false);
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", 320433149, 434.7479f, -983.2151f, 30.83926f, 0, 0.0f, 0.0f, 0.0f));
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", -1215222675, 434.7479f, -980.6184f, 30.83926f, 0, 0.0f, 0.0f, 0.0f));
|
||||
NAPI.Data.SetWorldData("policeDoors", false);
|
||||
Door currentDoor = saveDoor.Doors.FirstOrDefault(c => c.Id == d.Id);
|
||||
if (d.Locked == true)
|
||||
{
|
||||
if (d.FactionId == null)
|
||||
{
|
||||
if (user.AdminLevel >= Util.AdminLevel.ADMIN)
|
||||
{
|
||||
player.SendNotification(d.Name + " ~g~aufgeschlossen.", false);
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, 0, 0.0f, 0.0f, 0.0f));
|
||||
currentDoor.Locked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Du hast kein Recht diese T\u00fcr aufzuschlie\u00dfen!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d.FactionId == user.FactionId)
|
||||
{
|
||||
player.SendNotification(d.Name + " ~g~aufgeschlossen.", false);
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, 0, 0.0f, 0.0f, 0.0f));
|
||||
currentDoor.Locked = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Du hast kein Recht diese T\u00fcr aufzuschlie\u00dfen!");
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d.FactionId == null)
|
||||
{
|
||||
if (user.AdminLevel >= Util.AdminLevel.ADMIN)
|
||||
{
|
||||
player.SendNotification(d.Name + " ~r~abgeschlossen.", false);
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, 1, 0.0f, 0.0f, 0.0f));
|
||||
currentDoor.Locked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Du hast kein Recht diese T\u00fcr abzuschlie\u00dfen!");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (d.FactionId == user.FactionId)
|
||||
{
|
||||
player.SendNotification(d.Name + " ~r~abgeschlossen.", false);
|
||||
NAPI.Pools.GetAllPlayers().ForEach(p => p.TriggerEvent("changeDoorState", d.Model, d.X, d.Y, d.Z, 1, 0.0f, 0.0f, 0.0f));
|
||||
currentDoor.Locked = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
player.SendNotification("~r~Du hast kein Recht diese T\u00fcr abzuschlie\u00dfen!");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
saveDoor.SaveChanges();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user