From 490a71c3e3c80684e7c4fbca2185da6b9827e0d4 Mon Sep 17 00:00:00 2001 From: "michael.reiswich" Date: Mon, 10 May 2021 18:30:34 +0200 Subject: [PATCH] test carwash --- ReallifeGamemode.Client/index.ts | 3 + ReallifeGamemode.Client/util/carwash.ts | 16 +++++ .../Commands/AdminCommands.cs | 6 ++ .../Managers/PositionManager.cs | 59 ++++++++++++++++++- 4 files changed, 83 insertions(+), 1 deletion(-) create mode 100644 ReallifeGamemode.Client/util/carwash.ts diff --git a/ReallifeGamemode.Client/index.ts b/ReallifeGamemode.Client/index.ts index b79488aa..e1b91d2d 100644 --- a/ReallifeGamemode.Client/index.ts +++ b/ReallifeGamemode.Client/index.ts @@ -286,6 +286,9 @@ notification(); import rentCar from './util/rentcar'; rentCar(globalData); +import Carwash from './util/carwash'; +Carwash(globalData); + require('./Gui/policedepartment'); require('./Gui/helptext'); require('./admin/spectate'); diff --git a/ReallifeGamemode.Client/util/carwash.ts b/ReallifeGamemode.Client/util/carwash.ts new file mode 100644 index 00000000..600ca0ad --- /dev/null +++ b/ReallifeGamemode.Client/util/carwash.ts @@ -0,0 +1,16 @@ +export default function Carwash(globalData: IGlobalData) { + + mp.events.add('washcar', () => { + let vehicle = mp.players.local.vehicle; + + vehicle.setDirtLevel(0); + }); + + mp.events.add('entityStreamIn', (entity) => { + if (entity.type !== 'vehicle' || !entity.hasVariable('dirtLevel')) { + return; + } + const dirtLevel = entity.getVariable('dirtLevel') || 0; + entity.setDirtLevel(parseFloat(dirtLevel)); + }); +} \ No newline at end of file diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 916f4293..d2a3d842 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -4025,6 +4025,12 @@ namespace ReallifeGamemode.Server.Commands } } + [Command("washcar", "~m~Benutzung: ~s~/washcar")] + public void washcar(Player player) + { + player.TriggerEvent("washcar"); + } + [Command("makeadmin", "~m~Benutzung: ~s~/makeadmin [Name] [Adminlevel]")] public void CmdAdminMakeadmin(Player player, string name, int rank) { diff --git a/ReallifeGamemode.Server/Managers/PositionManager.cs b/ReallifeGamemode.Server/Managers/PositionManager.cs index 51ee78d2..daf97ffe 100644 --- a/ReallifeGamemode.Server/Managers/PositionManager.cs +++ b/ReallifeGamemode.Server/Managers/PositionManager.cs @@ -7,6 +7,9 @@ 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 { @@ -34,6 +37,9 @@ namespace ReallifeGamemode.Server.Managers public static List rentcarPoints = new List(); + public static List carwashPoints = new List(); + + public static Vector3 eventportPosition; public static bool eventportActive = false; @@ -347,9 +353,55 @@ namespace ReallifeGamemode.Server.Managers 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) + }; + + CarwashPoint Carwash2 = new CarwashPoint() + { + Position = new Vector3(111, 111, 29.32) + }; + + carwashPoints.Add(Carwash); + carwashPoints.Add(Carwash2); + + 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) return; + + c.TriggerEvent("washcar"); + using (var dbcontext = new DatabaseContext()) + { + User u = c.GetUser(dbcontext); + u.BankAccount.Balance -= 100; + dbcontext.SaveChanges(); + } + c.SendNotification("Die Autowäsche hat dich ~g~$~w~100 gekostet."); + }; + } + + #endregion Carwash + } - #endregion RentCar + [RemoteEvent("sendClientToStage")] public void ElevatorSendToStage(Player player, string level) { @@ -486,3 +538,8 @@ public class RentcarPoint public Vector3 Position { get; set; } } +public class CarwashPoint +{ + public Vector3 Position { get; set; } +} +