add job menu and start job
This commit is contained in:
25
ReallifeGamemode.Client/Jobs/main.ts
Normal file
25
ReallifeGamemode.Client/Jobs/main.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import * as NativeUI from 'NativeUI';
|
||||||
|
|
||||||
|
export default function (globalData: GlobalData) {
|
||||||
|
|
||||||
|
mp.events.add("SERVER:Job_ShowJobMenu", (jobName: string) => {
|
||||||
|
if (globalData.InMenu) return;
|
||||||
|
|
||||||
|
var menu = new NativeUI.Menu("Job", jobName, new NativeUI.Point(50, 50), null, null);
|
||||||
|
menu.AddItem(new NativeUI.UIMenuItem("Job starten"));
|
||||||
|
|
||||||
|
globalData.InMenu = true;
|
||||||
|
|
||||||
|
menu.ItemSelect.on((item: NativeUI.UIMenuItem, index: number) => {
|
||||||
|
if (index === 0) { // Job starten
|
||||||
|
mp.events.callRemote("CLIENT:Job_StartJob");
|
||||||
|
}
|
||||||
|
menu.Close();
|
||||||
|
});
|
||||||
|
|
||||||
|
menu.MenuClose.on(() => {
|
||||||
|
globalData.InMenu = false;
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
@@ -132,10 +132,17 @@ export default function keys(globalData: GlobalData) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
//X //Anschnallen
|
//X // Fahrzeug Verwaltung - Menü
|
||||||
mp.keys.bind(0x58, false, function () {
|
mp.keys.bind(0x58, false, function () {
|
||||||
if (!globalData.InChat) {
|
if (!globalData.InChat) {
|
||||||
mp.events.callRemote("keyPress:X");
|
mp.events.callRemote("keyPress:X");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//2 // Job Starten
|
||||||
|
mp.keys.bind(0x32, false, () => {
|
||||||
|
if (!globalData.InChat && !globalData.InInput && !globalData.InMenu && globalData.LoggedIn) {
|
||||||
|
mp.events.callRemote("CLIENT:JobManager_ShowJobMenu");
|
||||||
|
}
|
||||||
|
})
|
||||||
}
|
}
|
||||||
@@ -7,12 +7,25 @@
|
|||||||
let globalData: GlobalData = {
|
let globalData: GlobalData = {
|
||||||
InTuning: false,
|
InTuning: false,
|
||||||
HideGui: false,
|
HideGui: false,
|
||||||
InMenu: false,
|
|
||||||
InChat: false,
|
InChat: false,
|
||||||
LoggedIn: false,
|
LoggedIn: false,
|
||||||
InInput: false
|
InInput: false,
|
||||||
|
|
||||||
|
get InMenu(): boolean {
|
||||||
|
return inMenu;
|
||||||
|
},
|
||||||
|
set InMenu(value: boolean) {
|
||||||
|
inMenu = value;
|
||||||
|
|
||||||
|
mp.gui.chat.show(!value);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
var inMenu = false;
|
||||||
|
|
||||||
|
import jobMain from './Jobs/main';
|
||||||
|
jobMain(globalData);
|
||||||
|
|
||||||
import cityHall from './Gui/cityhall';
|
import cityHall from './Gui/cityhall';
|
||||||
cityHall(globalData);
|
cityHall(globalData);
|
||||||
|
|
||||||
|
|||||||
@@ -300,6 +300,7 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ALevel1
|
#region ALevel1
|
||||||
[Command("a", "~m~Benutzung: ~s~/a [Nachricht]", GreedyArg = true)]
|
[Command("a", "~m~Benutzung: ~s~/a [Nachricht]", GreedyArg = true)]
|
||||||
public void CmdAdminA(Client player, string message)
|
public void CmdAdminA(Client player, string message)
|
||||||
@@ -1050,8 +1051,6 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WeaponHash weaponHash = (WeaponHash)uHash;
|
|
||||||
|
|
||||||
target.GiveWeapon((WeaponHash)uHash, ammo);
|
target.GiveWeapon((WeaponHash)uHash, ammo);
|
||||||
target.SendChatMessage("~b~Du hast von " + player.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " erhalten.");
|
target.SendChatMessage("~b~Du hast von " + player.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " erhalten.");
|
||||||
player.SendChatMessage("~b~Du hast " + target.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " gegeben.");
|
player.SendChatMessage("~b~Du hast " + target.Name + " eine/n " + hash + " mit einer Munition von " + ammo + " gegeben.");
|
||||||
@@ -2394,10 +2393,9 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
DoorManager.ReloadDoors();
|
DoorManager.ReloadDoors();
|
||||||
player.SendChatMessage("~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
|
player.SendChatMessage("~b~[ADMIN]~s~ Die Türen wurden erfolgreich neugeladen.");
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
#region ALevel1338
|
|
||||||
|
|
||||||
|
#region ALevel1338
|
||||||
[Command("whitelist", "~m~Benutzung: ~s~/whitelist [Add / Remove] [Socialclub Name]")]
|
[Command("whitelist", "~m~Benutzung: ~s~/whitelist [Add / Remove] [Socialclub Name]")]
|
||||||
public void CmdAdminWhitelist(Client player, string option, string scName)
|
public void CmdAdminWhitelist(Client player, string option, string scName)
|
||||||
{
|
{
|
||||||
@@ -2478,8 +2476,6 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
player.SendChatMessage("Du hast " + target.Name + " auf Adminlevel " + target.GetUser().AdminLevel.GetName() + ":(" + rank + ") gesetzt.");
|
player.SendChatMessage("Du hast " + target.Name + " auf Adminlevel " + target.GetUser().AdminLevel.GetName() + ":(" + rank + ") gesetzt.");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
16
ReallifeGamemode.Server/Extensions/ListExtensions.cs
Normal file
16
ReallifeGamemode.Server/Extensions/ListExtensions.cs
Normal file
@@ -0,0 +1,16 @@
|
|||||||
|
using GTANetworkAPI;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
|
||||||
|
namespace ReallifeGamemode.Server.Extensions
|
||||||
|
{
|
||||||
|
static class ListExtensions
|
||||||
|
{
|
||||||
|
public static bool Contains(this List<Client> list, Client client)
|
||||||
|
{
|
||||||
|
return list.Any(l => l.Handle.Value == client.Handle.Value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,6 +1,8 @@
|
|||||||
using GTANetworkAPI;
|
using GTANetworkAPI;
|
||||||
using ReallifeGamemode.Server.Entities;
|
using ReallifeGamemode.Server.Entities;
|
||||||
|
using ReallifeGamemode.Server.Managers;
|
||||||
using ReallifeGamemode.Server.Models;
|
using ReallifeGamemode.Server.Models;
|
||||||
|
using ReallifeGamemode.Server.Services;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -22,21 +24,31 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
|
|
||||||
public abstract string Name { get; }
|
public abstract string Name { get; }
|
||||||
|
|
||||||
|
public abstract bool NeedVehicleToStart { get; }
|
||||||
|
|
||||||
public void StartJob(Client player)
|
public void StartJob(Client player)
|
||||||
{
|
{
|
||||||
_inJob.Add(player);
|
_inJob.Add(player);
|
||||||
JobStart();
|
|
||||||
|
if (NeedVehicleToStart && !GetJobVehicles().Any(v => VehicleManager.GetVehicleFromServerVehicle(v).Handle.Value == player.Vehicle?.Handle.Value))
|
||||||
|
{
|
||||||
|
ChatService.Error(player, "Zum Start dieses Jobs musst du in einem Jobfahrzeug sein");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JobStart?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StopJob(Client player)
|
public void StopJob(Client player)
|
||||||
{
|
{
|
||||||
_inJob.Remove(player);
|
_inJob.Remove(player);
|
||||||
JobStop();
|
|
||||||
|
JobStop?.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<JobVehicle> GetJobVehicles()
|
public List<JobVehicle> GetJobVehicles()
|
||||||
{
|
{
|
||||||
using(var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
|
return dbContext.JobVehicles.Where(j => j.JobId == Id).ToList();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,7 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
public override int Id => 3;
|
public override int Id => 3;
|
||||||
|
|
||||||
public override string Name => "Pilot";
|
public override string Name => "Pilot";
|
||||||
|
|
||||||
|
public override bool NeedVehicleToStart => true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,5 +9,7 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
public override int Id => 2;
|
public override int Id => 2;
|
||||||
|
|
||||||
public override string Name => "Müllmann";
|
public override string Name => "Müllmann";
|
||||||
|
|
||||||
|
public override bool NeedVehicleToStart => true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,5 +10,7 @@ namespace ReallifeGamemode.Server.Job
|
|||||||
public override int Id => 1;
|
public override int Id => 1;
|
||||||
|
|
||||||
public override string Name => "Taxifahrer";
|
public override string Name => "Taxifahrer";
|
||||||
|
|
||||||
|
public override bool NeedVehicleToStart => true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -96,5 +96,35 @@ namespace ReallifeGamemode.Server.Managers
|
|||||||
dbContext.SaveChanges();
|
dbContext.SaveChanges();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:JobManager_ShowJobMenu")]
|
||||||
|
public void ShowJobMenuEvent(Client player)
|
||||||
|
{
|
||||||
|
User u = player.GetUser();
|
||||||
|
|
||||||
|
if (u.JobId == null) return;
|
||||||
|
|
||||||
|
JobBase job = GetJob(u.JobId.Value);
|
||||||
|
|
||||||
|
player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("CLIENT:Job_StartJob")]
|
||||||
|
public void StartJobEvent(Client player)
|
||||||
|
{
|
||||||
|
User u = player.GetUser();
|
||||||
|
|
||||||
|
if (u.JobId == null) return;
|
||||||
|
|
||||||
|
JobBase job = GetJob(u.JobId.Value);
|
||||||
|
|
||||||
|
if(job.GetUsersInJob().Contains(player))
|
||||||
|
{
|
||||||
|
ChatService.Error(player, "Du bist schon in deinem Job aktiv");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
job.StartJob(player);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user