Finish DoorManager
This commit is contained in:
@@ -59,6 +59,7 @@ namespace reallife_gamemode.Model
|
||||
|
||||
//Saves
|
||||
public DbSet<Server.Saves.SavedBlip> Blips { get; set; }
|
||||
public DbSet<Server.Entities.Door> Doors { get; set; }
|
||||
public DbSet<Server.Entities.GotoPoint> GotoPoints { get; set; }
|
||||
public DbSet<Server.Saves.SavedMarker> Markers { get; set; }
|
||||
public DbSet<Server.Saves.SavedPed> Peds { get; set; }
|
||||
|
||||
32
Server/Entities/Door.cs
Normal file
32
Server/Entities/Door.cs
Normal file
@@ -0,0 +1,32 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Numerics;
|
||||
using System.Text;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Entities Door (Door.cs)
|
||||
* @author VegaZ
|
||||
* @copyright (c) 2008 - 2018 Life of German
|
||||
*/
|
||||
|
||||
namespace reallife_gamemode.Server.Entities
|
||||
{
|
||||
public class Door
|
||||
{
|
||||
[Key]
|
||||
public int Id { get; set; }
|
||||
public string Category { get; set; }
|
||||
public string Name { get; set; }
|
||||
public bool Locked { get; set; }
|
||||
public int Model { get; set; }
|
||||
public float X { get; set; }
|
||||
public float Y { get; set; }
|
||||
public float Z { get; set; }
|
||||
|
||||
[ForeignKey("FactionId")]
|
||||
public int? FactionId { get; set; }
|
||||
public Faction Faction { get; set; }
|
||||
}
|
||||
}
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,7 +20,6 @@ namespace reallife_gamemode.Server.Managers
|
||||
public static List<Vehicle> ShopVehicleList = new List<Vehicle>();
|
||||
public static List<Vehicle> UserVehicleList = new List<Vehicle>();
|
||||
|
||||
public static ColShape policeDoors;
|
||||
[ServerEvent(Event.ResourceStart)]
|
||||
public void OnResourceStart()
|
||||
{
|
||||
@@ -79,10 +78,6 @@ namespace reallife_gamemode.Server.Managers
|
||||
current.SetData("ownerId", v.UserId);
|
||||
UserVehicleList.Add(current);
|
||||
}
|
||||
policeDoors = NAPI.ColShape.CreateCylinderColShape(new Vector3(434.7479, -983.2151, 30.83926), 4, 3, 0);
|
||||
List<ColShape> colshapes = new List<ColShape>();
|
||||
colshapes.Add(policeDoors);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user