Gangwar-System base Structure
This commit is contained in:
@@ -28,7 +28,8 @@
|
|||||||
SET_BLIP_FLASHES: "0xB14552383D39CE3E",
|
SET_BLIP_FLASHES: "0xB14552383D39CE3E",
|
||||||
GET_FIRST_BLIP_INFO_ID: "0x1BEDE233E6CD2A1F",
|
GET_FIRST_BLIP_INFO_ID: "0x1BEDE233E6CD2A1F",
|
||||||
GET_NEXT_BLIP_INFO_ID: "0x14F96AA50D6FBEA7",
|
GET_NEXT_BLIP_INFO_ID: "0x14F96AA50D6FBEA7",
|
||||||
DOES_BLIP_EXIST: "0xA6DB27D19ECBB7DA"
|
DOES_BLIP_EXIST: "0xA6DB27D19ECBB7DA",
|
||||||
|
SET_BLIP_COORDS: "0xAE2AF67E9D9AF65D"
|
||||||
};
|
};
|
||||||
|
|
||||||
var Gangturf = class {
|
var Gangturf = class {
|
||||||
@@ -59,27 +60,30 @@
|
|||||||
}
|
}
|
||||||
|
|
||||||
_setup(name, id, x, y, range, color, rot, owner, edit) {
|
_setup(name, id, x, y, range, color, rot, owner, edit) {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
self.name = name;
|
self.name = name;
|
||||||
self.id = id;
|
self.id = id;
|
||||||
self.range = range;
|
self.range = range;
|
||||||
if (owner = "Ballas") {
|
if (owner === "Ballas") {
|
||||||
|
self.color = 83;
|
||||||
self.colorZone_r = 143;
|
self.colorZone_r = 143;
|
||||||
self.colorZone_g = 0;
|
self.colorZone_g = 0;
|
||||||
self.colorZone_b = 199;
|
self.colorZone_b = 199;
|
||||||
} else if (owner = "GroveStreet") {
|
} else if (owner === "GroveStreet") {
|
||||||
|
self.color = 2;
|
||||||
self.colorZone_r = 22;
|
self.colorZone_r = 22;
|
||||||
self.colorZone_g = 87;
|
self.colorZone_g = 87;
|
||||||
self.colorZone_b = 0;
|
self.colorZone_b = 0;
|
||||||
} else if (owner = "Neutral") {
|
} else if (owner === "Neutral") {
|
||||||
|
self.color = 0;
|
||||||
self.colorZone_r = 255;
|
self.colorZone_r = 255;
|
||||||
self.colorZone_g = 255;
|
self.colorZone_g = 255;
|
||||||
self.colorZone_b = 255;
|
self.colorZone_b = 255;
|
||||||
}
|
}
|
||||||
self.color = color;
|
|
||||||
self.x = x;
|
self.x = x;
|
||||||
self.y = y;
|
self.y = y;
|
||||||
|
|
||||||
self.rotation = rot;
|
self.rotation = rot;
|
||||||
self._colshape = null;
|
self._colshape = null;
|
||||||
self._status = "normal";
|
self._status = "normal";
|
||||||
@@ -97,20 +101,31 @@
|
|||||||
|
|
||||||
loadArea() {
|
loadArea() {
|
||||||
var self = this;
|
var self = this;
|
||||||
self.blip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, self.range);
|
|
||||||
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.blip, 5);
|
self.blip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, self.range);
|
||||||
mp.game.invoke(Natives.SET_BLIP_ALPHA, self.blip, 70);
|
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.blip, 5);
|
||||||
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
mp.game.invoke(Natives.SET_BLIP_ALPHA, self.blip, 70);
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_COLOUR, self.blip, self.color);
|
||||||
|
|
||||||
self._colshape = mp.colshapes.newCircle(self.x, self.y, self.range * 1.5);
|
self._colshape = mp.colshapes.newCircle(self.x, self.y, self.range * 1.5);
|
||||||
}
|
}
|
||||||
render() {
|
render() {
|
||||||
|
|
||||||
var self = this;
|
var self = this;
|
||||||
if (self.blip) {
|
if (self._colshape) {
|
||||||
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
|
if (self.edit == true) {
|
||||||
|
let vector3 = mp.players.local.getRotation(2);
|
||||||
|
self.rotation = Math.round(vector3.z);
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_COORDS, self.blip, mp.players.local.position.x, mp.players.local.position.y, 1);
|
||||||
|
self.x = mp.players.local.position.x;
|
||||||
|
self.y = mp.players.local.position.y;
|
||||||
|
}
|
||||||
|
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
|
||||||
|
|
||||||
}
|
}
|
||||||
if (self._status == "attack") {
|
|
||||||
if (self.blip) {
|
if (self._status == "attack" || self.edit == true) {
|
||||||
|
if (self._colshape) {
|
||||||
if (mp.game.gameplay.getDistanceBetweenCoords(mp.players.local.position.x, mp.players.local.position.y, 0, self.x, self.y, 0, true) < self.range * 1.5) {
|
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)));
|
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 degrees = (self.rotation + 45) * (Math.PI / 180);
|
||||||
@@ -310,15 +325,33 @@
|
|||||||
|
|
||||||
mp.events.add('GangAreas:Create', (turfsJSON) => {
|
mp.events.add('GangAreas:Create', (turfsJSON) => {
|
||||||
var turfs = JSON.parse(turfsJSON);
|
var turfs = JSON.parse(turfsJSON);
|
||||||
|
if (gangturfs.length > 0) {
|
||||||
|
gangturfs[gangturfs.length - 1].edit = false;
|
||||||
|
}
|
||||||
clearBlips();
|
clearBlips();
|
||||||
if (turfs.length > 0) {
|
if (turfs.length > 0) {
|
||||||
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);
|
mp.gui.chat.push(turf.Owner);
|
||||||
|
gangturfs[gangturfs.length] = new Gangturf(turf.Name, turf.Id, turf.X, turf.Y, turf.Range, turf.Color, turf.Rotation, turf.Owner, false);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
mp.events.add('ADMIN:CreateTurf', (rangeJSON) => {
|
||||||
|
var range = JSON.parse(rangeJSON);
|
||||||
|
gangturfs[gangturfs.length] = new Gangturf("Reload For Name", -1, mp.players.local.position.x, mp.players.local.position.y, range, 0, mp.players.local.getHeading(), "Neutral", true);
|
||||||
|
});
|
||||||
|
|
||||||
|
mp.events.add('ADMIN:SetTurf', (name) => {
|
||||||
|
gangturfs[gangturfs.length - 1].edit = false;
|
||||||
|
if (gangturfs[gangturfs.length - 1].id == -1) {
|
||||||
|
|
||||||
|
mp.events.callRemote("SERVER:SetTurf", JSON.stringify(gangturfs[gangturfs.length - 1].x), JSON.stringify(gangturfs[gangturfs.length - 1].y), JSON.stringify(gangturfs[gangturfs.length - 1].rotation), JSON.stringify(gangturfs[gangturfs.length - 1].range), name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -21,10 +21,10 @@ namespace ReallifeGamemode.Database.Entities
|
|||||||
public string Owner { get; set; }
|
public string Owner { get; set; }
|
||||||
|
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public int X { get; set; }
|
public float X { get; set; }
|
||||||
public int Y { get; set; }
|
public float Y { get; set; }
|
||||||
public int Rotation { get; set; }
|
public float Rotation { get; set; }
|
||||||
public int Range { get; set; }
|
public float Range { get; set; }
|
||||||
public int Color { get; set; }
|
public int Color { get; set; }
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2986,6 +2986,39 @@ 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]")]
|
||||||
|
public void CmdAdmCreateTurf(Client player, float option)
|
||||||
|
{
|
||||||
|
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.TriggerEvent("ADMIN:CreateTurf", JsonConvert.SerializeObject(option));
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("setturf", "~m~Benutzung:~s~ /setturf (Name)")]
|
||||||
|
public void CmdAdmSetTurf(Client player, string name)
|
||||||
|
{
|
||||||
|
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
player.TriggerEvent("ADMIN:SetTurf", name);
|
||||||
|
}
|
||||||
|
|
||||||
|
[Command("cancleturf", "~m~Benutzung:~s~ /cancleturf")]
|
||||||
|
public void CmdAdmCancleTurf(Client player)
|
||||||
|
{
|
||||||
|
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
|
||||||
|
{
|
||||||
|
ChatService.NotAuthorized(player);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Gangwar.Gangwar.loadClient(player);
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region ALevel1338
|
#region ALevel1338
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using Newtonsoft.Json;
|
|||||||
|
|
||||||
namespace ReallifeGamemode.Server.Gangwar
|
namespace ReallifeGamemode.Server.Gangwar
|
||||||
{
|
{
|
||||||
public class Gangwar
|
public class Gangwar : Script
|
||||||
{
|
{
|
||||||
public static Turf[] _loadedTurfs;
|
public static Turf[] _loadedTurfs;
|
||||||
private static List<Turfs> turfs;
|
private static List<Turfs> turfs;
|
||||||
@@ -40,5 +40,33 @@ namespace ReallifeGamemode.Server.Gangwar
|
|||||||
return _loadedTurfs;
|
return _loadedTurfs;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
[RemoteEvent("SERVER:SetTurf")]
|
||||||
|
public void RmtEvent_SetTurf(Client 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 = client.Heading,
|
||||||
|
Range = Range,
|
||||||
|
Owner = "Neutral",
|
||||||
|
Color = 0
|
||||||
|
};
|
||||||
|
using(var dbContext = new DatabaseContext())
|
||||||
|
{
|
||||||
|
dbContext.Turfs.Add(newTurf);
|
||||||
|
dbContext.SaveChanges();
|
||||||
|
}
|
||||||
|
loadTurfs();
|
||||||
|
NAPI.ClientEvent.TriggerClientEventForAll("GangAreas:Create", JsonConvert.SerializeObject(turfs.ToArray()));
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user