add usable item config

This commit is contained in:
kac5a
2022-09-30 17:14:27 +02:00
parent 2571b33943
commit 1f29913af1
4 changed files with 33 additions and 2 deletions

View File

@@ -250,6 +250,11 @@ AddEventHandler('k5_documents:copyGave', function(data)
Notification(Config.Locale.giveNotification .. " " .. data)
end)
RegisterNetEvent("k5_documents:useItem")
AddEventHandler("k5_documents:useItem", function()
ExecuteCommand(Config.Command)
end)
RegisterNetEvent('k5_documents:copyReceived')
AddEventHandler('k5_documents:copyReceived', function(data)

View File

@@ -2,6 +2,8 @@ Config = {}
Config.Command = "documents"
Config.DocumentItemName = nil -- The name of the item you want to open the documents. If nil, no item will be registered
Config.PaperProp = {
name = "prop_cd_paper_pile1",
xRot = -130.0,

View File

@@ -2,8 +2,8 @@ fx_version "cerulean"
description "A better document management script"
author "K5 Scripts"
version '1.2.0'
update "ESX import change, added different logo options for jobs, custom CSS options"
version '1.2.1'
update "Added usable item config"
repository 'https://github.com/kac5a/k5_documents'
lua54 'yes'

View File

@@ -1,4 +1,5 @@
local RegisterCallback
local RegisterItem
ESX = nil
local QBCore
local CurrentFramework
@@ -17,11 +18,17 @@ if CurrentFramework == "esx" then
RegisterCallback = function (name, fn)
ESX.RegisterServerCallback(name, fn)
end
RegisterItem = function(itemName, fn)
ESX.RegisterUsableItem(itemName, fn)
end
elseif CurrentFramework == "qb" then
QBCore = exports['qb-core']:GetCoreObject()
RegisterCallback = function (name, fn)
QBCore.Functions.CreateCallback(name, fn)
end
RegisterItem = function(itemName, fn)
QBCore.Functions.CreateUseableItem(itemName, fn)
end
end
Citizen.CreateThread(function()
@@ -90,6 +97,12 @@ RegisterCallback('k5_documents:getPlayerCopies', function(source, cb)
end)
end)
if Config.DocumentItemName then
RegisterItem(Config.DocumentItemName, function(source)
local src = source
TriggerClientEvent("k5_documents:useItem", src)
end)
end
RegisterCallback('k5_documents:getPlayerDocuments', function(source, cb)
local src = source
@@ -279,6 +292,17 @@ AddEventHandler("k5_documents:receiveDocument", function(data, targetId)
end)
end)
function GetPlayer(src)
local Player
if CurrentFramework == "esx" then
Player = ESX.GetPlayerFromId(src)
elseif CurrentFramework == "qb" then
Player = QBCore.Functions.GetPlayer(src)
end
return Player
end
function GetPlayerIdentifier(src)
local PlayerIdentifier
if CurrentFramework == "esx" then