Added persistent/onplayerload option.
This commit is contained in:
parent
7108f3fed8
commit
f1a2d3fb13
@ -1,4 +1,20 @@
|
|||||||
local entity_ids = {}
|
local entity_ids = {}
|
||||||
|
if Config.Persistent then
|
||||||
|
if Config.Framework == 'qb' then
|
||||||
|
QBCore = exports['qb-core']:GetCoreObject()
|
||||||
|
AddEventHandler('QBCore:Client:OnPlayerLoaded', function()
|
||||||
|
Wait(1500)
|
||||||
|
SpawnProps()
|
||||||
|
end)
|
||||||
|
elseif Config.Framework == 'esx' then
|
||||||
|
local ESX = exports["es_extended"]:getSharedObject()
|
||||||
|
RegisterNetEvent('esx:playerLoaded')
|
||||||
|
AddEventHandler('esx:playerLoaded', function()
|
||||||
|
Wait(1500)
|
||||||
|
SpawnProps()
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function SpawnProps()
|
function SpawnProps()
|
||||||
for k, v in pairs(Config.PropLocations) do
|
for k, v in pairs(Config.PropLocations) do
|
||||||
@ -6,7 +22,7 @@ function SpawnProps()
|
|||||||
while not HasModelLoaded(v.model) do
|
while not HasModelLoaded(v.model) do
|
||||||
Wait(0)
|
Wait(0)
|
||||||
end
|
end
|
||||||
local prop = CreateObject(v.model, v.coords.x, v.coords.y, v.coords.z - 1, true, true, false)
|
local prop = CreateObject(v.model, v.coords.x, v.coords.y, v.coords.z - 1, false, true, false)
|
||||||
entity_ids[#entity_ids + 1] = prop
|
entity_ids[#entity_ids + 1] = prop
|
||||||
SetEntityHeading(prop, v.coords.w - 180)
|
SetEntityHeading(prop, v.coords.w - 180)
|
||||||
FreezeEntityPosition(prop, true)
|
FreezeEntityPosition(prop, true)
|
||||||
@ -22,13 +38,14 @@ function DeleteProps()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if Config.debug then
|
||||||
RegisterCommand(Config.DeleteCommand, function()
|
RegisterCommand(Config.DeleteCommand, function()
|
||||||
DeleteProps()
|
DeleteProps()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterCommand(Config.SpawnCommand, function()
|
RegisterCommand(Config.SpawnCommand, function()
|
||||||
SpawnProps()
|
SpawnProps()
|
||||||
end)
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(resourceName)
|
AddEventHandler('onResourceStop', function(resourceName)
|
||||||
if (GetCurrentResourceName() ~= resourceName) then return end
|
if (GetCurrentResourceName() ~= resourceName) then return end
|
||||||
|
@ -1,9 +1,12 @@
|
|||||||
Config = {}
|
Config = {}
|
||||||
|
|
||||||
|
Config.Persistent = true --Spawn props on player load.
|
||||||
|
Config.FrameWork = 'qb' --qb or esx
|
||||||
|
Config.debug = false --Enables prints and commands below.
|
||||||
Config.SpawnCommand = 'spawnprops'
|
Config.SpawnCommand = 'spawnprops'
|
||||||
Config.DeleteCommand = 'deleteprops'
|
Config.DeleteCommand = 'deleteprops'
|
||||||
|
|
||||||
Config.PropLocations = {
|
Config.PropLocations = {
|
||||||
[1] = { coords = vector4(-1652.76, -3143.40, 13.99, 76), model = `YOURPROPNAMEHERE` },
|
[1] = { coords = vector4(-1652.76, -3143.40, 13.99, 76), model = `bkr_prop_clubhouse_jukebox_02a` },
|
||||||
[2] = { coords = vector4(-1658.76, -3143.40, 13.99, 76), model = `YOURPROPNAMEHERE` },
|
[2] = { coords = vector4(-1658.76, -3143.40, 13.99, 76), model = `hei_prop_heist_box` },
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user