Files
reallife-gamemode/ReallifeGamemode.Server/Managers/PositionManager.cs
2021-05-27 23:22:37 +02:00

573 lines
19 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System.Collections.Generic;
using System.Linq;
using GTANetworkAPI;
using ReallifeGamemode.Server.Shop.Clothing;
using ReallifeGamemode.Server.Shop.SevenEleven;
using ReallifeGamemode.Server.Shop.Friseur;
using ReallifeGamemode.Server.Util;
using ReallifeGamemode.Server.Extensions;
using ReallifeGamemode.Server.Shop.Ammunation;
using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
namespace ReallifeGamemode.Server.Managers
{
public class PositionManager : Script
{
public static List<DutyPoint> DutyPoints = new List<DutyPoint>();
public static List<WeaponPoint> WeaponPoints = new List<WeaponPoint>();
public static List<JailReleasePoint> JailReleasePoints = new List<JailReleasePoint>();
public static List<ElevatorPoint> ElevatorPoints = new List<ElevatorPoint>();
public static List<ClotheshopPoint> clotheshopPoints = new List<ClotheshopPoint>();
public static List<FriseurPoint> friseurPoints = new List<FriseurPoint>();
public static List<ItemshopPoint> itemshopPoints = new List<ItemshopPoint>();
public static List<JobPoint> JobPoints = new List<JobPoint>();
public static List<Player> cuffPoints = new List<Player>();
public static List<AmmunationPoint> AmmunationPoints = new List<AmmunationPoint>();
public static List<RentcarPoint> rentcarPoints = new List<RentcarPoint>();
public static List<CarwashPoint> carwashPoints = new List<CarwashPoint>();
public static List<JailPoint> jailPoints = new List<JailPoint>();
public static Vector3 eventportPosition;
public static bool eventportActive = false;
public static void LoadPositionManager()
{
#region DutyPoints
DutyPoint dutyPointLSPD = new DutyPoint()
{
Position = new Vector3(458.24, -990.86, 30.68),
FactionId = 1
};
DutyPoint dutyPointFIB = new DutyPoint()
{
Position = new Vector3(109.5706, -745.2126, 242.1521),
FactionId = 3
};
DutyPoint dutyPointLSED = new DutyPoint()
{
Position = new Vector3(1152.181, -1527.95, 34.8434),
FactionId = 2
};
DutyPoints.Add(dutyPointLSPD);
DutyPoints.Add(dutyPointFIB);
DutyPoints.Add(dutyPointLSED);
foreach (DutyPoint d in DutyPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(d.Position.X, d.Position.Y, d.Position.Z - 2), new Vector3(d.Position.X, d.Position.Y, d.Position.Z + 1),
new Vector3(0, 0, 0), 3, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("Stempeluhr - Dr\u00fccke ~y~E\n~s~Dienstkleidung - Dr\u00fccke ~y~K", d.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
#endregion DutyPoints
#region WeaponPoints
WeaponPoint weaponPointLSPD = new WeaponPoint()
{
Position = new Vector3(460.3162, -981.0168, 30.68959),
FactionId = 1
};
WeaponPoint weaponPointFIB = new WeaponPoint()
{
//Position = new Vector3(119.6835, -729.3273, 242.1519), old
Position = new Vector3(143.5561, -762.7424, 242.152),
FactionId = 3
};
WeaponPoint weaponPointBallas = new WeaponPoint()
{
Position = new Vector3(1381.08, -1505.67, 58.04),
FactionId = 8
};
WeaponPoint weaponPointGrove = new WeaponPoint()
{
Position = new Vector3(129.8998, -1938.709, 20.61865),
FactionId = 7
};
WeaponPoint weaponPointVagos = new WeaponPoint()
{
Position = new Vector3(-1076.6572, -1677.4907, 4.575236),
FactionId = 5
};
WeaponPoints.Add(weaponPointLSPD);
WeaponPoints.Add(weaponPointFIB);
WeaponPoints.Add(weaponPointBallas);
WeaponPoints.Add(weaponPointGrove);
WeaponPoints.Add(weaponPointVagos);
foreach (WeaponPoint w in WeaponPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(w.Position.X, w.Position.Y, w.Position.Z - 2), new Vector3(w.Position.X, w.Position.Y, w.Position.Z + 1),
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("Waffenspind - Dr\u00fccke ~y~E", w.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
#endregion WeaponPoints
#region JailPoints
JailPoint jail = new JailPoint()
{
Position = new Vector3(1854.06, 2582.38, 45.67)
};
jailPoints.Add(jail);
foreach (JailPoint j in jailPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(j.Position.X, j.Position.Y, j.Position.Z - 2), new Vector3(j.Position.X, j.Position.Y, j.Position.Z + 1),
new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 0), false, 0);
NAPI.TextLabel.CreateTextLabel("Stellen - Dr\u00fccke ~y~E", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
#endregion JailReleasePoints
#region JailReleasePoints
JailReleasePoint jailPointLSPD = new JailReleasePoint()
{
Position = new Vector3(459.5327, -988.8435, 24.91487)
};
JailReleasePoint jailPointFIB = new JailReleasePoint()
{
Position = new Vector3(119.6362, -727.6199, 242.152)
};
JailReleasePoints.Add(jailPointLSPD);
JailReleasePoints.Add(jailPointFIB);
foreach (JailReleasePoint j in JailReleasePoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(j.Position.X, j.Position.Y, j.Position.Z - 2), new Vector3(j.Position.X, j.Position.Y, j.Position.Z + 1),
new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("Gefängnis PC - Dr\u00fccke ~y~E", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
#endregion JailReleasePoints
#region ElevatorPoints
ElevatorPoint FibElevatorPointEG = new ElevatorPoint()
{
Position = new Vector3(136.1958, -761.657, 242.152), //FBI oben
FactionId = 3,
Stage = "Büro"
};
ElevatorPoint FibElevatorPointIntern = new ElevatorPoint()
{
Position = new Vector3(136.1958, -761.7176, 45.75203), //FBI unten
FactionId = 3,
Stage = "EG"
};
ElevatorPoint FibElevatorPointGarage = new ElevatorPoint()
{
Position = new Vector3(125.172, -739.3329, 33.13322), //FBI ganz ganz unten
FactionId = 3,
Stage = "Garage"
};
ElevatorPoints.Add(FibElevatorPointEG);
ElevatorPoints.Add(FibElevatorPointIntern);
ElevatorPoints.Add(FibElevatorPointGarage);
foreach (ElevatorPoint j in ElevatorPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(j.Position.X, j.Position.Y, j.Position.Z - 2), new Vector3(j.Position.X, j.Position.Y, j.Position.Z + 1),
new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("Aufzug - Dr\u00fccke ~y~E", j.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
#endregion ElevatorPoints
#region JobPoints
JobPoint jobPointRefuseCollector = new JobPoint()
{
Position = new Vector3(485.4114685058594, -2173.25, 5.918273448944092),
jobId = 2,
Skill = 0,
eventOnStart = false,
eventName = ""
};
JobPoint jobPointPilot = new JobPoint()
{
Position = new Vector3(1707.2711181640625, 3276.216064453125, 41.155494689941406),
jobId = 3,
Skill = 0,
eventOnStart = false,
eventName = ""
};
JobPoint jobPointPilot2 = new JobPoint()
{
Position = new Vector3(-1622.44189453125, -3151.955810546875, 13.992053985595703),
jobId = 3,
Skill = 300
};
JobPoint jobPointBusDriver = new JobPoint()
{
Position = new Vector3(-535.46, -2144.97, 5.95),
jobId = 4,
Skill = 0
};
JobPoints.Add(jobPointRefuseCollector);
JobPoints.Add(jobPointPilot);
JobPoints.Add(jobPointPilot2);
JobPoints.Add(jobPointBusDriver);
foreach (JobPoint p in JobPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(p.Position.X, p.Position.Y, p.Position.Z - 2), new Vector3(p.Position.X, p.Position.Y, p.Position.Z + 1),
new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 150), false, 0);
if (p.jobId == 2)
{
NAPI.TextLabel.CreateTextLabel("M\u00fcllmann - Dr\u00fccke ~y~E~s~ um Job zu starten/beenden", p.Position, 15, 1, 0, new Color(255, 255, 255), false, 0);
NAPI.Blip.CreateBlip(318, p.Position, 1f, 16, "Müllmann", 255, 0, true);
}
if (p.jobId == 3)
{
if (p.Skill < 2)
{
NAPI.TextLabel.CreateTextLabel("Pilot Anf\u00E4nger - Dr\u00fccke ~y~E~s~ um Job zu starten/beenden", p.Position, 15, 1, 0, new Color(255, 255, 255), false, 0);
NAPI.Blip.CreateBlip(251, p.Position, 1f, 16, "Pilot Anfänger", 255, 0, true);
}
if (p.Skill >= 2)
{
NAPI.TextLabel.CreateTextLabel("Pilot Fortgeschritten - Dr\u00fccke ~y~E~s~ um Job zu starten/beenden", p.Position, 15, 1, 0, new Color(255, 255, 255), false, 0);
NAPI.Blip.CreateBlip(251, p.Position, 1f, 16, "Pilot Fortgeschritten", 255, 0, true);
}
}
if (p.jobId == 4)
{
NAPI.TextLabel.CreateTextLabel("Busfahrer - Dr\u00fccke ~y~E~s~ um Job zu starten/beenden", p.Position, 15, 1, 0, new Color(255, 255, 255), false, 0);
NAPI.Blip.CreateBlip(513, p.Position, 1f, 16, "Busfahrer", 255, 0, true);
}
}
#endregion JobPoints
#region Shops
foreach (var shop in ShopManager.clotheStores)
{
shop.LoadClothes();
ClotheshopPoint shopPoint = new ClotheshopPoint()
{
Position = shop.vector,
clotheShop = shop
};
clotheshopPoints.Add(shopPoint);
}
foreach (ClotheshopPoint s in clotheshopPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(s.Position.X, s.Position.Y, s.Position.Z - 2), new Vector3(s.Position.X, s.Position.Y, s.Position.Z + 1),
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("Kleiderladen - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
foreach (var shop in ShopManager.FriseurStores)
{
shop.LoadClothes();
FriseurPoint shopPoint = new FriseurPoint()
{
Position = shop.vector,
friseurShop = shop
};
friseurPoints.Add(shopPoint);
}
foreach (FriseurPoint s in friseurPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(s.Position.X, s.Position.Y, s.Position.Z - 2), new Vector3(s.Position.X, s.Position.Y, s.Position.Z + 1),
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("Friseur - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
foreach (var shop in ShopManager.itemShops)
{
shop.LoadItems();
ItemshopPoint shopPoint = new ItemshopPoint()
{
Position = shop.vector3,
itemShop = shop
};
itemshopPoints.Add(shopPoint);
}
foreach (ItemshopPoint s in itemshopPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(s.Position.X, s.Position.Y, s.Position.Z - 2), new Vector3(s.Position.X, s.Position.Y, s.Position.Z + 1),
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("24/7 - Dr\u00fccke ~y~E", s.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
}
foreach (Ammunation s in ShopManager.Ammunations)
{
NAPI.Marker.CreateMarker(1, new Vector3(s.vector.X, s.vector.Y, s.vector.Z - 2), new Vector3(s.vector.X, s.vector.Y, s.vector.Z + 1),
new Vector3(0, 0, 0), 2, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("Ammunation - Dr\u00fccke ~y~E", s.vector, 7, 1, 0, new Color(255, 255, 255), false, 0);
AmmunationPoint ammuShop = new AmmunationPoint
{
Position = s.vector,
Ammunation = s
};
AmmunationPoints.Add(ammuShop);
}
#endregion Shops
#region RentCar
RentcarPoint rentCarNoobSpawn = new RentcarPoint()
{
Position = Rentcar.noobSpawnBlipPosition
};
RentcarPoint rentCarStadthalle = new RentcarPoint()
{
Position = Rentcar.stadthalleBlipPosition
};
RentcarPoint rentCarKnast = new RentcarPoint()
{
Position = Rentcar.knastBlipPosition
};
RentcarPoint rentCarPaleto = new RentcarPoint()
{
Position = Rentcar.paletoBlipPosition
};
RentcarPoint rentCarLamesa = new RentcarPoint()
{
Position = Rentcar.lamesaBlipPosition
};
rentcarPoints.Add(rentCarNoobSpawn);
rentcarPoints.Add(rentCarLamesa);
rentcarPoints.Add(rentCarStadthalle);
rentcarPoints.Add(rentCarKnast);
rentcarPoints.Add(rentCarPaleto);
foreach (RentcarPoint point in rentcarPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(point.Position.X, point.Position.Y, point.Position.Z - 2), new Vector3(point.Position.X, point.Position.Y, point.Position.Z + 1),
new Vector3(0, 0, 0), 1.5f, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("~y~Fahrzeugverleih\n~w~Drücke ~b~E~w~ um ein Fahrzeug zu mieten", point.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
NAPI.Blip.CreateBlip(88, new Vector3(point.Position.X, point.Position.Y, point.Position.Z), (float)0.7, 59, "Fahrzeugverleih", 255, 200, true, 0, 0);
}
#endregion RentCar
#region Carwash
CarwashPoint Carwash = new CarwashPoint()
{
Position = new Vector3(26.37, -1391.99, 29.36)
};
carwashPoints.Add(Carwash);
foreach (CarwashPoint point in carwashPoints)
{
NAPI.Marker.CreateMarker(1, new Vector3(point.Position.X, point.Position.Y, point.Position.Z - 2), new Vector3(point.Position.X, point.Position.Y, point.Position.Z + 1),
new Vector3(0, 0, 0), 5.5f, new Color(255, 255, 255, 50), false, 0);
NAPI.TextLabel.CreateTextLabel("~y~Autowaschanlage", point.Position, 7, 1, 0, new Color(255, 255, 255), false, 0);
NAPI.Blip.CreateBlip(100, new Vector3(point.Position.X, point.Position.Y, point.Position.Z), (float)0.7, 0, "´Carwash", 255, 200, true, 0, 0);
Vector3 pos = point.Position;
ColShape colShape = NAPI.ColShape.CreateSphereColShape(pos, 5, 0);
colShape.OnEntityEnterColShape += (cs, c) =>
{
if (!(c.IsInVehicle && c.VehicleSeat == 0)) return;
using (var dbcontext = new DatabaseContext())
{
User u = c.GetUser(dbcontext);
if(u.Handmoney < 0)
{
c.SendNotification("Du hast nicht genug Geld auf der Hand!");
return;
}
else {
c.TriggerEvent("washcar");
c.SendNotification("Die Autowäsche hat dich ~g~$~w~100 gekostet.");
u.Handmoney -= 100;
dbcontext.SaveChanges();
}
}
};
}
#endregion Carwash
}
[RemoteEvent("sendClientToStage")]
public void ElevatorSendToStage(Player player, string level)
{
//HERELOL
ElevatorPoint nearestElevatorPoint = PositionManager.ElevatorPoints.Find(e => e.Position.DistanceTo(player.Position) <= 1.5);
if (nearestElevatorPoint == null)
{
return;
}
player.SafeTeleport(ElevatorPoints.Where(e => e.Stage == level).First().Position);
}
}
}
public static class MarkerBehinVehicle
{
public static List<BehindVehiclePoint> behindVehiclePoints = new List<BehindVehiclePoint>();
public static bool HasMarkerBehind(this Vehicle vehicle)
{
BehindVehiclePoint point = behindVehiclePoints.Find(v => v.vehicle == vehicle);
if (point != null)
{
return true;
}
return false;
}
public static void RemoveMarkerBehind(this Vehicle vehicle)
{
BehindVehiclePoint point = behindVehiclePoints.Find(v => v.vehicle == vehicle);
point.marker.Delete();
point.textLabel.Delete();
behindVehiclePoints.Remove(point);
}
public static void AddMarkerBehind(this Vehicle vehicle, Vector3 vector3)
{
Marker marker = NAPI.Marker.CreateMarker(1, vector3, new Vector3(), new Vector3(), 2, new Color(255, 255, 255, 70));
TextLabel textLabel = NAPI.TextLabel.CreateTextLabel("Dr\u00fccke ~y~E~s~ um zu benutzen", new Vector3(vector3.X, vector3.Y, vector3.Z + 1.4), 7, 1, 0, new Color(255, 255, 255), false, 0);
BehindVehiclePoint behindVehiclePoint = new BehindVehiclePoint(vehicle, marker, textLabel);
behindVehiclePoints.Add(behindVehiclePoint);
}
}
public class DutyPoint
{
public Vector3 Position { get; set; }
public int FactionId { get; set; }
}
public class BehindVehiclePoint
{
public Vehicle vehicle { get; set; }
public Marker marker { get; set; }
public TextLabel textLabel { get; set; }
public BehindVehiclePoint(Vehicle vehicle, Marker marker, TextLabel textLabel)
{
this.vehicle = vehicle;
this.marker = marker;
this.textLabel = textLabel;
}
public void usePoint(Player player)
{
if (vehicle.HasData("WeaponDealLoad") && vehicle.GetData<bool>("WeaponDealLoad") == true)
{
if (!player.HasAttachment("ammobox"))
{
player.SyncAnimation("carryBox");
player.AddAttachment("ammobox", false);
NAPI.Player.SetPlayerCurrentWeapon(player, WeaponHash.Unarmed);
}
}
}
}
public class WeaponPoint
{
public Vector3 Position { get; set; }
public int FactionId { get; set; }
}
public class JailReleasePoint
{
public Vector3 Position { get; set; }
}
public class ClotheshopPoint
{
public Vector3 Position { get; set; }
public ClotheShop clotheShop { get; set; }
}
public class ItemshopPoint
{
public Vector3 Position { get; set; }
public ItemShop itemShop { get; set; }
}
public class FriseurPoint
{
public Vector3 Position { get; set; }
public Friseur friseurShop { get; set; }
}
public class JobPoint
{
public Vector3 Position { get; set; }
public int jobId { get; set; }
public int Skill { get; set; }
public bool eventOnStart { get; set; }
public string eventName { get; set; }
}
public class ElevatorPoint
{
public Vector3 Position { get; set; }
public int FactionId { get; set; }
public string Stage { get; set; }
}
public class AmmunationPoint
{
public Vector3 Position { get; set; }
public Ammunation Ammunation { get; set; }
}
public class RentcarPoint
{
public Vector3 Position { get; set; }
}
public class CarwashPoint
{
public Vector3 Position { get; set; }
}
public class JailPoint
{
public Vector3 Position { get; set; }
}