Merge branch 'develop' of ssh://development.life-of-german.org:451/log-gtav/reallife-gamemode into develop
This commit is contained in:
@@ -18,7 +18,7 @@ export default function factionInteraction(globalData: IGlobalData) {
|
|||||||
var newTasks;
|
var newTasks;
|
||||||
var sorting = 0;
|
var sorting = 0;
|
||||||
var firstSorting = true;
|
var firstSorting = true;
|
||||||
var activeTask = false;
|
var activeTask = null;
|
||||||
var activeCheckpoint;
|
var activeCheckpoint;
|
||||||
var taskStart;
|
var taskStart;
|
||||||
var taskFinish;
|
var taskFinish;
|
||||||
@@ -327,7 +327,7 @@ export default function factionInteraction(globalData: IGlobalData) {
|
|||||||
mp.game.ui.setNewWaypoint(tasks[index].Position.x, tasks[index].Position.y);
|
mp.game.ui.setNewWaypoint(tasks[index].Position.x, tasks[index].Position.y);
|
||||||
activeCheckpoint = mp.checkpoints.new(1, new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 2), 3.0,
|
activeCheckpoint = mp.checkpoints.new(1, new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 2), 3.0,
|
||||||
{
|
{
|
||||||
direction: new mp.Vector3(0, 0, 75),
|
direction: new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 5),
|
||||||
color: [255, 0, 0, 150],
|
color: [255, 0, 0, 150],
|
||||||
visible: true,
|
visible: true,
|
||||||
dimension: 0
|
dimension: 0
|
||||||
@@ -340,7 +340,7 @@ export default function factionInteraction(globalData: IGlobalData) {
|
|||||||
taskStart = player.position;
|
taskStart = player.position;
|
||||||
taskFinish = tasks[index].Position;
|
taskFinish = tasks[index].Position;
|
||||||
taskRange = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z, true);
|
taskRange = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z, true);
|
||||||
activeTask = true;
|
activeTask = tasks[index];
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -383,7 +383,7 @@ export default function factionInteraction(globalData: IGlobalData) {
|
|||||||
mp.game.ui.setNewWaypoint(tasks[index].Position.x, tasks[index].Position.y);
|
mp.game.ui.setNewWaypoint(tasks[index].Position.x, tasks[index].Position.y);
|
||||||
activeCheckpoint = mp.checkpoints.new(1, new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 2), 3.0,
|
activeCheckpoint = mp.checkpoints.new(1, new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 2), 3.0,
|
||||||
{
|
{
|
||||||
direction: new mp.Vector3(0, 0, 75),
|
direction: new mp.Vector3(tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z - 5),
|
||||||
color: [255, 0, 0, 150],
|
color: [255, 0, 0, 150],
|
||||||
visible: true,
|
visible: true,
|
||||||
dimension: 0
|
dimension: 0
|
||||||
@@ -395,7 +395,7 @@ export default function factionInteraction(globalData: IGlobalData) {
|
|||||||
taskStart = player.position;
|
taskStart = player.position;
|
||||||
taskFinish = tasks[index].Position;
|
taskFinish = tasks[index].Position;
|
||||||
taskRange = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z, true);
|
taskRange = mp.game.gameplay.getDistanceBetweenCoords(player.position.x, player.position.y, player.position.z, tasks[index].Position.x, tasks[index].Position.y, tasks[index].Position.z, true);
|
||||||
activeTask = true;
|
activeTask = tasks[index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -481,7 +481,7 @@ export default function factionInteraction(globalData: IGlobalData) {
|
|||||||
|
|
||||||
mp.events.add("destroyMedicTaskCheckpoint", () => {
|
mp.events.add("destroyMedicTaskCheckpoint", () => {
|
||||||
activeCheckpoint.destroy();
|
activeCheckpoint.destroy();
|
||||||
activeTask = false;
|
activeTask = null;
|
||||||
timeLeft = 0;
|
timeLeft = 0;
|
||||||
mp.events.callRemote("MedicTaskTimeout");
|
mp.events.callRemote("MedicTaskTimeout");
|
||||||
});
|
});
|
||||||
@@ -490,9 +490,13 @@ export default function factionInteraction(globalData: IGlobalData) {
|
|||||||
if (deadRespawned == true) {
|
if (deadRespawned == true) {
|
||||||
activeCheckpoint.destroy();
|
activeCheckpoint.destroy();
|
||||||
mp.events.callRemote("PayCutMedicEarnings");
|
mp.events.callRemote("PayCutMedicEarnings");
|
||||||
activeTask = false;
|
activeTask = null;
|
||||||
deadRespawned = false;
|
deadRespawned = false;
|
||||||
timeLeft = 0;
|
timeLeft = 0;
|
||||||
|
} else if (activeTask.Type == 1){
|
||||||
|
activeCheckpoint.destroy();
|
||||||
|
mp.events.callRemote("delHealTaskAsMedic", activeTask.Victim);
|
||||||
|
activeTask = null;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -200,9 +200,6 @@ planeSchoolHandle(globalData);
|
|||||||
import PilotRouteList from './Jobs/PilotRouteSelect';
|
import PilotRouteList from './Jobs/PilotRouteSelect';
|
||||||
PilotRouteList(globalData);
|
PilotRouteList(globalData);
|
||||||
|
|
||||||
import gangwarHandle from './util/Gangwar';
|
|
||||||
gangwarHandle(globalData);
|
|
||||||
|
|
||||||
import weapondamageUtil from './util/weapondamage';
|
import weapondamageUtil from './util/weapondamage';
|
||||||
weapondamageUtil();
|
weapondamageUtil();
|
||||||
|
|
||||||
@@ -251,6 +248,7 @@ drivingschool(globalData);
|
|||||||
|
|
||||||
require('./Gui/policedepartment');
|
require('./Gui/policedepartment');
|
||||||
require('./Gui/helptext');
|
require('./Gui/helptext');
|
||||||
|
require('./util/Gangwar');
|
||||||
|
|
||||||
interface VehicleData {
|
interface VehicleData {
|
||||||
EngineState: boolean;
|
EngineState: boolean;
|
||||||
|
|||||||
@@ -1,596 +1,334 @@
|
|||||||
export default function gangwarHandle(globalData: IGlobalData) {
|
//GANGZONE EDITOR
|
||||||
function inside(point, vs) {
|
var gzEdit = false;
|
||||||
let x = point[0],
|
var editVisualHelpX = 0.5;
|
||||||
y = point[1];
|
var editVisualHelpY = 0.8;
|
||||||
let inside = false;
|
var pointCounter = -1;
|
||||||
for (let i = 0, j = vs.length - 1; i < vs.length; j = i++) {
|
var editorState = 0;
|
||||||
let xi = vs[i][0],
|
var gangZoneMidHeight;
|
||||||
yi = vs[i][1];
|
var helpScale = 0.1;
|
||||||
let xj = vs[j][0],
|
var editPoint = null;
|
||||||
yj = vs[j][1];
|
|
||||||
let intersect = ((yi > y) != (yj > y)) && (x < (xj - xi) * (y - yi) / (yj - yi) + xi);
|
|
||||||
if (intersect) inside = !inside;
|
|
||||||
}
|
|
||||||
return inside;
|
|
||||||
};
|
|
||||||
|
|
||||||
const Natives = {
|
var colorG = [0, 255, 0, 255];
|
||||||
SET_BLIP_CATEGORY: "0x234CDD44D996FD9A",
|
var colorR = [255, 0, 0, 255];
|
||||||
SHOW_HEADING_INDICATOR_ON_BLIP: "0x5FBCA48327B914DF",
|
var colorW = [255, 255, 255, 255];
|
||||||
SET_BLIP_AS_SHORT_RANGE: "0xBE8BE4FE60E27B72",
|
var colorY = [245, 229, 27, 255];
|
||||||
SET_BLIP_DISPLAY: "0x9029B2F3DA924928",
|
var pointColors = <any>[colorW, colorR, colorR, colorR];
|
||||||
SET_BLIP_SPRITE: "0xDF735600A4696DAF",
|
|
||||||
SET_BLIP_ALPHA: "0x45FF974EEE1C8734",
|
|
||||||
ADD_BLIP_FOR_RADIUS: "0x46818D79B1F7499A",
|
|
||||||
SET_BLIP_COLOUR: "0x03D7FB09E75D6B7E",
|
|
||||||
SET_BLIP_ROTATION: "0xF87683CDF73C3F6E",
|
|
||||||
SET_BLIP_FLASHES: "0xB14552383D39CE3E",
|
|
||||||
GET_FIRST_BLIP_INFO_ID: "0x1BEDE233E6CD2A1F",
|
|
||||||
GET_NEXT_BLIP_INFO_ID: "0x14F96AA50D6FBEA7",
|
|
||||||
DOES_BLIP_EXIST: "0xA6DB27D19ECBB7DA",
|
|
||||||
SET_BLIP_COORDS: "0xAE2AF67E9D9AF65D"
|
|
||||||
};
|
|
||||||
|
|
||||||
var Gangturf = class {
|
var gPoints; //Eckpunkte
|
||||||
name: string;
|
var gZoneBorders;
|
||||||
|
|
||||||
|
/*
|
||||||
|
class gPoint {
|
||||||
|
constructor(id: number, x: number, y: number) { }
|
||||||
id: number;
|
id: number;
|
||||||
range: number;
|
|
||||||
x: number;
|
x: number;
|
||||||
y: number;
|
y: number;
|
||||||
color: number;
|
}*/
|
||||||
colorZone_r: number;
|
|
||||||
colorZone_g: number;
|
|
||||||
colorZone_b: number;
|
|
||||||
rotation: number;
|
|
||||||
owner: string;
|
|
||||||
attacker: string;
|
|
||||||
blip: BlipMp;
|
|
||||||
_colshape: ColshapeMp;
|
|
||||||
_marker: MarkerMp;
|
|
||||||
vector: Vector3Mp;
|
|
||||||
value: number;
|
|
||||||
|
|
||||||
_status: string;
|
mp.events.add("SERVER:Load_Gangzone_Editor", () => {
|
||||||
_entered: boolean;
|
/*if (gzEdit == false) {
|
||||||
_isEntering: boolean;
|
|
||||||
_inColshape: boolean;
|
|
||||||
_timerCheck;
|
|
||||||
edit: boolean;
|
|
||||||
attackBlip: BlipMp;
|
|
||||||
leaderBlip: BlipMp;
|
|
||||||
leaderBlipVector: Vector3Mp;
|
|
||||||
leaderColShape: MarkerMp;
|
|
||||||
|
|
||||||
constructor(name, id, x, y, range, color, rot, owner, edit, vector, value) {
|
}*/
|
||||||
this._setup(name, id, x, y, range, color, rot, owner, edit, vector, value);
|
reloadGangZoneEditor();
|
||||||
}
|
});
|
||||||
|
|
||||||
_setup(name, id, x, y, range, color, rot, owner, edit, vector, value) {
|
function reloadGangZoneEditor() {
|
||||||
var self = this;
|
gzEdit = true;
|
||||||
self.name = name;
|
pointCounter = -1;
|
||||||
self.id = id;
|
gangZoneMidHeight = new mp.Vector3(0, 0, 0);
|
||||||
self.range = range;
|
pointColors = [colorW, colorR, colorR, colorR];
|
||||||
self.setColor(owner);
|
gPoints = new Array<Vector3Mp>();
|
||||||
self.x = x;
|
editorState = 0;
|
||||||
self.y = y;
|
editPoint = null;
|
||||||
self.rotation = rot;
|
gZoneBorders = new Array<number>();
|
||||||
self._colshape = null;
|
}
|
||||||
self._status = "normal";
|
|
||||||
self._entered = false;
|
|
||||||
self._isEntering = false;
|
|
||||||
self._inColshape = false;
|
|
||||||
self._timerCheck;
|
|
||||||
self.owner = owner;
|
|
||||||
self.attacker = null;
|
|
||||||
self.edit = edit;
|
|
||||||
self.loadArea();
|
|
||||||
self.attackBlip = null;
|
|
||||||
self.leaderBlip = null;
|
|
||||||
self.value = value;
|
|
||||||
if (vector != null) {
|
|
||||||
self.leaderBlipVector = JSON.parse(vector);
|
|
||||||
} else {
|
|
||||||
self.leaderBlipVector = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
self.leaderColShape = null;
|
//TASTE NUM5
|
||||||
|
mp.keys.bind(0x65, false, function () {
|
||||||
|
if (gzEdit) {
|
||||||
|
switch (editorState) {
|
||||||
|
case 0:
|
||||||
|
if (pointCounter < 0) { //Map-Höhe definieren
|
||||||
|
gangZoneMidHeight = mp.players.local.position;
|
||||||
|
} else { //Eckpunkte abspeichern
|
||||||
|
var newPoint = mp.players.local.position;
|
||||||
|
newPoint.z = gangZoneMidHeight.z;
|
||||||
|
gPoints.push(newPoint);
|
||||||
|
pointColors[pointCounter] = colorG;
|
||||||
|
pointColors[pointCounter + 1] = colorW;
|
||||||
}
|
}
|
||||||
|
pointCounter++;
|
||||||
|
if (pointCounter == 4) { //Alle Eckpunkte abgespeichert
|
||||||
|
editorState = 1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 1: //Bearbeiteten Punkt abspeichern
|
||||||
|
var newPoint = mp.players.local.position;
|
||||||
|
newPoint.z = gangZoneMidHeight.z;
|
||||||
|
gPoints[editPoint - 1] = newPoint;
|
||||||
|
pointColors[editPoint - 1] = colorG;
|
||||||
|
editPoint = null;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
setColor(owner) {
|
//NUM0
|
||||||
var self = this;
|
mp.keys.bind(0x60, false, function () {
|
||||||
if (owner === "Ballas") {
|
if (gzEdit && editorState == 1 && editPoint == null) {
|
||||||
self.color = 83;
|
reloadGangZoneEditor();
|
||||||
self.colorZone_r = 143;
|
gzEdit = false;
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
scoreUpdate(attackerScore, defenderScore) {
|
|
||||||
mp.gui.chat.push(this.owner + " " + defenderScore + " : " + attackerScore + " " + this.attacker);
|
|
||||||
}
|
|
||||||
|
|
||||||
loadArea() {
|
//NUM1
|
||||||
var self = this;
|
mp.keys.bind(0x61, false, function () {
|
||||||
self.blip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, self.range);
|
if (gzEdit && editorState == 1) {
|
||||||
|
editPoint = 1;
|
||||||
|
pointColors[0] = colorY;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.blip, 5);
|
//NUM2
|
||||||
mp.game.invoke(Natives.SET_BLIP_ALPHA, self.blip, 70);
|
mp.keys.bind(0x62, false, function () {
|
||||||
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
if (gzEdit && editorState == 1) {
|
||||||
|
editPoint = 2;
|
||||||
|
pointColors[1] = colorY;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
self._colshape = mp.colshapes.newCircle(self.x, self.y, self.range * 1.5);
|
//NUM3
|
||||||
|
mp.keys.bind(0x63, false, function () {
|
||||||
|
if (gzEdit && editorState == 1) {
|
||||||
|
editPoint = 3;
|
||||||
|
pointColors[2] = colorY;
|
||||||
}
|
}
|
||||||
render() {
|
});
|
||||||
var self = this;
|
|
||||||
if (self._colshape) {
|
|
||||||
if (self.edit == true) {
|
|
||||||
let vector3 = mp.players.local.getRotation(2);
|
|
||||||
self.rotation = Math.round(vector3.z);
|
|
||||||
//self.blip.setPosition(mp.players.local.position.x, mp.players.local.position.y, 1);
|
|
||||||
|
|
||||||
mp.game.invoke(Natives.SET_BLIP_COORDS, self.blip, mp.players.local.position.x, mp.players.local.position.y, 1);
|
//NUM4
|
||||||
self.x = mp.players.local.position.x;
|
mp.keys.bind(0x64, false, function () {
|
||||||
self.y = mp.players.local.position.y;
|
if (gzEdit && editorState == 1) {
|
||||||
}
|
editPoint = 4;
|
||||||
//self.blip.setRotation(self.rotation);
|
pointColors[3] = colorY;
|
||||||
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
//NUM7
|
||||||
|
mp.keys.bind(0x67, false, function () {
|
||||||
|
if (gzEdit && editorState == 2) {
|
||||||
|
|
||||||
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);
|
|
||||||
let top_right = {
|
|
||||||
x: self.x + range * Math.cos(degrees),
|
|
||||||
y: self.y + range * Math.sin(degrees)
|
|
||||||
}
|
}
|
||||||
degrees = (self.rotation + 135) * (Math.PI / 180);
|
});
|
||||||
let top_left = {
|
|
||||||
x: self.x + range * Math.cos(degrees),
|
|
||||||
y: self.y + range * Math.sin(degrees)
|
//NUM9
|
||||||
}
|
mp.keys.bind(0x69, false, function () {
|
||||||
degrees = (self.rotation + 225) * (Math.PI / 180);
|
if (gzEdit && editorState == 2) {
|
||||||
let bottom_left = {
|
|
||||||
x: self.x + range * Math.cos(degrees),
|
|
||||||
y: self.y + range * Math.sin(degrees)
|
|
||||||
}
|
|
||||||
degrees = (self.rotation + 315) * (Math.PI / 180);
|
|
||||||
let bottom_right = {
|
|
||||||
x: self.x + range * Math.cos(degrees),
|
|
||||||
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);
|
|
||||||
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
|
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function squarItUp() {
|
||||||
|
|
||||||
|
/* A B
|
||||||
|
*
|
||||||
|
* D C
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
var A = gPoints[0];
|
||||||
|
var B = gPoints[1];
|
||||||
|
var C = gPoints[2];
|
||||||
|
var D = gPoints[3];
|
||||||
|
|
||||||
|
var distAB = A - B;
|
||||||
|
var distBC = B - C;
|
||||||
|
var distCD = C - D;
|
||||||
|
var distDA = D - A;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
mp.events.add("render", () => {
|
||||||
|
if (gzEdit) {
|
||||||
|
if (pointCounter >= 0) { //Wenn Y-Spielhöhe definiert wurde
|
||||||
|
renderVisualHelp(); //Onscreen Texte
|
||||||
|
renderVisualWorld(); //RealWorld Geometrie
|
||||||
|
} else { //Ansonsten Spielhöhe definieren
|
||||||
|
renderGangzonePreSetup();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (self.isInsideArea()) {
|
/*mp.game.graphics.drawText("GW-Edit DEBUG\n" +
|
||||||
mp.game.graphics.drawText(self.name, [self.x, self.y, mp.players.local.position.z + 20], {
|
"editorState: " + editorState + "\n" +
|
||||||
font: 7,
|
"pointCounter: " + pointCounter + "\n"
|
||||||
color: [255, 255, 255, 185],
|
, [editVisualHelpX, 0.1],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: [255, 255, 255, 255],
|
||||||
|
scale: [0.3, 0.3],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
*/
|
||||||
|
});
|
||||||
|
|
||||||
|
function renderVisualHelp() {
|
||||||
|
if (gzEdit == true) {
|
||||||
|
if (editorState == 0) {
|
||||||
|
//Visualisierungshilfe zum erstelln von Gangzonen
|
||||||
|
mp.game.graphics.drawText("Speicher bitte Punkt ~y~" + (pointCounter + 1) + "~s~ ab. Taste ~g~NUM-5", [editVisualHelpX, editVisualHelpY],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: [255, 255, 255, 255],
|
||||||
|
scale: [0.3, 0.3],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.game.graphics.drawRect(editVisualHelpX, editVisualHelpY, helpScale * 2, helpScale * 2, 255, 255, 255, 150);
|
||||||
|
mp.game.graphics.drawText("1", [editVisualHelpX - helpScale, editVisualHelpY - helpScale - 0.025],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: pointColors[0],
|
||||||
scale: [0.4, 0.4],
|
scale: [0.4, 0.4],
|
||||||
outline: true,
|
outline: true,
|
||||||
centre: true
|
centre: false
|
||||||
});
|
});
|
||||||
}
|
|
||||||
}
|
mp.game.graphics.drawText("2", [editVisualHelpX + helpScale, editVisualHelpY - helpScale - 0.025],
|
||||||
}
|
{
|
||||||
if (self.leaderBlipVector != null) {
|
font: 0,
|
||||||
let dist = mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, mp.players.local.position.z, self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z, false);
|
color: pointColors[1],
|
||||||
if (self.isInsideArea() && self._status != "attack" && dist <= 6) {
|
|
||||||
if (self.leaderBlipVector != null) {
|
|
||||||
mp.game.graphics.drawText(self.name + "\n~y~Gang: ~s~" + self.owner + "\n~y~Wert: ~s~$~g~" + self.value, [self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z], {
|
|
||||||
font: 7,
|
|
||||||
color: [255, 255, 255, 185],
|
|
||||||
scale: [0.4, 0.4],
|
scale: [0.4, 0.4],
|
||||||
outline: true,
|
outline: true,
|
||||||
centre: true
|
centre: false
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.game.graphics.drawText("3", [editVisualHelpX + helpScale, editVisualHelpY + helpScale],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: pointColors[2],
|
||||||
|
scale: [0.4, 0.4],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.game.graphics.drawText("4", [editVisualHelpX - helpScale, editVisualHelpY + helpScale],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: pointColors[3],
|
||||||
|
scale: [0.4, 0.4],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
} else if (editorState == 1) {
|
||||||
|
if (editPoint == null) {
|
||||||
|
mp.game.graphics.drawText("Welchen Eckpunkt möchtest du bearbeiten? \nDrücke ~g~NUM1-4\n"+
|
||||||
|
"~s~Oder drücke ~g~NUM-0 ~s~ zum Beenden", [editVisualHelpX, editVisualHelpY],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: [255, 255, 255, 255],
|
||||||
|
scale: [0.3, 0.3],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
mp.game.graphics.drawRect(editVisualHelpX, editVisualHelpY, helpScale * 2, helpScale * 2, 255, 255, 255, 150);
|
||||||
|
mp.game.graphics.drawText("1", [editVisualHelpX - helpScale, editVisualHelpY - helpScale - 0.025],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: pointColors[0],
|
||||||
|
scale: [0.4, 0.4],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.game.graphics.drawText("2", [editVisualHelpX + helpScale, editVisualHelpY - helpScale - 0.025],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: pointColors[1],
|
||||||
|
scale: [0.4, 0.4],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.game.graphics.drawText("3", [editVisualHelpX + helpScale, editVisualHelpY + helpScale],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: pointColors[2],
|
||||||
|
scale: [0.4, 0.4],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.game.graphics.drawText("4", [editVisualHelpX - helpScale, editVisualHelpY + helpScale],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: pointColors[3],
|
||||||
|
scale: [0.4, 0.4],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
mp.game.graphics.drawText("Du bearbeitest Eckpunkt ~y~" + editPoint + "~s~. Zum Speichern ~g~NUM-5", [editVisualHelpX, editVisualHelpY],
|
||||||
|
{
|
||||||
|
font: 0,
|
||||||
|
color: [255, 255, 255, 255],
|
||||||
|
scale: [0.3, 0.3],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function renderVisualWorld() {
|
||||||
|
var playerPosition = mp.players.local.position;
|
||||||
|
|
||||||
|
if (pointCounter >= 1 && pointCounter < 4) {
|
||||||
|
mp.game.graphics.drawLine(gPoints[pointCounter - 1].x, gPoints[pointCounter - 1].y, gangZoneMidHeight.z, playerPosition.x, playerPosition.y, playerPosition.z, 255, 0, 0, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
startGangWar() {
|
if (pointCounter > 1) mp.game.graphics.drawLine(gPoints[0].x, gPoints[0].y, gangZoneMidHeight.z, gPoints[1].x, gPoints[1].y, gangZoneMidHeight.z, 0, 255, 0, 200);
|
||||||
var self = this;
|
if (pointCounter > 2) mp.game.graphics.drawLine(gPoints[1].x, gPoints[1].y, gangZoneMidHeight.z, gPoints[2].x, gPoints[2].y, gangZoneMidHeight.z, 0, 255, 0, 200);
|
||||||
if (self._status == "normal") {
|
if (pointCounter > 3) {
|
||||||
let dist = mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, 0, self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z, false);
|
mp.game.graphics.drawLine(gPoints[2].x, gPoints[2].y, gangZoneMidHeight.z, gPoints[3].x, gPoints[3].y, gangZoneMidHeight.z, 0, 255, 0, 200);
|
||||||
if (dist <= 3) {
|
mp.game.graphics.drawLine(gPoints[3].x, gPoints[3].y, gangZoneMidHeight.z, gPoints[0].x, gPoints[0].y, gangZoneMidHeight.z, 0, 255, 0, 200);
|
||||||
mp.events.callRemote("SERVER:StartGangwar");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
updateArea(status, ...args) {
|
if (editorState == 1 && editPoint != null) {
|
||||||
var self = this;
|
mp.game.graphics.drawLine(gPoints[editPoint - 1].x, gPoints[editPoint - 1].y, gangZoneMidHeight.z, playerPosition.x, playerPosition.y, playerPosition.z, 255, 0, 0, 200);
|
||||||
if (status == "attack") {
|
|
||||||
if (self.leaderColShape != null) {
|
|
||||||
self.leaderColShape.destroy();
|
|
||||||
self.leaderColShape = null;
|
|
||||||
}
|
|
||||||
self._status = "attack";
|
|
||||||
self.attacker = args[1];
|
|
||||||
//self.blip.setFlashes(true);
|
|
||||||
//mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (status == "normal") {
|
|
||||||
self._status = "normal";
|
|
||||||
//self.blip.setFlashes(false);
|
|
||||||
//mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (status == "conquered") {
|
|
||||||
//mp.game.graphics.stopScreenEffect("MinigameTransitionIn");
|
|
||||||
self._status = "normal";
|
|
||||||
self.owner = args[0];
|
|
||||||
self.attacker = null;
|
|
||||||
//self.blip.setFlashes(false);
|
|
||||||
//mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
|
|
||||||
|
|
||||||
self.setColor(self.owner)
|
|
||||||
self.blip.setColour(self.color)
|
|
||||||
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
|
||||||
self.setLeaderColShape();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setAttackBlip(bool) {
|
//QUADER
|
||||||
var self = this;
|
/*
|
||||||
if (bool) {
|
if (pointCounter > 3) {
|
||||||
self.attackBlip = mp.game.ui.addBlipForCoord(self.x, self.y, 0);
|
for (var x = 0; x < 4; x++) {
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 378);
|
var newPoint = gPoints[0];
|
||||||
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.attackBlip, false);
|
newPoint.z += 5.0;
|
||||||
} else if (!bool) {
|
gPoints.push(newPoint);
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 5);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
setLeaderBlip(bool) {
|
for (var v = 4; v < 8; v++) { //Verdrahtung horizontal
|
||||||
var self = this;
|
if (v < 7) {
|
||||||
if (this.leaderColShape != null) {
|
mp.game.graphics.drawLine(gPoints[v].x, gPoints[v].y, gPoints[v].z, gPoints[v + 1].x, gPoints[v + 1].y, gPoints[v + 1].z, 0, 255, 0, 200);
|
||||||
this.leaderColShape.destroy();
|
} else {
|
||||||
this.leaderColShape = null;
|
mp.game.graphics.drawLine(gPoints[v].x, gPoints[v].y, gPoints[v].z, gPoints[4].x, gPoints[4].y, gPoints[4].z, 0, 255, 0, 200);
|
||||||
}
|
}
|
||||||
if (bool) {
|
mp.game.graphics.drawLine(gPoints[v].x, gPoints[v].y, gPoints[v].z, gPoints[v-4].x, gPoints[v-4].y, gPoints[v-4].z, 0, 255, 0, 200); //Verdrahtung Vertikal
|
||||||
self.leaderBlipVector = mp.players.local.position;
|
|
||||||
mp.events.callRemote("SERVER:Turf_SetNewLeaderPoint", JSON.stringify(self.leaderBlipVector), JSON.stringify(self.id));
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
}*/
|
||||||
|
}
|
||||||
|
|
||||||
if (self.leaderBlipVector != null) {
|
function renderGangzonePreSetup() {
|
||||||
self.leaderBlip = mp.game.ui.addBlipForRadius(self.leaderBlipVector.x, self.leaderBlipVector.y, 1, 60);
|
mp.game.graphics.drawText("Stelle dich ungefähr in die Mitte der Gangzone um die Z-Koordinatenhöhe zu berechnen und drücke ~y~NUM5", [editVisualHelpX, editVisualHelpY - 0.05],
|
||||||
self.setLeaderColShape();
|
{
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.leaderBlip, 437);
|
font: 0,
|
||||||
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.leaderBlip, false);
|
color: [255,255,255,255],
|
||||||
}
|
scale: [0.3, 0.3],
|
||||||
}
|
outline: true,
|
||||||
|
centre: false
|
||||||
setLeaderColShape() {
|
|
||||||
var self = this;
|
|
||||||
let newVector = new mp.Vector3(self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z - 2)
|
|
||||||
|
|
||||||
self.leaderColShape = mp.markers.new(1, newVector, 2, {
|
|
||||||
color: [255, 255, 0, 150],
|
|
||||||
visible: true,
|
|
||||||
dimension: 0
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
isTurfArea(shape) {
|
|
||||||
return (shape == this._colshape)
|
|
||||||
}
|
|
||||||
|
|
||||||
isOwner(gang) {
|
|
||||||
return (gang == this.owner)
|
|
||||||
}
|
|
||||||
|
|
||||||
check() {
|
|
||||||
var self = this
|
|
||||||
if (self._entered == true) {
|
|
||||||
if (!self.isInsideArea() || (self.isNearGround() == false)) {
|
|
||||||
self._entered = false;
|
|
||||||
mp.events.callRemote("Gangarea:Leave", self.id);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
enter() {
|
|
||||||
var self = this;
|
|
||||||
self._timerCheck = setInterval(function () {
|
|
||||||
if ((!self._entered)) {
|
|
||||||
if (self.isInsideArea() && (self.isNearGround() == true)) {
|
|
||||||
self._entered = true;
|
|
||||||
if (self._status == "attack") {
|
|
||||||
mp.game.audio.playSoundFrontend(1, "Enter_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds", true);
|
|
||||||
//mp.game.graphics.stopScreenEffect("MinigameTransitionIn");
|
|
||||||
//mp.game.graphics.startScreenEffect("MinigameTransitionOut", 500, false);
|
|
||||||
}
|
|
||||||
mp.events.callRemote("Gangarea:Enter", JSON.stringify(self.id));
|
|
||||||
}
|
|
||||||
} else if (self._entered == true) {
|
|
||||||
if (!self.isInsideArea() || (self.isNearGround() == false)) {
|
|
||||||
self._entered = false;
|
|
||||||
if (self._status === "attack") {
|
|
||||||
mp.game.audio.playSoundFrontend(1, "Exit_Capture_Zone", "DLC_Apartments_Drop_Zone_Sounds", true);
|
|
||||||
//mp.game.graphics.startScreenEffect("MinigameTransitionIn", 500, false);
|
|
||||||
}
|
|
||||||
mp.events.callRemote("Gangarea:Leave", JSON.stringify(self.id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 1000);
|
|
||||||
}
|
|
||||||
|
|
||||||
leave() {
|
|
||||||
var self = this;
|
|
||||||
clearInterval(self._timerCheck);
|
|
||||||
|
|
||||||
self.check();
|
|
||||||
}
|
|
||||||
isNearGround() {
|
|
||||||
let self = this;
|
|
||||||
let ground = mp.game.gameplay.getGroundZFor3dCoord(self.x, self.y, 9000, 0, false);
|
|
||||||
let max_diff = 75;
|
|
||||||
let dist = mp.game.system.vdist(0, 0, ground, 0, 0, mp.players.local.position.z);
|
|
||||||
if (dist <= max_diff) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
isInsideArea() {
|
|
||||||
var self = this;
|
|
||||||
let player = {
|
|
||||||
x: mp.players.local.position.x,
|
|
||||||
y: mp.players.local.position.y,
|
|
||||||
z: mp.players.local.position.z
|
|
||||||
};
|
|
||||||
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);
|
|
||||||
let top_right = {
|
|
||||||
x: self.x + range * Math.cos(degrees),
|
|
||||||
y: self.y + range * Math.sin(degrees)
|
|
||||||
}
|
|
||||||
degrees = (self.rotation + 135) * (Math.PI / 180);
|
|
||||||
let top_left = {
|
|
||||||
x: self.x + range * Math.cos(degrees),
|
|
||||||
y: self.y + range * Math.sin(degrees)
|
|
||||||
}
|
|
||||||
degrees = (self.rotation + 225) * (Math.PI / 180);
|
|
||||||
let bottom_left = {
|
|
||||||
x: self.x + range * Math.cos(degrees),
|
|
||||||
y: self.y + range * Math.sin(degrees)
|
|
||||||
}
|
|
||||||
degrees = (self.rotation + 315) * (Math.PI / 180);
|
|
||||||
let bottom_right = {
|
|
||||||
x: self.x + range * Math.cos(degrees),
|
|
||||||
y: self.y + range * Math.sin(degrees)
|
|
||||||
}
|
|
||||||
let turf = [
|
|
||||||
[top_right.x, top_right.y],
|
|
||||||
[top_left.x, top_left.y],
|
|
||||||
[bottom_left.x, bottom_left.y],
|
|
||||||
[bottom_right.x, bottom_right.y]
|
|
||||||
]
|
|
||||||
if (inside([player.x, player.y], turf)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
setValue(value) {
|
|
||||||
var self = this;
|
|
||||||
self.value = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
var gangturfs = [];
|
|
||||||
|
|
||||||
mp.events.add('playerEnterColshape', (shape) => {
|
|
||||||
let turfEntered;
|
|
||||||
gangturfs.forEach(function (turf) {
|
|
||||||
if (turf.isTurfArea(shape) == true) {
|
|
||||||
turfEntered = turf;
|
|
||||||
turfEntered.enter()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
mp.events.add('playerExitColshape', (shape) => {
|
|
||||||
let turfExitted;
|
|
||||||
gangturfs.forEach(function (turf) {
|
|
||||||
if (turf.isTurfArea(shape) == true) {
|
|
||||||
turfExitted = turf;
|
|
||||||
turfExitted.leave()
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
mp.events.add('render', () => {
|
|
||||||
gangturfs.forEach(function (turf, id) {
|
|
||||||
turf.render();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
mp.events.add('CLIENT:loose', () => {
|
|
||||||
mp.game.audio.playSoundFrontend(1, "Zone_Enemy_Capture", "DLC_Apartments_Drop_Zone_Sounds", true);
|
|
||||||
});
|
|
||||||
mp.events.add('CLIENT:win', () => {
|
|
||||||
mp.game.audio.playSoundFrontend(1, "Zone_Team_Capture", "DLC_Apartments_Drop_Zone_Sounds", true);
|
|
||||||
});
|
|
||||||
|
|
||||||
function clearBlips() {
|
|
||||||
mp.game.gameplay.setThisScriptCanRemoveBlipsCreatedByAnyScript(true);
|
|
||||||
var x = 0;
|
|
||||||
var y = 0;
|
|
||||||
var z = 0;
|
|
||||||
let last_blip = mp.game.invoke(Natives.GET_FIRST_BLIP_INFO_ID, 5);
|
|
||||||
|
|
||||||
while (mp.game.invoke(Natives.DOES_BLIP_EXIST, last_blip)) {
|
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, last_blip, -1);
|
|
||||||
mp.game.ui.removeBlip(last_blip);
|
|
||||||
last_blip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 5);
|
|
||||||
x++;
|
|
||||||
}
|
|
||||||
|
|
||||||
let last_attackBlip = mp.game.invoke(Natives.GET_FIRST_BLIP_INFO_ID, 378);
|
|
||||||
while (mp.game.invoke(Natives.DOES_BLIP_EXIST, last_attackBlip)) {
|
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, last_attackBlip, -1);
|
|
||||||
mp.game.ui.removeBlip(last_attackBlip);
|
|
||||||
last_attackBlip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 378);
|
|
||||||
y++
|
|
||||||
}
|
|
||||||
|
|
||||||
let last_leaderBlip = mp.game.invoke(Natives.GET_FIRST_BLIP_INFO_ID, 437);
|
|
||||||
while (mp.game.invoke(Natives.DOES_BLIP_EXIST, last_leaderBlip)) {
|
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, last_leaderBlip, -1);
|
|
||||||
mp.game.ui.removeBlip(last_leaderBlip);
|
|
||||||
last_leaderBlip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 437);
|
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, last_attackBlip, -1);
|
|
||||||
mp.game.ui.removeBlip(last_attackBlip);
|
|
||||||
last_attackBlip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 378);
|
|
||||||
y++
|
|
||||||
z++
|
|
||||||
|
|
||||||
}
|
|
||||||
mp.gui.chat.push("DEBUG: Turf blips not removed: " + x);
|
|
||||||
mp.gui.chat.push("DEBUG: Attack blips not removed: " + y);
|
|
||||||
mp.gui.chat.push("DEBUG: LeaderBlips blips not removed: " + z);
|
|
||||||
}
|
|
||||||
|
|
||||||
mp.events.add('GangAreas:Create', (turfsJSON) => {
|
|
||||||
var turfs = JSON.parse(turfsJSON);
|
|
||||||
if (gangturfs.length > 0) {
|
|
||||||
gangturfs[gangturfs.length - 1].edit = false;
|
|
||||||
gangturfs.forEach(function (turf) {
|
|
||||||
turf._status = "disabled";
|
|
||||||
turf.id = -420; //Due to garbage collecting this value needs to be negative, so that the Server doesn't find multiple Turfs in the Database with same ID's.
|
|
||||||
if (turf.leaderColShape != null) {
|
|
||||||
turf.leaderColShape.destroy();
|
|
||||||
turf.leaderColShape = null;
|
|
||||||
}
|
|
||||||
if (turf._marker)
|
|
||||||
if (turf.blip != null) {
|
|
||||||
mp.game.ui.removeBlip(turf.blip);
|
|
||||||
}
|
|
||||||
if (turf.leaderBlip != null) {
|
|
||||||
mp.game.ui.removeBlip(turf.leaderBlip);
|
|
||||||
}
|
|
||||||
if (turf.attackBlip != null) {
|
|
||||||
mp.game.ui.removeBlip(turf.attackBlip);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
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, false, turf.Vector, turf.Value);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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, null, 0);
|
|
||||||
});
|
|
||||||
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
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:setAttackBlip', (bool, id) => {
|
|
||||||
gangturfs.forEach(function (turf) {
|
|
||||||
if (turf.id == id) {
|
|
||||||
turf.setAttackBlip(bool);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
mp.events.add('CLIENT:Turf_LoadLeaderBlip', () => {
|
|
||||||
gangturfs.forEach(function (turf) {
|
|
||||||
turf.setLeaderBlip(false);
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
mp.events.add('ADMIN:Turf_CreateLeaderBlip', () => {
|
|
||||||
gangturfs.forEach(function (turf) {
|
|
||||||
if (turf._entered == true) {
|
|
||||||
turf.setLeaderBlip(true);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
mp.events.add('CLIENT:StartGangwar', () => {
|
|
||||||
gangturfs.forEach(function (turf) {
|
|
||||||
if (turf._entered == true) {
|
|
||||||
turf.startGangWar();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
});
|
|
||||||
|
|
||||||
mp.events.add('CLIENT:UpdateTurfValue', (jsonValues) => {
|
|
||||||
let values = JSON.parse(jsonValues);
|
|
||||||
for (var i = 0; i < gangturfs.length; i++) {
|
|
||||||
let turf = gangturfs[i];
|
|
||||||
turf.setValue(values[i]);
|
|
||||||
turf.render();
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -3464,73 +3464,23 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
player.SendChatMessage("~m~Benutzung:~s~ /business [price] [Option]");
|
player.SendChatMessage("~m~Benutzung:~s~ /business [price] [Option]");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("createturf", "~m~Benutzung:~s~ /createturf [radius]")]
|
[Command("creategangzone", "~m~Benutzung:~s~ /creategangzone")]
|
||||||
public void CmdAdmCreateTurf(Player player, float option)
|
public void CmdAdminCreateGangZone(Player player)
|
||||||
{
|
{
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||||
{
|
{
|
||||||
ChatService.NotAuthorized(player);
|
ChatService.NotAuthorized(player);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.TriggerEvent("ADMIN:CreateTurf", JsonConvert.SerializeObject(option));
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("setturf", "~m~Benutzung:~s~ /setturf (Name)")]
|
if (player.GetData<bool>("editmode") == false)
|
||||||
public void CmdAdmSetTurf(Player player, string name)
|
|
||||||
{
|
{
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
ChatService.SendMessage(player, "Bitte vorher den Edit-Mode aktivieren");
|
||||||
{
|
|
||||||
ChatService.NotAuthorized(player);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
player.TriggerEvent("ADMIN:SetTurf", name);
|
player.SendNotification("Gangzone-Editor aktiviert");
|
||||||
|
player.TriggerEvent("SERVER:Load_Gangzone_Editor");
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("cancleturf", "~m~Benutzung:~s~ /cancleturf")]
|
|
||||||
public void CmdAdmCancleTurf(Player player)
|
|
||||||
{
|
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
|
||||||
{
|
|
||||||
ChatService.NotAuthorized(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Gangwar.Gangwar.loadPlayer(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("reloadturfs", "~m~Benutzung:~s~ /ReloadTurfs")]
|
|
||||||
public void CmdAdmReloadTurf(Player player)
|
|
||||||
{
|
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
|
||||||
{
|
|
||||||
ChatService.NotAuthorized(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
Gangwar.Gangwar.loadTurfs();
|
|
||||||
Gangwar.Gangwar.loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("deleteturf", "~m~Benutzung:~s~ /DeleteTurfs")]
|
|
||||||
public void CmdAdmDeleteTurf(Player player)
|
|
||||||
{
|
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
|
||||||
{
|
|
||||||
ChatService.NotAuthorized(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.TriggerEvent("ADMIN:DeleteTurf");
|
|
||||||
}
|
|
||||||
|
|
||||||
[Command("setturfpoint", "~m~Benutzung:~s~ /setturfpoint")]
|
|
||||||
public void CmdAdmSetTurfPoint(Player player)
|
|
||||||
{
|
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
|
||||||
{
|
|
||||||
ChatService.NotAuthorized(player);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
player.TriggerEvent("ADMIN:Turf_CreateLeaderBlip");
|
|
||||||
}
|
|
||||||
|
|
||||||
#endregion ALevel1337
|
#endregion ALevel1337
|
||||||
|
|
||||||
#region ALevel1338
|
#region ALevel1338
|
||||||
|
|||||||
@@ -369,7 +369,7 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
target.Health = 100;
|
target.Health = 100;
|
||||||
target.SendNotification($"Du wurdest von ~g~{player.Name} ~s~ für ~g~{price.ToMoneyString()} geheilt.", false);
|
target.SendNotification($"Du wurdest von ~g~{player.Name} ~s~ für ~g~{price.ToMoneyString()} geheilt.", false);
|
||||||
player.SendNotification($"Du hast ~g~{target.Name} ~s~ für {price.ToMoneyString()} geheilt.", false);
|
player.SendNotification($"Du hast ~g~{target.Name} ~s~ für {price.ToMoneyString()} geheilt.", false);
|
||||||
player.TriggerEvent("delHealTask");
|
Medic.delHealTask(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion Sanitäter Commands
|
#endregion Sanitäter Commands
|
||||||
|
|||||||
@@ -75,10 +75,10 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
killerPosY = killer.Position.Y;
|
killerPosY = killer.Position.Y;
|
||||||
killerPosZ = killer.Position.Z;
|
killerPosZ = killer.Position.Z;
|
||||||
killerHeading = killer.Heading;
|
killerHeading = killer.Heading;
|
||||||
if (player.HasData("inGangWar") && killer.HasData("inGangWar"))
|
/*if (player.HasData("inGangWar") && killer.HasData("inGangWar"))
|
||||||
{
|
{
|
||||||
Gangwar.Gangwar.GangwarKill(killer, player);
|
Gangwar.Gangwar.GangwarKill(killer, player);
|
||||||
}
|
}*/
|
||||||
|
|
||||||
if (player != killer)
|
if (player != killer)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
player.SetData("duty", false);
|
player.SetData("duty", false);
|
||||||
player.SetData("Adminduty", false);
|
player.SetData("Adminduty", false);
|
||||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||||
Gangwar.Gangwar.loadPlayer(player);
|
//Gangwar.Gangwar.loadPlayer(player);
|
||||||
if (user.FactionLeader)
|
if (user.FactionLeader)
|
||||||
{
|
{
|
||||||
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||||
|
|||||||
@@ -130,6 +130,14 @@ namespace ReallifeGamemode.Server.Factions.Medic
|
|||||||
player.SetData("healauftrag", false);
|
player.SetData("healauftrag", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[RemoteEvent("delHealTaskAsMedic")]
|
||||||
|
public static void delHealTaskAsMedic(Player player, string victimName)
|
||||||
|
{
|
||||||
|
MedicTask task = HealTasks.FirstOrDefault(t => t.Victim == victimName);
|
||||||
|
RemoveTaskFromList(task);
|
||||||
|
player.SetData("healauftrag", false);
|
||||||
|
}
|
||||||
|
|
||||||
[RemoteEvent("delReviveTask")]
|
[RemoteEvent("delReviveTask")]
|
||||||
public static void delReviveTask(Player player)
|
public static void delReviveTask(Player player)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -11,219 +11,6 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
{
|
{
|
||||||
public class Gangwar : Script
|
public class Gangwar : Script
|
||||||
{
|
{
|
||||||
public static Turf[] _loadedTurfs;
|
|
||||||
private static List<Turfs> turfs;
|
|
||||||
|
|
||||||
public static void loadTurfs()
|
|
||||||
{
|
|
||||||
_loadedTurfs = null;
|
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
turfs = context.Turfs.Select(t => t).ToList();
|
|
||||||
List<Turf> turfing = new List<Turf>();
|
|
||||||
foreach (var t in turfs)
|
|
||||||
{
|
|
||||||
Turf newTurf = new Turf(t.Id, t.Name, t.Color, t.Owner, t.Value, t.MaxValue, t.Surplus);
|
|
||||||
turfing.Add(newTurf);
|
|
||||||
}
|
|
||||||
_loadedTurfs = turfing.ToArray();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadPlayer(Player client)
|
|
||||||
{
|
|
||||||
client.TriggerEvent("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void loadTurfs_ToAllPlayers()
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
|
||||||
foreach (var l in NAPI.Pools.GetAllPlayers())
|
|
||||||
{
|
|
||||||
if (!l.IsLoggedIn() && !l.GetUser().FactionLeader)
|
|
||||||
return;
|
|
||||||
|
|
||||||
l.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void GangwarKill(Player killer, Player victim)
|
|
||||||
{
|
|
||||||
if (killer.HasData("GotInsideOfTurf") && victim.HasData("GotInsideOfTurf"))
|
|
||||||
{
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if (turf.getId() == victim.GetData<int>("inGangWar"))
|
|
||||||
{
|
|
||||||
turf.setKill(victim.GetUser().Faction.Name);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static Turf[] getTurfs()
|
|
||||||
{
|
|
||||||
return _loadedTurfs;
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("Gangarea:Enter")]
|
|
||||||
public void RmtEvent_TurfEnter(Player client, string jsonId)
|
|
||||||
{
|
|
||||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
|
||||||
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if (turf.getId() == id)
|
|
||||||
{
|
|
||||||
turf.enter(client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("Gangarea:Leave")]
|
|
||||||
public void RmtEvent_TurfLeave(Player client, string jsonId)
|
|
||||||
{
|
|
||||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
|
||||||
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if (turf.getId() == id)
|
|
||||||
{
|
|
||||||
turf.leave(client);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:SetTurf")]
|
|
||||||
public void RmtEvent_SetTurf(Player client, string jsonX, string jsonY, string jsonRot, string jsonRange, string Name)
|
|
||||||
{
|
|
||||||
float pX = JsonConvert.DeserializeObject<float>(jsonX);
|
|
||||||
float pY = (float)JsonConvert.DeserializeObject<float>(jsonY);
|
|
||||||
float Rot = (float)JsonConvert.DeserializeObject<float>(jsonRot);
|
|
||||||
float Range = (float)JsonConvert.DeserializeObject<float>(jsonRange);
|
|
||||||
|
|
||||||
var newTurf = new Turfs
|
|
||||||
{
|
|
||||||
Name = Name,
|
|
||||||
X = pX,
|
|
||||||
Y = pY,
|
|
||||||
Rotation = Rot,
|
|
||||||
Range = Range,
|
|
||||||
Owner = "Neutral",
|
|
||||||
Color = 0,
|
|
||||||
Vector = null
|
|
||||||
};
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
dbContext.Turfs.Add(newTurf);
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
loadTurfs();
|
|
||||||
loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:DeleteTurf")]
|
|
||||||
public void RmtEvent_DeleteTurf(Player client, string jsonId)
|
|
||||||
{
|
|
||||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
|
||||||
if (id == -1)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
|
||||||
if (dturf != null)
|
|
||||||
{
|
|
||||||
dbContext.Turfs.Remove(dturf);
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
loadTurfs();
|
|
||||||
loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
|
|
||||||
public void RmtEvent_SetNewLeaderPoint(Player client, string vector, string jsonId)
|
|
||||||
{
|
|
||||||
int id = JsonConvert.DeserializeObject<int>(jsonId);
|
|
||||||
if (id == -1)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(client, "Du befindest dich in keinem Gebiet");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
Turfs dturf = dbContext.Turfs.Where(t => t.Id == id).FirstOrDefault();
|
|
||||||
if (dturf != null)
|
|
||||||
{
|
|
||||||
dturf.Vector = vector;
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
loadTurfs();
|
|
||||||
loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
[RemoteEvent("SERVER:StartGangwar")]
|
|
||||||
public void RmtEvent_StartGangwar(Player client)
|
|
||||||
{
|
|
||||||
if (!client.GetUser().FactionLeader)
|
|
||||||
return;
|
|
||||||
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if (turf.status == "attack")
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(client, "Du kannst momentan kein Gangwar starten");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (client.GetUser().Faction.Name == "Ballas" || client.GetUser().Faction.Name == "Grove")
|
|
||||||
{
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
foreach (var u in turf.playerInside)
|
|
||||||
{
|
|
||||||
if (u == client)
|
|
||||||
{
|
|
||||||
if (turf.Owner != client.GetUser().Faction.Name)
|
|
||||||
turf.attack(client.GetUser().Faction.Name);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void Value_TimerElapsed()
|
|
||||||
{
|
|
||||||
List<int> values = new List<int>();
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
foreach (var turf in getTurfs())
|
|
||||||
{
|
|
||||||
if ((turf.getValue() + 5) >= turf.getMaxValue())
|
|
||||||
{
|
|
||||||
turf.setValue(turf.getMaxValue());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
turf.addValue(5);
|
|
||||||
}
|
|
||||||
values.Add(turf.getValue());
|
|
||||||
Turfs _turf = dbContext.Turfs.Where(t => t.Id == turf.getId()).FirstOrDefault();
|
|
||||||
_turf.Value = turf.getValue();
|
|
||||||
}
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
NAPI.Task.Run(() =>
|
|
||||||
{
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:UpdateTurfValue", JsonConvert.SerializeObject(values.ToArray()));
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,339 +14,6 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
{
|
{
|
||||||
public class Turf
|
public class Turf
|
||||||
{
|
{
|
||||||
public int TurfID { get; set; }
|
|
||||||
public string TurfName { get; set; }
|
|
||||||
public int Color { get; set; }
|
|
||||||
public string Owner { get; set; }
|
|
||||||
public string Attacker { get; set; }
|
|
||||||
public int Att_Score { get; set; }
|
|
||||||
public int Def_Score { get; set; }
|
|
||||||
public string status { get; set; }
|
|
||||||
public int value { get; set; }
|
|
||||||
public int maxValue { get; set; }
|
|
||||||
public bool surplus { get; set; }
|
|
||||||
public List<Player> playerInside { get; set; }
|
|
||||||
public Timer timer { get; set; }
|
|
||||||
public Player[] playerInGangwar { get; set; }
|
|
||||||
public int timerCount;
|
|
||||||
|
|
||||||
public Turf(int TurfID, string TurfName, int color, string Owner, int value, int maxValue, bool surplus)
|
|
||||||
{
|
|
||||||
this.TurfID = TurfID;
|
|
||||||
this.TurfName = TurfName;
|
|
||||||
this.Color = color;
|
|
||||||
this.Owner = Owner;
|
|
||||||
this.value = value;
|
|
||||||
this.maxValue = maxValue;
|
|
||||||
this.surplus = surplus;
|
|
||||||
this.Attacker = null;
|
|
||||||
this.Att_Score = 1;
|
|
||||||
this.Def_Score = 0;
|
|
||||||
this.status = "normal";
|
|
||||||
this.timer = null;
|
|
||||||
this.playerInside = new List<Player>();
|
|
||||||
this.timerCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId()
|
|
||||||
{
|
|
||||||
return this.TurfID;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getValue()
|
|
||||||
{
|
|
||||||
return this.value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(int value)
|
|
||||||
{
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void addValue(int addedValue)
|
|
||||||
{
|
|
||||||
this.value += addedValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMaxValue()
|
|
||||||
{
|
|
||||||
return maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
public bool getSurplus()
|
|
||||||
{
|
|
||||||
return surplus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSurplus(bool surplus)
|
|
||||||
{
|
|
||||||
this.surplus = surplus;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getName()
|
|
||||||
{
|
|
||||||
return this.TurfName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getColor()
|
|
||||||
{
|
|
||||||
return this.Color;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getOwner()
|
|
||||||
{
|
|
||||||
return this.Owner;
|
|
||||||
}
|
|
||||||
|
|
||||||
public string getAttacker()
|
|
||||||
{
|
|
||||||
return this.Attacker;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void TurfTick()
|
|
||||||
{
|
|
||||||
this.timer = new System.Timers.Timer(1000);
|
|
||||||
|
|
||||||
this.timer.Elapsed += Tick;
|
|
||||||
this.timer.AutoReset = true;
|
|
||||||
this.timer.Enabled = true;
|
|
||||||
this.timerCount = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
|
||||||
{
|
|
||||||
if (this.status == "attack")
|
|
||||||
{
|
|
||||||
update();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void update()
|
|
||||||
{
|
|
||||||
#region Ticket system
|
|
||||||
|
|
||||||
/*
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Owner).ToArray();
|
|
||||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.GetUser().Faction.Name == this.Attacker).ToArray();
|
|
||||||
}catch(NullReferenceException ex)
|
|
||||||
{
|
|
||||||
int i = 0;
|
|
||||||
foreach(var c in playerInGangwar)
|
|
||||||
{
|
|
||||||
if (!NAPI.Entity.DoesEntityExist(c.Handle))
|
|
||||||
{
|
|
||||||
this.playerInside = this.playerInside.Where(gp => gp != c).ToArray();
|
|
||||||
}
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (owners.Length > attackers.Length)
|
|
||||||
this.Att_Score -= owners.Length - attackers.Length;
|
|
||||||
if(owners.Length < attackers.Length)
|
|
||||||
this.Def_Score -= attackers.Length - owners.Length;
|
|
||||||
*/
|
|
||||||
|
|
||||||
#endregion Ticket system
|
|
||||||
|
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score, 900 - timerCount);
|
|
||||||
}
|
|
||||||
if (this.Att_Score >= 200)
|
|
||||||
{
|
|
||||||
this.takeOver(this.Attacker);
|
|
||||||
}
|
|
||||||
else if (this.Def_Score >= 200)
|
|
||||||
{
|
|
||||||
this.takeOver(this.Owner);
|
|
||||||
}
|
|
||||||
timerCount += 1;
|
|
||||||
if (timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like
|
|
||||||
{
|
|
||||||
if (this.Att_Score > this.Def_Score)
|
|
||||||
{
|
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0, 0);
|
|
||||||
}
|
|
||||||
this.takeOver(this.Attacker);
|
|
||||||
this.Def_Score = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (this.Att_Score < this.Def_Score)
|
|
||||||
{
|
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0, 0);
|
|
||||||
}
|
|
||||||
this.takeOver(this.Owner);
|
|
||||||
this.Att_Score = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (this.Def_Score == this.Att_Score)
|
|
||||||
{
|
|
||||||
foreach (Player gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0, 0);
|
|
||||||
}
|
|
||||||
this.takeOver(this.Owner);
|
|
||||||
this.Def_Score = 0;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void enter(Player client)
|
|
||||||
{
|
|
||||||
if (this.status == "attack")
|
|
||||||
{
|
|
||||||
if (client.GetUser().Faction.Name != getOwner() && client.GetUser().Faction.Name != getAttacker())
|
|
||||||
return;
|
|
||||||
Player gPlayer = playerInGangwar.Where(c => c.GetUser().Id == client.GetUser().Id).FirstOrDefault();
|
|
||||||
if (gPlayer == null)
|
|
||||||
{
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~r~" + client.Name + "~w~ ist nicht im Gangwar beteiligt !", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
|
||||||
}
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (playerInside.Find(c => c == client) == null)
|
|
||||||
{
|
|
||||||
playerInside.Add(client);
|
|
||||||
client.SetData("GotInsideOfTurf", true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void leave(Player client)
|
|
||||||
{
|
|
||||||
if (playerInside.Find(c => c == client) != null)
|
|
||||||
{
|
|
||||||
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
|
||||||
if (this.status != "attack")
|
|
||||||
client.ResetData("GotInsideOfTurf");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void takeOver(string FactionName)
|
|
||||||
{
|
|
||||||
this.timer.Stop();
|
|
||||||
this.timer = null;
|
|
||||||
using (var dbContext = new DatabaseContext())
|
|
||||||
{
|
|
||||||
if (getOwner() == FactionName)
|
|
||||||
{
|
|
||||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
|
||||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
|
||||||
foreach (var o in owners)
|
|
||||||
{
|
|
||||||
o.TriggerEvent("CLIENT:win");
|
|
||||||
}
|
|
||||||
foreach (var a in attackers)
|
|
||||||
{
|
|
||||||
a.TriggerEvent("CLIENT:loose");
|
|
||||||
}
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat erfolgreich das Gebiet ~g~" + getName() + "~w~ verteidigt.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion hat den Angrif auf das Gebiet ~r~" + getName() + "~w~ verloren.", dbContext.Factions.Where(f => f.Name == getAttacker()).FirstOrDefault());
|
|
||||||
}
|
|
||||||
else if (getOwner() != FactionName)
|
|
||||||
{
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
|
||||||
Player[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
|
||||||
Player[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
|
||||||
foreach (var o in owners)
|
|
||||||
{
|
|
||||||
o.TriggerEvent("CLIENT:loose");
|
|
||||||
}
|
|
||||||
foreach (var a in attackers)
|
|
||||||
{
|
|
||||||
a.TriggerEvent("CLIENT:win");
|
|
||||||
}
|
|
||||||
this.Owner = FactionName;
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte erfolgreich das Gebiet ~g~" + getName() + "~w~ erobern.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
|
||||||
Turfs turf = dbContext.Turfs.Where(t => t.Id == getId()).FirstOrDefault();
|
|
||||||
turf.Owner = this.Owner;
|
|
||||||
turf.FactionId = dbContext.Factions.Where(f => f.Name == this.Owner).FirstOrDefault().Id;
|
|
||||||
dbContext.SaveChanges();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
this.Attacker = null;
|
|
||||||
foreach (var c in playerInGangwar)
|
|
||||||
{
|
|
||||||
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
|
||||||
c.ResetData("inGangWar");
|
|
||||||
c.ResetData("GotInsideOfTurf");
|
|
||||||
}
|
|
||||||
this.playerInGangwar = null;
|
|
||||||
Gangwar.loadTurfs();
|
|
||||||
Gangwar.loadTurfs_ToAllPlayers();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void attack(string attacker)
|
|
||||||
{
|
|
||||||
Player[] usersInGangwar;
|
|
||||||
using (var context = new DatabaseContext())
|
|
||||||
{
|
|
||||||
var onlinePlayers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn()).Select(c => c.Name);
|
|
||||||
|
|
||||||
List<Player> ownersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == getOwner()).Select(u => u.Player).ToList();
|
|
||||||
List<Player> attackersInGangwar = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker).Select(u => u.Player).ToList();
|
|
||||||
|
|
||||||
if (ownersInGangwar.Count < 0 && attackersInGangwar.Count < 0)
|
|
||||||
{
|
|
||||||
List<Player> leaders = context.Users.Include(u => u.Faction).Where(u => onlinePlayers.Contains(u.Name) && u.Faction.Name == attacker && u.FactionLeader).Select(u => u.Player).ToList();
|
|
||||||
foreach (var l in leaders)
|
|
||||||
{
|
|
||||||
ChatService.ErrorMessage(l, "Gangwarstart ist nicht möglich, da die beteiligten Fraktionen nicht genügend Mitglieder aufweisen.");
|
|
||||||
}
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
List<Player> inGangwar = new List<Player>(ownersInGangwar.Concat(attackersInGangwar));
|
|
||||||
|
|
||||||
usersInGangwar = inGangwar.ToArray();
|
|
||||||
}
|
|
||||||
if (this.status == "normal")
|
|
||||||
{
|
|
||||||
if (this.timer != null)
|
|
||||||
{
|
|
||||||
this.timer.Stop();
|
|
||||||
this.timer = null;
|
|
||||||
}
|
|
||||||
this.Attacker = attacker;
|
|
||||||
this.status = "attack";
|
|
||||||
|
|
||||||
List<Player> clientsInGangwar = new List<Player>();
|
|
||||||
|
|
||||||
foreach (var u in usersInGangwar)
|
|
||||||
{
|
|
||||||
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
|
||||||
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
|
||||||
u.SetData("inGangWar", getId());
|
|
||||||
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen.");
|
|
||||||
clientsInGangwar.Add(u);
|
|
||||||
}
|
|
||||||
playerInGangwar = clientsInGangwar.ToArray();
|
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("CLIENT:Turf_Update", JsonConvert.SerializeObject(this.TurfID), JsonConvert.SerializeObject(this.status), JsonConvert.SerializeObject(this.Owner), JsonConvert.SerializeObject(this.Attacker));
|
|
||||||
this.TurfTick();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setKill(string FactionName)
|
|
||||||
{
|
|
||||||
if (getOwner() == FactionName)
|
|
||||||
{
|
|
||||||
Att_Score += 1;
|
|
||||||
}
|
|
||||||
else if (getAttacker() == FactionName)
|
|
||||||
{
|
|
||||||
Def_Score += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ namespace ReallifeGamemode.Server
|
|||||||
//HouseManager.LoadHouses();
|
//HouseManager.LoadHouses();
|
||||||
DrivingSchool.DrivingSchool.Setup();
|
DrivingSchool.DrivingSchool.Setup();
|
||||||
PlaneSchool.Setup();
|
PlaneSchool.Setup();
|
||||||
Gangwar.Gangwar.loadTurfs();
|
//Gangwar.Gangwar.loadTurfs();
|
||||||
Bank.bank.Setup();
|
Bank.bank.Setup();
|
||||||
Introduction.Setup();
|
Introduction.Setup();
|
||||||
|
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ namespace ReallifeGamemode.Server.Util
|
|||||||
{
|
{
|
||||||
WantedEscapeTimer.Timer_Elapsed();
|
WantedEscapeTimer.Timer_Elapsed();
|
||||||
Jail.JailIn_Elapsed();
|
Jail.JailIn_Elapsed();
|
||||||
Gangwar.Gangwar.Value_TimerElapsed();
|
//Gangwar.Gangwar.Value_TimerElapsed();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user