Remove cache and batch event libraries, update locales
Deleted the cache and batch event libraries from the codebase, including all related client, server, and shared files. Removed server-side particle library and associated client event handlers. Updated utility and clothing modules to remove cache dependencies. Improved utility logging and deprecated point functions with notices. Updated all locales to use a consistent 'PurchasedItem' message format and added Bulgarian (bg) translation. Bumped version to 0.13.1 in fxmanifest.
This commit is contained in:
1 parent
5fd0744ca5
commit
48f8122197
76 files changed
+488
-875
No files matched your search
@@ -1,33 +1,34 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
Clothing = Clothing or {}
|
||||
|
||||
ClothingBackup = {}
|
||||
Callback = Callback or Require("lib/callback/shared/callback.lua")
|
||||
Ultility = Utility or Require('lib/utility/client/utility.lua')
|
||||
Cache = Cache or Require('lib/cache/shared/cache.lua')
|
||||
|
||||
|
||||
function Clothing.IsMale()
|
||||
local ped = PlayerPedId()
|
||||
if not ped then return end
|
||||
if GetEntityModel(ped) == `mp_m_freemode_01` then
|
||||
return true
|
||||
end
|
||||
return false
|
||||
end
|
||||
|
||||
local ClothingBackup = {}
|
||||
|
||||
---This will get the name of the in use resource.
|
||||
---@return string
|
||||
Clothing.GetResourceName = function()
|
||||
function Clothing.GetResourceName()
|
||||
return 'default'
|
||||
end
|
||||
|
||||
---This will open the clothing menu for a player, in the event there is not a supported menu it will print that.
|
||||
function Clothing.OpenMenu()
|
||||
print("^6 No supported clothing menu in use in community_bridge. ^0 ")
|
||||
end
|
||||
|
||||
---This will check if the player model if male/female
|
||||
---@return boolean
|
||||
function Clothing.IsMale()
|
||||
local ped = PlayerPedId()
|
||||
if not ped or not DoesEntityExist(ped) then return false end
|
||||
if GetEntityModel(ped) == `mp_m_freemode_01` then return true end
|
||||
return false
|
||||
end
|
||||
|
||||
---Get the skin data of a ped
|
||||
---@param entity number
|
||||
---@return table
|
||||
function Clothing.GetAppearance(entity)
|
||||
if not entity and not DoesEntityExist(entity) then return end
|
||||
if not entity and not DoesEntityExist(entity) then return {} end
|
||||
local model = GetEntityModel(entity)
|
||||
local skinData = { model = model, components = {}, props = {} }
|
||||
for i = 0, 11 do
|
||||
@@ -38,17 +39,10 @@ function Clothing.GetAppearance(entity)
|
||||
table.insert(skinData.props,
|
||||
{ prop_id = i, drawable = GetPedPropIndex(entity, i), texture = GetPedPropTextureIndex(entity, i) })
|
||||
end
|
||||
ClothingBackup = skinData
|
||||
return skinData
|
||||
end
|
||||
|
||||
function Clothing.CopyAppearanceToClipboard()
|
||||
local ped = PlayerPedId()
|
||||
if not ped or not DoesEntityExist(ped) then return end
|
||||
local skinData = Clothing.GetAppearance(ped)
|
||||
if not skinData then return end
|
||||
Ultility.CopyToClipboard(skinData)
|
||||
end
|
||||
|
||||
Callback.Register('community_bridge:cb:GetAppearance', function()
|
||||
local ped = PlayerPedId()
|
||||
if not ped or not DoesEntityExist(ped) then return end
|
||||
@@ -57,101 +51,45 @@ Callback.Register('community_bridge:cb:GetAppearance', function()
|
||||
end)
|
||||
|
||||
---Apply skin data to a ped
|
||||
---@param entity number
|
||||
---@param ped number
|
||||
---@param skinData table
|
||||
---@return boolean
|
||||
function Clothing.SetAppearance(entity, skinData)
|
||||
function Clothing.SetAppearance(ped, skinData)
|
||||
for k, v in pairs(skinData.components or {}) do
|
||||
if v.component_id then
|
||||
SetPedComponentVariation(entity, v.component_id, v.drawable, v.texture, 0)
|
||||
SetPedComponentVariation(ped, v.component_id, v.drawable, v.texture, 0)
|
||||
end
|
||||
end
|
||||
for k, v in pairs(skinData.props or {}) do
|
||||
if v.prop_id then
|
||||
SetPedPropIndex(entity, v.prop_id, v.drawable, v.texture, 0)
|
||||
SetPedPropIndex(ped, v.prop_id, v.drawable, v.texture, false)
|
||||
end
|
||||
end
|
||||
ClothingBackup = nil
|
||||
return true
|
||||
end
|
||||
|
||||
---This will return the peds components to the previously stored components
|
||||
---@param ped number
|
||||
---@return boolean
|
||||
Clothing.RestoreAppearance = function(entity)
|
||||
Clothing.SetAppearance(entity, ClothingBackup)
|
||||
Clothing.RestoreAppearance = function(ped)
|
||||
Clothing.SetAppearance(ped, ClothingBackup)
|
||||
return true
|
||||
end
|
||||
|
||||
Clothing.UpdateAppearanceBackup = function(data)
|
||||
ClothingBackup = data
|
||||
end
|
||||
|
||||
Clothing.RunningDebug = false
|
||||
Clothing.Cache = nil -- maybe change this to the actual cache system???!? For future not lazy me
|
||||
|
||||
Cache.Create('Clothing', function()
|
||||
local ped = Cache.Get('Ped')
|
||||
local appearance = Clothing.GetAppearance(ped)
|
||||
if Table.Compare(Clothing.Cache, appearance) then
|
||||
return false
|
||||
end
|
||||
return appearance
|
||||
end, 1000)
|
||||
|
||||
local onChange = nil
|
||||
Clothing.ToggleDebugging = function()
|
||||
if Clothing.RunningDebug then
|
||||
Clothing.RunningDebug = false
|
||||
print("Clothing Debugging Disabled")
|
||||
return Cache.RemoveOnChange('Clothing', onChange)
|
||||
end
|
||||
Clothing.RunningDebug = true
|
||||
print("Clothing Debugging Enabled")
|
||||
|
||||
if Clothing.OpenMenu then
|
||||
Clothing.OpenMenu()
|
||||
end
|
||||
|
||||
onChange = Cache.OnChange('Clothing', function(new, old)
|
||||
print("Clothing Debugging", new)
|
||||
for k, v in pairs(old.components) do
|
||||
if v.component_id then
|
||||
if new.components[k].drawable ~= v.drawable or new.components[k].texture ~= v.texture then
|
||||
print("Component ID: " ..
|
||||
v.component_id ..
|
||||
" Drawable: " .. new.components[k].drawable .. " Texture: " .. new.components[k].texture)
|
||||
end
|
||||
end
|
||||
end
|
||||
for k, v in pairs(old.props) do
|
||||
if v.prop_id then
|
||||
if new.props[k].drawable ~= v.drawable or new.props[k].texture ~= v.texture then
|
||||
print("Prop ID: " ..
|
||||
v.prop_id .. " Drawable: " .. new.props[k].drawable .. " Texture: " .. new.props[k].texture)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
RegisterNetEvent('community_bridge:client:SetAppearance', function(data)
|
||||
if source ~= 65535 then return end
|
||||
Clothing.SetAppearance(PlayerPedId(), data)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('community_bridge:client:GetAppearance', function()
|
||||
if source ~= 65535 then return end
|
||||
Clothing.GetAppearance(PlayerPedId())
|
||||
end)
|
||||
|
||||
RegisterNetEvent('community_bridge:client:RestoreAppearance', function()
|
||||
if source ~= 65535 then return end
|
||||
Clothing.RestoreAppearance(PlayerPedId())
|
||||
end)
|
||||
|
||||
-- RegisterCommand("clothing:enabledebug", function(source, args, rawCommand)
|
||||
-- Clothing.ToggleDebugging()
|
||||
-- end)
|
||||
|
||||
-- RegisterCommand("clothing:copy", function(source, args, rawCommand)
|
||||
-- Clothing.CopyAppearanceToClipboard()
|
||||
-- end)
|
||||
|
||||
|
||||
return Clothing
|
||||
return Clothing
|
||||
@@ -3,23 +3,32 @@ Clothing = Clothing or {}
|
||||
Clothing.LastAppearance = Clothing.LastAppearance or {}
|
||||
Callback = Callback or Require("lib/callback/shared/callback.lua")
|
||||
|
||||
function Clothing.IsMale(src)
|
||||
local ped = GetPlayerPed(src)
|
||||
if not ped or not DoesEntityExist(ped) then return end
|
||||
return GetEntityModel(ped) == `mp_m_freemode_01`
|
||||
end
|
||||
|
||||
---This will get the name of the in use resource.
|
||||
---@return string
|
||||
Clothing.GetResourceName = function()
|
||||
return 'default'
|
||||
end
|
||||
|
||||
---This will check if the player model if male/female
|
||||
---@param src number
|
||||
---@return boolean
|
||||
function Clothing.IsMale(src)
|
||||
local ped = GetPlayerPed(src)
|
||||
if not ped or not DoesEntityExist(ped) then return false end
|
||||
return GetEntityModel(ped) == `mp_m_freemode_01`
|
||||
end
|
||||
|
||||
---Get the skin data of a player
|
||||
---@param src number
|
||||
---@return table
|
||||
function Clothing.GetAppearance(src)
|
||||
return Callback.Trigger('community_bridge:cb:GetAppearance', src)
|
||||
end
|
||||
|
||||
Clothing.SetAppearance = function(src, data)
|
||||
---Apply skin data to a player
|
||||
---@param src number
|
||||
---@param data table
|
||||
function Clothing.SetAppearance(src, data)
|
||||
local strSrc = tostring(src)
|
||||
Clothing.LastAppearance[strSrc] = Clothing.GetAppearance(src)
|
||||
TriggerClientEvent('community_bridge:client:SetAppearance', src, data)
|
||||
@@ -34,29 +43,10 @@ function Clothing.SetAppearanceExt(src, data)
|
||||
Clothing.SetAppearance(src, tbl)
|
||||
end
|
||||
|
||||
Clothing.RestoreAppearance = function(src)
|
||||
---Restore the last saved appearance of a player
|
||||
---@param src number
|
||||
function Clothing.RestoreAppearance(src)
|
||||
TriggerClientEvent('community_bridge:client:RestoreAppearance', src)
|
||||
end
|
||||
|
||||
|
||||
-- RegisterNetEvent('community_bridge:client:SetAppearance', function(data)
|
||||
-- local src = source
|
||||
-- Clothing.SetAppearance(src, data)
|
||||
-- end)
|
||||
|
||||
-- RegisterNetEvent('community_bridge:client:GetAppearance', function()
|
||||
-- local src = source
|
||||
-- Clothing.GetAppearance(src)
|
||||
-- end)
|
||||
|
||||
-- RegisterNetEvent('community_bridge:client:RestoreAppearance', function()
|
||||
-- local src = source
|
||||
-- Clothing.RestoreAppearance(src)
|
||||
-- end)
|
||||
|
||||
-- RegisterNetEvent('community_bridge:client:ReloadSkin', function()
|
||||
-- local src = source
|
||||
-- Clothing.ReloadSkin(src)
|
||||
-- end)
|
||||
|
||||
return Clothing
|
||||
return Clothing
|
||||
@@ -146,6 +146,13 @@ function Clothing.OpenMenu(src)
|
||||
TriggerClientEvent('esx_skin:openMenu', src)
|
||||
end
|
||||
|
||||
---Callback handler for retrieving a player's appearance data
|
||||
Callback.Register('community_bridge:cb:GetAppearance', function(source)
|
||||
local src = source
|
||||
return Clothing.GetAppearance(src)
|
||||
end)
|
||||
|
||||
|
||||
---Event handler for when a player loads into the server
|
||||
---Caches the player's appearance data
|
||||
AddEventHandler('community_bridge:Server:OnPlayerLoaded', function(src)
|
||||
@@ -175,10 +182,4 @@ AddEventHandler('onResourceStart', function(resource)
|
||||
Clothing.Players[strSrc] = Clothing.GetAppearance(src)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
---Callback handler for retrieving a player's appearance data
|
||||
Callback.Register('community_bridge:cb:GetAppearance', function(source)
|
||||
local src = source
|
||||
return Clothing.GetAppearance(src)
|
||||
end)
|
||||
end)
|
||||
@@ -1,11 +1,8 @@
|
||||
--[[This module is incomplete]]--
|
||||
|
||||
Dialogue = {}
|
||||
|
||||
local promises = {}
|
||||
local activeDialogue = nil
|
||||
local pendingCameraDestroy = false
|
||||
Dialogue = {}
|
||||
|
||||
local cam = nil
|
||||
local npc = nil
|
||||
|
||||
@@ -25,7 +22,7 @@ function Dialogue.Close(name)
|
||||
Wait(200) -- Small delay to allow new dialogue to open
|
||||
if pendingCameraDestroy and not activeDialogue then
|
||||
-- No new dialogue opened, safe to destroy camera
|
||||
RenderScriptCams(false, 1, 1000, 1, 0)
|
||||
RenderScriptCams(false, true, 1000, true, false)
|
||||
SetCamActive(cam, false)
|
||||
DestroyCam(cam, false)
|
||||
cam = nil
|
||||
@@ -38,7 +35,10 @@ end
|
||||
--- Open a dialogue with the player
|
||||
---@param name string
|
||||
---@param dialogue string
|
||||
---@param options table example = {{ id = string, label = string}}
|
||||
---@param characterOptions number|table entity or entity and offset/rotationOffset
|
||||
---@param dialogueOptions table
|
||||
---@param onSelected function
|
||||
---@return any
|
||||
function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSelected)
|
||||
assert(name, "Name is required")
|
||||
assert(dialogue, "Dialogue is required")
|
||||
@@ -53,14 +53,12 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
|
||||
pendingCameraDestroy = false
|
||||
activeDialogue = name
|
||||
|
||||
-- camera magic!
|
||||
if entity then
|
||||
Wait(500)
|
||||
local endLocation = GetOffsetFromEntityInWorldCoords(entity, offset.x, offset.y + 2.0, offset.z)
|
||||
local pedHeading = GetEntityHeading(entity)
|
||||
-- Get position in front of ped based on their heading
|
||||
local pedHeading = GetEntityHeading(entity) -- Get position in front of ped based on their heading
|
||||
|
||||
if not cam then cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", 1) end
|
||||
if not cam then cam = CreateCam("DEFAULT_SCRIPTED_CAMERA", true) end
|
||||
local camAngle = (pedHeading + 180.0) % 360.0
|
||||
SetCamRot(cam, rotationOffset.x, rotationOffset.y, camAngle + rotationOffset.z, 2)
|
||||
SetCamCoord(cam, endLocation.x, endLocation.y, endLocation.z)
|
||||
@@ -75,7 +73,6 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
|
||||
})
|
||||
SetNuiFocus(true, true)
|
||||
|
||||
|
||||
local prom = promise.new()
|
||||
local wrappedFunction = function(selected)
|
||||
SetNuiFocus(false, false)
|
||||
@@ -87,7 +84,6 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
|
||||
return Citizen.Await(prom)
|
||||
end
|
||||
|
||||
|
||||
RegisterNuiCallback("dialogue:SelectOption", function(data)
|
||||
local promis = promises[data.name]
|
||||
if not promis then return end
|
||||
|
||||
@@ -19,7 +19,7 @@ end
|
||||
---@description This will get the name of the framework being used (if a supported framework).
|
||||
---@return string
|
||||
Framework.GetFrameworkName = function()
|
||||
print("This is depricated, please use Framework.GetResourceName() instead.")
|
||||
--print("This is depricated, please use Framework.GetResourceName() instead.")
|
||||
return Framework.GetResourceName()
|
||||
end
|
||||
|
||||
@@ -108,7 +108,7 @@ end
|
||||
---@return string
|
||||
---@return string
|
||||
Framework.GetPlayerJob = function()
|
||||
print("This is depricated, please use Framework.GetPlayerJobData() instead.")
|
||||
--print("This is depricated, please use Framework.GetPlayerJobData() instead.")
|
||||
local jobData = Framework.GetPlayerJobData()
|
||||
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
||||
end
|
||||
|
||||
@@ -13,7 +13,7 @@ local cachedItemList = nil
|
||||
--- @description This will return the name of the framework in use
|
||||
--- @return string
|
||||
Framework.GetFrameworkName = function()
|
||||
print("This is deprecated, please use Framework.GetResourceName() instead.")
|
||||
--print("This is deprecated, please use Framework.GetResourceName() instead.")
|
||||
return Framework.GetResourceName()
|
||||
end
|
||||
|
||||
|
||||
@@ -150,7 +150,7 @@ end
|
||||
---@return string
|
||||
---@return string
|
||||
Framework.GetPlayerJob = function()
|
||||
print("This is depricated, please use Framework.GetPlayerJobData() instead.")
|
||||
--print("This is depricated, please use Framework.GetPlayerJobData() instead.")
|
||||
local jobData = Framework.GetPlayerJobData()
|
||||
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
||||
end
|
||||
|
||||
@@ -372,7 +372,7 @@ end
|
||||
---@return string | string | string | number | nil
|
||||
---@return string | string | string | number | nil
|
||||
Framework.GetPlayerJob = function(src)
|
||||
print("[Community Bridge] Warning: Framework.GetPlayerJob is deprecated, use Framework.GetPlayerJobData instead.")
|
||||
--print("[Community Bridge] Warning: Framework.GetPlayerJob is deprecated, use Framework.GetPlayerJobData instead.")
|
||||
local jobData = Framework.GetPlayerJobData(src)
|
||||
if not jobData then return end
|
||||
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeLevel
|
||||
|
||||
@@ -107,7 +107,7 @@ end
|
||||
---@return string
|
||||
---@return string
|
||||
Framework.GetPlayerJob = function()
|
||||
print("This is depricated, please use Framework.GetPlayerJobData() instead.")
|
||||
--print("This is depricated, please use Framework.GetPlayerJobData() instead.")
|
||||
local jobData = Framework.GetPlayerJobData()
|
||||
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
||||
end
|
||||
|
||||
@@ -357,7 +357,7 @@ Framework.GetPlayerJob = function(src)
|
||||
local player = Framework.GetPlayer(src)
|
||||
if not player then return end
|
||||
local playerData = player.PlayerData
|
||||
print("This function is depricated, please use GetPlayerJobData instead.")
|
||||
--print("This function is depricated, please use GetPlayerJobData instead.")
|
||||
return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level
|
||||
end
|
||||
|
||||
|
||||
@@ -5,6 +5,8 @@ Notify.GetResourceName = function()
|
||||
return "default"
|
||||
end
|
||||
|
||||
|
||||
|
||||
---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification
|
||||
---12/13/25
|
||||
---@param message string
|
||||
@@ -12,7 +14,8 @@ end
|
||||
---@param time number
|
||||
---@return nil
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
return Notify.SendNotification(nil, message, _type, time)
|
||||
time = time or 3000
|
||||
return Framework.Notify(message, nil, time)
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
|
||||
@@ -5,6 +5,10 @@ Notify.GetResourceName = function()
|
||||
return "default"
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification
|
||||
---12/13/25
|
||||
---@param src number
|
||||
@@ -27,7 +31,7 @@ end
|
||||
Notify.SendNotification = function(src, title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then
|
||||
title = Bridge.Language.Locale("Notifications.PlaceholderTitle")
|
||||
title = placeHolderText
|
||||
end
|
||||
TriggerClientEvent('community_bridge:Client:Notify', src, title, message, _type, time, props)
|
||||
end
|
||||
|
||||
@@ -9,6 +9,15 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
return exports['brutal_notify']:SendAlert('Notification', message, time, _type or "success", false)
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -18,7 +27,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
return exports['brutal_notify']:SendAlert(title, message, time, _type or "success", false)
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,25 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
if _type == "error" or _type == "info" then
|
||||
_type = tostring(1)
|
||||
elseif _type == "success" then
|
||||
_type = tostring(2)
|
||||
elseif _type == "warning" or _type == "warn" then
|
||||
_type = tostring(3)
|
||||
else
|
||||
_type = tostring(2) -- Default to 2 if type is not recognized
|
||||
end
|
||||
return exports['FL-Notify']:Notify("Notification", "", message, 5000, tonumber(_type), 0)
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -17,7 +36,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
if _type == "error" or _type == "info" then
|
||||
_type = tostring(1)
|
||||
elseif _type == "success" then
|
||||
|
||||
@@ -9,6 +9,16 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
return exports.lation_ui:notify({ message = message, type = _type or "success", duration = time, position = 'top-right' })
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -18,7 +28,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
return exports.lation_ui:notify({ title = title, message = message, type = _type or "success", duration = time, position = 'top-right' })
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,17 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
_type = _type or "inform"
|
||||
return exports['mythic_notify']:SendAlert(_type, message, time)
|
||||
end
|
||||
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -17,7 +28,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
_type = _type or "inform"
|
||||
return exports['mythic_notify']:SendAlert(_type, message, time)
|
||||
end
|
||||
|
||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
return exports['okokNotify']:Alert('Notification', message, time, _type or "Success", false)
|
||||
end
|
||||
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -17,7 +27,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
return exports['okokNotify']:Alert(title, message, time, _type or "Success", false)
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
return exports.ox_lib:notify({ description = message, type = _type, duration = time, position = 'top-right' })
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -17,7 +27,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
return exports.ox_lib:notify({ title = title, description = message, type = _type or "success", duration = time, position = 'top-right' })
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
return exports['pNotify']:SendNotification({ text = message, type = _type, timeout = time, layout = 'centerRight' })
|
||||
end
|
||||
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -17,7 +27,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
return exports['pNotify']:SendNotification({ title = title, text = message, type = _type or "success", timeout = time, layout = 'centerRight' })
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,15 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
return exports.r_notify:notify({title = 'Notification', content = message, type = _type, icon = "fas fa-check", duration = time, position = 'top-right', sound = false})
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -17,7 +26,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
return exports.r_notify:notify({title = title, content = message, type = _type or "success", icon = "fas fa-check", duration = time, position = 'top-right', sound = false})
|
||||
end
|
||||
|
||||
|
||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
_type = _type or "info"
|
||||
return exports['t-notify']:Alert({ style = _type, message = message, duration = time, })
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -17,7 +27,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
_type = _type or "info"
|
||||
return exports['t-notify']:Alert({ title = title, style = _type, message = message, duration = time, })
|
||||
end
|
||||
|
||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locale = Language.Locale
|
||||
local placeHolderText = locale("Notifications.PlaceholderTitle")
|
||||
|
||||
Notify.SendNotify = function(message, _type, time)
|
||||
time = time or 3000
|
||||
_type = _type or "info"
|
||||
return exports.wasabi_notify:notify(_type, message, time, _type)
|
||||
end
|
||||
|
||||
---This will send a notify message of the type and time passed
|
||||
---@param title string
|
||||
---@param message string
|
||||
@@ -17,7 +27,7 @@ end
|
||||
---@return nil
|
||||
Notify.SendNotification = function(title, message, _type, time, props)
|
||||
time = time or 3000
|
||||
if not title then title = Bridge.Language.Locale("Notifications.PlaceholderTitle") end
|
||||
if not title then title = placeHolderText end
|
||||
_type = _type or "info"
|
||||
return exports.wasabi_notify:notify(_type, message, time, _type)
|
||||
end
|
||||
|
||||
@@ -4,7 +4,7 @@ Shops = Shops or {}
|
||||
local registeredShops = {}
|
||||
|
||||
local Language = Language or Require("modules/locales/shared.lua")
|
||||
local locales = Language.Locale
|
||||
local locale = Language.Locale
|
||||
|
||||
---This can open a shop for the client
|
||||
---@param src number
|
||||
@@ -51,23 +51,23 @@ Shops.CompleteCheckout = function(src, shopName, item, amount, account)
|
||||
end
|
||||
end
|
||||
if not itemData or not itemData.price then return print("community_bridge Player ID "..src.." attempted to purchase invalid item from shop: "..shopName) end
|
||||
if itemData.count and itemData.count <= 0 then return Notify.SendNotify(src, locales('Shops.NotEnoughStock'), "error", 5000) end
|
||||
if itemData.count and itemData.count <= 0 then return Notify.SendNotify(src, locale('Shops.NotEnoughStock'), "error", 5000) end
|
||||
local totalCost = tonumber(itemData.price) * amount
|
||||
local balance = Framework.GetAccountBalance(src, account)
|
||||
if not balance then return end
|
||||
if balance <= 0 then return Notify.SendNotify(src, locales('Shops.NotEnoughMoney'), "error", 5000) end
|
||||
if balance < totalCost then return Notify.SendNotify(src, locales('Shops.NotEnoughMoney'), "error", 5000) end
|
||||
if balance <= 0 then return Notify.SendNotify(src, locale('Shops.NotEnoughMoney'), "error", 5000) end
|
||||
if balance < totalCost then return Notify.SendNotify(src, locale('Shops.NotEnoughMoney'), "error", 5000) end
|
||||
|
||||
if not Framework.RemoveAccountBalance(src, account, totalCost) then return end
|
||||
|
||||
local success = Inventory.AddItem(src, itemData.name, amount)
|
||||
if not success then
|
||||
Framework.AddAccountBalance(src, account, totalCost)
|
||||
return Notify.SendNotify(src, locales('Shops.PurchaseFailed'), "error", 5000)
|
||||
return Notify.SendNotify(src, locale('Shops.PurchaseFailed'), "error", 5000)
|
||||
end
|
||||
|
||||
local itemLabel = Inventory.GetItemInfo(itemData.name).label or itemData.name
|
||||
Notify.SendNotify(src, locales('Shops.PurchasedItem', itemLabel), "success", 5000)
|
||||
Notify.SendNotify(src, locale('Shops.PurchasedItem', amount, itemLabel), "success", 5000)
|
||||
end
|
||||
|
||||
---This is an internal event to complete a checkout, complete with multiple validations. Please do not use this event directly.
|
||||
|
||||
@@ -1,42 +1,54 @@
|
||||
---@diagnostic disable: duplicate-set-field
|
||||
Skills = Skills or {}
|
||||
|
||||
XP_CACHE = {}
|
||||
local cachedXp = {}
|
||||
|
||||
-- Calculate XP required for a level using RuneScape algorithm (with caching)
|
||||
Skills.GetXPForLevel = function(level)
|
||||
function Skills.GetResourceName()
|
||||
return "default"
|
||||
end
|
||||
|
||||
---Calculate XP required for a level using RuneScape algorithm (with caching)
|
||||
---@param level number
|
||||
---@return number
|
||||
function Skills.GetXPForLevel(level)
|
||||
if not level or level < 1 then return 0 end
|
||||
if level == 1 then return 0 end -- Level 1 requires 0 XP
|
||||
|
||||
-- Check cache first
|
||||
if XP_CACHE[level] then
|
||||
return XP_CACHE[level]
|
||||
end
|
||||
if cachedXp[level] then return cachedXp[level] end
|
||||
|
||||
-- Calculate and cache
|
||||
local xp = 0
|
||||
for n = 1, level - 1 do
|
||||
xp = xp + math.floor(n + 300 * (2 ^ (n / 7)))
|
||||
end
|
||||
local result = math.floor(xp / 4)
|
||||
XP_CACHE[level] = result
|
||||
cachedXp[level] = result
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
-- Create a skill (for initialization)
|
||||
Skills.Create = function(name, maxLevel, baseXP)
|
||||
---Create a skill (for initialization)
|
||||
---@param name string
|
||||
---@param maxLevel number
|
||||
---@param baseXP number
|
||||
---@return table
|
||||
function Skills.Create(name, maxLevel, baseXP)
|
||||
if not name then return end
|
||||
Skills.All[name] = { name = name, maxLevel = maxLevel or 99, baseXP = baseXP or 50 }
|
||||
return Skills.All[name]
|
||||
end
|
||||
|
||||
Skills.GetScaledXP = function(baseXP, playerLevel)
|
||||
---Get scaled XP based on player level
|
||||
---@param baseXP number
|
||||
---@param playerLevel number
|
||||
---@return number
|
||||
function Skills.GetScaledXP(baseXP, playerLevel)
|
||||
return math.floor(baseXP * (1 + playerLevel * 0.05))
|
||||
end
|
||||
|
||||
-- Get XP required to complete the current level
|
||||
Skills.GetXPRequiredForLevel = function(level)
|
||||
---@param level number
|
||||
---@return number
|
||||
function Skills.GetXPRequiredForLevel(level)
|
||||
if not level or level < 1 then return 0 end
|
||||
if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP
|
||||
return Skills.GetXPForLevel(level)
|
||||
@@ -45,7 +57,7 @@ end
|
||||
---This will get the skill level of the passed skill name. (returns 1 if not found)
|
||||
---@param skillName string
|
||||
---@return number
|
||||
Skills.GetSkillLevel = function(skillName)
|
||||
function Skills.GetSkillLevel(skillName)
|
||||
if not skillName then return 0 end
|
||||
local plyrSkills = Bridge.Framework.GetPlayerMetaData("community_bridge_skills")
|
||||
if not plyrSkills or not plyrSkills[skillName] then return 1 end
|
||||
@@ -55,20 +67,11 @@ end
|
||||
---This will get the skill xp of the passed skill name. (returns 1 if not found)
|
||||
---@param skillName string
|
||||
---@return number
|
||||
Skills.GetXP = function(skillName)
|
||||
function Skills.GetXP(skillName)
|
||||
if not skillName then return 0 end
|
||||
local plyrSkills = Bridge.Framework.GetPlayerMetaData("community_bridge_skills")
|
||||
if not plyrSkills or not plyrSkills[skillName] then return 1 end
|
||||
return plyrSkills[skillName].currentXP or 1
|
||||
end
|
||||
|
||||
Skills.GetResourceName = function()
|
||||
return "default"
|
||||
end
|
||||
|
||||
-- RegisterCommand("getfishingLevel", function(source, args)
|
||||
-- local level = Skills.GetSkillLevel("fishing")
|
||||
-- print("Client Fishing Level issssssssss " .. level)
|
||||
-- end, false)
|
||||
|
||||
return Skills
|
||||
@@ -3,31 +3,39 @@ Skills = Skills or {}
|
||||
Skills.All = Skills.All or {}
|
||||
|
||||
-- XP Cache for performance
|
||||
local XP_CACHE = {}
|
||||
|
||||
local cachedXp = {}
|
||||
-- Default skill object: currentXP (0 to required), level
|
||||
local DEFAULT_SKILL = { currentXP = 0, level = 1 }
|
||||
local defaultSkills = { currentXP = 0, level = 1 }
|
||||
|
||||
function Skills.GetResourceName()
|
||||
return "default"
|
||||
end
|
||||
|
||||
-- Helper function to get or create a skill object
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@return table
|
||||
local function getOrCreateSkill(src, skillName)
|
||||
if not src or not skillName then return table.clone(DEFAULT_SKILL) end
|
||||
if not src or not skillName then return table.clone(defaultSkills) end
|
||||
|
||||
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
|
||||
if not playerSkills[skillName] then
|
||||
playerSkills[skillName] = table.clone(DEFAULT_SKILL)
|
||||
playerSkills[skillName] = table.clone(defaultSkills)
|
||||
end
|
||||
|
||||
return playerSkills[skillName]
|
||||
end
|
||||
|
||||
-- Calculate XP required for a level using RuneScape algorithm (with caching)
|
||||
Skills.GetXPForLevel = function(level)
|
||||
---Calculate XP required for a level using RuneScape algorithm (with caching)
|
||||
---@param level number
|
||||
---@return number
|
||||
function Skills.GetXPForLevel(level)
|
||||
if not level or level < 1 then return 0 end
|
||||
if level == 1 then return 0 end -- Level 1 requires 0 XP
|
||||
|
||||
-- Check cache first
|
||||
if XP_CACHE[level] then
|
||||
return XP_CACHE[level]
|
||||
if cachedXp[level] then
|
||||
return cachedXp[level]
|
||||
end
|
||||
|
||||
-- Calculate and cache
|
||||
@@ -36,30 +44,44 @@ Skills.GetXPForLevel = function(level)
|
||||
xp = xp + math.floor(n + 300 * (2 ^ (n / 7)))
|
||||
end
|
||||
local result = math.floor(xp / 4)
|
||||
XP_CACHE[level] = result
|
||||
cachedXp[level] = result
|
||||
|
||||
return result
|
||||
end
|
||||
|
||||
-- Create a skill (for initialization)
|
||||
Skills.Create = function(name, maxLevel, baseXP)
|
||||
if not name then return end
|
||||
---@param name string
|
||||
---@param maxLevel number
|
||||
---@param baseXP number
|
||||
---@return table
|
||||
function Skills.Create(name, maxLevel, baseXP)
|
||||
if not name then return {} end
|
||||
Skills.All[name] = { name = name, maxLevel = maxLevel or 99, baseXP = baseXP or 50 }
|
||||
return Skills.All[name]
|
||||
end
|
||||
|
||||
-- Get player's current level
|
||||
Skills.GetSkillLevel = function(src, skillName)
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@return number
|
||||
function Skills.GetSkillLevel(src, skillName)
|
||||
if not src or not skillName then return 1 end
|
||||
local skill = getOrCreateSkill(src, skillName)
|
||||
return skill.level or 1
|
||||
end
|
||||
|
||||
Skills.GetScaledXP = function(baseXP, playerLevel)
|
||||
-- returns scaled XP based on player level
|
||||
---@param baseXP number
|
||||
---@param playerLevel number
|
||||
---@return integer
|
||||
function Skills.GetScaledXP(baseXP, playerLevel)
|
||||
return math.floor(baseXP * (1 + playerLevel * 0.05))
|
||||
end
|
||||
-- Get current XP (0 to required XP for current level)
|
||||
Skills.GetXP = function(src, skillName)
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@return number
|
||||
function Skills.GetXP(src, skillName)
|
||||
if not src or not skillName then return 0 end
|
||||
local skill = getOrCreateSkill(src, skillName)
|
||||
local currentXP = skill.currentXP or 0
|
||||
@@ -67,17 +89,21 @@ Skills.GetXP = function(src, skillName)
|
||||
end
|
||||
|
||||
-- Get XP required to complete the current level
|
||||
Skills.GetXPRequiredForLevel = function(level)
|
||||
---@param level number
|
||||
---@return number
|
||||
function Skills.GetXPRequiredForLevel(level)
|
||||
if not level or level < 1 then return 0 end
|
||||
if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP
|
||||
return Skills.GetXPForLevel(level)
|
||||
end
|
||||
|
||||
-- Add XP and handle level ups
|
||||
Skills.AddXP = function(src, skillName, xp)
|
||||
if not src or not skillName then
|
||||
return false
|
||||
end
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@param xp number
|
||||
---@return boolean, number, number
|
||||
function Skills.AddXP(src, skillName, xp)
|
||||
if not src or not skillName then return false, 0, 0 end
|
||||
|
||||
if not xp or xp <= 0 then
|
||||
xp = Skills.GetScaledXP(50, Skills.GetSkillLevel(src, skillName))
|
||||
@@ -86,15 +112,14 @@ Skills.AddXP = function(src, skillName, xp)
|
||||
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
|
||||
local skill = playerSkills[skillName]
|
||||
if not skill then
|
||||
skill = table.clone(DEFAULT_SKILL)
|
||||
skill = table.clone(defaultSkills)
|
||||
playerSkills[skillName] = skill
|
||||
end
|
||||
|
||||
local oldLevel = skill.level or 1
|
||||
local currentXP = skill.currentXP or 0
|
||||
-- Add XP
|
||||
currentXP = currentXP + xp
|
||||
|
||||
currentXP = currentXP + xp
|
||||
|
||||
local xpNeeded = Skills.GetXPRequiredForLevel(oldLevel + 1)
|
||||
if currentXP >= xpNeeded then
|
||||
@@ -112,11 +137,15 @@ Skills.AddXP = function(src, skillName, xp)
|
||||
end
|
||||
|
||||
-- Set skill level directly (resets currentXP to 0)
|
||||
Skills.SetSkillLevel = function(src, skillName, level)
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@param level number
|
||||
---@return boolean
|
||||
function Skills.SetSkillLevel(src, skillName, level)
|
||||
if not src or not skillName or not level or level < 1 then return false end
|
||||
|
||||
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
|
||||
local skill = playerSkills[skillName] or table.clone(DEFAULT_SKILL)
|
||||
local skill = playerSkills[skillName] or table.clone(defaultSkills)
|
||||
|
||||
level = math.min(math.max(1, level), 99)
|
||||
skill.level = level
|
||||
@@ -128,11 +157,15 @@ Skills.SetSkillLevel = function(src, skillName, level)
|
||||
end
|
||||
|
||||
-- Set current XP directly
|
||||
Skills.SetXP = function(src, skillName, xp)
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@param xp number
|
||||
---@return boolean
|
||||
function Skills.SetXP(src, skillName, xp)
|
||||
if not src or not skillName or not xp or xp < 0 then return false end
|
||||
|
||||
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
|
||||
local skill = playerSkills[skillName] or table.clone(DEFAULT_SKILL)
|
||||
local skill = playerSkills[skillName] or table.clone(defaultSkills)
|
||||
|
||||
skill.currentXP = xp
|
||||
playerSkills[skillName] = skill
|
||||
@@ -141,17 +174,4 @@ Skills.SetXP = function(src, skillName, xp)
|
||||
return true
|
||||
end
|
||||
|
||||
Skills.GetResourceName = function()
|
||||
return "default"
|
||||
end
|
||||
|
||||
-- Debug Commands
|
||||
-- RegisterCommand('clearskill', function(source, args, rawCommand)
|
||||
-- if not source or source == 0 then return end
|
||||
-- local skillName = args[1] or "fishing"
|
||||
-- Skills.SetXP(source, skillName, 0)
|
||||
-- Skills.SetSkillLevel(source, skillName, 1)
|
||||
-- print("Skill " .. skillName .. " cleared for player " .. source)
|
||||
-- end, false)
|
||||
|
||||
return Skills
|
||||
@@ -13,7 +13,7 @@ end
|
||||
---This will return the skill level of the passed skill name.
|
||||
---@param skillName string
|
||||
---@return number
|
||||
Skills.GetSkillLevel = function(skillName)
|
||||
function Skills.GetSkillLevel(skillName)
|
||||
local skillData = exports.evolent_skills:getSkillLevel(skillName)
|
||||
return skillData or 0
|
||||
end
|
||||
|
||||
@@ -7,14 +7,14 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c
|
||||
|
||||
---This will get the name of the Skills system being used.
|
||||
---@return string
|
||||
Skills.GetResourceName = function()
|
||||
function Skills.GetResourceName()
|
||||
return resourceName
|
||||
end
|
||||
---This will return the skill level of the passed skill name.
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@return number
|
||||
Skills.GetSkillLevel = function(src, skillName)
|
||||
function Skills.GetSkillLevel(src, skillName)
|
||||
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
||||
return skillData or 0
|
||||
end
|
||||
@@ -24,7 +24,7 @@ end
|
||||
---@param skillName string
|
||||
---@param amount number
|
||||
---@return boolean
|
||||
Skills.AddXp = function(src, skillName, amount)
|
||||
function Skills.AddXp(src, skillName, amount)
|
||||
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
||||
if not skillData then return false, print("Skill not found") end
|
||||
if not Skills.All[skillName] then
|
||||
@@ -39,7 +39,7 @@ end
|
||||
---@param skillName string
|
||||
---@param amount number
|
||||
---@return boolean
|
||||
Skills.RemoveXp = function(src, skillName, amount)
|
||||
function Skills.RemoveXp(src, skillName, amount)
|
||||
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
||||
if not skillData then return false, print("Skill not found") end
|
||||
exports.evolent_skills:removeXp(src, skillName, amount)
|
||||
|
||||
@@ -7,14 +7,14 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c
|
||||
|
||||
---This will return the name of the Skills system being used.
|
||||
---@return string
|
||||
Skills.GetResourceName = function()
|
||||
function Skills.GetResourceName()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
---This will return the skill level of the passed skill name.
|
||||
---@param skillName string
|
||||
---@return number
|
||||
Skills.GetSkillLevel = function(skillName)
|
||||
function Skills.GetSkillLevel(skillName)
|
||||
local skillData = exports.OT_skills:getSkill(skillName)
|
||||
return skillData.level or 0
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c
|
||||
|
||||
---This will return the name of the Skills system being used.
|
||||
---@return string
|
||||
Skills.GetResourceName = function()
|
||||
function Skills.GetResourceName()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ end
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@return number
|
||||
Skills.GetSkillLevel = function(src, skillName)
|
||||
function Skills.GetSkillLevel(src, skillName)
|
||||
local skillData = exports.OT_skills:getSkill(src, skillName)
|
||||
return skillData.level or 0
|
||||
end
|
||||
@@ -25,7 +25,7 @@ end
|
||||
---@param skillName string
|
||||
---@param amount number
|
||||
---@return boolean
|
||||
Skills.AddXp = function(src, skillName, amount)
|
||||
function Skills.AddXp(src, skillName, amount)
|
||||
local skillData = exports.OT_skills:getSkill(src, skillName)
|
||||
if not skillData then return false, print("Skill not found") end
|
||||
if not Skills.All[skillName] then
|
||||
@@ -40,7 +40,7 @@ end
|
||||
---@param skillName string
|
||||
---@param amount number
|
||||
---@return boolean
|
||||
Skills.RemoveXp = function(src, skillName, amount)
|
||||
function Skills.RemoveXp(src, skillName, amount)
|
||||
local skillData = exports.OT_skills:getSkill(src, skillName)
|
||||
if not skillData then return false, print("Skill not found") end
|
||||
exports.OT_skills:removeXP(src, skillName, amount)
|
||||
|
||||
@@ -6,14 +6,14 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c
|
||||
|
||||
---This will get the name of the Skills system being used.
|
||||
---@return string
|
||||
Skills.GetResourceName = function()
|
||||
function Skills.GetResourceName()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
---This will return the skill level of the passed skill name.
|
||||
---@param skillName string
|
||||
---@return number
|
||||
Skills.GetSkillLevel = function(skillName)
|
||||
function Skills.GetSkillLevel(skillName)
|
||||
local skillData = exports.pickle_xp:GetLevel(skillName)
|
||||
return skillData or 0
|
||||
end
|
||||
|
||||
@@ -7,7 +7,7 @@ if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (c
|
||||
|
||||
---This will get the name of the Skills system being used.
|
||||
---@return string
|
||||
Skills.GetResourceName = function()
|
||||
function Skills.GetResourceName()
|
||||
return resourceName
|
||||
end
|
||||
|
||||
@@ -15,7 +15,7 @@ end
|
||||
---@param src number
|
||||
---@param skillName string
|
||||
---@return number
|
||||
Skills.GetSkillLevel = function(src, skillName)
|
||||
function Skills.GetSkillLevel(src, skillName)
|
||||
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
||||
return skillData or 0
|
||||
end
|
||||
@@ -25,15 +25,11 @@ end
|
||||
---@param skillName string
|
||||
---@param amount number
|
||||
---@return boolean
|
||||
Skills.AddXp = function(src, skillName, amount)
|
||||
function Skills.AddXp(src, skillName, amount)
|
||||
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
||||
if not skillData then return false, print("Skill not found") end
|
||||
if not Skills.All[skillName] then
|
||||
Skills.All[skillName] = Skills.Create(skillName, 99, 50)
|
||||
end
|
||||
-- if not amount or amount < 0 then
|
||||
-- amount = Skills.GetScaledXP(Skills.All[skillName].baseXP, Skills.GetSkillLevel(src, skillName))
|
||||
-- end
|
||||
if not skillData then return false, print("^6 Skill "..skillName.." not found ^0 ") end
|
||||
if not Skills.All[skillName] then Skills.All[skillName] = Skills.Create(skillName, 99, 50) end
|
||||
|
||||
exports.pickle_xp:AddPlayerXP(src, skillName, amount)
|
||||
return true
|
||||
end
|
||||
@@ -43,7 +39,7 @@ end
|
||||
---@param skillName string
|
||||
---@param amount number
|
||||
---@return boolean
|
||||
Skills.RemoveXp = function(src, skillName, amount)
|
||||
function Skills.RemoveXp(src, skillName, amount)
|
||||
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
||||
if not skillData then return false, print("Skill not found") end
|
||||
exports.pickle_xp:RemovePlayerXP(src, skillName, amount)
|
||||
|
||||
@@ -2,16 +2,21 @@
|
||||
Target = Target or {}
|
||||
Ids = Ids or Require("lib/utility/shared/ids.lua")
|
||||
|
||||
local InteractIds = {}
|
||||
|
||||
local function warnUser()
|
||||
print("Currently Only Targeting Is Supported By Community Bridge, You Are Using A Resource That Requires The Target Module To Be Used.")
|
||||
end
|
||||
local InteractIds = {}
|
||||
|
||||
Target.GetCanInteract = function(id)
|
||||
function Target.GetResourceName()
|
||||
return "default"
|
||||
end
|
||||
|
||||
function Target.GetCanInteract(id)
|
||||
return InteractIds[id]
|
||||
end
|
||||
|
||||
Target.CreateCanInteract = function(cb)
|
||||
function Target.CreateCanInteract(cb)
|
||||
if not cb then return end
|
||||
local id = Ids.CreateUniqueId(InteractIds)
|
||||
InteractIds[id] = {
|
||||
@@ -22,7 +27,7 @@ Target.CreateCanInteract = function(cb)
|
||||
return id
|
||||
end
|
||||
|
||||
Target.CanInteract = function(id, ...)
|
||||
function Target.CanInteract(id, ...)
|
||||
local interactData = InteractIds[id]
|
||||
if not interactData then return true end
|
||||
if interactData.ableToInteract == -1 then
|
||||
@@ -36,7 +41,7 @@ Target.CanInteract = function(id, ...)
|
||||
return interactData.ableToInteract > 0
|
||||
end
|
||||
|
||||
Target.FixOptions = function(options)
|
||||
function Target.FixOptions(options)
|
||||
for k, v in pairs(options) do
|
||||
local action = v.onSelect or v.action
|
||||
local select = function(entityOrData)
|
||||
@@ -57,19 +62,19 @@ Target.FixOptions = function(options)
|
||||
return options
|
||||
end
|
||||
|
||||
Target.AddGlobalPlayer = function(options)
|
||||
function Target.AddGlobalPlayer(options)
|
||||
warnUser()
|
||||
end
|
||||
|
||||
Target.AddGlobalVehicle = function(options)
|
||||
function Target.AddGlobalVehicle(options)
|
||||
warnUser()
|
||||
end
|
||||
|
||||
Target.RemoveGlobalVehicle = function(options)
|
||||
function Target.RemoveGlobalVehicle(options)
|
||||
warnUser()
|
||||
end
|
||||
|
||||
Target.AddLocalEntity = function(entities, _options)
|
||||
function Target.AddLocalEntity(entities, _options)
|
||||
local fixedOptions = Target.FixOptions(_options)
|
||||
if type(entities) == "string" or type(entities) == "number" then
|
||||
entities = { entities }
|
||||
@@ -117,11 +122,11 @@ Target.AddLocalEntity = function(entities, _options)
|
||||
end
|
||||
end
|
||||
|
||||
Target.AddModel = function(models, options)
|
||||
function Target.AddModel(models, options)
|
||||
warnUser()
|
||||
end
|
||||
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options)
|
||||
function Target.AddBoxZone(name, coords, size, heading, options)
|
||||
local fixedOptions = Target.FixOptions(options)
|
||||
local id = Ids.RandomString()
|
||||
local title = Bridge.Language.Locale("target.title")
|
||||
@@ -162,24 +167,20 @@ Target.AddBoxZone = function(name, coords, size, heading, options)
|
||||
end)
|
||||
end
|
||||
|
||||
Target.RemoveGlobalPlayer = function()
|
||||
function Target.RemoveGlobalPlayer()
|
||||
warnUser()
|
||||
end
|
||||
|
||||
Target.RemoveLocalEntity = function(entity)
|
||||
function Target.RemoveLocalEntity(entity)
|
||||
warnUser()
|
||||
end
|
||||
|
||||
Target.RemoveModel = function(model)
|
||||
function Target.RemoveModel(model)
|
||||
warnUser()
|
||||
end
|
||||
|
||||
Target.RemoveZone = function(name)
|
||||
function Target.RemoveZone(name)
|
||||
warnUser()
|
||||
end
|
||||
|
||||
Target.GetResourceName = function()
|
||||
return "default"
|
||||
end
|
||||
|
||||
return Target
|
||||
@@ -4,12 +4,9 @@ if GetResourceState(resourceName) == 'missing' then return end
|
||||
|
||||
Target = Target or {}
|
||||
local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false
|
||||
|
||||
local ox_target = exports.ox_target
|
||||
local targetZones = {}
|
||||
|
||||
Target = Target or {}
|
||||
|
||||
Target.GetResourceName = function()
|
||||
return "ox_target"
|
||||
end
|
||||
@@ -17,7 +14,7 @@ end
|
||||
---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc.
|
||||
---@param options table
|
||||
---@return table
|
||||
Target.FixOptions = function(options)
|
||||
function Target.FixOptions(options)
|
||||
for _, v in pairs(options) do
|
||||
local action = v.onSelect or v.action
|
||||
if not action then
|
||||
@@ -50,45 +47,45 @@ end
|
||||
|
||||
---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely.
|
||||
---@param bool boolean
|
||||
Target.DisableTargeting = function(bool)
|
||||
function Target.DisableTargeting(bool)
|
||||
ox_target:disableTargeting(bool)
|
||||
end
|
||||
|
||||
---This will add target options to players.
|
||||
---@param options table
|
||||
Target.AddGlobalPlayer = function(options)
|
||||
function Target.AddGlobalPlayer(options)
|
||||
options = Target.FixOptions(options)
|
||||
ox_target:addGlobalPlayer(options)
|
||||
end
|
||||
|
||||
---This will remove target options from all players.
|
||||
Target.RemoveGlobalPlayer = function()
|
||||
function Target.RemoveGlobalPlayer()
|
||||
ox_target:removeGlobalPlayer()
|
||||
end
|
||||
|
||||
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
|
||||
---@param options table
|
||||
Target.AddGlobalPed = function(options)
|
||||
function Target.AddGlobalPed(options)
|
||||
options = Target.FixOptions(options)
|
||||
ox_target:addGlobalPed(options)
|
||||
end
|
||||
|
||||
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
|
||||
---@param options any
|
||||
Target.RemoveGlobalPed = function(options)
|
||||
function Target.RemoveGlobalPed(options)
|
||||
ox_target:removeGlobalPed(options)
|
||||
end
|
||||
|
||||
---This will add taget options to all vehicles.
|
||||
---@param options table
|
||||
Target.AddGlobalVehicle = function(options)
|
||||
function Target.AddGlobalVehicle(options)
|
||||
options = Target.FixOptions(options)
|
||||
ox_target:addGlobalVehicle(options)
|
||||
end
|
||||
|
||||
---This will remove target options from all vehicles.
|
||||
---@param options table
|
||||
Target.RemoveGlobalVehicle = function(options)
|
||||
function Target.RemoveGlobalVehicle(options)
|
||||
local assembledLables = {}
|
||||
for k, v in pairs(options) do
|
||||
table.insert(assembledLables, v.name)
|
||||
@@ -99,7 +96,7 @@ end
|
||||
---This will generate targets on non networked entites with the passed options.
|
||||
---@param entities number | table
|
||||
---@param options table
|
||||
Target.AddLocalEntity = function(entities, options)
|
||||
function Target.AddLocalEntity(entities, options)
|
||||
options = Target.FixOptions(options)
|
||||
ox_target:addLocalEntity(entities, options)
|
||||
end
|
||||
@@ -107,14 +104,14 @@ end
|
||||
---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity.
|
||||
---@param entities table
|
||||
---@param optionNames string | table | nil
|
||||
Target.RemoveLocalEntity = function(entities, optionNames)
|
||||
function Target.RemoveLocalEntity(entities, optionNames)
|
||||
ox_target:removeLocalEntity(entities, optionNames)
|
||||
end
|
||||
|
||||
---This will add a networked entity to the target system.
|
||||
---@param netids table | number
|
||||
---@param options table
|
||||
Target.AddNetworkedEntity = function(netids, options)
|
||||
function Target.AddNetworkedEntity(netids, options)
|
||||
options = Target.FixOptions(options)
|
||||
ox_target:addEntity(netids, options)
|
||||
end
|
||||
@@ -122,21 +119,21 @@ end
|
||||
---This will remove a networked entity from the target system.
|
||||
---@param netids table | number
|
||||
---@param optionNames string
|
||||
Target.RemoveNetworkedEntity = function(netids, optionNames)
|
||||
function Target.RemoveNetworkedEntity(netids, optionNames)
|
||||
ox_target:removeEntity(netids, optionNames)
|
||||
end
|
||||
|
||||
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
|
||||
---@param models number | table
|
||||
---@param options table
|
||||
Target.AddModel = function(models, options)
|
||||
function Target.AddModel(models, options)
|
||||
options = Target.FixOptions(options)
|
||||
ox_target:addModel(models, options)
|
||||
end
|
||||
|
||||
---This will remove target options from all specified models.
|
||||
---@param model number
|
||||
Target.RemoveModel = function(model)
|
||||
function Target.RemoveModel(model)
|
||||
ox_target:removeModel(model)
|
||||
end
|
||||
|
||||
@@ -146,7 +143,7 @@ end
|
||||
---@param size table
|
||||
---@param heading number
|
||||
---@param options table
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options, debug)
|
||||
function Target.AddBoxZone(name, coords, size, heading, options, debug)
|
||||
options = Target.FixOptions(options or {})
|
||||
if not next(options) then return end
|
||||
local target = ox_target:addBoxZone({
|
||||
@@ -165,7 +162,7 @@ end
|
||||
---@param coords table
|
||||
---@param radius number
|
||||
---@param options table
|
||||
Target.AddSphereZone = function(name, coords, radius, options, debug)
|
||||
function Target.AddSphereZone(name, coords, radius, options, debug)
|
||||
options = Target.FixOptions(options)
|
||||
local target = ox_target:addSphereZone({
|
||||
coords = coords,
|
||||
@@ -180,7 +177,7 @@ end
|
||||
|
||||
---This will remove target options from a specific zone.
|
||||
---@param name string
|
||||
Target.RemoveZone = function(name)
|
||||
function Target.RemoveZone(name)
|
||||
if not name then return end
|
||||
for _, data in pairs(targetZones) do
|
||||
if data.name == name then
|
||||
|
||||
@@ -5,18 +5,14 @@ if GetResourceState("ox_target") ~= 'missing' then return end
|
||||
|
||||
Target = Target or {}
|
||||
local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false
|
||||
|
||||
local targetZones = {}
|
||||
|
||||
Target = Target or {}
|
||||
|
||||
local qb_target = exports['qb-target']
|
||||
|
||||
Target.GetResourceName = function()
|
||||
function Target.GetResourceName()
|
||||
return "qb-target"
|
||||
end
|
||||
|
||||
function GetLargestDistance(data)
|
||||
local function getLargestDistance(data)
|
||||
local largestDistance = -1
|
||||
for _, v in pairs(data) do
|
||||
if v.distance and v.distance > largestDistance then
|
||||
@@ -30,7 +26,7 @@ end
|
||||
---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc.
|
||||
---@param options table
|
||||
---@return table
|
||||
Target.FixOptions = function(options)
|
||||
function Target.FixOptions(options)
|
||||
for k, v in pairs(options) do
|
||||
local action = v.onSelect or v.action
|
||||
local select = action and function(entityOrData)
|
||||
@@ -62,55 +58,55 @@ end
|
||||
|
||||
---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely.
|
||||
---@param bool boolean
|
||||
Target.DisableTargeting = function(bool)
|
||||
function Target.DisableTargeting(bool)
|
||||
qb_target:AllowTargeting(not bool)
|
||||
end
|
||||
|
||||
---This will add target options to players.
|
||||
---@param options table
|
||||
Target.AddGlobalPlayer = function(options)
|
||||
function Target.AddGlobalPlayer(options)
|
||||
options = Target.FixOptions(options)
|
||||
qb_target:AddGlobalPlayer({
|
||||
options = options,
|
||||
distance = GetLargestDistance(options)
|
||||
distance = getLargestDistance(options)
|
||||
})
|
||||
end
|
||||
|
||||
---This will remove target options from all players.
|
||||
Target.RemoveGlobalPlayer = function()
|
||||
function Target.RemoveGlobalPlayer()
|
||||
qb_target:RemoveGlobalPlayer()
|
||||
end
|
||||
|
||||
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
|
||||
---@param options table
|
||||
Target.AddGlobalPed = function(options)
|
||||
function Target.AddGlobalPed(options)
|
||||
options = Target.FixOptions(options)
|
||||
qb_target:AddGlobalPed({
|
||||
options = options,
|
||||
distance = GetLargestDistance(options)
|
||||
distance = getLargestDistance(options)
|
||||
})
|
||||
end
|
||||
|
||||
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
|
||||
---@param options any
|
||||
Target.RemoveGlobalPed = function(options)
|
||||
function Target.RemoveGlobalPed(options)
|
||||
qb_target:RemoveGlobalPed(options)
|
||||
end
|
||||
|
||||
---This will add taget options to all vehicles.
|
||||
---@param options table
|
||||
Target.AddGlobalVehicle = function(options)
|
||||
function Target.AddGlobalVehicle(options)
|
||||
options = Target.FixOptions(options)
|
||||
qb_target:AddGlobalVehicle({
|
||||
options = options,
|
||||
distance = GetLargestDistance(options)
|
||||
distance = getLargestDistance(options)
|
||||
})
|
||||
end
|
||||
|
||||
---This will add a networked entity to the target system.
|
||||
---@param netids table | number
|
||||
---@param options table
|
||||
Target.AddNetworkedEntity = function(netids, options)
|
||||
function Target.AddNetworkedEntity(netids, options)
|
||||
options = Target.FixOptions(options)
|
||||
qb_target:AddTargetEntity(netids, options)
|
||||
end
|
||||
@@ -118,13 +114,13 @@ end
|
||||
---This will remove a networked entity from the target system.
|
||||
---@param netids table | number
|
||||
---@param optionNames string
|
||||
Target.RemoveNetworkedEntity = function(netids, optionNames)
|
||||
function Target.RemoveNetworkedEntity(netids, optionNames)
|
||||
qb_target:RemoveTargetEntity(netids, optionNames)
|
||||
end
|
||||
|
||||
---This will remove target options from all vehicles.
|
||||
---@param options table
|
||||
Target.RemoveGlobalVehicle = function(options)
|
||||
function Target.RemoveGlobalVehicle(options)
|
||||
local assembledLables = {}
|
||||
for k, v in pairs(options) do
|
||||
table.insert(assembledLables, v.label)
|
||||
@@ -135,35 +131,35 @@ end
|
||||
---This will generate targets on non networked entites with the passed options.
|
||||
---@param entities number | table
|
||||
---@param options table
|
||||
Target.AddLocalEntity = function(entities, options)
|
||||
function Target.AddLocalEntity(entities, options)
|
||||
options = Target.FixOptions(options)
|
||||
qb_target:AddTargetEntity(entities, {
|
||||
options = options,
|
||||
distance = GetLargestDistance(options)
|
||||
distance = getLargestDistance(options)
|
||||
})
|
||||
end
|
||||
|
||||
---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity.
|
||||
---@param entity number | table
|
||||
---@param labels string | table | nil
|
||||
Target.RemoveLocalEntity = function(entity, labels)
|
||||
function Target.RemoveLocalEntity(entity, labels)
|
||||
qb_target:RemoveTargetEntity(entity, labels)
|
||||
end
|
||||
|
||||
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
|
||||
---@param models number | table
|
||||
---@param options table
|
||||
Target.AddModel = function(models, options, distance)
|
||||
function Target.AddModel(models, options, distance)
|
||||
options = Target.FixOptions(options)
|
||||
qb_target:AddTargetModel(models, {
|
||||
options = options,
|
||||
distance = GetLargestDistance(options),
|
||||
distance = getLargestDistance(options),
|
||||
})
|
||||
end
|
||||
|
||||
---This will remove target options from all specified models.
|
||||
---@param model number
|
||||
Target.RemoveModel = function(model)
|
||||
function Target.RemoveModel(model)
|
||||
qb_target:RemoveTargetModel(model)
|
||||
end
|
||||
|
||||
@@ -173,7 +169,7 @@ end
|
||||
---@param size table
|
||||
---@param heading number
|
||||
---@param options table
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options, debug)
|
||||
function Target.AddBoxZone(name, coords, size, heading, options, debug)
|
||||
options = Target.FixOptions(options)
|
||||
if not next(options) then return end
|
||||
qb_target:AddBoxZone(name, coords, size.x, size.y, {
|
||||
@@ -184,7 +180,7 @@ Target.AddBoxZone = function(name, coords, size, heading, options, debug)
|
||||
maxZ = coords.z + (size.z * 0.5),
|
||||
}, {
|
||||
options = options,
|
||||
distance = GetLargestDistance(options),
|
||||
distance = getLargestDistance(options),
|
||||
})
|
||||
table.insert(targetZones, { name = name, creator = GetInvokingResource() })
|
||||
return name
|
||||
@@ -195,14 +191,14 @@ end
|
||||
---@param coords table
|
||||
---@param radius number
|
||||
---@param options table
|
||||
Target.AddSphereZone = function(name, coords, radius, options, debug)
|
||||
function Target.AddSphereZone(name, coords, radius, options, debug)
|
||||
options = Target.FixOptions(options)
|
||||
qb_target:AddCircleZone(name, coords, radius, {
|
||||
name = name,
|
||||
debugPoly = targetDebug or debug,
|
||||
}, {
|
||||
options = options,
|
||||
distance = GetLargestDistance(options),
|
||||
distance = getLargestDistance(options),
|
||||
})
|
||||
table.insert(targetZones, { name = name, creator = GetInvokingResource() })
|
||||
return name
|
||||
@@ -210,7 +206,7 @@ end
|
||||
|
||||
---This will remove target options from a specific zone.
|
||||
---@param name string
|
||||
Target.RemoveZone = function(name)
|
||||
function Target.RemoveZone(name)
|
||||
if not name then return end
|
||||
for _, data in pairs(targetZones) do
|
||||
if data.name == name then
|
||||
|
||||
@@ -3,22 +3,20 @@ local resourceName = "sleepless_interact"
|
||||
if GetResourceState(resourceName) == 'missing' then return end
|
||||
if GetResourceState("ox_target") == 'started' then return end
|
||||
|
||||
local targetDebug = false
|
||||
local function detectDebugEnabled()
|
||||
if BridgeSharedConfig.DebugLevel == 2 then targetDebug = true end
|
||||
end
|
||||
|
||||
detectDebugEnabled()
|
||||
|
||||
local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false
|
||||
local sleepless_interact = exports.sleepless_interact
|
||||
local targetZones = {}
|
||||
|
||||
Target = Target or {}
|
||||
|
||||
function Target.GetResourceName()
|
||||
return "sleepless_interact"
|
||||
end
|
||||
|
||||
---This is an internal function that is used to fix the options passed to fit alternative target systems, for example qb-ox or ox-qb etc.
|
||||
---@param options table
|
||||
---@return table
|
||||
Target.FixOptions = function(options)
|
||||
function Target.FixOptions(options)
|
||||
for k, v in pairs(options) do
|
||||
local action = v.onSelect or v.action
|
||||
local select = function(entityOrData)
|
||||
@@ -42,45 +40,45 @@ end
|
||||
|
||||
---This will toggle the targeting system on or off. This is useful for when you want to disable the targeting system for a specific player entirely.
|
||||
---@param bool boolean
|
||||
Target.DisableTargeting = function(bool) -- someone disabled this mistakenly
|
||||
function Target.DisableTargeting(bool) -- someone disabled this mistakenly
|
||||
sleepless_interact:disableInteract(bool)
|
||||
end
|
||||
|
||||
---This will add target options to players.
|
||||
---@param options table
|
||||
Target.AddGlobalPlayer = function(options)
|
||||
function Target.AddGlobalPlayer(options)
|
||||
options = Target.FixOptions(options)
|
||||
sleepless_interact:addGlobalPlayer(options)
|
||||
end
|
||||
|
||||
---This will remove target options from all players.
|
||||
Target.RemoveGlobalPlayer = function()
|
||||
function Target.RemoveGlobalPlayer()
|
||||
sleepless_interact:removeGlobalPlayer()
|
||||
end
|
||||
|
||||
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
|
||||
---@param options table
|
||||
Target.AddGlobalPed = function(options)
|
||||
function Target.AddGlobalPed(options)
|
||||
options = Target.FixOptions(options)
|
||||
sleepless_interact:addGlobalPed(options)
|
||||
end
|
||||
|
||||
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
|
||||
---@param options any
|
||||
Target.RemoveGlobalPed = function(options)
|
||||
function Target.RemoveGlobalPed(options)
|
||||
sleepless_interact:removeGlobalPed(options)
|
||||
end
|
||||
|
||||
---This will add taget options to all vehicles.
|
||||
---@param options table
|
||||
Target.AddGlobalVehicle = function(options)
|
||||
function Target.AddGlobalVehicle(options)
|
||||
options = Target.FixOptions(options)
|
||||
sleepless_interact:addGlobalVehicle(options)
|
||||
end
|
||||
|
||||
---This will remove target options from all vehicles.
|
||||
---@param options table
|
||||
Target.RemoveGlobalVehicle = function(options)
|
||||
function Target.RemoveGlobalVehicle(options)
|
||||
local assembledLables = {}
|
||||
for k, v in pairs(options) do
|
||||
table.insert(assembledLables, v.name)
|
||||
@@ -91,7 +89,7 @@ end
|
||||
---This will add a networked entity to the target system.
|
||||
---@param netids table | number
|
||||
---@param options table
|
||||
Target.AddNetworkedEntity = function(netids, options)
|
||||
function Target.AddNetworkedEntity(netids, options)
|
||||
options = Target.FixOptions(options)
|
||||
sleepless_interact:addEntity(netids, options)
|
||||
end
|
||||
@@ -99,14 +97,14 @@ end
|
||||
---This will remove a networked entity from the target system.
|
||||
---@param netids table | number
|
||||
---@param optionNames string
|
||||
Target.RemoveNetworkedEntity = function(netids, optionNames)
|
||||
function Target.RemoveNetworkedEntity(netids, optionNames)
|
||||
sleepless_interact:removeEntity(netids, optionNames)
|
||||
end
|
||||
|
||||
---This will generate targets on non networked entites with the passed options.
|
||||
---@param entities number | table
|
||||
---@param options table
|
||||
Target.AddLocalEntity = function(entities, options)
|
||||
function Target.AddLocalEntity(entities, options)
|
||||
options = Target.FixOptions(options)
|
||||
sleepless_interact:addLocalEntity(entities, options)
|
||||
end
|
||||
@@ -114,21 +112,21 @@ end
|
||||
---This will remove the target options from a local entity. This is useful for when you want to remove target options from a specific entity.
|
||||
---@param entity number | table
|
||||
---@param labels string | table | nil
|
||||
Target.RemoveLocalEntity = function(entity, labels)
|
||||
function Target.RemoveLocalEntity(entity, labels)
|
||||
sleepless_interact:removeLocalEntity(entity, labels)
|
||||
end
|
||||
|
||||
---This will add target options to all specified models. This is useful for when you want to add target options to all models of a specific type.
|
||||
---@param models number | table
|
||||
---@param options table
|
||||
Target.AddModel = function(models, options)
|
||||
function Target.AddModel(models, options)
|
||||
options = Target.FixOptions(options)
|
||||
sleepless_interact:addModel(models, options)
|
||||
end
|
||||
|
||||
---This will remove target options from all specified models.
|
||||
---@param model number
|
||||
Target.RemoveModel = function(model)
|
||||
function Target.RemoveModel(model)
|
||||
sleepless_interact:removeModel(model)
|
||||
end
|
||||
|
||||
@@ -138,7 +136,7 @@ end
|
||||
---@param size table
|
||||
---@param heading number
|
||||
---@param options table
|
||||
Target.AddBoxZone = function(name, coords, size, heading, options)
|
||||
function Target.AddBoxZone(name, coords, size, heading, options)
|
||||
options = Target.FixOptions(options)
|
||||
local target = sleepless_interact:addCoords({
|
||||
coords = coords,
|
||||
@@ -153,7 +151,7 @@ end
|
||||
---@param coords table
|
||||
---@param radius number
|
||||
---@param options table
|
||||
Target.AddSphereZone = function(name, coords, radius, options, debug)
|
||||
function Target.AddSphereZone(name, coords, radius, options, debug)
|
||||
options = Target.FixOptions(options)
|
||||
local target = sleepless_interact:addSphereZone({
|
||||
coords = coords,
|
||||
@@ -168,7 +166,7 @@ end
|
||||
|
||||
---This will remove target options from a specific zone.
|
||||
---@param name string
|
||||
Target.RemoveZone = function(name)
|
||||
function Target.RemoveZone(name)
|
||||
for _, data in pairs(targetZones) do
|
||||
if data.name == name then
|
||||
sleepless_interact:removeCoords(data.id)
|
||||
@@ -188,8 +186,4 @@ AddEventHandler('onResourceStop', function(resource)
|
||||
targetZones = {}
|
||||
end)
|
||||
|
||||
Target.GetResourceName = function()
|
||||
return "sleepless_interact"
|
||||
end
|
||||
|
||||
return Target
|
||||
Reference in new issue
Block a user