Medic Fix die 10241581259
This commit is contained in:
@@ -389,73 +389,13 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
mp.events.add("sortFactionTasks", (sortByKey) => {
|
||||
if (firstSorting) {
|
||||
sortText = "Nach Uhrzeit";
|
||||
firstSorting = false;
|
||||
//mp.gui.chat.push("Init Sort");
|
||||
return;
|
||||
} else {
|
||||
if (sortByKey) {
|
||||
if (sorting < 1) {
|
||||
sorting++;
|
||||
} else {
|
||||
sorting = 0;
|
||||
mp.events.add('playerEnterCheckpoint', (activeCheckpoint) => {
|
||||
if (activeTask.Type == 1) {
|
||||
activeCheckpoint.destroy();
|
||||
activeCheckpoint = null;
|
||||
activeTask = null;
|
||||
timeLeft = null;
|
||||
}
|
||||
|
||||
switch (sorting) {
|
||||
case 0: //Standartsortierung
|
||||
|
||||
reviveTaskMenuMedic.Close();
|
||||
factionInteractionMenu.Close();
|
||||
sortText = "Nach Uhrzeit";
|
||||
mp.events.call("showMedicTasks", 0, JSON.stringify(initTasks));
|
||||
break;
|
||||
|
||||
case 1: //Sortierung nach Metern (aufsteigend)
|
||||
for (var d = 0; d < tasks.length; d++) {
|
||||
for (var e = 0; e < tasks.length - 1; e++) {
|
||||
if (getDistance1(e) > getDistance2(e + 1)) {
|
||||
var tempTask = tasks[e];
|
||||
tasks[e] = tasks[e + 1];
|
||||
tasks[e + 1] = tempTask;
|
||||
mp.gui.chat.push("SWITCH");
|
||||
}
|
||||
}
|
||||
}
|
||||
reviveTaskMenuMedic.Close();
|
||||
factionInteractionMenu.Close();
|
||||
sortText = "Entfernung aufsteigend";
|
||||
mp.events.call("showMedicTasks", 0, JSON.stringify(tasks));
|
||||
break;
|
||||
|
||||
//case 2: //Sortierung nach Metern (absteigend)
|
||||
// mp.gui.chat.push("Sorting 2");
|
||||
// sortText = "Entfernung absteigend";
|
||||
// break;
|
||||
//case 3: //Sortierung nach Zeit (aufsteigend)
|
||||
// mp.gui.chat.push("Sorting 3");
|
||||
// sortText = "Restzeit aufsteigend";
|
||||
// break;
|
||||
//case 4: //Sortierung nach Zeit (absteigend)
|
||||
// mp.gui.chat.push("Sorting 4");
|
||||
// sortText = "Restzeit absteigend";
|
||||
// break;
|
||||
}
|
||||
}
|
||||
}
|
||||
});*/
|
||||
|
||||
function getDistance1(index) {
|
||||
return mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, newTasks[index].Position.x, newTasks[index].Position.y, newTasks[index].Position.z, true).toFixed(2);
|
||||
}
|
||||
function getDistance2(index) {
|
||||
return mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, newTasks[index].Position.x, newTasks[index].Position.y, newTasks[index].Position.z, true).toFixed(2);
|
||||
}
|
||||
|
||||
mp.events.add("cutMedicEarnings", () => {
|
||||
deadRespawned = true;
|
||||
});
|
||||
|
||||
mp.events.add("destroyMedicTaskCheckpoint", () => {
|
||||
@@ -464,24 +404,6 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
activeCheckpoint = null;
|
||||
activeTask = null;
|
||||
timeLeft = null;
|
||||
mp.events.callRemote("MedicTaskTimeout");
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('playerEnterCheckpoint', (activeCheckpoint) => {
|
||||
if (deadRespawned == true) {
|
||||
activeCheckpoint.destroy();
|
||||
activeCheckpoint = null;
|
||||
mp.events.callRemote("PayCutMedicEarnings");
|
||||
activeTask = null;
|
||||
deadRespawned = false;
|
||||
timeLeft = null;
|
||||
} else if (activeTask.Type == 1) {
|
||||
activeCheckpoint.destroy();
|
||||
activeCheckpoint = null;
|
||||
mp.events.callRemote("delHealTaskAsMedic", activeTask.Victim);
|
||||
activeTask = null;
|
||||
timeLeft = null;
|
||||
}
|
||||
});
|
||||
|
||||
@@ -491,7 +413,7 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('render', () => {
|
||||
function renderMedicGui() {
|
||||
if (activeTask) {
|
||||
rangeLeft = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, taskFinish.x, taskFinish.y, taskFinish.z, true).toFixed(2);
|
||||
if (rangeLeft > 1.9) {
|
||||
@@ -513,18 +435,10 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
}
|
||||
}
|
||||
|
||||
var currentDate = new Date();
|
||||
|
||||
if (timeLeft != null) {
|
||||
if (deadRespawned == false) {
|
||||
//timeLeft = Math.round(Math.abs(Math.floor(currentDate.getTime() / 1000) - activeTask.TimeLeft - 60));
|
||||
if (timeLeft < 120) mp.events.call("cutMedicEarnings");
|
||||
} else {
|
||||
//timeLeft = Math.round(Math.abs(Math.floor(currentDate.getTime() / 1000) - activeTask.TimeLeft - 120));
|
||||
if (timeLeft < 1) mp.events.call("destroyMedicTaskCheckpoint");
|
||||
}
|
||||
|
||||
if (deadRespawned == false) {
|
||||
mp.game.graphics.drawText(timeLeft + "s", [0.5, 0.85], {
|
||||
font: 7,
|
||||
color: [60, 179, 113, 255],
|
||||
@@ -545,5 +459,9 @@ export default function factionInteraction(globalData: IGlobalData) {
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
mp.events.add('render', () => {
|
||||
renderMedicGui();
|
||||
});
|
||||
}
|
||||
@@ -13,6 +13,7 @@ using ReallifeGamemode.Server.Services;
|
||||
using ReallifeGamemode.Server.Types;
|
||||
using ReallifeGamemode.Server.Util;
|
||||
using ReallifeGamemode.Server.Wanted;
|
||||
using ReallifeGamemode.Services;
|
||||
|
||||
/**
|
||||
* @overview Life of German Reallife - Events Death (Death.cs)
|
||||
@@ -234,6 +235,7 @@ namespace ReallifeGamemode.Server.Events
|
||||
}
|
||||
player.RemoveAllWeapons();
|
||||
MedicTask task = Medic.ReviveTasks.FirstOrDefault(t => t.Victim == player.Name);
|
||||
Player medicPlayer = PlayerService.GetPlayerByNameOrId(task.MedicName);
|
||||
Medic.RemoveTaskFromList(task);
|
||||
|
||||
NAPI.Player.SpawnPlayer(player, new Vector3(-495.45, -336.33, 34.5), -98.36f);
|
||||
|
||||
@@ -26,7 +26,7 @@ namespace ReallifeGamemode.Server.Factions.Medic
|
||||
public static List<HealDecision> HealDecisions = new List<HealDecision>();
|
||||
public static int ReviveIncome = 100;
|
||||
public static int dutyMedics = 0;
|
||||
public static int reviveTaskTime = 240;
|
||||
public static int reviveTaskTime = 120;
|
||||
|
||||
public class HealDecision
|
||||
{
|
||||
@@ -156,14 +156,14 @@ namespace ReallifeGamemode.Server.Factions.Medic
|
||||
|
||||
public static void UpdateTaskTimeLeft()
|
||||
{
|
||||
DateTime actualTime = DateTime.Now;
|
||||
if (ReviveTasks.Count != 0)
|
||||
{
|
||||
DateTime actualTime = DateTime.Now;
|
||||
foreach (var task in ReviveTasks)
|
||||
{
|
||||
if (task.MedicName != null)
|
||||
{
|
||||
var taskTimeLeft = Math.Abs((Int32)(((DateTimeOffset)actualTime).ToUnixTimeSeconds() - ((DateTimeOffset)task.Time).ToUnixTimeSeconds() - reviveTaskTime));
|
||||
var taskTimeLeft = Math.Abs((int)(((DateTimeOffset)actualTime).ToUnixTimeSeconds() - ((DateTimeOffset)task.Time).ToUnixTimeSeconds() - reviveTaskTime));
|
||||
task.TimeLeft = taskTimeLeft;
|
||||
var medic = PlayerService.GetPlayerByNameOrId(task.MedicName);
|
||||
if(medic != null) medic.TriggerEvent("setTaskTimeLeft", taskTimeLeft);
|
||||
@@ -239,48 +239,6 @@ namespace ReallifeGamemode.Server.Factions.Medic
|
||||
MedicTask task = ReviveTasks.FirstOrDefault(t => t.Victim == player.Name);
|
||||
RemoveTaskFromList(task);
|
||||
}
|
||||
[RemoteEvent("delReviveTaskMedic")]
|
||||
public static void delReviveTaskMedic(Player player)
|
||||
{
|
||||
MedicTask task = ReviveTasks.FirstOrDefault(t => t.MedicName == player.Name);
|
||||
RemoveTaskFromList(task);
|
||||
}
|
||||
|
||||
[RemoteEvent("CutMedicEarnings")]
|
||||
public void CutMedicEarnings(Player player)
|
||||
{
|
||||
MedicTask task = ReviveTasks.FirstOrDefault(t => t.Victim == player.Name);
|
||||
var medic = PlayerService.GetPlayerByNameOrId(task.MedicName);
|
||||
medic.TriggerEvent("cutMedicEarnings");
|
||||
}
|
||||
[RemoteEvent("PayCutMedicEarnings")]
|
||||
public void PayCutMedicEarnings(Player player)
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
{
|
||||
dbContext.Factions.Include(f => f.BankAccount).Where(f => f.Id == 2).First().BankAccount.Balance += Medic.ReviveIncome / 4;
|
||||
player.SendNotification($"Du hast den Einsatzort erreicht und ~g~{Medic.ReviveIncome / 4}$ ~s~für die Fraktion verdient.");
|
||||
Medic.delReviveTaskMedic(player);
|
||||
dbContext.SaveChanges();
|
||||
}
|
||||
}
|
||||
|
||||
[RemoteEvent("MedicTaskTimeout")]
|
||||
public void RemoveMedicTask(Player player)
|
||||
{
|
||||
Medic.delReviveTaskMedic(player);
|
||||
}
|
||||
|
||||
[RemoteEvent("getTaskTimeLeft")]
|
||||
public void GetTaskTimeLeft(Player player, string victimName)
|
||||
{
|
||||
using var dbContext = new DatabaseContext();
|
||||
{
|
||||
var activeTaskTime = ReviveTasks.FirstOrDefault(t => t.MedicName == player.Name && t.Victim == victimName).TimeLeft;
|
||||
|
||||
player.TriggerEvent("setTaskTimeLeft", activeTaskTime);
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateDutyMedics(int modifier)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user