Fix Job RefuseCollector Client Side

This commit is contained in:
2021-04-05 17:17:18 +02:00
parent 492154e3ec
commit 2ddeb289f4
2 changed files with 32 additions and 25 deletions

View File

@@ -13,7 +13,7 @@
var interval = null;
var garbageToCollect = new Map<BlipMp, ColshapeMp>();
var garbageToCollect = new Map<number, { blip: BlipMp, colshape: ColshapeMp }>();
mp.events.add('SERVER:MuellmannStatusTrue', () => {
State = true;
@@ -34,7 +34,7 @@
newBlip.setFlashTimer(2000);
garbageToCollect.set(newBlip, newColShape);
garbageToCollect.set(i, { blip: newBlip, colshape: newColShape });
}
blipBase = mp.blips.new(1, new mp.Vector3(-442.3999, -1701.5234, 18.933002 - 1), { name: 'Recylinganlage', color: 5, shortRange: false });
@@ -42,7 +42,9 @@
colshapeBase = mp.colshapes.newSphere(-442.3999, -1701.5234, 18.933002 - 1, 10);
});
mp.events.add('SERVER:MuellmannBCSEntfernen', () => {
garbageToCollect.forEach((colshape, blip) => {
garbageToCollect.forEach((collection, index) => {
let { blip, colshape } = collection;
if (colshape && mp.colshapes.exists(colshape))
colshape.destroy();
if (blip && mp.blips.exists(blip))
@@ -69,14 +71,16 @@
mp.events.add("playerEnterColshape", (currentShape, player) => {
//mp.events.callRemote('CLIENT:ImShape', JSON.stringify(Shape));
garbageToCollect.forEach((colshape, blip) => {
if (!colshape || colshape != currentShape) { return; }
let i = getIndex(currentShape);
if (garbageToCollect.has(i)) {
let { blip, colshape } = garbageToCollect.get(i);
if (mp.players.local.vehicle) { mp.events.call("renderTextOnScreen", "Steige aus dem Müllwagen aus um den Müllsack zu entnehmen."); return; }
if (hasBinBag) { mp.gui.chat.push("Du trägst bereits einen Müllsack!"); return; }
if (!dumptruckIsFull) {
mp.events.callRemote('CLIENT:MuellmannImShape', blip.getCoords());
mp.events.callRemote('CLIENT:MuellmannImShape', i);
hasBinBag = true;
if (colshape)
@@ -84,13 +88,15 @@
if (blip)
blip.destroy();
garbageToCollect.delete(i);
interval = setInterval(function () { createMarker(); }, 2);
}
else {
mp.gui.chat.push("Der Müllwagen ist bereits voll! Fahre zur Base und lade ab!");
return;
}
});
}
if (currentShape == colshapeDumptruck) {
if (hasBinBag) {
@@ -113,28 +119,20 @@
dumptruckIsFull = false;
}
});
mp.events.add("MuellmannUpdateColshape", (vector3) => {
let currBlip;
garbageToCollect.forEach((colShape, blip) => {
if (blip.getCoords() == vector3) currBlip = blip;
});
mp.events.add("MuellmannUpdateColshape", (index) => {
if (!garbageToCollect.has(index)) return;
if (!garbageToCollect.has(currBlip)) return;
mp.gui.chat.push("Has Blip.");
let { blip, colshape } = garbageToCollect.get(index);
var colShape = garbageToCollect.get(currBlip);
if (currBlip && mp.blips.exists(currBlip)) {
mp.gui.chat.push("Delete Blip.");
currBlip.destroy();
if (blip && mp.blips.exists(blip)) {
blip.destroy();
}
if (colShape && mp.colshapes.exists(colShape)) {
mp.gui.chat.push("Delete Colshape.");
colShape.destroy();
if (colshape && mp.colshapes.exists(colshape)) {
colshape.destroy();
}
garbageToCollect.delete(currBlip);
garbageToCollect.delete(index);
});
mp.events.add("SERVER:MuellmannZuBase", () => {
@@ -143,6 +141,15 @@
dumptruckIsFull = true;
});
function getIndex(shape: ColshapeMp): number {
let i = -1;
garbageToCollect.forEach((collection, index) => {
let { blip, colshape } = collection;
if (shape == colshape) i = index;
});
return i;
}
function createMarker() {
let vehicle;
if (vehRemoteID)

View File

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