From 2130c783bc90b3b0e12d512c6f64bae64e2cc120 Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Thu, 20 Jan 2022 03:11:44 -0600 Subject: [PATCH] Add some JSDoc info for intellisense --- scripts/server/animation.js | 4 ++++ scripts/server/business.js | 4 ++++ scripts/server/clan.js | 4 ++++ scripts/server/house.js | 4 ++++ scripts/server/npc.js | 19 ++++++++++++++++--- scripts/server/utilities.js | 4 ++++ scripts/server/vehicle.js | 4 ++++ 7 files changed, 40 insertions(+), 3 deletions(-) diff --git a/scripts/server/animation.js b/scripts/server/animation.js index b6aa16e3..271fcb3e 100644 --- a/scripts/server/animation.js +++ b/scripts/server/animation.js @@ -83,6 +83,10 @@ function showAnimationListCommand(command, params, client) { // =========================================================================== +/** + * @param {number} animationSlot - The slot index of the animation + * @return {Array} The animation's data (array) + */ function getAnimationData(animationSlot, gameId = getServerGame()) { return getGameData().animations[gameId][animationSlot]; } diff --git a/scripts/server/business.js b/scripts/server/business.js index 87775966..0dcd81d4 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -1506,6 +1506,10 @@ function getBusinessOwnerTypeText(ownerType) { // =========================================================================== +/** + * @param {number} businessId - The data index of the business + * @return {BusinessData} The business's data (class instance) + */ function getBusinessData(businessId) { if(typeof getServerData().businesses[businessId] != null) { return getServerData().businesses[businessId]; diff --git a/scripts/server/clan.js b/scripts/server/clan.js index 3e1199d3..f2d8fa1a 100644 --- a/scripts/server/clan.js +++ b/scripts/server/clan.js @@ -887,6 +887,10 @@ function deleteClan(clanId) { // =========================================================================== +/** + * @param {number} clanId - The data index of the clan + * @return {ClanData} The clan's data (class instance) + */ function getClanData(clanId) { if(typeof getServerData().clans[clanId] != null) { return getServerData().clans[clanId]; diff --git a/scripts/server/house.js b/scripts/server/house.js index d559aca6..a7626982 100644 --- a/scripts/server/house.js +++ b/scripts/server/house.js @@ -1116,6 +1116,10 @@ function isPlayerInAnyHouse(client) { // =========================================================================== +/** + * @param {number} houseIndex - The data index of the house + * @return {HouseData} The house's data (class instance) + */ function getHouseData(houseId) { if(typeof getServerData().houses[houseId] != "undefined") { return getServerData().houses[houseId]; diff --git a/scripts/server/npc.js b/scripts/server/npc.js index 65c40b2e..745e5930 100644 --- a/scripts/server/npc.js +++ b/scripts/server/npc.js @@ -8,13 +8,19 @@ // =========================================================================== function initNPCScript() { - loadNPCsFromDatabase(); + getServerData().npcs = loadNPCsFromDatabase(); setAllNPCDataIndexes(); + + spawnAllNPCs(); } // =========================================================================== -function getNPCData(ped) { +/** + * @param {number} npcId - The data index of the NPC + * @return {NPCData} The NPC's data (class instancee) + */ +function getNPCData(npcId) { return ped.getData("vrr.dataIndex"); } @@ -187,7 +193,14 @@ function spawnNPC(npcIndex) { let civilian = createGameCivilian(getNPCData(npcIndex).model, getNPCData(npcIndex).spawnPosition, getNPCData(npcIndex).spawnRotation); if(civilian) { civilian.setData("vrr.dataIndex", npcIndex); + getNPCData(npcIndex).ped = civilian; } } -// =========================================================================== \ No newline at end of file +// =========================================================================== + +function spawnAllNPCs() { + for(let i in getServerData().npcs) { + spawnNPC(npcIndex); + } +} \ No newline at end of file diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index db77d6ef..6df4839f 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -57,6 +57,10 @@ function getGameAreas(gameId) { // =========================================================================== +/** + * @param {Client} client - The client + * @return {ClientData} The player/client's data (class instancee) + */ function getPlayerData(client) { if(client != null) { return getServerData().clients[client.index]; diff --git a/scripts/server/vehicle.js b/scripts/server/vehicle.js index 49616035..ba777cba 100644 --- a/scripts/server/vehicle.js +++ b/scripts/server/vehicle.js @@ -189,6 +189,10 @@ function spawnAllVehicles() { // =========================================================================== +/** + * @param {Vehicle} vehicle - The vehicle element + * @return {VehicleData} The vehicles's data (class instance) + */ function getVehicleData(vehicle) { if(isVehicleObject(vehicle)) { let dataIndex = getEntityData(vehicle, "vrr.dataSlot");