This commit is contained in:
hydrant
2021-03-27 16:28:10 +01:00
parent 043a2f3a83
commit 7238764307
4 changed files with 38 additions and 16 deletions

View File

@@ -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;
}
}