[+] Added Gangwar playability
This commit is contained in:
@@ -45,6 +45,7 @@
|
||||
colorZone_b: number;
|
||||
rotation: number;
|
||||
owner: string;
|
||||
attacker: string;
|
||||
blip: BlipMp;
|
||||
_colshape: ColshapeMp;
|
||||
vector: Vector3Mp;
|
||||
@@ -60,28 +61,12 @@
|
||||
}
|
||||
|
||||
_setup(name, id, x, y, range, color, rot, owner, edit) {
|
||||
|
||||
|
||||
var self = this;
|
||||
self.name = name;
|
||||
self.id = id;
|
||||
self.range = range;
|
||||
if (owner === "Ballas") {
|
||||
self.color = 83;
|
||||
self.colorZone_r = 143;
|
||||
self.colorZone_g = 0;
|
||||
self.colorZone_b = 199;
|
||||
} else if (owner === "GroveStreet") {
|
||||
self.color = 2;
|
||||
self.colorZone_r = 22;
|
||||
self.colorZone_g = 87;
|
||||
self.colorZone_b = 0;
|
||||
} else if (owner === "Neutral") {
|
||||
self.color = 0;
|
||||
self.colorZone_r = 255;
|
||||
self.colorZone_g = 255;
|
||||
self.colorZone_b = 255;
|
||||
}
|
||||
|
||||
self.setColor(owner);
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
self.rotation = rot;
|
||||
@@ -92,11 +77,30 @@
|
||||
self._inColshape = false;
|
||||
self._timerCheck;
|
||||
self.owner = owner;
|
||||
self.attacker = null;
|
||||
self.edit = edit;
|
||||
self.loadArea();
|
||||
}
|
||||
|
||||
|
||||
setColor(owner) {
|
||||
var self = this;
|
||||
if (owner === "Ballas") {
|
||||
self.color = 83;
|
||||
self.colorZone_r = 143;
|
||||
self.colorZone_g = 0;
|
||||
self.colorZone_b = 199;
|
||||
} else if (owner === "Grove") {
|
||||
self.color = 2;
|
||||
self.colorZone_r = 22;
|
||||
self.colorZone_g = 87;
|
||||
self.colorZone_b = 0;
|
||||
} else if (owner === "Neutral") {
|
||||
self.color = 0;
|
||||
self.colorZone_r = 255;
|
||||
self.colorZone_g = 255;
|
||||
self.colorZone_b = 255;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
loadArea() {
|
||||
@@ -149,16 +153,25 @@
|
||||
y: self.y + range * Math.sin(degrees)
|
||||
}
|
||||
let z = mp.game.gameplay.getGroundZFor3dCoord(mp.players.local.position.x, mp.players.local.position.y, mp.players.local.position.z, 0, false);
|
||||
//mp.game.graphics.drawLine(bottom_right.x, bottom_right.y, z, bottom_right.x, bottom_right.y, z + 25, 0, 255, 0, 255);
|
||||
//mp.game.graphics.drawLine(top_left.x, top_left.y, z, top_left.x, top_left.y, z + 25, 0, 0, 255, 255);
|
||||
let a = 0;
|
||||
for (var i = z; i < z + 1; i += 0.001) {
|
||||
mp.game.graphics.drawLine(top_left.x, top_left.y, i, top_right.x, top_right.y, i, self.colorZone_r, self.colorZone_g, self.colorZone_b, 60 - a * 100);
|
||||
mp.game.graphics.drawLine(top_right.x, top_right.y, i, bottom_right.x, bottom_right.y, i, self.colorZone_r, self.colorZone_g, self.colorZone_b, 60 - a * 100);
|
||||
mp.game.graphics.drawLine(bottom_right.x, bottom_right.y, i, bottom_left.x, bottom_left.y, i, self.colorZone_r, self.colorZone_g, self.colorZone_b, 60 - a * 100);
|
||||
mp.game.graphics.drawLine(bottom_left.x, bottom_left.y, i, top_left.x, top_left.y, i, self.colorZone_r, self.colorZone_g, self.colorZone_b, 60 - a * 100);
|
||||
a += 0.001
|
||||
}
|
||||
if (self.edit) {
|
||||
mp.game.graphics.drawLine(bottom_right.x, bottom_right.y, z, bottom_right.x, bottom_right.y, z + 25, 0, 255, 0, 255);
|
||||
mp.game.graphics.drawLine(top_left.x, top_left.y, z, top_left.x, top_left.y, z + 25, 0, 0, 255, 255);
|
||||
for (var i = z; i < z + 25; i += 0.5) {
|
||||
mp.game.graphics.drawLine(top_left.x, top_left.y, i, top_right.x, top_right.y, i, 255, 0, 0, 255);
|
||||
mp.game.graphics.drawLine(top_right.x, top_right.y, i, bottom_right.x, bottom_right.y, i, 255, 0, 0, 255);
|
||||
mp.game.graphics.drawLine(bottom_right.x, bottom_right.y, i, bottom_left.x, bottom_left.y, i, 255, 0, 0, 255);
|
||||
mp.game.graphics.drawLine(bottom_left.x, bottom_left.y, i, top_left.x, top_left.y, i, 255, 0, 0, 255);
|
||||
}
|
||||
} else {
|
||||
let a = 0;
|
||||
for (var i = z; i < z + 1; i += 0.001) {
|
||||
mp.game.graphics.drawLine(top_left.x, top_left.y, i, top_right.x, top_right.y, i, self.colorZone_r, self.colorZone_g, self.colorZone_b, 60 - a * 100);
|
||||
mp.game.graphics.drawLine(top_right.x, top_right.y, i, bottom_right.x, bottom_right.y, i, self.colorZone_r, self.colorZone_g, self.colorZone_b, 60 - a * 100);
|
||||
mp.game.graphics.drawLine(bottom_right.x, bottom_right.y, i, bottom_left.x, bottom_left.y, i, self.colorZone_r, self.colorZone_g, self.colorZone_b, 60 - a * 100);
|
||||
mp.game.graphics.drawLine(bottom_left.x, bottom_left.y, i, top_left.x, top_left.y, i, self.colorZone_r, self.colorZone_g, self.colorZone_b, 60 - a * 100);
|
||||
a += 0.001
|
||||
}
|
||||
}
|
||||
}
|
||||
if (self.isInsideArea()) {
|
||||
mp.game.graphics.drawText(self.name, [self.x, self.y, mp.players.local.position.z + 20], {
|
||||
@@ -177,6 +190,7 @@
|
||||
var self = this;
|
||||
if (status == "attack") {
|
||||
self._status = "attack";
|
||||
self.attacker = args[1];
|
||||
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, true);
|
||||
return;
|
||||
}
|
||||
@@ -187,9 +201,11 @@
|
||||
}
|
||||
if (status == "conquered") {
|
||||
self._status = "normal";
|
||||
self.owner = args[1];
|
||||
self.owner = args[0];
|
||||
self.attacker = null;
|
||||
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
|
||||
self.blip.setColour(args[0]);
|
||||
self.setColor(self.owner)
|
||||
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -207,7 +223,7 @@
|
||||
if (self._entered == true) {
|
||||
if (!self.isInsideArea() || (self.isNearGround() == false)) {
|
||||
self._entered = false;
|
||||
// mp.events.callRemote("Gangarea:Leave", self.id);
|
||||
mp.events.callRemote("Gangarea:Leave", self.id);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -218,12 +234,12 @@
|
||||
if ((!self._entered)) {
|
||||
if (self.isInsideArea() && (self.isNearGround() == true)) {
|
||||
self._entered = true;
|
||||
// mp.events.callRemote("Gangarea:Enter", self.id);
|
||||
mp.events.callRemote("Gangarea:Enter", JSON.stringify(self.id));
|
||||
}
|
||||
} else if (self._entered == true) {
|
||||
if (!self.isInsideArea() || (self.isNearGround() == false)) {
|
||||
self._entered = false;
|
||||
//mp.events.callRemote("Gangarea:Leave", self.id);
|
||||
mp.events.callRemote("Gangarea:Leave", JSON.stringify(self.id));
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
@@ -353,5 +369,39 @@
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('ADMIN:DeleteTurf', () => {
|
||||
gangturfs.forEach(function (turf) {
|
||||
if (turf._entered == true) {
|
||||
mp.events.callRemote("SERVER:DeleteTurf", JSON.stringify(turf.id));
|
||||
return;
|
||||
}
|
||||
});
|
||||
mp.events.callRemote("SERVER:DeleteTurf", JSON.stringify(-1));
|
||||
});
|
||||
|
||||
mp.events.add('CLIENT:Turf_Update', (jsonId, jsonStatus, jsonOwner, jsonAttacker) => {
|
||||
var id = JSON.parse(jsonId);
|
||||
var status = JSON.parse(jsonStatus);
|
||||
var owner = JSON.parse(jsonOwner);
|
||||
var attacker = JSON.parse(jsonAttacker);
|
||||
|
||||
gangturfs.forEach(function (turf) {
|
||||
if (turf.id == id) {
|
||||
turf.updateArea(status, owner, attacker);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
mp.events.add('CLIENT:ScoreUpdate1', (JSONattackerScore, JSONdefenderScore, JSONid) => {
|
||||
var attackerScore = JSON.parse(JSONattackerScore);
|
||||
var defenderScore = JSON.parse(JSONdefenderScore);
|
||||
var id = JSON.parse(JSONid);
|
||||
gangturfs.forEach(function (turf) {
|
||||
if (turf.id == id) {
|
||||
turf.scoreUpdate(attackerScore, defenderScore);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user