From fb15ebd5081af2cdfd8fb84d6d53f31ad296c569 Mon Sep 17 00:00:00 2001 From: moscovium Date: Sun, 11 Jun 2017 13:49:12 +0200 Subject: [PATCH] update some stock res --- .../mapmanager/mapmanager_client.lua | 2 +- resources/[system]/baseevents/deathevents.lua | 2 +- resources/[system]/spawnmanager/__resource.lua | 1 + .../[system]/spawnmanager/spawnmanager.lua | 18 ++++++++++++++++++ 4 files changed, 21 insertions(+), 2 deletions(-) diff --git a/resources/[managers]/mapmanager/mapmanager_client.lua b/resources/[managers]/mapmanager/mapmanager_client.lua index 515728b..3995167 100644 --- a/resources/[managers]/mapmanager/mapmanager_client.lua +++ b/resources/[managers]/mapmanager/mapmanager_client.lua @@ -87,7 +87,7 @@ AddEventHandler('onClientResourceStart', function(res) end) end) -AddEventHandler('onClientResourceStop', function(res) +AddEventHandler('onResourceStop', function(res) if maps[res] then TriggerEvent('onClientMapStop', res) elseif gametypes[res] then diff --git a/resources/[system]/baseevents/deathevents.lua b/resources/[system]/baseevents/deathevents.lua index d87871c..089cdc3 100644 --- a/resources/[system]/baseevents/deathevents.lua +++ b/resources/[system]/baseevents/deathevents.lua @@ -38,7 +38,7 @@ Citizen.CreateThread(function() else killerid = -1 end - if killer == ped then + if killer == ped or killer == -1 then TriggerEvent('baseevents:onPlayerDied', killertype, { table.unpack(GetEntityCoords(ped)) }) TriggerServerEvent('baseevents:onPlayerDied', killertype, { table.unpack(GetEntityCoords(ped)) }) hasBeenDead = true diff --git a/resources/[system]/spawnmanager/__resource.lua b/resources/[system]/spawnmanager/__resource.lua index e77aef6..71eccd4 100644 --- a/resources/[system]/spawnmanager/__resource.lua +++ b/resources/[system]/spawnmanager/__resource.lua @@ -3,6 +3,7 @@ client_script 'spawnmanager.lua' export 'getRandomSpawnPoint' export 'spawnPlayer' export 'addSpawnPoint' +export 'removeSpawnPoint' export 'loadSpawns' export 'setAutoSpawn' export 'setAutoSpawnCallback' diff --git a/resources/[system]/spawnmanager/spawnmanager.lua b/resources/[system]/spawnmanager/spawnmanager.lua index c211fd8..b4cf87b 100644 --- a/resources/[system]/spawnmanager/spawnmanager.lua +++ b/resources/[system]/spawnmanager/spawnmanager.lua @@ -85,6 +85,8 @@ function loadSpawns(spawnString) end end +local spawnNum = 1 + function addSpawnPoint(spawn) -- validate the spawn (position) if not tonumber(spawn.x) or not tonumber(spawn.y) or not tonumber(spawn.z) then @@ -117,8 +119,24 @@ function addSpawnPoint(spawn) -- overwrite the model in case we hashed it spawn.model = model + -- add an index + spawn.idx = spawnNum + spawnNum = spawnNum + 1 + -- all OK, add the spawn entry to the list table.insert(spawnPoints, spawn) + + return spawn.idx +end + +-- removes a spawn point +function removeSpawnPoint(spawn) + for i = 1, #spawnPoints do + if spawnPoints[i].idx == spawn then + table.remove(spawnPoints, i) + return + end + end end -- changes the auto-spawn flag