Gangwar-System base Structure
This commit is contained in:
@@ -28,7 +28,8 @@
|
||||
SET_BLIP_FLASHES: "0xB14552383D39CE3E",
|
||||
GET_FIRST_BLIP_INFO_ID: "0x1BEDE233E6CD2A1F",
|
||||
GET_NEXT_BLIP_INFO_ID: "0x14F96AA50D6FBEA7",
|
||||
DOES_BLIP_EXIST: "0xA6DB27D19ECBB7DA"
|
||||
DOES_BLIP_EXIST: "0xA6DB27D19ECBB7DA",
|
||||
SET_BLIP_COORDS: "0xAE2AF67E9D9AF65D"
|
||||
};
|
||||
|
||||
var Gangturf = class {
|
||||
@@ -59,27 +60,30 @@
|
||||
}
|
||||
|
||||
_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") {
|
||||
if (owner === "Ballas") {
|
||||
self.color = 83;
|
||||
self.colorZone_r = 143;
|
||||
self.colorZone_g = 0;
|
||||
self.colorZone_b = 199;
|
||||
} else if (owner = "GroveStreet") {
|
||||
} else if (owner === "GroveStreet") {
|
||||
self.color = 2;
|
||||
self.colorZone_r = 22;
|
||||
self.colorZone_g = 87;
|
||||
self.colorZone_b = 0;
|
||||
} else if (owner = "Neutral") {
|
||||
} else if (owner === "Neutral") {
|
||||
self.color = 0;
|
||||
self.colorZone_r = 255;
|
||||
self.colorZone_g = 255;
|
||||
self.colorZone_b = 255;
|
||||
}
|
||||
self.color = color;
|
||||
|
||||
self.x = x;
|
||||
self.y = y;
|
||||
|
||||
self.rotation = rot;
|
||||
self._colshape = null;
|
||||
self._status = "normal";
|
||||
@@ -97,20 +101,31 @@
|
||||
|
||||
loadArea() {
|
||||
var self = this;
|
||||
self.blip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, self.range);
|
||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.blip, 5);
|
||||
mp.game.invoke(Natives.SET_BLIP_ALPHA, self.blip, 70);
|
||||
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
||||
|
||||
self.blip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, self.range);
|
||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.blip, 5);
|
||||
mp.game.invoke(Natives.SET_BLIP_ALPHA, self.blip, 70);
|
||||
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
||||
|
||||
self._colshape = mp.colshapes.newCircle(self.x, self.y, self.range * 1.5);
|
||||
}
|
||||
render() {
|
||||
|
||||
var self = this;
|
||||
if (self.blip) {
|
||||
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
|
||||
if (self._colshape) {
|
||||
if (self.edit == true) {
|
||||
let vector3 = mp.players.local.getRotation(2);
|
||||
self.rotation = Math.round(vector3.z);
|
||||
mp.game.invoke(Natives.SET_BLIP_COORDS, self.blip, mp.players.local.position.x, mp.players.local.position.y, 1);
|
||||
self.x = mp.players.local.position.x;
|
||||
self.y = mp.players.local.position.y;
|
||||
}
|
||||
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
|
||||
|
||||
}
|
||||
if (self._status == "attack") {
|
||||
if (self.blip) {
|
||||
|
||||
if (self._status == "attack" || self.edit == true) {
|
||||
if (self._colshape) {
|
||||
if (mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, 0, self.x, self.y, 0, true) < self.range * 1.5) {
|
||||
var range = Math.sqrt(((self.range * 1.2) * (self.range * 1.2)) + (((self.range * 1.2) / 2) * ((self.range * 1.2) / 2)));
|
||||
let degrees = (self.rotation + 45) * (Math.PI / 180);
|
||||
@@ -310,15 +325,33 @@
|
||||
|
||||
mp.events.add('GangAreas:Create', (turfsJSON) => {
|
||||
var turfs = JSON.parse(turfsJSON);
|
||||
if (gangturfs.length > 0) {
|
||||
gangturfs[gangturfs.length - 1].edit = false;
|
||||
}
|
||||
clearBlips();
|
||||
if (turfs.length > 0) {
|
||||
gangturfs = [];
|
||||
turfs.forEach(function (turf) {
|
||||
if (turf.Id != undefined) {
|
||||
gangturfs[gangturfs.length] = new Gangturf(turf.Name, turf.Id, turf.X, turf.Y, turf.Range, turf.Color, turf.Rotation, turf.Owner);
|
||||
mp.gui.chat.push(turf.Owner);
|
||||
gangturfs[gangturfs.length] = new Gangturf(turf.Name, turf.Id, turf.X, turf.Y, turf.Range, turf.Color, turf.Rotation, turf.Owner, false);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
mp.events.add('ADMIN:CreateTurf', (rangeJSON) => {
|
||||
var range = JSON.parse(rangeJSON);
|
||||
gangturfs[gangturfs.length] = new Gangturf("Reload For Name", -1, mp.players.local.position.x, mp.players.local.position.y, range, 0, mp.players.local.getHeading(), "Neutral", true);
|
||||
});
|
||||
|
||||
mp.events.add('ADMIN:SetTurf', (name) => {
|
||||
gangturfs[gangturfs.length - 1].edit = false;
|
||||
if (gangturfs[gangturfs.length - 1].id == -1) {
|
||||
|
||||
mp.events.callRemote("SERVER:SetTurf", JSON.stringify(gangturfs[gangturfs.length - 1].x), JSON.stringify(gangturfs[gangturfs.length - 1].y), JSON.stringify(gangturfs[gangturfs.length - 1].rotation), JSON.stringify(gangturfs[gangturfs.length - 1].range), name);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user