UNPKG

rock-mod

Version:

Rock-Mod is a powerful framework designed for creating and managing mods for Grand Theft Auto (GTA) games.

156 lines (155 loc) 5.04 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.AltVPlayer = void 0; const AltVEntity_1 = require("../entity/AltVEntity"); const RockMod_1 = require("../../../RockMod"); var Player = AltVServer.Player; var Vehicle = AltVServer.Vehicle; var Vector3 = AltVShared.Vector3; var hash = AltVShared.hash; const Math_1 = require("../../../../shared/common/utils/math/Math"); class AltVPlayer extends AltVEntity_1.AltVEntity { get name() { return this.mpEntity.name; } get socialClub() { return this.mpEntity.socialClubName; } get heading() { return this.mpEntity.headRot.z; } get health() { return this.mpEntity.health; } get armour() { return this.mpEntity.armour; } get isDead() { return this.mpEntity.isDead; } get ip() { return this.mpEntity.ip; } get serial() { return this.mpEntity.hwidHash; } get vehicle() { const mpVehicle = this.mpEntity.vehicle; if (!mpVehicle) { return null; } return RockMod_1.RockMod.instance.vehicles.getByID(mpVehicle.id); } get seat() { return this.mpEntity.seat; } get weapon() { return this.mpEntity.currentWeapon; } get weaponAmmo() { return this.mpEntity.getAmmo(this.weapon); } get eyeColor() { return this.mpEntity.getEyeColor(); } get streamedPlayers() { const players = []; for (const { entity } of this.mpEntity.streamedEntities) { if (entity instanceof Player) { players.push(RockMod_1.RockMod.instance.players.getByID(entity.id)); } } return players; } constructor(options) { super(options); } emitEvent(eventName, ...args) { return RockMod_1.RockMod.instance.net.events.emitClient(this, eventName, ...args); } emitRPC(rpcName, ...args) { return RockMod_1.RockMod.instance.net.rpc.emitClient(this, rpcName, ...args); } spawn(position) { return this.mpEntity.spawn(position); } setName(name) { throw new Error(`Not implemented (setName: ${name})`); } setHeading(value) { this.mpEntity.rot = new Vector3(0, 0, value); } setHealth(value) { this.mpEntity.health = (0, Math_1.MathClamp)(value, 0, 100); } setArmour(value) { this.mpEntity.armour = (0, Math_1.MathClamp)(value, 0, 100); } setWeaponAmmo(weapon, ammo) { return this.mpEntity.setWeaponAmmo(weapon, ammo); } giveWeapon(weapon, ammo) { return this.mpEntity.giveWeapon(weapon, ammo, true); } removeWeapon(weapon) { return this.mpEntity.removeWeapon(hash(weapon)); } enableVoiceTo(player) { throw new Error(`Not implemented (enableVoiceTo: ${this.id} -> ${player.id})`); } disableVoiceTo(player) { throw new Error(`Not implemented (disableVoiceTo: ${this.id} -> ${player.id})`); } putIntoVehicle(vehicle, seat) { const mpVehicle = Vehicle.getByID(vehicle.id); if (!mpVehicle) { throw new Error(`Multiplayer vehicle with id ${vehicle.id} not found`); } return this.mpEntity.setIntoVehicle(mpVehicle, seat ?? 0); } ejectFromVehicle() { return this.mpEntity.clearTasks(); } setCustomization(data) { throw new Error(`Not implemented (setCustomization: ${data})`); } setHeadOverlay(overlayID, index, opacity, firstColor, secondColor) { this.mpEntity.setHeadOverlayColor(overlayID, 1, firstColor, secondColor); this.mpEntity.setHeadOverlay(overlayID, index, opacity); } setEyeColor(colorID) { this.mpEntity.setEyeColor(colorID); } setProp(propID, drawableID, textureID) { this.mpEntity.setProp(propID, drawableID, textureID); } setClothes(componentID, drawableID, textureID, paletteID) { this.mpEntity.setClothes(componentID, drawableID, textureID, paletteID); } setHairColor(colorID, highlightColorID) { this.mpEntity.setHairColor(colorID); this.mpEntity.setHairHighlightColor(highlightColorID); } kick(reason) { return this.mpEntity.kick(reason); } playAnimation(dictionary, name, speed, flag) { const durationDefault = 10000; const blendInSpeedDefault = undefined; const blendOutSpeedDefault = undefined; const duration = durationDefault * speed; const flags = flag; const playbackRate = 1; const lockX = false; const lockY = false; const lockZ = false; return this.mpEntity.playAnimation(dictionary, name, blendInSpeedDefault, blendOutSpeedDefault, duration, flags, playbackRate, lockX, lockY, lockZ); } stopAnimation() { this.mpEntity.clearTasks(); } removeFromVehicle() { throw new Error("Not implemented (removeFromVehicle)"); } } exports.AltVPlayer = AltVPlayer;