Merge branch 'develop' of ssh://development.life-of-german.org:451/log-gtav/reallife-gamemode into develop

This commit is contained in:
2021-04-05 17:28:56 +02:00
8 changed files with 146 additions and 101 deletions

View File

@@ -113,9 +113,7 @@ export default function keys(globalData: IGlobalData) {
//N //Motor Starten
mp.keys.bind(0x4E, false, function () {
if (!globalData.InChat) {
if (!player.vehicle) return;
if (player.vehicle.getSpeed() > 5) return;
mp.events.callRemote("keyPress:N");
mp.events.callRemote("keyPress:N", player.vehicle.getSpeed());
}
});
@@ -136,7 +134,8 @@ export default function keys(globalData: IGlobalData) {
//J // Job Starten
mp.keys.bind(0x4A, false, () => {
if (!globalData.InChat && globalData.LoggedIn && !globalData.InTuning) {
mp.events.callRemote("CLIENT:JobManager_ShowJobMenu");
//mp.events.callRemote("CLIENT:JobManager_ShowJobMenu");
mp.events.callRemote("keyPress:J");
}
});

View File

@@ -277,7 +277,7 @@ namespace ReallifeGamemode.Server.Commands
public void CmdAdminTSupport(Player player)
{
User user = player.GetUser();
if (user.IsAdmin(AdminLevel.SUPPORTER))
if (!user.IsAdmin(AdminLevel.SUPPORTER))
{
ChatService.NotAuthorized(player);
return;

View File

@@ -347,7 +347,7 @@ namespace ReallifeGamemode.Server.Commands
}
[Command("heal", "~m~Benutzung: ~s~/heal [Spieler] (Preis)")] //TODO Eventuell noch mit Geldbetrag wie bei SA:MP
public void CmdFactionMedicHealive(Player player, string receiver, int price = 100)
public void CmdFactionMedicHealive(Player player, string receiver, int price = 10)
{
Player target = PlayerService.GetPlayerByNameOrId(receiver);
if (player.GetUser()?.FactionId != 2)
@@ -391,28 +391,10 @@ namespace ReallifeGamemode.Server.Commands
return;
}
using var dbContext = new DatabaseContext();
User targetUser = target.GetUser(dbContext);
if (targetUser.Handmoney >= price)
{
targetUser.Handmoney -= price;
}
else
{
int bankMoney = price - targetUser.Handmoney;
targetUser.Handmoney = 0;
targetUser.BankAccount.Balance -= bankMoney;
}
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += price;
dbContext.SaveChanges();
target.Health = 100;
target.SendNotification($"Du wurdest von ~g~{player.Name} ~s~ für ~g~{price.ToMoneyString()} geheilt.", false);
player.SendNotification($"Du hast ~g~{target.Name} ~s~ für {price.ToMoneyString()} geheilt.", false);
player.TriggerEvent("delHealTask");
ChatService.SendMessage(target,"~g~" + player.Name + " ~s~möchte dich für ~g~$" + price + " ~s~heilen. Drücke ~g~J~s~ zum Erlauben oder ~r~N ~s~zum Verbieten");
player.SendNotification("Du hast " + target.Name + " einen Heal angeboten",false);
target.SetData<bool>("healDecision", true);
Medic.HealDecisions.Add(new Medic.HealDecision {dMedic = player, dTarget = target, dPrice = price});
}
#endregion Sanitäter Commands

View File

@@ -1,4 +1,5 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using GTANetworkAPI;
using Newtonsoft.Json;
@@ -11,6 +12,7 @@ using ReallifeGamemode.Server.Factions.Medic;
using ReallifeGamemode.Server.Finance;
using ReallifeGamemode.Server.Inventory;
using ReallifeGamemode.Server.Inventory.Interfaces;
using ReallifeGamemode.Server.Job;
using ReallifeGamemode.Server.Managers;
using ReallifeGamemode.Server.Services;
using ReallifeGamemode.Server.Types;
@@ -214,7 +216,7 @@ namespace ReallifeGamemode.Server.Events
FriseurPoint nearestFriseurPoint = PositionManager.friseurPoints.Find(s => s.Position.DistanceTo(player.Position) <= 1.5 && (!user.GetData<bool>("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));
@@ -609,6 +611,71 @@ namespace ReallifeGamemode.Server.Events
InventoryManager.SetBackpackItems(player);
}
[RemoteEvent("keyPress:J")]
public void KeyPressJ(Player player)
{
if (!player.IsLoggedIn()) return;
if (player.GetData<bool>("healDecision") == true)
{
player.SetData<bool>("healDecision", false);
Medic.MakeHealDecision(player, true);
}
User u = player.GetUser();
if (u.JobId == null) return;
JobBase job = JobManager.GetJob(u.JobId.Value);
dynamic data = null;
if (job.Id == 1 && job.GetUsersInJob().Contains(player))
{
var taxiCalls = JobManager.GetJob<TaxiDriverJob>().TaxiContracts;
if (!taxiCalls.Any(t => t.Driver?.Handle == player.Handle)) // Spieler in keiner aktiven Fahrt
{
data = new
{
job.Id,
Status = 0,
JobData = new
{
TaxiCalls = taxiCalls
.Where(t => t.Driver == null)
.Select(t => new
{
t.Name,
Distance = Math.Round(t.Position.DistanceTo(player.Position), 0)
})
.OrderBy(t => t.Distance)
}
};
}
else // Spieler in aktiver Fahrt
{
data = new
{
job.Id,
Status = 1,
JobData = new
{
taxiCalls.Where(t => t.Driver.Handle == player.Handle).First().Name
}
};
}
}
//JobPoint nearJobPoint = PositionManager.JobPoints.Find(p => p.Position.DistanceTo(player.Position) <= 2);
if (u.JobId == 2 || u.JobId == 3 || u.JobId == 4)
{
return;
}
var json = JsonConvert.SerializeObject(data);
player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json);
}
[RemoteEvent("keyPress:O")]
public void KeyPressO(Player player)
{
@@ -693,12 +760,19 @@ namespace ReallifeGamemode.Server.Events
}
[RemoteEvent("keyPress:N")]
public void KeyPressN(Player player)
public void KeyPressN(Player player, int vSpeed)
{
if (!player.IsLoggedIn()) return;
if (player.GetData<bool>("healDecision") == true)
{
player.SetData<bool>("healDecision", false);
Medic.MakeHealDecision(player, false);
}
if (!player.IsInVehicle) return;
if (player.VehicleSeat != 0) return;
if (vSpeed > 5) return;
GTANetworkAPI.Vehicle v = player.Vehicle;

View File

@@ -266,9 +266,13 @@ namespace ReallifeGamemode.Server.Extensions
nameTagColor = -1;
blipColor = 64;
}
else if (user.Faction != null)
else if (user.FactionId != null)
{
nameTagColor = user.FactionId.Value;
if(user.FactionId > 3 || (user.FactionId >= 1 && user.FactionId <= 3 && duty))
{
nameTagColor = user.FactionId.Value;
}
switch (user.FactionId)
{
case 1 when duty:
@@ -307,8 +311,6 @@ namespace ReallifeGamemode.Server.Extensions
}
}
NAPI.Util.ConsoleOutput($"{player.Name} - Setting blip and nametag color: nametag = {nameTagColor}, blip = {blipColor}");
user.Player.SetSharedData("nameTagColor", nameTagColor);
user.Player.SetSharedData("blipColor", blipColor);
}

View File

@@ -8,6 +8,7 @@ using ReallifeGamemode.Database.Entities;
using ReallifeGamemode.Database.Models;
using Microsoft.EntityFrameworkCore;
using System;
using ReallifeGamemode.Server.Extensions;
/**
* @overview Life of German Reallife - Server Factions Medic Medic.cs
@@ -22,10 +23,18 @@ namespace ReallifeGamemode.Server.Factions.Medic
public static List<MedicTask> ReviveTasks = new List<MedicTask>();
public static List<MedicTask> HealTasks = new List<MedicTask>();
public static List<MedicTask> FireTasks = new List<MedicTask>();
public static List<HealDecision> HealDecisions = new List<HealDecision>();
public static int ReviveIncome = 100;
public static int dutyMedics = 0;
public static int reviveTaskTime = 240;
public class HealDecision
{
public Player dMedic;
public Player dTarget;
public int dPrice;
}
public static void AddTaskToList(MedicTask task)
{
if (task == null)
@@ -72,6 +81,45 @@ namespace ReallifeGamemode.Server.Factions.Medic
}
}
public static void MakeHealDecision(Player target, bool decision)
{
var activeDecision = HealDecisions.FirstOrDefault(d => d.dTarget == target);
if(decision == false)
{
activeDecision.dMedic.SendNotification(activeDecision.dTarget.Name + " hat den Heal ~r~abgelehnt",false);
return;
}
else
{
activeDecision.dMedic.SendNotification(activeDecision.dTarget.Name + " hat den Heal ~g~akzeptiert", false);
using var dbContext = new DatabaseContext();
{
User targetUser = target.GetUser(dbContext);
if (targetUser.Handmoney >= activeDecision.dPrice)
{
targetUser.Handmoney -= activeDecision.dPrice;
}
else
{
int bankMoney = activeDecision.dPrice - targetUser.Handmoney;
targetUser.Handmoney = 0;
targetUser.BankAccount.Balance -= bankMoney;
}
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += activeDecision.dPrice / 2;
activeDecision.dMedic.GetUser(dbContext).Wage += activeDecision.dPrice / 2;
dbContext.SaveChanges();
}
activeDecision.dTarget.Health = 100;
activeDecision.dTarget.SendNotification($"Du wurdest von ~g~{activeDecision.dMedic.Name} ~s~ für ~g~{activeDecision.dPrice.ToMoneyString()} geheilt", false);
activeDecision.dMedic.SendNotification($"Du hast ~g~{activeDecision.dTarget.Name} ~s~ für {activeDecision.dPrice.ToMoneyString()} geheilt", false);
delHealTask(activeDecision.dTarget);
}
HealDecisions.Remove(activeDecision);
}
public static void UpdateTaskTimeLeft()
{
DateTime actualTime = DateTime.Now;
@@ -139,7 +187,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
public static void delHealTask(Player player)
{
MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == player.Name);
RemoveTaskFromList(task);
if(task != null) RemoveTaskFromList(task);
player.SetData("healauftrag", false);
}

View File

@@ -290,16 +290,13 @@ namespace ReallifeGamemode.Server.Managers
return;
}
using (var dbContext = new DatabaseContext())
{
target.GetUser(dbContext).Group = null;
target.GetUser(dbContext).GroupRank = GroupRank.NONE;
targetUser.Group = null;
targetUser.GroupRank = GroupRank.NONE;
ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " aus der Gruppe geworfen.");
ChatService.SendMessage(target, "!{02FCFF}Du wurdest von " + player.Name + " aus der Gruppe geworfen.");
ChatService.SendMessage(player, "!{02FCFF}Du hast " + target.Name + " aus der Gruppe geworfen.");
ChatService.SendMessage(target, "!{02FCFF}Du wurdest von " + player.Name + " aus der Gruppe geworfen.");
dbContext.SaveChanges();
}
dbContext.SaveChanges();
}
}

View File

@@ -122,63 +122,6 @@ namespace ReallifeGamemode.Server.Managers
}
}
[RemoteEvent("CLIENT:JobManager_ShowJobMenu")]
public void ShowJobMenuEvent(Player player)
{
User u = player.GetUser();
if (u.JobId == null) return;
JobBase job = GetJob(u.JobId.Value);
dynamic data = null;
if (job.Id == 1 && job.GetUsersInJob().Contains(player))
{
var taxiCalls = JobManager.GetJob<TaxiDriverJob>().TaxiContracts;
if (!taxiCalls.Any(t => t.Driver?.Handle == player.Handle)) // Spieler in keiner aktiven Fahrt
{
data = new
{
job.Id,
Status = 0,
JobData = new
{
TaxiCalls = taxiCalls
.Where(t => t.Driver == null)
.Select(t => new
{
t.Name,
Distance = Math.Round(t.Position.DistanceTo(player.Position), 0)
})
.OrderBy(t => t.Distance)
}
};
}
else // Spieler in aktiver Fahrt
{
data = new
{
job.Id,
Status = 1,
JobData = new
{
taxiCalls.Where(t => t.Driver.Handle == player.Handle).First().Name
}
};
}
}
//JobPoint nearJobPoint = PositionManager.JobPoints.Find(p => p.Position.DistanceTo(player.Position) <= 2);
if (u.JobId == 2 || u.JobId == 3 || u.JobId == 4)
{
return;
}
var json = JsonConvert.SerializeObject(data);
player.TriggerEvent("SERVER:Job_ShowJobMenu", job.Name, json);
}
[RemoteEvent("CLIENT:Job_StartJob")]
public void StartJobEvent(Player player)
{