try fix Job

This commit is contained in:
2021-04-05 15:55:41 +02:00
parent 90514a381d
commit b49cbffb32
2 changed files with 17 additions and 13 deletions

View File

@@ -43,9 +43,9 @@
}); });
mp.events.add('SERVER:MuellmannBCSEntfernen', () => { mp.events.add('SERVER:MuellmannBCSEntfernen', () => {
garbageToCollect.forEach((colshape, blip) => { garbageToCollect.forEach((colshape, blip) => {
if (colshape) if (colshape && mp.colshapes.exists(colshape))
colshape.destroy(); colshape.destroy();
if (blip) if (blip && mp.blips.exists(blip))
blip.destroy(); blip.destroy();
}); });
@@ -76,7 +76,7 @@
if (hasBinBag) { mp.gui.chat.push("Du trägst bereits einen Müllsack!"); return; } if (hasBinBag) { mp.gui.chat.push("Du trägst bereits einen Müllsack!"); return; }
if (!dumptruckIsFull) { if (!dumptruckIsFull) {
mp.events.callRemote('CLIENT:MuellmannImShape', JSON.stringify(blip)); mp.events.callRemote('CLIENT:MuellmannImShape', blip.getCoords());
hasBinBag = true; hasBinBag = true;
if (colshape) if (colshape)
@@ -113,18 +113,22 @@
dumptruckIsFull = false; dumptruckIsFull = false;
} }
}); });
mp.events.add("MuellmannUpdateColshape", (jsonIdentifier) => { mp.events.add("MuellmannUpdateColshape", (vector3) => {
var blip = JSON.parse(jsonIdentifier); let currBlip;
if (!garbageToCollect.has(blip)) return; garbageToCollect.forEach((colShape, blip) => {
if (blip.getCoords == vector3) currBlip = blip;
});
var colShape = garbageToCollect.get(blip); if (!garbageToCollect.has(currBlip)) return;
if (blip) var colShape = garbageToCollect.get(currBlip);
blip.destroy();
if (colShape) if (currBlip && mp.blips.exists(currBlip))
currBlip.destroy();
if (colShape && mp.colshapes.exists(colShape))
colShape.destroy(); colShape.destroy();
garbageToCollect.delete(blip); garbageToCollect.delete(currBlip);
}); });
mp.events.add("SERVER:MuellmannZuBase", () => { mp.events.add("SERVER:MuellmannZuBase", () => {

View File

@@ -209,13 +209,13 @@ namespace ReallifeGamemode.Server.Job
} }
[RemoteEvent("CLIENT:MuellmannImShape")] [RemoteEvent("CLIENT:MuellmannImShape")]
public void MuellmannImShape(Player player, string jsonIdentifier) public void MuellmannImShape(Player player, Vector3 blipCoords)
{ {
foreach (var data in muellmanData) foreach (var data in muellmanData)
{ {
if (data.getDataFromClient(player) == null) continue; if (data.getDataFromClient(player) == null) continue;
Player target = data.getPartnerClient(player); Player target = data.getPartnerClient(player);
if (target != null) target.TriggerEvent("MuellmannUpdateColshape", jsonIdentifier); if (target != null) target.TriggerEvent("MuellmannUpdateColshape", blipCoords);
player.TriggerEvent("renderTextOnScreen", "Wirf den Müllsack in den Müllwagen."); player.TriggerEvent("renderTextOnScreen", "Wirf den Müllsack in den Müllwagen.");
player.AddAttachment("binbag", false); player.AddAttachment("binbag", false);
return; return;