Add RefuseCollector Job and other misc
This commit is contained in:
155
ReallifeGamemode.Client/Jobs/RefuseCollector.ts
Normal file
155
ReallifeGamemode.Client/Jobs/RefuseCollector.ts
Normal file
@@ -0,0 +1,155 @@
|
||||
export default function RefuseCollector() {
|
||||
|
||||
var State = false;
|
||||
var Traegt = false;
|
||||
var HintenVoll = false;
|
||||
var MuellSack = null;
|
||||
var BlipTonneHinten = null;
|
||||
var CheckpointTonneHinten = null;
|
||||
var ShapeTonneHinten = null;
|
||||
var BlipTonneBase = null;
|
||||
var CheckpointTonneBase = null;
|
||||
var ShapeTonneBase = null;
|
||||
var vehicle = null;
|
||||
|
||||
var BlipTonne = [];
|
||||
var ShapeTonne = [];
|
||||
|
||||
|
||||
|
||||
mp.events.add('SERVER:MuellmannStatusTrue', () => {
|
||||
State = true;
|
||||
});
|
||||
|
||||
mp.events.add('SERVER:MuellmannStatusFalse', () => {
|
||||
State = false;
|
||||
});
|
||||
|
||||
mp.events.add('SERVER:MuellmannBCSErstellen', (jsonPosArr, veh) => {
|
||||
|
||||
let posArr = JSON.parse(jsonPosArr);
|
||||
vehicle = veh;
|
||||
for (var i = 0; i < posArr.length; i++) {
|
||||
let pos = new mp.Vector3(posArr[i].x, posArr[i].y, posArr[i].z - 1)
|
||||
BlipTonne.push(mp.blips.new(1, pos, { name: 'Müllmann', color: 45, shortRange: false }));
|
||||
ShapeTonne.push(mp.colshapes.newSphere(posArr[i].x, posArr[i].y, posArr[i].z +0.5, 1.75));
|
||||
}
|
||||
|
||||
BlipTonneBase = mp.blips.new(1, new mp.Vector3(-535.1912, -1713.742, 19.23861 - 1), { name: 'Müllmann', color: 5, shortRange: false });
|
||||
CheckpointTonneBase = mp.markers.new(1, new mp.Vector3(-535.1912, -1713.742, 19.23861 - 1), 10, { direction: new mp.Vector3(-235.5747, -1685.475, 32.7207), color: [255, 255, 0, 150], visible: true, dimension: 0 });
|
||||
ShapeTonneBase = mp.colshapes.newSphere(-535.1912, -1713.742, 19.23861 - 1, 10);
|
||||
});
|
||||
mp.events.add('SERVER:MuellmannBCSEntfernen', () => {
|
||||
|
||||
for (var i = 0; i < BlipTonne.length; i++) {
|
||||
if (BlipTonne[i] == null) continue;
|
||||
BlipTonne[i].destroy();
|
||||
ShapeTonne[i].destroy();
|
||||
}
|
||||
BlipTonne = [];
|
||||
ShapeTonne = [];
|
||||
|
||||
if (BlipTonneHinten) BlipTonneHinten.destroy();
|
||||
BlipTonneHinten = null;
|
||||
if (CheckpointTonneHinten) CheckpointTonneHinten.destroy();
|
||||
CheckpointTonneHinten = null;
|
||||
if (ShapeTonneHinten) ShapeTonneHinten.destroy();
|
||||
ShapeTonneHinten = null;
|
||||
if (BlipTonneBase) BlipTonneBase.destroy();
|
||||
BlipTonneBase = null;
|
||||
if (CheckpointTonneBase) CheckpointTonneBase.destroy();
|
||||
CheckpointTonneBase = null;
|
||||
if (ShapeTonneBase) ShapeTonneBase.destroy();
|
||||
ShapeTonneBase = null;
|
||||
Traegt = false;
|
||||
});
|
||||
|
||||
mp.events.add("playerEnterColshape", (Shape, player) => {
|
||||
//mp.events.callRemote('CLIENT:ImShape', JSON.stringify(Shape));
|
||||
for (var i = 0; i < ShapeTonne.length; i++) {
|
||||
if (Shape != ShapeTonne[i]) continue;
|
||||
if (!Traegt) {
|
||||
if (!HintenVoll) {
|
||||
mp.events.callRemote('CLIENT:MuellmannImShape', JSON.stringify(Shape));
|
||||
Traegt = true;
|
||||
BlipTonne[i].destroy();
|
||||
BlipTonne[i] = null;
|
||||
ShapeTonne[i].destroy();
|
||||
ShapeTonne[i] = null;
|
||||
MuellSack = mp.objects.new(600967813, mp.players.local.position, { rotation: new mp.Vector3(0.0, 0.0, 0.0), alpha: 255, dimension: 0 });
|
||||
MuellSack.attachTo(mp.players.local.handle, mp.players.local.getBoneIndex(6286), 0.45, -0.9, -0.075, 270.0, 0.0, 25.0, true, true, false, false, 0, true);
|
||||
|
||||
createMarker();
|
||||
}
|
||||
else {
|
||||
mp.gui.chat.push("Der Müllwagen ist bereits voll! Fahre zur Base und lade ab!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
else {
|
||||
mp.gui.chat.push(`Du trägst bereits einen Müllsack!`);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (Shape == ShapeTonneHinten) {
|
||||
if (Traegt) {
|
||||
|
||||
Traegt = false;
|
||||
mp.events.callRemote('CLIENT:MuellmannAddSack');
|
||||
|
||||
if (BlipTonneHinten) BlipTonneHinten.destroy();
|
||||
BlipTonneHinten = null;
|
||||
if (CheckpointTonneHinten) CheckpointTonneHinten.destroy();
|
||||
CheckpointTonneHinten = null;
|
||||
if (ShapeTonneHinten) ShapeTonneHinten.destroy();
|
||||
ShapeTonneHinten = null;
|
||||
MuellSack.destroy();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
else if (Shape == ShapeTonneBase) {
|
||||
BlipTonneBase.setRoute(false);
|
||||
mp.events.callRemote('CLIENT:MuellmannBaseSack');
|
||||
}
|
||||
});
|
||||
mp.events.add("MuellmannUpdateColshape", (jsonColShape) => {
|
||||
let ColShape = JSON.parse(jsonColShape);
|
||||
for (var i = 0; i < ShapeTonne.length; i++) {
|
||||
if (ColShape != ShapeTonne[i]) continue;
|
||||
BlipTonne[i].destroy();
|
||||
BlipTonne[i] = null;
|
||||
ShapeTonne[i].destroy();
|
||||
ShapeTonne[i] = null;
|
||||
}
|
||||
|
||||
|
||||
});
|
||||
|
||||
mp.events.add("SERVER:MuellmannZuBase", () => {
|
||||
BlipTonneBase.setRoute(true);
|
||||
BlipTonneBase.setRouteColour(5);
|
||||
HintenVoll = true;
|
||||
});
|
||||
|
||||
mp.events.add("SERVER:MuellmannWiederLeer", () => {
|
||||
HintenVoll = false;
|
||||
});
|
||||
|
||||
function createMarker() {
|
||||
if (vehicle != null) {
|
||||
const playerPos = vehicle.position;
|
||||
let pos = new mp.Vector3(vehicle.position.x, vehicle.position.y - 5.5, vehicle.position.z - 1);
|
||||
if (BlipTonneHinten) BlipTonneHinten.destroy();
|
||||
BlipTonneHinten = null;
|
||||
if (CheckpointTonneHinten) CheckpointTonneHinten.destroy();
|
||||
CheckpointTonneHinten = null;
|
||||
if (ShapeTonneHinten) ShapeTonneHinten.destroy();
|
||||
ShapeTonneHinten = null;
|
||||
BlipTonneHinten = mp.blips.new(1, pos, { name: 'Müllmann', color: 24, shortRange: false });
|
||||
CheckpointTonneHinten = mp.markers.new(1, pos, 1, { direction: new mp.Vector3(-235.5747, -1685.475, 32.7207), color: [0, 255, 0, 255], visible: true, dimension: 0 });
|
||||
ShapeTonneHinten = mp.colshapes.newSphere(vehicle.position.x, vehicle.position.y - 5.5, vehicle.position.z - 1, 2);
|
||||
}
|
||||
};
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user