diff --git a/ReallifeGamemode.Client/Interaction/interactionmenu.ts b/ReallifeGamemode.Client/Interaction/interactionmenu.ts index 01ecc976..683e0030 100644 --- a/ReallifeGamemode.Client/Interaction/interactionmenu.ts +++ b/ReallifeGamemode.Client/Interaction/interactionmenu.ts @@ -10,12 +10,16 @@ const Point = NativeUI.Point; const ItemsCollection = NativeUI.ItemsCollection; const Color = NativeUI.Color; +import { getStreetName, getZoneName } from '../streetnames'; + export default function (globalData: GlobalData) { var menuClose = false; var accountItem = new UIMenuItem("Account", "Account Informationen"); + var serviceItem = new UIMenuItem("Service rufen", "Rufe einen Dienstleister an"); + var factionItem = new UIMenuItem("Fraktion", "Verwalte deine Fraktion"); var groupItem = new UIMenuItem("Gruppe", "Verwalte deine Gruppe"); @@ -25,6 +29,10 @@ export default function (globalData: GlobalData) { var menu = getInteractionMenu(); + var serviceMenu = getServicesMenu(menu); + menu.AddItem(serviceItem); + menu.BindMenuToItem(serviceMenu, serviceItem); + menu.AddItem(accountItem); menu.BindMenuToItem(getAccountMenu(accountData), accountItem); @@ -82,6 +90,10 @@ export default function (globalData: GlobalData) { menuItem.SetRightLabel(data.factionRank); accountMenu.AddItem(menuItem); + menuItem = new UIMenuItem("Job"); + menuItem.SetRightLabel(data.job); + accountMenu.AddItem(menuItem); + menuItem = new UIMenuItem("Gruppe"); menuItem.SetRightLabel(data.group); accountMenu.AddItem(menuItem); @@ -155,4 +167,20 @@ export default function (globalData: GlobalData) { return groupMenu; } + + function getServicesMenu(parentMenu: NativeUI.Menu): NativeUI.Menu { + var servicesMenu = new Menu("Services", "Rufe einen Service", new Point(50, 50), null, null); + servicesMenu.AddItem(new UIMenuItem("Taxi rufen", "Rufe ein Taxu zu deiner Position")); + + servicesMenu.Visible = false; + + servicesMenu.ItemSelect.on((item, index) => { + if (index === 0) { // Taxi + mp.events.callRemote("CLIENT:InteractionMenu_CallService_Taxi", getStreetName(), getZoneName()); + } + parentMenu.Close(); + }); + + return servicesMenu; + } } \ No newline at end of file diff --git a/ReallifeGamemode.Client/global.d.ts b/ReallifeGamemode.Client/global.d.ts index b704cefa..9c3e391d 100644 --- a/ReallifeGamemode.Client/global.d.ts +++ b/ReallifeGamemode.Client/global.d.ts @@ -14,6 +14,7 @@ declare interface AccountData { factionRank: string; group: string; groupRank: string; + job: string; } declare interface FactionRanks { diff --git a/ReallifeGamemode.Client/streetnames/index.ts b/ReallifeGamemode.Client/streetnames/index.ts new file mode 100644 index 00000000..223e2eb1 --- /dev/null +++ b/ReallifeGamemode.Client/streetnames/index.ts @@ -0,0 +1,21 @@ +let zoneNamesShort = ["AIRP", "ALAMO", "ALTA", "ARMYB", "BANHAMC", "BANNING", "BEACH", "BHAMCA", "BRADP", "BRADT", "BURTON", "CALAFB", "CANNY", "CCREAK", "CHAMH", "CHIL", "CHU", "CMSW", "CYPRE", "DAVIS", "DELBE", "DELPE", "DELSOL", "DESRT", "DOWNT", "DTVINE", "EAST_V", "EBURO", "ELGORL", "ELYSIAN", "GALFISH", "GOLF", "GRAPES", "GREATC", "HARMO", "HAWICK", "HORS", "HUMLAB", "JAIL", "KOREAT", "LACT", "LAGO", "LDAM", "LEGSQU", "LMESA", "LOSPUER", "MIRR", "MORN", "MOVIE", "MTCHIL", "MTGORDO", "MTJOSE", "MURRI", "NCHU", "NOOSE", "OCEANA", "PALCOV", "PALETO", "PALFOR", "PALHIGH", "PALMPOW", "PBLUFF", "PBOX", "PROCOB", "RANCHO", "RGLEN", "RICHM", "ROCKF", "RTRAK", "SANAND", "SANCHIA", "SANDY", "SKID", "SLAB", "STAD", "STRAW", "TATAMO", "TERMINA", "TEXTI", "TONGVAH", "TONGVAV", "VCANA", "VESP", "VINE", "WINDF", "WVINE", "ZANCUDO", "ZP_ORT", "ZQ_UAR"]; + +let zoneNames = ["Los Santos International Airport", "Alamo Sea", "Alta", "Fort Zancudo", "Banham Canyon Dr", "Banning", "Vespucci Beach", "Banham Canyon", "Braddock Pass", "Braddock Tunnel", "Burton", "Calafia Bridge", "Raton Canyon", "Cassidy Creek", "Chamberlain Hills", "Vinewood Hills", "Chumash", "Chiliad Mountain State Wilderness", "Cypress Flats", "Davis", "Del Perro Beach", "Del Perro", "La Puerta", "Grand Senora Desert", "Downtown", "Downtown Vinewood", "East Vinewood", "El Burro Heights", "El Gordo Lighthouse", "Elysian Island", "Galilee", "GWC and Golfing Society", "Grapeseed", "Great Chaparral", "Harmony", "Hawick", "Vinewood Racetrack", "Humane Labs and Research", "Bolingbroke Penitentiary", "Little Seoul", "Land Act Reservoir", "Lago Zancudo", "Land Act Dam", "Legion Square", "La Mesa", "La Puerta", "Mirror Park", "Morningwood", "Richards Majestic", "Mount Chiliad", "Mount Gordo", "Mount Josiah", "Murrieta Heights", "North Chumash", "N.O.O.S.E", "Pacific Ocean", "Paleto Cove", "Paleto Bay", "Paleto Forest", "Palomino Highlands", "Palmer-Taylor Power Station", "Pacific Bluffs", "Pillbox Hill", "Procopio Beach", "Rancho", "Richman Glen", "Richman", "Rockford Hills", "Redwood Lights Track", "San Andreas", "San Chianski Mountain Range", "Sandy Shores", "Mission Row", "Stab City", "Maze Bank Arena", "Strawberry", "Tataviam Mountains", "Terminal", "Textile City", "Tongva Hills", "Tongva Valley", "Vespucci Canals", "Vespucci", "Vinewood", "Ron Alternates Wind Farm", "West Vinewood", "Zancudo River", "Port of South Los Santos", "Davis Quartz"]; + +export function getStreetName(): string { + var pos: Vector3Mp = mp.players.local.position; + var streetId: number = mp.game.pathfind.getStreetNameAtCoord(pos.x, pos.y, pos.z, 0, 0).streetName; + return mp.game.ui.getStreetNameFromHashKey(streetId); +} + +export function getZoneName(): string { + let position = mp.players.local.position; + let zoneName = mp.game.zone.getNameOfZone(position.x, position.y, position.z); + + if (zoneNamesShort.includes(zoneName)) { + let zoneID = zoneNamesShort.indexOf(zoneName); + return zoneNames[zoneID]; + } + + return undefined; +} \ No newline at end of file diff --git a/ReallifeGamemode.Server/Commands/AdminCommands.cs b/ReallifeGamemode.Server/Commands/AdminCommands.cs index 10d6cbff..78264765 100644 --- a/ReallifeGamemode.Server/Commands/AdminCommands.cs +++ b/ReallifeGamemode.Server/Commands/AdminCommands.cs @@ -93,7 +93,7 @@ namespace ReallifeGamemode.Server.Commands } using (var getFaction = new DatabaseContext()) { - Entities.Faction receiverUser = getFaction.Factions.FirstOrDefault(u => u.Name == receiver); + Faction receiverUser = getFaction.Factions.FirstOrDefault(u => u.Name == receiver); if (receiverUser == null) { diff --git a/ReallifeGamemode.Server/Events/Key.cs b/ReallifeGamemode.Server/Events/Key.cs index d860c575..6695c63f 100644 --- a/ReallifeGamemode.Server/Events/Key.cs +++ b/ReallifeGamemode.Server/Events/Key.cs @@ -111,7 +111,8 @@ namespace ReallifeGamemode.Server.Events faction = u.Faction?.Name ?? "Zivilist", factionRank = u.GetFactionRank().RankName, group = u.Group?.Name ?? "Keine", - groupRank = u.GroupRank.GetName() + groupRank = u.GroupRank.GetName(), + job = JobManager.GetJob(u.JobId ?? 0)?.Name ?? "Keiner" }; string faction = u.FactionLeader ? u.Faction.Name : null; diff --git a/ReallifeGamemode.Server/Managers/InteractionManager.cs b/ReallifeGamemode.Server/Managers/InteractionManager.cs index 5d6446be..c3ea1291 100644 --- a/ReallifeGamemode.Server/Managers/InteractionManager.cs +++ b/ReallifeGamemode.Server/Managers/InteractionManager.cs @@ -2,6 +2,7 @@ using Newtonsoft.Json; using ReallifeGamemode.Server.Entities; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Job; using ReallifeGamemode.Server.Models; using ReallifeGamemode.Server.Services; using ReallifeGamemode.Server.Util; @@ -246,6 +247,13 @@ namespace ReallifeGamemode.Server.Managers } } } + + [RemoteEvent("CLIENT:InteractionMenu_CallService_Taxi")] + public void CallServiceTaxi(Client player, string street, string zone) + { + string msg = $"!{{02FCFF}}{player.Name} hat in der {street} in {zone} ein Taxi gerufen."; + ChatService.BroadcastJob(msg, JobManager.GetJob()); + } #endregion #region Spielerinteraktionen PFEILTASTE-LINKS [RemoteEvent("openTradeInventory")] diff --git a/ReallifeGamemode.Server/Services/ChatService.cs b/ReallifeGamemode.Server/Services/ChatService.cs index bcc4cb8f..aa23a796 100644 --- a/ReallifeGamemode.Server/Services/ChatService.cs +++ b/ReallifeGamemode.Server/Services/ChatService.cs @@ -1,6 +1,7 @@ using GTANetworkAPI; using ReallifeGamemode.Server.Entities; using ReallifeGamemode.Server.Extensions; +using ReallifeGamemode.Server.Job; using ReallifeGamemode.Server.Util; using System.Collections.Generic; @@ -88,5 +89,10 @@ namespace ReallifeGamemode.Server.Services } }); } + + public static void BroadcastJob(string message, JobBase job) + { + job.GetUsersInJob().ForEach(c => c.SendChatMessage(message)); + } } }