[+] Add Gangwar System (bugs incl.)
This commit is contained in:
@@ -240,7 +240,7 @@ export default function (globalData: GlobalData): void {
|
|||||||
})
|
})
|
||||||
|
|
||||||
if (jailTime > 0) {
|
if (jailTime > 0) {
|
||||||
mp.game.graphics.drawText("~y~Knastzeit: " + jailTime + " Minuten", [0.92, 0.52],
|
mp.game.graphics.drawText("~y~Knastzeit: ~ " + jailTime + " Minuten", [0.92, 0.52],
|
||||||
{
|
{
|
||||||
font: 4,
|
font: 4,
|
||||||
color: [255, 255, 255, 255],
|
color: [255, 255, 255, 255],
|
||||||
@@ -251,7 +251,7 @@ export default function (globalData: GlobalData): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (att_score > 0 && def_score > 0) {
|
if (att_score > 0 && def_score > 0) {
|
||||||
mp.game.graphics.drawText("~y~" + def + " " + def_score + " : " + att_score + " " + att, [0.1, 0.416],
|
mp.game.graphics.drawText("~y~" + def + " " + def_score + " : " + att_score + " " + att, [0.07, 0.55],
|
||||||
{
|
{
|
||||||
font: 4,
|
font: 4,
|
||||||
color: [255, 255, 255, 255],
|
color: [255, 255, 255, 255],
|
||||||
@@ -259,6 +259,15 @@ export default function (globalData: GlobalData): void {
|
|||||||
outline: true,
|
outline: true,
|
||||||
centre: false
|
centre: false
|
||||||
})
|
})
|
||||||
|
mp.game.graphics.drawText("~w~Gangwar", [0.07, 0.514],
|
||||||
|
{
|
||||||
|
font: 1,
|
||||||
|
color: [255, 255, 255, 255],
|
||||||
|
scale: [0.5, 0.5],
|
||||||
|
outline: true,
|
||||||
|
centre: false
|
||||||
|
})
|
||||||
|
mp.game.graphics.drawRect(0.0, 0.555, 0.3, 0.08, 0, 0, 0, 70)
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ export default function keys(globalData: GlobalData) {
|
|||||||
|
|
||||||
//E
|
//E
|
||||||
mp.keys.bind(0x45, false, function () {
|
mp.keys.bind(0x45, false, function () {
|
||||||
if (!globalData.InChat) {
|
if (!globalData.InChat && !globalData.InMenu) {
|
||||||
mp.events.callRemote("keyPress:E");
|
mp.events.callRemote("keyPress:E");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -95,8 +95,8 @@ export default function keys(globalData: GlobalData) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
//O //Spielerliste
|
//O //Spielerliste
|
||||||
mp.keys.bind(0x4F, false, function () {
|
mp.keys.bind(0x4F, true, function () {
|
||||||
if (!globalData.InChat && !globalData.InMenu) {
|
if (!globalData.InChat && !globalData.InMenu && !globalData.InTuning && !showInv) {
|
||||||
mp.events.callRemote("keyPress:O");
|
mp.events.callRemote("keyPress:O");
|
||||||
//mp.events.call("showPlayerlist");
|
//mp.events.call("showPlayerlist");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,12 +56,15 @@
|
|||||||
_timerCheck;
|
_timerCheck;
|
||||||
edit: boolean;
|
edit: boolean;
|
||||||
attackBlip: BlipMp;
|
attackBlip: BlipMp;
|
||||||
|
leaderBlip: BlipMp;
|
||||||
|
leaderBlipVector: Vector3Mp;
|
||||||
|
leaderColShape: MarkerMp;
|
||||||
|
|
||||||
constructor(name, id, x, y, range, color, rot, owner, edit) {
|
constructor(name, id, x, y, range, color, rot, owner, edit, vector) {
|
||||||
this._setup(name, id, x, y, range, color, rot, owner, edit);
|
this._setup(name, id, x, y, range, color, rot, owner, edit, vector);
|
||||||
}
|
}
|
||||||
|
|
||||||
_setup(name, id, x, y, range, color, rot, owner, edit) {
|
_setup(name, id, x, y, range, color, rot, owner, edit, vector) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
self.name = name;
|
self.name = name;
|
||||||
@@ -82,6 +85,14 @@
|
|||||||
self.edit = edit;
|
self.edit = edit;
|
||||||
self.loadArea();
|
self.loadArea();
|
||||||
self.attackBlip = null;
|
self.attackBlip = null;
|
||||||
|
self.leaderBlip = null;
|
||||||
|
if (vector != null) {
|
||||||
|
self.leaderBlipVector = JSON.parse(vector);
|
||||||
|
} else {
|
||||||
|
self.leaderBlipVector = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
self.leaderColShape = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
setColor(owner) {
|
setColor(owner) {
|
||||||
@@ -133,6 +144,8 @@
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (self._status == "attack" || self.edit == true) {
|
if (self._status == "attack" || self.edit == true) {
|
||||||
if (self._colshape) {
|
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) {
|
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) {
|
||||||
@@ -182,6 +195,8 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (self.isInsideArea()) {
|
if (self.isInsideArea()) {
|
||||||
mp.game.graphics.drawText(self.name, [self.x, self.y, mp.players.local.position.z + 20], {
|
mp.game.graphics.drawText(self.name, [self.x, self.y, mp.players.local.position.z + 20], {
|
||||||
font: 7,
|
font: 7,
|
||||||
@@ -190,14 +205,49 @@
|
|||||||
outline: true,
|
outline: true,
|
||||||
centre: true
|
centre: true
|
||||||
});
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (self.leaderBlipVector != null) {
|
||||||
|
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);
|
||||||
|
if (self.isInsideArea() && self._status != "attack" && dist <= 3) {
|
||||||
|
if (self.leaderBlipVector != null) {
|
||||||
|
mp.game.graphics.drawText(self.name + "\n~y~Gang: ~s~" + self.owner + "\n~y~Wert: ~s~$~g~187", [self.leaderBlipVector.x, self.leaderBlipVector.y, self.leaderBlipVector.z], {
|
||||||
|
font: 7,
|
||||||
|
color: [255, 255, 255, 185],
|
||||||
|
scale: [0.4, 0.4],
|
||||||
|
outline: true,
|
||||||
|
centre: true
|
||||||
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private delay(ms: number) {
|
||||||
|
return new Promise(resolve => setTimeout(resolve, ms));
|
||||||
|
}
|
||||||
|
|
||||||
|
async startGangWar() {
|
||||||
|
var self = this;
|
||||||
|
await this.delay(1000);
|
||||||
|
if (self._status == "normal") {
|
||||||
|
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);
|
||||||
|
if (dist <= 3) {
|
||||||
|
mp.events.callRemote("SERVER:StartGangwar");
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
updateArea(status, ...args) {
|
updateArea(status, ...args) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (status == "attack") {
|
if (status == "attack") {
|
||||||
|
if (self.leaderColShape != null) {
|
||||||
|
self.leaderColShape.destroy();
|
||||||
|
self.leaderColShape = null;
|
||||||
|
}
|
||||||
self._status = "attack";
|
self._status = "attack";
|
||||||
self.attacker = args[1];
|
self.attacker = args[1];
|
||||||
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, true);
|
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, true);
|
||||||
@@ -216,6 +266,7 @@
|
|||||||
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
|
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
|
||||||
self.setColor(self.owner)
|
self.setColor(self.owner)
|
||||||
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
||||||
|
self.setLeaderColShape();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -223,7 +274,7 @@
|
|||||||
setAttackBlip(bool) {
|
setAttackBlip(bool) {
|
||||||
var self = this;
|
var self = this;
|
||||||
if (bool) {
|
if (bool) {
|
||||||
self.attackBlip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, 60);
|
self.attackBlip = mp.game.ui.addBlipForCoord(self.x, self.y, 0);
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 378);
|
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 378);
|
||||||
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.attackBlip, false);
|
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.attackBlip, false);
|
||||||
|
|
||||||
@@ -232,6 +283,36 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setLeaderBlip(bool) {
|
||||||
|
var self = this;
|
||||||
|
if (bool) {
|
||||||
|
self.leaderBlipVector = mp.players.local.position;
|
||||||
|
mp.events.callRemote("SERVER:Turf_SetNewLeaderPoint", JSON.stringify(self.leaderBlipVector), JSON.stringify(self.id));
|
||||||
|
self.setLeaderColShape();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (self.leaderBlipVector != null) {
|
||||||
|
self.leaderBlip = mp.game.ui.addBlipForRadius(self.leaderBlipVector.x, self.leaderBlipVector.y, 1, 60);
|
||||||
|
self.setLeaderColShape();
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.leaderBlip, 437);
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, self.leaderBlip, 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, 255, 150],
|
||||||
|
visible: true,
|
||||||
|
dimension: 0
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
isTurfArea(shape) {
|
isTurfArea(shape) {
|
||||||
return (shape == this._colshape)
|
return (shape == this._colshape)
|
||||||
}
|
}
|
||||||
@@ -384,6 +465,11 @@
|
|||||||
last_attackBlip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 378);
|
last_attackBlip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 378);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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.ui.removeBlip(last_leaderBlip);
|
||||||
|
last_leaderBlip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 437);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
mp.events.add('GangAreas:Create', (turfsJSON) => {
|
mp.events.add('GangAreas:Create', (turfsJSON) => {
|
||||||
@@ -396,7 +482,7 @@
|
|||||||
gangturfs = [];
|
gangturfs = [];
|
||||||
turfs.forEach(function (turf) {
|
turfs.forEach(function (turf) {
|
||||||
if (turf.Id != undefined) {
|
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);
|
gangturfs[gangturfs.length] = new Gangturf(turf.Name, turf.Id, turf.X, turf.Y, turf.Range, turf.Color, turf.Rotation, turf.Owner, false, turf.Vector);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -404,7 +490,7 @@
|
|||||||
|
|
||||||
mp.events.add('ADMIN:CreateTurf', (rangeJSON) => {
|
mp.events.add('ADMIN:CreateTurf', (rangeJSON) => {
|
||||||
var range = JSON.parse(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);
|
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);
|
||||||
});
|
});
|
||||||
|
|
||||||
mp.events.add('ADMIN:SetTurf', (name) => {
|
mp.events.add('ADMIN:SetTurf', (name) => {
|
||||||
@@ -446,5 +532,31 @@
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mp.events.add('CLIENT:Turf_LoadLeaderBlip', () => {
|
||||||
|
gangturfs.forEach(function (turf) {
|
||||||
|
if (turf.Id != undefined) {
|
||||||
|
turf.setLeaderBlip(false);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add('ADMIN:Turf_CreateLeaderBlip', () => {
|
||||||
|
gangturfs.forEach(function (turf) {
|
||||||
|
if (turf._entered == true) {
|
||||||
|
if (turf.leaderColShape != null) {
|
||||||
|
turf.leaderColShape.destroy();
|
||||||
|
turf.leaderColShape = null;
|
||||||
|
}
|
||||||
|
turf.setLeaderBlip(true);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add('CLIENT:StartGangwar', () => {
|
||||||
|
gangturfs.forEach(function (turf) {
|
||||||
|
if (turf._entered == true) {
|
||||||
|
turf.startGangWar();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
}
|
}
|
||||||
@@ -21,6 +21,7 @@ namespace ReallifeGamemode.Database.Entities
|
|||||||
public float Rotation { get; set; }
|
public float Rotation { get; set; }
|
||||||
public float Range { get; set; }
|
public float Range { get; set; }
|
||||||
public int Color { get; set; }
|
public int Color { get; set; }
|
||||||
|
public string Vector { get; set; } = null;
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -3,35 +3,35 @@ using Microsoft.EntityFrameworkCore.Migrations;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Database.Migrations
|
namespace ReallifeGamemode.Database.Migrations
|
||||||
{
|
{
|
||||||
public partial class Turfs : Migration
|
public partial class Turfs : Migration
|
||||||
{
|
|
||||||
protected override void Up(MigrationBuilder migrationBuilder)
|
|
||||||
{
|
{
|
||||||
migrationBuilder.CreateTable(
|
protected override void Up(MigrationBuilder migrationBuilder)
|
||||||
name: "Turfs",
|
{
|
||||||
columns: table => new
|
migrationBuilder.CreateTable(
|
||||||
{
|
name: "Turfs",
|
||||||
Id = table.Column<int>(nullable: false)
|
columns: table => new
|
||||||
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
{
|
||||||
FactionId = table.Column<int>(nullable: true),
|
Id = table.Column<int>(nullable: false)
|
||||||
Owner = table.Column<string>(nullable: true),
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
||||||
Name = table.Column<string>(nullable: true),
|
FactionId = table.Column<int>(nullable: true),
|
||||||
X = table.Column<int>(nullable: false),
|
Owner = table.Column<string>(nullable: true),
|
||||||
Y = table.Column<int>(nullable: false),
|
Name = table.Column<string>(nullable: true),
|
||||||
Rotation = table.Column<float>(nullable: false),
|
X = table.Column<float>(nullable: false),
|
||||||
Range = table.Column<float>(nullable: false),
|
Y = table.Column<float>(nullable: false),
|
||||||
Color = table.Column<int>(nullable: false)
|
Rotation = table.Column<float>(nullable: false),
|
||||||
},
|
Range = table.Column<float>(nullable: false),
|
||||||
constraints: table =>
|
Color = table.Column<int>(nullable: false)
|
||||||
{
|
},
|
||||||
table.PrimaryKey("PK_Turfs", x => x.Id);
|
constraints: table =>
|
||||||
});
|
{
|
||||||
}
|
table.PrimaryKey("PK_Turfs", x => x.Id);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
protected override void Down(MigrationBuilder migrationBuilder)
|
protected override void Down(MigrationBuilder migrationBuilder)
|
||||||
{
|
{
|
||||||
migrationBuilder.DropTable(
|
migrationBuilder.DropTable(
|
||||||
name: "Turfs");
|
name: "Turfs");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -907,9 +907,11 @@ namespace ReallifeGamemode.Database.Migrations
|
|||||||
|
|
||||||
b.Property<float>("Rotation");
|
b.Property<float>("Rotation");
|
||||||
|
|
||||||
b.Property<int>("X");
|
b.Property<string>("Vector");
|
||||||
|
|
||||||
b.Property<int>("Y");
|
b.Property<float>("X");
|
||||||
|
|
||||||
|
b.Property<float>("Y");
|
||||||
|
|
||||||
b.HasKey("Id");
|
b.HasKey("Id");
|
||||||
|
|
||||||
|
|||||||
@@ -1767,7 +1767,6 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast hast den Spieler ~y~" + target.Name + "~s~ zum Leader der Fraktion ~o~" + f.Name + "~s~ ernannt.");
|
ChatService.SendMessage(player, "~b~[ADMIN]~s~ Du hast hast den Spieler ~y~" + target.Name + "~s~ zum Leader der Fraktion ~o~" + f.Name + "~s~ ernannt.");
|
||||||
ChatService.SendMessage(target, "~b~[ADMIN]~s~ Du wurdest von ~y~" + player.Name + "~s~ zum Leader der Fraktion ~o~" + f.Name + "~s~ ernannt.");
|
ChatService.SendMessage(target, "~b~[ADMIN]~s~ Du wurdest von ~y~" + player.Name + "~s~ zum Leader der Fraktion ~o~" + f.Name + "~s~ ernannt.");
|
||||||
|
|
||||||
u.FactionLeader = false;
|
|
||||||
switch (u.FactionId)
|
switch (u.FactionId)
|
||||||
{
|
{
|
||||||
case null:
|
case null:
|
||||||
@@ -3056,7 +3055,7 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
Gangwar.Gangwar.loadClient(player);
|
Gangwar.Gangwar.loadClient(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("reloadturfs", "~m~Benutzung:~s~ /reloadturfs")]
|
[Command("reloadturfs", "~m~Benutzung:~s~ /ReloadTurfs")]
|
||||||
public void CmdAdmReloadTurf(Client player)
|
public void CmdAdmReloadTurf(Client player)
|
||||||
{
|
{
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||||
@@ -3067,7 +3066,7 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
Gangwar.Gangwar.loadTurfs();
|
Gangwar.Gangwar.loadTurfs();
|
||||||
Gangwar.Gangwar.loadTurfs_ToAllClients();
|
Gangwar.Gangwar.loadTurfs_ToAllClients();
|
||||||
}
|
}
|
||||||
[Command("deleteturf", "~m~Benutzung:~s~ /reloadturfs")]
|
[Command("deleteturf", "~m~Benutzung:~s~ /DeleteTurfs")]
|
||||||
public void CmdAdmDeleteTurf(Client player)
|
public void CmdAdmDeleteTurf(Client player)
|
||||||
{
|
{
|
||||||
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||||
@@ -3077,7 +3076,16 @@ namespace ReallifeGamemode.Server.Commands
|
|||||||
}
|
}
|
||||||
player.TriggerEvent("ADMIN:DeleteTurf");
|
player.TriggerEvent("ADMIN:DeleteTurf");
|
||||||
}
|
}
|
||||||
|
[Command("setturfpoint", "~m~Benutzung:~s~ /setturfpoint")]
|
||||||
|
public void CmdAdmSetTurfPoint(Client player)
|
||||||
|
{
|
||||||
|
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.TriggerEvent("ADMIN:Turf_CreateLeaderBlip");
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ALevel1338
|
#region ALevel1338
|
||||||
|
|||||||
@@ -53,6 +53,10 @@ namespace ReallifeGamemode.Server.Events
|
|||||||
player.SetData("duty", false);
|
player.SetData("duty", false);
|
||||||
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
player.TriggerEvent("SERVER:SET_HANDMONEY", user.Handmoney, 0);
|
||||||
Gangwar.Gangwar.loadClient(player);
|
Gangwar.Gangwar.loadClient(player);
|
||||||
|
if (player.GetUser().FactionLeader)
|
||||||
|
{
|
||||||
|
player.TriggerEvent("CLIENT:Turf_LoadLeaderBlip");
|
||||||
|
}
|
||||||
if (user.IsAdmin(AdminLevel.HEADADMIN) == true)
|
if (user.IsAdmin(AdminLevel.HEADADMIN) == true)
|
||||||
{
|
{
|
||||||
player.SetData("editmode", false);
|
player.SetData("editmode", false);
|
||||||
|
|||||||
@@ -40,6 +40,14 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
public static void loadTurfs_ToAllClients()
|
public static void loadTurfs_ToAllClients()
|
||||||
{
|
{
|
||||||
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
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(Client killer, Client victim)
|
public static void GangwarKill(Client killer, Client victim)
|
||||||
@@ -108,7 +116,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
Rotation = Rot,
|
Rotation = Rot,
|
||||||
Range = Range,
|
Range = Range,
|
||||||
Owner = "Neutral",
|
Owner = "Neutral",
|
||||||
Color = 0
|
Color = 0,
|
||||||
|
Vector = null
|
||||||
};
|
};
|
||||||
using (var dbContext = new DatabaseContext())
|
using (var dbContext = new DatabaseContext())
|
||||||
{
|
{
|
||||||
@@ -141,8 +150,30 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[Command("/gwstart")]
|
[RemoteEvent("SERVER:Turf_SetNewLeaderPoint")]
|
||||||
public void StartGangwar(Client client)
|
public void RmtEvent_SetNewLeaderPoint(Client 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_ToAllClients();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:StartGangwar")]
|
||||||
|
public void RmtEvent_StartGangwar(Client client)
|
||||||
{
|
{
|
||||||
if (!client.GetUser().FactionLeader)
|
if (!client.GetUser().FactionLeader)
|
||||||
return;
|
return;
|
||||||
@@ -151,7 +182,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
{
|
{
|
||||||
if (turf.status == "attack")
|
if (turf.status == "attack")
|
||||||
{
|
{
|
||||||
client.SendChatMessage("Ein GW läuft grad bruder"); // DEBUG
|
client.SendChatMessage("Ein GW läuft grad bruder"); // DEBUG //change to smth more serious
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -36,8 +36,8 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
this.Color = color;
|
this.Color = color;
|
||||||
this.Owner = Owner;
|
this.Owner = Owner;
|
||||||
this.Attacker = null;
|
this.Attacker = null;
|
||||||
this.Att_Score = 5;
|
this.Att_Score = 50;
|
||||||
this.Def_Score = 5;
|
this.Def_Score = 50;
|
||||||
this.status = "normal";
|
this.status = "normal";
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
this.playerInside = new List<Client>();
|
this.playerInside = new List<Client>();
|
||||||
@@ -81,7 +81,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
|
|
||||||
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
private void Tick(object sender, System.Timers.ElapsedEventArgs e)
|
||||||
{
|
{
|
||||||
if (this.status == "attack")
|
if(this.status == "attack")
|
||||||
{
|
{
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -91,6 +91,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
|
|
||||||
private void update()
|
private void update()
|
||||||
{
|
{
|
||||||
|
#region Ticket system
|
||||||
/*
|
/*
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -113,6 +114,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
if(owners.Length < attackers.Length)
|
if(owners.Length < attackers.Length)
|
||||||
this.Def_Score -= attackers.Length - owners.Length;
|
this.Def_Score -= attackers.Length - owners.Length;
|
||||||
*/
|
*/
|
||||||
|
#endregion
|
||||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||||
{
|
{
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||||
@@ -120,43 +122,40 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
if (this.Def_Score <= 0)
|
if (this.Def_Score <= 0)
|
||||||
{
|
{
|
||||||
this.takeOver(this.Attacker);
|
this.takeOver(this.Attacker);
|
||||||
}
|
} else if (this.Att_Score <= 0)
|
||||||
else if (this.Att_Score <= 0)
|
|
||||||
{
|
{
|
||||||
this.takeOver(this.Owner);
|
this.takeOver(this.Owner);
|
||||||
}
|
}
|
||||||
timerCount += 1;
|
timerCount += 1;
|
||||||
if (timerCount >= 60) //change to 900 before release
|
if(timerCount >= 900) //change to 900 (seconds) before release for testing reasons change to whatever you like
|
||||||
{
|
{
|
||||||
this.timer.Stop();
|
if(this.Def_Score > this.Att_Score)
|
||||||
this.timer = null;
|
|
||||||
if (this.Def_Score > this.Att_Score)
|
|
||||||
{
|
{
|
||||||
|
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||||
|
{
|
||||||
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||||
|
}
|
||||||
this.takeOver(this.Owner);
|
this.takeOver(this.Owner);
|
||||||
this.Att_Score = 0;
|
this.Att_Score = 0;
|
||||||
|
}else if(this.Def_Score < this.Att_Score)
|
||||||
|
{
|
||||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||||
{
|
{
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
else if (this.Def_Score < this.Att_Score)
|
|
||||||
{
|
|
||||||
this.takeOver(this.Attacker);
|
this.takeOver(this.Attacker);
|
||||||
this.Def_Score = 0;
|
this.Def_Score = 0;
|
||||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
|
||||||
{
|
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
|
||||||
}
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (this.Def_Score == this.Att_Score)
|
else if(this.Def_Score == this.Att_Score)
|
||||||
{
|
{
|
||||||
this.takeOver(this.Attacker);
|
|
||||||
this.Def_Score = 0;
|
|
||||||
foreach (Client gangwarPlayer in this.playerInGangwar)
|
foreach (Client gangwarPlayer in this.playerInGangwar)
|
||||||
{
|
{
|
||||||
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
gangwarPlayer.TriggerEvent("GangwarScore", this.Attacker, this.Owner, 0, 0);
|
||||||
}
|
}
|
||||||
|
this.takeOver(this.Attacker);
|
||||||
|
this.Def_Score = 0;
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -180,8 +179,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (playerInside.Find(c => c == client) == null)
|
if(playerInside.Find(c => c == client) == null) {
|
||||||
{
|
|
||||||
playerInside.Add(client);
|
playerInside.Add(client);
|
||||||
client.SetData("GotInsideOfTurf", true);
|
client.SetData("GotInsideOfTurf", true);
|
||||||
}
|
}
|
||||||
@@ -189,10 +187,10 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
|
|
||||||
public void leave(Client client)
|
public void leave(Client client)
|
||||||
{
|
{
|
||||||
if (playerInside.Find(c => c == client) != null)
|
if(playerInside.Find(c => c == client) != null)
|
||||||
{
|
{
|
||||||
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
this.playerInside = this.playerInside.Where(c => c != client).ToList();
|
||||||
if (this.status != "attack")
|
if(this.status != "attack")
|
||||||
client.ResetData("GotInsideOfTurf");
|
client.ResetData("GotInsideOfTurf");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -220,10 +218,6 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
}
|
}
|
||||||
else if (getOwner() != FactionName)
|
else if (getOwner() != FactionName)
|
||||||
{
|
{
|
||||||
foreach (var c in playerInGangwar)
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
ChatService.BroadcastFaction("~y~[GANGWAR] ~w~Deine Fraktion konnte das Gebiet ~r~" + getName() + "~w~ nicht verteidigen.", dbContext.Factions.Where(f => f.Name == getOwner()).FirstOrDefault());
|
||||||
Client[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
Client[] owners = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Owner).ToArray();
|
||||||
Client[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
Client[] attackers = NAPI.Pools.GetAllPlayers().Where(c => c.IsLoggedIn() && c.GetUser().Faction.Name == this.Attacker).ToArray();
|
||||||
@@ -245,7 +239,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
|
|
||||||
}
|
}
|
||||||
this.Attacker = null;
|
this.Attacker = null;
|
||||||
foreach (var c in playerInGangwar)
|
foreach(var c in playerInGangwar)
|
||||||
{
|
{
|
||||||
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
c.TriggerEvent("CLIENT:setAttackBlip", false, TurfID);
|
||||||
c.ResetData("inGangWar");
|
c.ResetData("inGangWar");
|
||||||
@@ -258,9 +252,9 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
|
|
||||||
public void attack(string attacker)
|
public void attack(string attacker)
|
||||||
{
|
{
|
||||||
if (this.status == "normal")
|
if(this.status == "normal")
|
||||||
{
|
{
|
||||||
if (this.timer != null)
|
if(this.timer != null)
|
||||||
{
|
{
|
||||||
this.timer.Stop();
|
this.timer.Stop();
|
||||||
this.timer = null;
|
this.timer = null;
|
||||||
@@ -277,7 +271,7 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
u.TriggerEvent("CLIENT:setAttackBlip", true, TurfID);
|
||||||
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
u.TriggerEvent("GangwarScore", this.Attacker, this.Owner, this.Att_Score, this.Def_Score);
|
||||||
u.SetData("inGangWar", getId());
|
u.SetData("inGangWar", getId());
|
||||||
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " hat das Gebiet ~y~" + TurfName + "~w~ der " + getOwner() + " angegriffen.");
|
ChatService.SendMessage(u, "~y~[GANGWAR]~w~ Die " + getAttacker() + " haben das Gebiet ~y~"+ TurfName +"~w~ der "+ getOwner() +" angegriffen.");
|
||||||
clientsInGangwar.Add(u);
|
clientsInGangwar.Add(u);
|
||||||
}
|
}
|
||||||
playerInGangwar = clientsInGangwar.ToArray();
|
playerInGangwar = clientsInGangwar.ToArray();
|
||||||
|
|||||||
Reference in New Issue
Block a user