From 72387643075fc4c19472ec43b134c2941e9aa720 Mon Sep 17 00:00:00 2001 From: hydrant Date: Sat, 27 Mar 2021 16:28:10 +0100 Subject: [PATCH] test --- ReallifeGamemode.Client/Gui/blips.ts | 21 ++++++++------ .../core/rage-mp/entities.ts | 4 +++ ReallifeGamemode.Client/game.ts | 1 + .../util/attachmentMngr.ts | 28 ++++++++++++++----- 4 files changed, 38 insertions(+), 16 deletions(-) diff --git a/ReallifeGamemode.Client/Gui/blips.ts b/ReallifeGamemode.Client/Gui/blips.ts index e6a105f7..4020d0c5 100644 --- a/ReallifeGamemode.Client/Gui/blips.ts +++ b/ReallifeGamemode.Client/Gui/blips.ts @@ -1,16 +1,16 @@ - - -const Natives = { - SET_BLIP_CATEGORY: "0x234CDD44D996FD9A", - SHOW_HEADING_INDICATOR_ON_BLIP: "0x5FBCA48327B914DF", - SET_BLIP_AS_SHORT_RANGE: "0xBE8BE4FE60E27B72", - SET_BLIP_DISPLAY: "0x9029B2F3DA924928" +const Natives = { + SET_BLIP_CATEGORY: RageEnums.Natives.Ui.SET_BLIP_CATEGORY, + SHOW_HEADING_INDICATOR_ON_BLIP: RageEnums.Natives.Ui.SHOW_HEADING_INDICATOR_ON_BLIP, + SET_BLIP_AS_SHORT_RANGE: RageEnums.Natives.Ui.SET_BLIP_AS_SHORT_RANGE, + SET_BLIP_DISPLAY: RageEnums.Natives.Ui.SET_BLIP_DISPLAY }; export default function playerBlips() { mp.events.add("entityStreamIn", (entity) => { if (entity.type === "player") { + var entityMp = entity; + mp.gui.chat.push("Player recieved: Yes"); let color = parseInt(entity.getVariable("blipColor")); @@ -19,19 +19,22 @@ export default function playerBlips() { entity.createBlip(1); + var blip: BlipMp; + mp.gui.chat.push(parseInt(entity.blip) == 0 ? "Blip was not created" : "Blip was created"); mp.gui.chat.push("entity.blip is actually " + entity.blip); var blip = mp.blips.at(entity.blip); - mp.gui.chat.push("1 -" + blip.getAlpha() + " 2- " + blip.doesExist() + " 3-" + blip.dimension); + mp.gui.chat.push("1 -" + blip.getAlpha() + " 2- " + blip.doesExist() + " 3-" + blip.dimension + " 4-" + entityMp.dimension); entity.setBlipColor(isNaN(color) ? 0 : color); + mp.game.invoke(Natives.SET_BLIP_CATEGORY, entity.blip, 7); mp.game.invoke(Natives.SHOW_HEADING_INDICATOR_ON_BLIP, entity.blip, true); mp.game.invoke(Natives.SET_BLIP_AS_SHORT_RANGE, entity.blip, true); - mp.game.invoke(Natives.SET_BLIP_DISPLAY, entity.blip, 8); + //mp.game.invoke(Natives.SET_BLIP_DISPLAY, entity.blip, 8); } }); diff --git a/ReallifeGamemode.Client/core/rage-mp/entities.ts b/ReallifeGamemode.Client/core/rage-mp/entities.ts index 49a411cf..42130b45 100644 --- a/ReallifeGamemode.Client/core/rage-mp/entities.ts +++ b/ReallifeGamemode.Client/core/rage-mp/entities.ts @@ -13,6 +13,10 @@ class RageEntity implements IEntity { return this.entity.id; } + get handle() { + return this.entity.handle; + } + get remoteId(): number { if (!this.entity) { return null; diff --git a/ReallifeGamemode.Client/game.ts b/ReallifeGamemode.Client/game.ts index 53b45caa..4ae798f5 100644 --- a/ReallifeGamemode.Client/game.ts +++ b/ReallifeGamemode.Client/game.ts @@ -43,6 +43,7 @@ interface IBrowser { interface IEntity { id: number; remoteId: number; + handle: number; type: EntityType; getSharedData(key: string): T; } diff --git a/ReallifeGamemode.Client/util/attachmentMngr.ts b/ReallifeGamemode.Client/util/attachmentMngr.ts index 03eed85e..8ce4599d 100644 --- a/ReallifeGamemode.Client/util/attachmentMngr.ts +++ b/ReallifeGamemode.Client/util/attachmentMngr.ts @@ -1,6 +1,8 @@ -import { IGame, EntityType } from "../game"; +import { IGame, EntityType, IEntity } from "../game"; import relativeVector from "./relativevector"; +var attachId = 0; + 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)); @@ -21,11 +23,19 @@ export default function attachmentManager(game: IGame) { return; } - let entity; + ++attachId; + + let entity: IEntity; if (entityRage.type === "player") { - entity = game.players.at(entityRage.remoteId); + var player = game.players.at(entityRage.remoteId); + entity = player; + mp.gui.chat.push(`ATTACH: ${attachId} - Player: ${player.name}`); + } else if (entityRage.type === "vehicle") { - entity = game.vehicles.at(entityRage.remoteId); + var vehicle = game.vehicles.at(entityRage.remoteId); + entity = vehicle; + var realName = mp.game.ui.getLabelText(mp.game.vehicle.getDisplayNameFromVehicleModel(entityRage.model)); + mp.gui.chat.push(`ATTACH: ${attachId} - Vehicle: ${vehicle.remoteId}, ${realName}`); } let e = game.attachments.get(entity); @@ -36,12 +46,16 @@ export default function attachmentManager(game: IGame) { 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), + var bone = (typeof (attInfo.boneName) === 'string') ? entityRage.getBoneIndexByName(attInfo.boneName) : entityRage.getBoneIndex(attInfo.boneName) + + mp.gui.chat.push(`ATTACH: ${attachId} - bone = ${bone}`) + + object.attachTo(entity.id, + bone, attInfo.offset.x, attInfo.offset.y, attInfo.offset.z, attInfo.rotation.x, attInfo.rotation.y, attInfo.rotation.z, false, false, false, false, 2, true); - + mp.gui.chat.push(`ATTACH: ${attachId} - Attaching ${JSON.stringify(attInfo)}`); e.__attachmentObjects[id] = object; } }