From 52bb80a70a07abebaa8e4fc635a7023da50de339 Mon Sep 17 00:00:00 2001 From: kookroach Date: Wed, 7 Apr 2021 01:08:22 +0200 Subject: [PATCH] Testserver push --- ReallifeGamemode.Client/Gui/nametags.ts | 11 ++-- ReallifeGamemode.Client/Player/keys.ts | 20 +++--- ReallifeGamemode.Client/util/animationSync.ts | 2 + .../Commands/UserCommands.cs | 16 ++--- ReallifeGamemode.Server/Events/Key.cs | 61 +++++++++++-------- .../Inventory/GroundItem.cs | 5 +- .../Managers/PositionManager.cs | 10 +-- ReallifeGamemode.Server/Util/AnimationSync.cs | 2 - .../Util/AttachmentSync.cs | 4 +- 9 files changed, 70 insertions(+), 61 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/nametags.ts b/ReallifeGamemode.Client/Gui/nametags.ts index c780693d..7fee2fc4 100644 --- a/ReallifeGamemode.Client/Gui/nametags.ts +++ b/ReallifeGamemode.Client/Gui/nametags.ts @@ -1,7 +1,6 @@ import { IGame, IEntity } from "../game"; import game from ".."; - const maxDistance = 40 * 40; const width = 0.03; const height = 0.0065; @@ -27,9 +26,7 @@ const colors = [ { id: 9, color: [0, 166, 133, alpha] }, //news ]; - export default function customNametags() { - mp.nametags.enabled = false; mp.events.add('render', (nametags) => { @@ -67,19 +64,19 @@ export default function customNametags() { let y2 = y + 0.042; if (armour > 0) { - graphics.drawRect(x, y2, width + border * 2, height + border * 2, 0 , 0, 0, 200); - graphics.drawRect(x, y2, width, height, 150, 150, 150, 255); + graphics.drawRect(x, y2, width + border * 2, height + border * 2, 0, 0, 0, 200); + graphics.drawRect(x, y2, width, height, 50, 0, 0, 255); graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 200, 0, 0, 200); var x2 = x + width / 2 + border / 2; graphics.drawRect(x, y2 + height, width + border * 2, height + border * 2, 0, 0, 0, 200); - graphics.drawRect(x, y2 + height, width, height, 200, 200, 200, 255); + graphics.drawRect(x, y2 + height, width, height, 80, 80, 80, 255); graphics.drawRect(x - width / 2 * (1 - armour), y2 + height, width * armour, height, 255, 255, 255, 200); } else { graphics.drawRect(x, y2, width + border * 2, height + border * 2, 0, 0, 0, 200); - graphics.drawRect(x, y2, width, height, 150, 150, 150, 255); + graphics.drawRect(x, y2, width, height, 50, 0, 0, 255); graphics.drawRect(x - width / 2 * (1 - health), y2, width * health, height, 200, 0, 0, 200); } } diff --git a/ReallifeGamemode.Client/Player/keys.ts b/ReallifeGamemode.Client/Player/keys.ts index f4c11e13..1b9f4f92 100644 --- a/ReallifeGamemode.Client/Player/keys.ts +++ b/ReallifeGamemode.Client/Player/keys.ts @@ -6,11 +6,9 @@ //https://docs.microsoft.com/de-de/windows/desktop/inputdev/virtual-key-codes - const player = mp.players.local; export default function keys(globalData: IGlobalData) { - var showGui = true; //ENTER @@ -73,7 +71,6 @@ export default function keys(globalData: IGlobalData) { } }); - //I //Inventar mp.keys.bind(0x49, false, function () { if (!globalData.InChat && !globalData.InTuning) { @@ -83,9 +80,9 @@ export default function keys(globalData: IGlobalData) { //O //Spielerliste mp.keys.bind(0x4F, true, function () { - if (!globalData.InChat && !globalData.InTuning ) { + if (!globalData.InChat && !globalData.InTuning) { mp.events.callRemote("keyPress:O"); - //mp.events.call("showPlayerlist"); + //mp.events.call("showPlayerlist"); } }); @@ -113,7 +110,7 @@ export default function keys(globalData: IGlobalData) { //N //Motor Starten mp.keys.bind(0x4E, false, function () { if (!globalData.InChat) { - mp.events.callRemote("keyPress:N"); + mp.events.callRemote("keyPress:N"); } }); @@ -143,9 +140,16 @@ export default function keys(globalData: IGlobalData) { mp.gui.takeScreenshot(new Date().toLocaleDateString(), 1, 100, 80); }); + //H + mp.keys.bind(0x48, false, function () { + if (mp.keys.isDown(0x11)) { //CTRL + mp.events.call("keyPress:ControllH"); //hup + return; + } + }); + //F2 //Noclip mp.keys.bind(0x71, false, () => { - mp.events.callRemote("Noclip"); - + mp.events.callRemote("Noclip"); }); } \ No newline at end of file diff --git a/ReallifeGamemode.Client/util/animationSync.ts b/ReallifeGamemode.Client/util/animationSync.ts index c38d5052..6c435435 100644 --- a/ReallifeGamemode.Client/util/animationSync.ts +++ b/ReallifeGamemode.Client/util/animationSync.ts @@ -7,6 +7,8 @@ animationSyncData.register("getArrest", "mp_arrest_paired", "crook_p2_back_right", 3760, false, 0); animationSyncData.register("doUncuff", "mp_arresting", "a_uncuff", 5500, false, 0); animationSyncData.register("getUncuff", "mp_arresting", "b_uncuff", 5500, false, 0); + animationSyncData.register("hup", "mp_am_hold_up", "handsup_base", -1, true, 50); + animationSyncData.register("carryBox", "anim@heists@box_carry@", "idle", -1, true, 50); }); const animationSyncData = diff --git a/ReallifeGamemode.Server/Commands/UserCommands.cs b/ReallifeGamemode.Server/Commands/UserCommands.cs index 3804adc0..34a3312a 100644 --- a/ReallifeGamemode.Server/Commands/UserCommands.cs +++ b/ReallifeGamemode.Server/Commands/UserCommands.cs @@ -16,14 +16,12 @@ namespace ReallifeGamemode.Server.Commands { internal class UserCommands : Script { - [Command("skill")] public void CmdUserSkill(Player player) { User user = player.GetUser(new DatabaseContext()); player.SendChatMessage($"~c~BusSkill = {user.BusSkill}/800, PilotSkill = {user.PilotSkill}/300."); - } [Command("id", "~m~Benutzung: ~s~/id [Name]")] @@ -34,7 +32,8 @@ namespace ReallifeGamemode.Server.Commands if (target == null) { player.SendChatMessage("~c~Spieler ist nicht online."); - } else + } + else { player.SendChatMessage("~c~ID: (" + target.Id + ") " + target.Name); } @@ -90,6 +89,7 @@ namespace ReallifeGamemode.Server.Commands ChatService.SendMessage(player, "~m~" + ((VehicleHash)pVeh.Model) + " | Farbe 1: " + pVeh.PrimaryColor + " | Farbe 2: " + pVeh.SecondaryColor + " | ID: " + pVeh.Handle.Value); } } + [Command("help", "~m~Benutzung: ~s~/help")] public void CmdHelp(Player player) { @@ -106,8 +106,10 @@ namespace ReallifeGamemode.Server.Commands [Command("hup")] public void CmdAnim(Player player) { - player.StopAnimation(); - player.PlayAnimation("mp_am_hold_up", "handsup_base", (int)(AnimationFlags.Loop | AnimationFlags.OnlyAnimateUpperBody | AnimationFlags.AllowPlayerControl | AnimationFlags.Cancellable)); + if (player.HasAnimation()) + return; + + player.SyncAnimation("hup"); ChatService.SendInRange(player.Position, 20, $"~m~{player.Name} stellt sich..."); } @@ -119,9 +121,7 @@ namespace ReallifeGamemode.Server.Commands ChatService.NotAuthorized(player); return; } - ChatService.BroadcastFaction("~b~[Event] " + player.Name + ": " + msg, new List() { 9 }) ; - + ChatService.BroadcastFaction("~b~[Event] " + player.Name + ": " + msg, new List() { 9 }); } } } - diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index 6d74b0e9..6e2ca5b5 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -30,6 +30,7 @@ namespace ReallifeGamemode.Server.Events public class Key : Script { #region User Key + [RemoteEvent("keyPress:NUM2")] public void KeyPressNUM2(Player player) { @@ -60,6 +61,7 @@ namespace ReallifeGamemode.Server.Events GroundItem.PickUpGroundItem(player); } + /* [RemoteEvent("keyPress:LEFT_ARROW")] public void KeyPressLeftArrow(Player player) @@ -85,6 +87,7 @@ namespace ReallifeGamemode.Server.Events } } */ + [RemoteEvent("keyPress:RIGHT_ARROW")] public void KeyPressRightArrow(Player player) { @@ -115,7 +118,7 @@ namespace ReallifeGamemode.Server.Events { using var dbContext = new DatabaseContext(); User u = player.GetUser(dbContext); - if (u == null) return; + if (u == null) return; if (player.GetData("isDead")) return; var vehicles = dbContext.UserVehicles.Where(veh => veh.UserId == u.Id).OrderBy(veh => veh.Id).Select(v => new @@ -169,7 +172,7 @@ namespace ReallifeGamemode.Server.Events int pay_amount = 0; bool house = false; - if(u.House != null) + if (u.House != null) { house = true; } @@ -185,7 +188,6 @@ namespace ReallifeGamemode.Server.Events } player.TriggerEvent("SERVER:InteractionMenu_OpenMenu", JsonConvert.SerializeObject(accountData), factionleader, faction, group, factionInvite, groupInvite, ticket_boolean, ticket_amount, pay_amount, house); - } [RemoteEvent("keyPress:E")] @@ -194,16 +196,15 @@ namespace ReallifeGamemode.Server.Events if (!player.IsLoggedIn()) return; var user = player.GetUser(); - if (player.HasData("nearATM")) { ATMManager.ShowAtmUi(player, player.GetData("nearATM")); return; } - if(!player.IsInVehicle) + if (!player.IsInVehicle) { - if(GroundItem.PickUpGroundItem(player)) + if (GroundItem.PickUpGroundItem(player)) { return; } @@ -217,7 +218,7 @@ namespace ReallifeGamemode.Server.Events FriseurPoint nearestFriseurPoint = PositionManager.friseurPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData("duty"))); ItemshopPoint nearestItemShopPoint = PositionManager.itemshopPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5); JobPoint nearestJobPoint = PositionManager.JobPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.6); - + if (user?.FactionId != null) { BehindVehiclePoint nearestBehindVehiclePoint = MarkerBehinVehicle.behindVehiclePoints.Find(s => s.marker.Position.DistanceTo(player.Position) <= 3 && (user.FactionId == 8 || user.FactionId == 7 || user.FactionId == 1 || user.FactionId == 3)); @@ -229,7 +230,6 @@ namespace ReallifeGamemode.Server.Events List vehicleItems = dbContext.VehicleItems.ToList().Where(f => f.GetVehicle().GetVehicle() == nearestBehindVehiclePoint.vehicle && InventoryManager.GetItemById(f.ItemId) is IWeaponDealItem).ToList(); if (vehicleItems.Count == 0) { - GTANetworkAPI.Vehicle vehicle = nearestBehindVehiclePoint.vehicle; if (vehicle.HasAttachment("weapondeal")) @@ -367,7 +367,7 @@ namespace ReallifeGamemode.Server.Events if (player.HasAttachment("ammobox")) { player.AddAttachment("ammobox", true); - player.StopAnimation(); + player.ClearAnimation(); } bool unloadedWeaponPackage = false; @@ -430,13 +430,12 @@ namespace ReallifeGamemode.Server.Events if (user.FactionRank.Order >= weapon.Rank) specials.Add(weapon.WeaponModel.ToString()); break; + case 5: if (user.FactionRank.Order >= weapon.Rank) armor.Add(weapon.WeaponModel.ToString()); break; - } - } foreach (var weapon in weapons) { @@ -496,7 +495,7 @@ namespace ReallifeGamemode.Server.Events foreach (Player target in NAPI.Pools.GetAllPlayers()) { User c = target.GetUser(); - if(c == null) + if (c == null) { continue; } @@ -556,7 +555,7 @@ namespace ReallifeGamemode.Server.Events player.TriggerEvent("renderTextOnScreen", "Steige nun in eines der Fahrzeuge und starte den Motor mit der Taste 'N'."); return; } - } + } else if (nearestJobPoint.jobId == 3 && player.GetUser().JobId == 3) { if (nearestJobPoint.Skill < 300 && player.GetUser().PilotSkill >= 0) @@ -679,7 +678,6 @@ namespace ReallifeGamemode.Server.Events player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json); } - [RemoteEvent("keyPress:O")] public void KeyPressO(Player player) { @@ -688,13 +686,13 @@ namespace ReallifeGamemode.Server.Events List players = NAPI.Pools.GetAllPlayers().Where(p => p.IsLoggedIn() == true).OrderBy(o => o.Handle.Value).ToList(); var listPlayers = players.Select(p => new - { - Id = p.Handle.Value, - p.Name, - p.Ping, - FactionName = p.GetUser()?.Faction?.Name ?? "Zivilist", - }); - player.TriggerEvent("showPlayerlist", JsonConvert.SerializeObject(listPlayers)); + { + Id = p.Handle.Value, + p.Name, + p.Ping, + FactionName = p.GetUser()?.Faction?.Name ?? "Zivilist", + }); + player.TriggerEvent("showPlayerlist", JsonConvert.SerializeObject(listPlayers)); } [RemoteEvent("keyPress:K")] @@ -801,9 +799,9 @@ namespace ReallifeGamemode.Server.Events } else if (sV is FactionVehicle fV) { - if(fV.Model == VehicleHash.Burrito3 && u.FactionId == 1 - || fV.Model == VehicleHash.Burrito3 && u.FactionId == 3 - || fV.Model == VehicleHash.Burrito3 && u.FactionId == 7 + if (fV.Model == VehicleHash.Burrito3 && u.FactionId == 1 + || fV.Model == VehicleHash.Burrito3 && u.FactionId == 3 + || fV.Model == VehicleHash.Burrito3 && u.FactionId == 7 || fV.Model == VehicleHash.Burrito3 && u.FactionId == 8 || fV.Model == VehicleHash.Policet && u.FactionId == 1 || fV.Model == VehicleHash.Policet && u.FactionId == 3 @@ -967,8 +965,17 @@ namespace ReallifeGamemode.Server.Events player.TriggerEvent("ToggleVehicleMenu"); } } - #endregion - #region Faction Key - #endregion + + [RemoteEvent("keyPress:ControllH")] + public void KeyPressControllH(Player player) + { + if (player.HasAnimation()) + return; + + player.SyncAnimation("hup"); + ChatService.SendInRange(player.Position, 20, $"~m~{player.Name} stellt sich..."); + } + + #endregion User Key } } diff --git a/ReallifeGamemode.Server/Inventory/GroundItem.cs b/ReallifeGamemode.Server/Inventory/GroundItem.cs index 4c6ca743..0f059a5f 100644 --- a/ReallifeGamemode.Server/Inventory/GroundItem.cs +++ b/ReallifeGamemode.Server/Inventory/GroundItem.cs @@ -6,6 +6,7 @@ using ReallifeGamemode.Database.Models; using ReallifeGamemode.Server.Extensions; using ReallifeGamemode.Server.Inventory.Interfaces; using ReallifeGamemode.Server.Managers; +using ReallifeGamemode.Server.Util; namespace ReallifeGamemode.Server.Inventory { @@ -99,9 +100,9 @@ namespace ReallifeGamemode.Server.Inventory } if (nearestItem is IWeaponDealItem obj) { - if (!player.HasAttachment("ammobox")) + if (!player.HasAttachment("ammobox") && !player.HasAnimation()) { - player.PlayAnimation("anim@heists@box_carry@", "idle", 49); + player.SyncAnimation("carryBox"); player.AddAttachment("ammobox", false); NAPI.Player.SetPlayerCurrentWeapon(player, WeaponHash.Unarmed); } diff --git a/ReallifeGamemode.Server/Managers/PositionManager.cs b/ReallifeGamemode.Server/Managers/PositionManager.cs index ab097f63..ebe2b755 100644 --- a/ReallifeGamemode.Server/Managers/PositionManager.cs +++ b/ReallifeGamemode.Server/Managers/PositionManager.cs @@ -4,6 +4,7 @@ using GTANetworkAPI; using ReallifeGamemode.Server.Shop.Clothing; using ReallifeGamemode.Server.Shop.SevenEleven; using ReallifeGamemode.Server.Shop.Friseur; +using ReallifeGamemode.Server.Util; namespace ReallifeGamemode.Server.Managers { @@ -18,8 +19,8 @@ namespace ReallifeGamemode.Server.Managers public static List ElevatorPoints = new List(); public static List clotheshopPoints = new List(); - - public static List friseurPoints = new List(); + + public static List friseurPoints = new List(); public static List itemshopPoints = new List(); @@ -213,6 +214,7 @@ namespace ReallifeGamemode.Server.Managers NAPI.Blip.CreateBlip(513, p.Position, 1f, 16, "Busfahrer", 255, 0, true); } } + #endregion JobPoints #region Shops @@ -285,7 +287,6 @@ namespace ReallifeGamemode.Server.Managers return; } - player.Position = ElevatorPoints.Where(e => e.Stage == level).First().Position; } } @@ -347,7 +348,7 @@ public class BehindVehiclePoint { if (!player.HasAttachment("ammobox")) { - player.PlayAnimation("anim@heists@box_carry@", "idle", 49); + player.SyncAnimation("carryBox"); player.AddAttachment("ammobox", false); NAPI.Player.SetPlayerCurrentWeapon(player, WeaponHash.Unarmed); } @@ -389,7 +390,6 @@ public class JobPoint public Vector3 Position { get; set; } public int jobId { get; set; } public int Skill { get; set; } - } public class ElevatorPoint diff --git a/ReallifeGamemode.Server/Util/AnimationSync.cs b/ReallifeGamemode.Server/Util/AnimationSync.cs index 0f1e5dd3..7903c127 100644 --- a/ReallifeGamemode.Server/Util/AnimationSync.cs +++ b/ReallifeGamemode.Server/Util/AnimationSync.cs @@ -30,8 +30,6 @@ namespace ReallifeGamemode.Server.Util { string animationName = animations.ElementAt(0); List nextAnimations = animations.Skip(1).ToList(); - nextAnimations.ForEach(s => player.SendChatMessage(s)); - player.SyncAnimation(animationName); if (nextAnimations.Count != 0) diff --git a/ReallifeGamemode.Server/Util/AttachmentSync.cs b/ReallifeGamemode.Server/Util/AttachmentSync.cs index ba9322ea..04e1db94 100644 --- a/ReallifeGamemode.Server/Util/AttachmentSync.cs +++ b/ReallifeGamemode.Server/Util/AttachmentSync.cs @@ -142,13 +142,13 @@ public class AttachmentSyncExample : Script if (!player.HasAttachment("ammobox")) { player.AddAttachment("ammobox", false); - player.PlayAnimation("anim@heists@box_carry@", "idle", 49); + //player.SyncAnimation("carryBox"); //veh.AddAttachment("weapondeal1", false); //veh.AddAttachment("weapondeal2", false); } else { - player.StopAnimation(); + player.ClearAnimation(); player.ClearAttachments(); }