mirror of
https://github.com/kac5a/k5_documents.git
synced 2026-03-31 06:23:55 -04:00
add usable item config
This commit is contained in:
@@ -250,6 +250,11 @@ AddEventHandler('k5_documents:copyGave', function(data)
|
|||||||
Notification(Config.Locale.giveNotification .. " " .. data)
|
Notification(Config.Locale.giveNotification .. " " .. data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("k5_documents:useItem")
|
||||||
|
AddEventHandler("k5_documents:useItem", function()
|
||||||
|
ExecuteCommand(Config.Command)
|
||||||
|
end)
|
||||||
|
|
||||||
|
|
||||||
RegisterNetEvent('k5_documents:copyReceived')
|
RegisterNetEvent('k5_documents:copyReceived')
|
||||||
AddEventHandler('k5_documents:copyReceived', function(data)
|
AddEventHandler('k5_documents:copyReceived', function(data)
|
||||||
|
|||||||
@@ -2,6 +2,8 @@ Config = {}
|
|||||||
|
|
||||||
Config.Command = "documents"
|
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 = {
|
Config.PaperProp = {
|
||||||
name = "prop_cd_paper_pile1",
|
name = "prop_cd_paper_pile1",
|
||||||
xRot = -130.0,
|
xRot = -130.0,
|
||||||
|
|||||||
@@ -2,8 +2,8 @@ fx_version "cerulean"
|
|||||||
|
|
||||||
description "A better document management script"
|
description "A better document management script"
|
||||||
author "K5 Scripts"
|
author "K5 Scripts"
|
||||||
version '1.2.0'
|
version '1.2.1'
|
||||||
update "ESX import change, added different logo options for jobs, custom CSS options"
|
update "Added usable item config"
|
||||||
repository 'https://github.com/kac5a/k5_documents'
|
repository 'https://github.com/kac5a/k5_documents'
|
||||||
|
|
||||||
lua54 'yes'
|
lua54 'yes'
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
local RegisterCallback
|
local RegisterCallback
|
||||||
|
local RegisterItem
|
||||||
ESX = nil
|
ESX = nil
|
||||||
local QBCore
|
local QBCore
|
||||||
local CurrentFramework
|
local CurrentFramework
|
||||||
@@ -17,11 +18,17 @@ if CurrentFramework == "esx" then
|
|||||||
RegisterCallback = function (name, fn)
|
RegisterCallback = function (name, fn)
|
||||||
ESX.RegisterServerCallback(name, fn)
|
ESX.RegisterServerCallback(name, fn)
|
||||||
end
|
end
|
||||||
|
RegisterItem = function(itemName, fn)
|
||||||
|
ESX.RegisterUsableItem(itemName, fn)
|
||||||
|
end
|
||||||
elseif CurrentFramework == "qb" then
|
elseif CurrentFramework == "qb" then
|
||||||
QBCore = exports['qb-core']:GetCoreObject()
|
QBCore = exports['qb-core']:GetCoreObject()
|
||||||
RegisterCallback = function (name, fn)
|
RegisterCallback = function (name, fn)
|
||||||
QBCore.Functions.CreateCallback(name, fn)
|
QBCore.Functions.CreateCallback(name, fn)
|
||||||
end
|
end
|
||||||
|
RegisterItem = function(itemName, fn)
|
||||||
|
QBCore.Functions.CreateUseableItem(itemName, fn)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Citizen.CreateThread(function()
|
Citizen.CreateThread(function()
|
||||||
@@ -90,6 +97,12 @@ RegisterCallback('k5_documents:getPlayerCopies', function(source, cb)
|
|||||||
end)
|
end)
|
||||||
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)
|
RegisterCallback('k5_documents:getPlayerDocuments', function(source, cb)
|
||||||
local src = source
|
local src = source
|
||||||
@@ -279,6 +292,17 @@ AddEventHandler("k5_documents:receiveDocument", function(data, targetId)
|
|||||||
end)
|
end)
|
||||||
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)
|
function GetPlayerIdentifier(src)
|
||||||
local PlayerIdentifier
|
local PlayerIdentifier
|
||||||
if CurrentFramework == "esx" then
|
if CurrentFramework == "esx" then
|
||||||
|
|||||||
Reference in New Issue
Block a user