From 3c11eb5e8eb0600a7d5f865a108f142ee840fa4f Mon Sep 17 00:00:00 2001 From: Vortrex <3858226+VortrexFTW@users.noreply.github.com> Date: Fri, 3 Dec 2021 10:22:35 -0600 Subject: [PATCH] Start working on persistent NPCs --- scripts/server/npc.js | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/scripts/server/npc.js b/scripts/server/npc.js index b053464c..2bc79dca 100644 --- a/scripts/server/npc.js +++ b/scripts/server/npc.js @@ -17,4 +17,31 @@ function getNPCData(ped) { return false; } +// =========================================================================== + +function createNPCCommand(client, command, params) { + if(areParamsEmpty(params)) { + messagePlayerSyntax(client, getCommandSyntaxText(command)); + return false; + } + + let skinId = getSkinModelIndexFromParams(params); + + if(!skinId) { + messagePlayerError(client, `Invalid skin`); + return false; + } + + let position = getPosInFrontOfPos(getPlayerPosition(client), getPlayerHeading(client), 3); + + let tempNPCData = new NPCData(false); + tempNPCData.position = position; + tempNPCData.heading = getPlayerHeading(client); + tempNPCData.skin = skinId; + + let npcIndex = getServerData().npcs.push(tempNPCData); + + spawnNPC(npcIndex-1); +} + // =========================================================================== \ No newline at end of file