inshallah kein fehler

This commit is contained in:
hydrant
2020-05-10 23:18:53 +02:00
153 changed files with 6517 additions and 3407 deletions

View File

@@ -1,7 +1,4 @@

export default function gangwarHandle(globalData: IGlobalData) {
export default function gangwarHandle(globalData: IGlobalData) {
function inside(point, vs) {
let x = point[0],
y = point[1];
@@ -35,7 +32,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
};
var Gangturf = class {
name: string;
id: number;
range: number;
@@ -70,12 +66,11 @@ export default function gangwarHandle(globalData: IGlobalData) {
}
_setup(name, id, x, y, range, color, rot, owner, edit, vector, value) {
var self = this;
self.name = name;
self.id = id;
self.range = range;
self.setColor(owner);
self.setColor(owner);
self.x = x;
self.y = y;
self.rotation = rot;
@@ -97,7 +92,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
} else {
self.leaderBlipVector = null;
}
self.leaderColShape = null;
}
@@ -127,7 +122,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
loadArea() {
var self = this;
self.blip = mp.game.ui.addBlipForRadius(self.x, self.y, 1, self.range);
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.blip, 5);
@@ -137,25 +131,21 @@ export default function gangwarHandle(globalData: IGlobalData) {
self._colshape = mp.colshapes.newCircle(self.x, self.y, self.range * 1.5);
}
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);
self.x = mp.players.local.position.x;
self.y = mp.players.local.position.y;
}
//self.blip.setRotation(self.rotation);
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
mp.game.invoke(Natives.SET_BLIP_ROTATION, self.blip, self.rotation);
}
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) {
@@ -191,7 +181,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
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) {
@@ -202,10 +191,8 @@ export default function gangwarHandle(globalData: IGlobalData) {
a += 0.001
}
*/
}
}
}
if (self.isInsideArea()) {
mp.game.graphics.drawText(self.name, [self.x, self.y, mp.players.local.position.z + 20], {
@@ -215,7 +202,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
outline: true,
centre: true
});
}
}
}
@@ -233,11 +219,9 @@ export default function gangwarHandle(globalData: IGlobalData) {
}
}
}
}
startGangWar() {
startGangWar() {
var self = this;
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);
@@ -263,7 +247,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
if (status == "normal") {
self._status = "normal";
//self.blip.setFlashes(false);
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
mp.game.invoke(Natives.SET_BLIP_FLASHES, self.blip, false);
return;
}
if (status == "conquered") {
@@ -287,7 +271,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
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_AS_SHORT_RANGE, self.attackBlip, false);
} else if (!bool) {
mp.game.invoke(Natives.SET_BLIP_SPRITE, self.attackBlip, 5);
}
@@ -310,20 +293,18 @@ export default function gangwarHandle(globalData: IGlobalData) {
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, 0, 150],
visible: true,
dimension: 0
});
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) {
@@ -335,7 +316,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
}
check() {
var self = this
var self = this
if (self._entered == true) {
if (!self.isInsideArea() || (self.isNearGround() == false)) {
self._entered = false;
@@ -343,7 +324,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
}
}
}
enter() {
var self = this;
self._timerCheck = setInterval(function () {
@@ -354,8 +335,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
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) {
@@ -364,7 +344,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
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));
}
}
@@ -374,7 +354,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
leave() {
var self = this;
clearInterval(self._timerCheck);
self.check();
}
isNearGround() {
@@ -475,7 +455,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
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);
mp.game.ui.removeBlip(last_blip);
last_blip = mp.game.invoke(Natives.GET_NEXT_BLIP_INFO_ID, 5);
x++;
}
@@ -499,7 +479,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
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) {
@@ -512,9 +492,9 @@ export default function gangwarHandle(globalData: IGlobalData) {
turf.leaderColShape = null;
}
if (turf._marker)
if (turf.blip != null) {
mp.game.ui.removeBlip(turf.blip);
}
if (turf.blip != null) {
mp.game.ui.removeBlip(turf.blip);
}
if (turf.leaderBlip != null) {
mp.game.ui.removeBlip(turf.leaderBlip);
}
@@ -525,7 +505,6 @@ export default function gangwarHandle(globalData: IGlobalData) {
}
clearBlips();
if (turfs.length > 0) {
gangturfs = [];
turfs.forEach(function (turf) {
if (turf.Id != undefined) {
@@ -543,9 +522,8 @@ export default function gangwarHandle(globalData: IGlobalData) {
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', () => {
@@ -581,13 +559,13 @@ export default function gangwarHandle(globalData: IGlobalData) {
mp.events.add('CLIENT:Turf_LoadLeaderBlip', () => {
gangturfs.forEach(function (turf) {
turf.setLeaderBlip(false);
turf.setLeaderBlip(false);
});
});
mp.events.add('ADMIN:Turf_CreateLeaderBlip', () => {
gangturfs.forEach(function (turf) {
if (turf._entered == true) {
if (turf._entered == true) {
turf.setLeaderBlip(true);
}
});
@@ -596,7 +574,7 @@ export default function gangwarHandle(globalData: IGlobalData) {
mp.events.add('CLIENT:StartGangwar', () => {
gangturfs.forEach(function (turf) {
if (turf._entered == true) {
turf.startGangWar();
turf.startGangWar();
}
});
});

View File

@@ -0,0 +1,279 @@
import { IGame, EntityType } from "../game";
import relativeVector from "./relativevector";
export default function attachmentManager(game: IGame) {
mp.events.add("SERVER:LoadAttachments", () => {
attachmentMngr.register("char_creator_1", "prop_beggers_sign_04", 28422, new mp.Vector3(0, 0, 0), new mp.Vector3(0, 0, 0));
attachmentMngr.register("ammobox", "gr_prop_gr_crate_mag_01a", 28422, new mp.Vector3(0, -0.18, -0.18), new mp.Vector3(0, 0, 0));
attachmentMngr.register("binbag", "prop_cs_rub_binbag_01", 28422, new mp.Vector3(0.08, 0.0, -0.03), new mp.Vector3(270.0, 0.0, 25.0));
attachmentMngr.register("weapondeal", "ex_prop_crate_ammo_bc", "chassis_dummy", new mp.Vector3(0.08, -0.9, -0.2), new mp.Vector3(0, 0, 0));
attachmentMngr.register("weapondeal1", "ex_office_swag_guns02", "chassis_dummy", new mp.Vector3(0, 0.8, 0), new mp.Vector3(0, 0, 0));
attachmentMngr.register("weapondeal2", "w_sg_pumpshotgun", "weapondeal2w_sg_pumpshotgun", new mp.Vector3(0.4, 1.6, 0.62), new mp.Vector3(90, 0, 180));
});
const attachmentMngr =
{
attachments: {},
addFor: function (entityRage, id) {
let entity;
if (entityRage.type === "player") {
entity = game.players.at(entityRage.remoteId);
} else if (entityRage.type === "vehicle") {
entity = game.vehicles.at(entityRage.remoteId);
}
let e = game.attachments.get(entity);
if (this.attachments.hasOwnProperty(id)) {
if (e.__attachmentObjects == undefined) { e.__attachmentObjects = []; }
if (!e.__attachmentObjects.hasOwnProperty(id)) {
let attInfo = this.attachments[id];
let object = mp.objects.new(attInfo.model, entityRage.position);
object.attachTo(entityRage.handle,
(typeof (attInfo.boneName) === 'string') ? entityRage.getBoneIndexByName(attInfo.boneName) : entityRage.getBoneIndex(attInfo.boneName),
attInfo.offset.x, attInfo.offset.y, attInfo.offset.z,
attInfo.rotation.x, attInfo.rotation.y, attInfo.rotation.z,
false, false, false, false, 2, true);
e.__attachmentObjects[id] = object;
}
}
else {
mp.game.graphics.notify(`Static Attachments Error: ~r~Unknown Attachment Used: ~w~0x${id.toString(16)}`);
}
},
removeFor: function (entityRage, id) {
let entity;
if (entityRage.type === "player") {
entity = game.players.at(entityRage.remoteId);
} else if (entityRage.type === "vehicle") {
entity = game.vehicles.at(entityRage.remoteId);
}
let e = game.attachments.get(entity);
if (e.__attachmentObjects.hasOwnProperty(id)) {
let obj = e.__attachmentObjects[id];
obj.destroy();
delete e.__attachmentObjects[id];
}
},
initFor: function (entityRage) {
let entity;
if (entityRage.type === "player") {
entity = game.players.at(entityRage.remoteId);
} else if (entityRage.type === "vehicle") {
entity = game.vehicles.at(entityRage.remoteId);
}
let e = game.attachments.get(entity);
if (e != null) {
for (let attachment of e.__attachments) {
attachmentMngr.addFor(entityRage, attachment);
}
}
},
shutdownFor: function (entityRage) {
let entity;
if (entityRage.type === "player") {
entity = game.players.at(entityRage.remoteId);
} else if (entityRage.type === "vehicle") {
entity = game.vehicles.at(entityRage.remoteId);
}
let e = game.attachments.get(entity);
if (e != null) {
for (let attachment of e.__attachments) {
attachmentMngr.removeFor(entityRage, attachment);
}
}
},
register: function (id, model, boneName, offset, rotation) {
if (typeof (id) === 'string') {
id = mp.game.joaat(id);
}
if (typeof (model) === 'string') {
model = mp.game.joaat(model);
}
if (!this.attachments.hasOwnProperty(id)) {
if (mp.game.streaming.isModelInCdimage(model)) {
this.attachments[id] =
{
id: id,
model: model,
offset: offset,
rotation: rotation,
boneName: boneName
};
}
else {
mp.game.graphics.notify(`Static Attachments Error: ~r~Invalid Model(0x${model.toString(16)})`);
}
}
else {
mp.game.graphics.notify("Static Attachments Error: ~r~Duplicate Entry");
}
},
unregister: function (id) {
if (typeof (id) === 'string') {
id = mp.game.joaat(id);
}
if (this.attachments.hasOwnProperty(id)) {
this.attachments[id] = undefined;
}
},
addLocal: function (attachmentName) {
if (typeof (attachmentName) === 'string') {
attachmentName = mp.game.joaat(attachmentName);
}
let entity = game.players.local;
let e = game.attachments.get(entity);
if (!e.__attachments || e.__attachments.indexOf(attachmentName) === -1) {
mp.events.callRemote("staticAttachments.Add", attachmentName.toString(36));
}
},
removeLocal: function (attachmentName) {
if (typeof (attachmentName) === 'string') {
attachmentName = mp.game.joaat(attachmentName);
}
let entity = game.players.local;
let e = game.attachments.get(entity);
if (e.__attachments && e.__attachments.indexOf(attachmentName) !== -1) {
mp.events.callRemote("staticAttachments.Remove", attachmentName.toString(36));
}
},
getAttachments: function () {
return Object.assign({}, this.attachments);
}
};
mp.events.add("entityStreamIn", (entityRage) => {
if (entityRage.type === "player" || entityRage.type === "vehicle") {
let entity;
if (entityRage.type === "player") {
entity = game.players.at(entityRage.remoteId);
} else if (entityRage.type === "vehicle") {
entity = game.vehicles.at(entityRage.remoteId);
}
let e = game.attachments.get(entity);
if (e != null) {
if (e.__attachments) {
game.wait(5000);
attachmentMngr.initFor(entityRage);
}
}
}
});
mp.events.add("entityStreamOut", (entityRage) => {
if (entityRage == mp.players.local.vehicle) { mp.gui.chat.push("lol"); return; }
if (entityRage.type === "player" || entityRage.type === "vehicle") {
let e = game.attachments.at(entityRage.remoteId);
if (e != null) {
if (e.__attachmentObjects) {
//game.wait(2500);
attachmentMngr.shutdownFor(entityRage);
}
}
}
});
mp.events.addDataHandler("attachmentsData", (entityRage, data) => {
let newAttachments = (data != null) ? data.split('|').map(att => parseInt(att, 36)) : [];
if (entityRage.handle !== 0) {
let entity;
if (entityRage.type === "player") {
entity = game.players.at(entityRage.remoteId);
} else if (entityRage.type === "vehicle") {
entity = game.vehicles.at(entityRage.remoteId);
}
let e = game.attachments.get(entity);
if (e == null) {
let __attachments = [];
let __attachmentObjects = [];
e = game.attachments.set(entity, __attachments, __attachmentObjects);
}
let oldAttachments = e.__attachments;
if (!oldAttachments) {
oldAttachments = [];
e.__attachmentObjects = [];
}
// process outdated first
for (let attachment of oldAttachments.keys()) {
var obj = oldAttachments[attachment];
if (newAttachments.indexOf(obj) === -1) {
attachmentMngr.removeFor(entityRage, obj);
}
}
// then new attachments
for (let attachment of newAttachments) {
if (oldAttachments.indexOf(attachment) === -1) {
attachmentMngr.addFor(entityRage, attachment);
}
}
e.__attachments = newAttachments;
}
});
function InitAttachmentsOnJoin() {
game.players.forEach(_player => {
let player = mp.players.at(_player.remoteId);
let e = game.attachments.get(_player);
if (e == null) {
let __attachments = [];
let __attachmentObjects = [];
e = game.attachments.set(_player, __attachments, __attachmentObjects);
}
let data = player.getVariable("attachmentsData");
if (data && data.length > 0) {
let atts = data.split('|').map(att => parseInt(att, 36));
e.__attachments = atts;
e.__attachmentObjects = [];
}
});
game.vehicles.forEach(_veh => {
let vehicle = mp.vehicles.at(_veh.remoteId);
let e = game.attachments.get(_veh);
if (e == null) {
let __attachments = [];
let __attachmentObjects = [];
e = game.attachments.set(_veh, __attachments, __attachmentObjects);
}
let data = vehicle.getVariable("attachmentsData");
if (data && data.length > 0) {
let atts = data.split('|').map(att => parseInt(att, 36));
e.__attachments = atts;
e.__attachmentObjects = [];
}
});
}
InitAttachmentsOnJoin();
}

View File

@@ -0,0 +1,28 @@
export default function relativeVector() {
mp.events.add("SERVER:setMarkerBehindVehicle", (vehicle: EntityMp) => {
var boneIndex2 = vehicle.getBoneIndexByName("platelight");
var boneIndex1 = vehicle.getBoneIndexByName("chassis_dummy");
let posPlate = vehicle.getWorldPositionOfBone(boneIndex2);
let posCentre = vehicle.getWorldPositionOfBone(boneIndex1);
let plateVec = new mp.Vector3(posPlate.x, posPlate.y, posPlate.z);
let lightVec = new mp.Vector3(posCentre.x, posCentre.y, posCentre.z);
let posPL = lightVec.subtract(plateVec);
let temp = new mp.Vector3(posPL.x * -1, posPL.y * -1, posPL.z * -1)
let length = Math.sqrt((temp.x * temp.x) + (temp.y * temp.y) + (temp.z * temp.z));
let x = temp.x / length;
let y = temp.y / length;
let z = temp.z / length;
temp = new mp.Vector3(x, y, z - 1);
let pos = plateVec.add(temp);
mp.events.callRemote("CLIENT:setMarkerBehindVehicle", JSON.stringify(vehicle.remoteId), JSON.stringify(pos.x), JSON.stringify(pos.y), JSON.stringify(pos.z));
});
}