forked from Simnation/Main
41 lines
2 KiB
Lua
41 lines
2 KiB
Lua
ESX = nil
|
|
QBCore = nil
|
|
|
|
if (GetResourceState('es_extended') == 'started') then
|
|
ESX = exports['es_extended']:getSharedObject()
|
|
elseif (GetResourceState('qb-core') == 'started') then
|
|
QBCore = exports['qb-core']:GetCoreObject()
|
|
end
|
|
|
|
Functions = {}
|
|
|
|
-- This function give the player a specific item
|
|
Functions.GiveItem = function(source, itemName, amount)
|
|
-- This is an anticheat measure, check sv_config.lua for more information
|
|
if SVConfig.EnableItemCheck then
|
|
local isAllowed = SVConfig.AllowedItems[itemName]
|
|
if not isAllowed then
|
|
-- You can replace this with an anti-cheat message of your own, or even an auto-ban
|
|
print("gs_advancedtrunk: " .. source .. " tried to spawn a disallowed item: " .. itemName .. " x" .. amount)
|
|
return
|
|
end
|
|
end
|
|
|
|
-- Case for ESX
|
|
if (ESX ~= nil) then
|
|
local xPlayer = ESX.GetPlayerFromId(source)
|
|
xPlayer.addInventoryItem(itemName, amount)
|
|
|
|
-- Case for QBCore
|
|
elseif (QBCore ~= nil) then
|
|
local Player = QBCore.Functions.GetPlayer(source)
|
|
Player.Functions.AddItem(itemName, amount)
|
|
else
|
|
print("gs_advancedtrunk: No framework defined, unable to give item.")
|
|
end
|
|
end
|
|
|
|
-- The exports below can be triggered from the SERVER which will add or remove the trunk props for a vehicle. Normally, the trunk props should automatically be added or removed when the vehicle is created or deleted with the player as the driver.
|
|
-- But in some cases, you might want to add or remove the trunk props manually. For example, if you are using a vehicle spawn script that doesn't trigger the entityCreated or entityRemoved events or if you spawn a vehicle without teleporting the player to the driver seat.
|
|
exports('AddTrunkProps', AddTrunkProps) -- Call through exports.gs_advancedtrunk:AddTrunkProps(entity)
|
|
exports('RemoveTrunkProps', RemoveTrunkProps) -- Call through exports.gs_advancedtrunk:RemoveTrunkProps(entity)
|