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
-1
@@ -5,7 +5,7 @@ use_experimental_fxv2_oal 'yes'
|
|||||||
author 'The Order of the Sacred Framework'
|
author 'The Order of the Sacred Framework'
|
||||||
name 'community_bridge'
|
name 'community_bridge'
|
||||||
description 'A Universal Bridge for Our Community, created by a group of contributors with a shared vision to enhance both user and developer experiences. This bridge connects various frameworks, inventories, target systems, notification systems, and more, fostering compatibility and seamless integration.'
|
description 'A Universal Bridge for Our Community, created by a group of contributors with a shared vision to enhance both user and developer experiences. This bridge connects various frameworks, inventories, target systems, notification systems, and more, fostering compatibility and seamless integration.'
|
||||||
version '0.13.0'
|
version '0.13.1'
|
||||||
|
|
||||||
shared_scripts {
|
shared_scripts {
|
||||||
'@ox_lib/init.lua',
|
'@ox_lib/init.lua',
|
||||||
|
|||||||
@@ -1,65 +0,0 @@
|
|||||||
Batch = Batch or {}
|
|
||||||
Batch.Event = Batch.Event or {}
|
|
||||||
Batch.Event.Queued = Batch.Event.Queued or {}
|
|
||||||
Batch.Event.IsQueued = Batch.Event.IsQueued or false
|
|
||||||
|
|
||||||
local SERVER = IsDuplicityVersion()
|
|
||||||
|
|
||||||
-- could do a callback from client to server back to client with a time stamp. Use that timestamp to generate some random string/number and use that fo
|
|
||||||
-- this event name. Would help by masking from exploits. Thinking about making a module out of it
|
|
||||||
|
|
||||||
--- This is used to batch single events together to reduce network strain
|
|
||||||
---
|
|
||||||
if SERVER then
|
|
||||||
function Batch.Event.Queue(src, event, ...)
|
|
||||||
if src == -1 then
|
|
||||||
src = GetPlayers()
|
|
||||||
for k, v in pairs(src) do
|
|
||||||
local strSrc = tostring(v)
|
|
||||||
Batch.Event.Queued[strSrc] = Batch.Event.Queued[strSrc] or {}
|
|
||||||
table.insert(Batch.Event.Queued[strSrc], {
|
|
||||||
src = v,
|
|
||||||
event = event,
|
|
||||||
args = {...}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
else
|
|
||||||
local strSrc = tostring(src)
|
|
||||||
Batch.Event.Queued[strSrc] = Batch.Event.Queued[strSrc] or {}
|
|
||||||
table.insert(Batch.Event.Queued[strSrc], {
|
|
||||||
src = src,
|
|
||||||
event = event,
|
|
||||||
args = {...}
|
|
||||||
})
|
|
||||||
end
|
|
||||||
|
|
||||||
if Batch.Event.IsQueued then return end
|
|
||||||
Batch.Event.IsQueued = true
|
|
||||||
SetTimeout(100, function()
|
|
||||||
for k, v in pairs(Batch.Event.Queued) do
|
|
||||||
TriggerClientEvent('community_bridge:client:BatchEvents', v.src, v)
|
|
||||||
end
|
|
||||||
Batch.Event.IsQueued = false
|
|
||||||
Batch.Event.Queued = {}
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
return Batch
|
|
||||||
else
|
|
||||||
|
|
||||||
Batch.Event.Fire = function(array)
|
|
||||||
local playerSrc = PlayerId()
|
|
||||||
for k, v in pairs(array) do
|
|
||||||
if v.src == playerSrc then
|
|
||||||
local event = v.event
|
|
||||||
local args = v.args
|
|
||||||
TriggerEvent(event, table.unpack(args))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
RegisterNetEvent('community_bridge:client:BatchEvents', function(array)
|
|
||||||
Batch.Event.Fire(array)
|
|
||||||
end)
|
|
||||||
|
|
||||||
return Batch
|
|
||||||
end
|
|
||||||
Vendored
-43
@@ -1,43 +0,0 @@
|
|||||||
Cache = Require("lib/cache/shared/cache.lua")
|
|
||||||
local PlayerPedId = PlayerPedId
|
|
||||||
local GetVehiclePedIsIn = GetVehiclePedIsIn
|
|
||||||
local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers
|
|
||||||
local GetPedInVehicleSeat = GetPedInVehicleSeat
|
|
||||||
local GetSelectedPedWeapon = GetSelectedPedWeapon
|
|
||||||
|
|
||||||
--- Get the vehicle the player is in, if any
|
|
||||||
---@return integer | nil
|
|
||||||
function GetVehicle()
|
|
||||||
local ped = PlayerPedId()
|
|
||||||
if not ped then return end
|
|
||||||
return GetVehiclePedIsIn(ped, false)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get the seat of the player in the vehicle if the vehicle is occupied
|
|
||||||
---@return integer | nil
|
|
||||||
function GetVehicleSeat()
|
|
||||||
local vehicle = GetVehicle()
|
|
||||||
if not vehicle then return end
|
|
||||||
local ped = PlayerPedId()
|
|
||||||
if not ped then return end
|
|
||||||
for i = -1, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do
|
|
||||||
if ped == GetPedInVehicleSeat(vehicle, i) then
|
|
||||||
return i
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get the current weapon of the player
|
|
||||||
--- @return integer | nil
|
|
||||||
function GetWeapon()
|
|
||||||
local ped = PlayerPedId()
|
|
||||||
if not ped then return end -- Return unarmed hash if no ped
|
|
||||||
return GetSelectedPedWeapon(ped)
|
|
||||||
end
|
|
||||||
|
|
||||||
Cache.Create("Ped", PlayerPedId, 1000) -- Check ped every second (adjust as needed)
|
|
||||||
Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms
|
|
||||||
Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms
|
|
||||||
Cache.Create("Weapon", GetWeapon , 250) -- Check weapon every 250ms
|
|
||||||
|
|
||||||
return Cache
|
|
||||||
Vendored
Whitespace-only changes.
Vendored
-276
@@ -1,276 +0,0 @@
|
|||||||
---@class CacheEntry
|
|
||||||
---@field Name string
|
|
||||||
---@field Compare fun(): any
|
|
||||||
---@field WaitTime integer | nil
|
|
||||||
---@field LastChecked integer|nil
|
|
||||||
---@field OnChange fun(new:any, old:any)[]
|
|
||||||
---@field Value any
|
|
||||||
|
|
||||||
---@class CacheModule
|
|
||||||
---@field Caches table<string, CacheEntry>
|
|
||||||
---@field LoopRunning boolean
|
|
||||||
---@field Create fun(name:string, compare:fun():any, waitTime:integer | nil): CacheEntry
|
|
||||||
---@field Get fun(name:string): any
|
|
||||||
---@field OnChange fun(name:string, onChange:fun(new:any, old:any))
|
|
||||||
---@field Remove fun(name:string)
|
|
||||||
Cache = Cache or {} ---@type CacheModule -- <-- we use Cache as a global variable so that if we dont required it more than once
|
|
||||||
|
|
||||||
Table = Table or Require('lib/utility/shared/tables.lua')
|
|
||||||
Id = Id or Require('lib/utility/shared/ids.lua')
|
|
||||||
|
|
||||||
local Config = Require("settings/sharedConfig.lua")
|
|
||||||
local max = 5000
|
|
||||||
local CreateThread = CreateThread
|
|
||||||
local Wait = Wait
|
|
||||||
local GetGameTimer = GetGameTimer
|
|
||||||
|
|
||||||
local resourceCallbacks = {} -- Add callbacks from resources
|
|
||||||
local resourceTracker = {
|
|
||||||
caches = {},
|
|
||||||
callbacks = {},
|
|
||||||
initialized = {}
|
|
||||||
}
|
|
||||||
|
|
||||||
Cache.Caches = Cache.Caches or {}
|
|
||||||
Cache.LoopRunning = Cache.LoopRunning or false
|
|
||||||
|
|
||||||
---@param ... any
|
|
||||||
local function debugPrint(...)
|
|
||||||
if Config.DebugLevel == 0 then return end
|
|
||||||
print("^2[Cache]^0", ...)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function HasActiveCaches()
|
|
||||||
for _, cache in pairs(Cache.Caches) do
|
|
||||||
if cache.WaitTime ~= nil then
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
local function processCacheEntry(now, cache)
|
|
||||||
cache.LastChecked = cache.LastChecked or now
|
|
||||||
cache.WaitTime = tonumber(cache.WaitTime) or max
|
|
||||||
local elapsed = now - cache.LastChecked
|
|
||||||
local remaining = cache.WaitTime - elapsed
|
|
||||||
|
|
||||||
if remaining <= 0 then
|
|
||||||
local oldValue = cache.Value
|
|
||||||
cache.Value = cache.Compare()
|
|
||||||
if not Table.Compare(cache.Value, oldValue) and cache.OnChange then
|
|
||||||
for i, onChange in pairs(cache.OnChange) do
|
|
||||||
onChange(cache.Value, oldValue)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
cache.LastChecked = now
|
|
||||||
remaining = cache.WaitTime
|
|
||||||
end
|
|
||||||
|
|
||||||
return remaining
|
|
||||||
end
|
|
||||||
|
|
||||||
local function getNextWait(now)
|
|
||||||
local minWait = nil
|
|
||||||
for name, cache in pairs(Cache.Caches) do
|
|
||||||
if cache.Compare and cache.WaitTime ~= nil then
|
|
||||||
local remaining = processCacheEntry(now, cache)
|
|
||||||
if not minWait or remaining < minWait then
|
|
||||||
minWait = remaining
|
|
||||||
if minWait <= 0 then break end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return minWait
|
|
||||||
end
|
|
||||||
|
|
||||||
local function StartLoop()
|
|
||||||
if Cache.LoopRunning then return end
|
|
||||||
if not HasActiveCaches() then return end
|
|
||||||
Cache.LoopRunning = true
|
|
||||||
CreateThread(function()
|
|
||||||
while Cache.LoopRunning do
|
|
||||||
local now = GetGameTimer()
|
|
||||||
local minWait = getNextWait(now)
|
|
||||||
if minWait then
|
|
||||||
Wait(math.max(0, minWait))
|
|
||||||
else
|
|
||||||
Wait(max)
|
|
||||||
end
|
|
||||||
if not HasActiveCaches() then
|
|
||||||
Cache.LoopRunning = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
local function trackResource(resourceName, type, data)
|
|
||||||
if not resourceName then return end
|
|
||||||
|
|
||||||
-- Initialize resource tracking if needed
|
|
||||||
if not resourceTracker.initialized[resourceName] then
|
|
||||||
resourceTracker.initialized[resourceName] = true
|
|
||||||
resourceTracker.caches[resourceName] = resourceTracker.caches[resourceName] or {}
|
|
||||||
resourceTracker.callbacks[resourceName] = resourceTracker.callbacks[resourceName] or {}
|
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(stoppingResource)
|
|
||||||
if stoppingResource ~= resourceName then return end
|
|
||||||
|
|
||||||
-- Clean up caches
|
|
||||||
for _, cacheName in ipairs(resourceTracker.caches[resourceName] or {}) do
|
|
||||||
if Cache.Caches[cacheName] then
|
|
||||||
Cache.Caches[cacheName] = nil
|
|
||||||
debugPrint(("Removed cache '%s' - resource '%s' stopped"):format(cacheName, resourceName))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Clean up callbacks
|
|
||||||
for _, cb in ipairs(resourceTracker.callbacks[resourceName] or {}) do
|
|
||||||
local targetCache = Cache.Caches[cb.cacheName]
|
|
||||||
if targetCache then
|
|
||||||
targetCache.OnChange[cb.index] = nil
|
|
||||||
debugPrint(("Removed callback '%s' from cache '%s' - resource '%s' stopped"):format(cb.index, cb.cacheName, resourceName))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Clear tracking data
|
|
||||||
resourceTracker.caches[resourceName] = nil
|
|
||||||
resourceTracker.callbacks[resourceName] = nil
|
|
||||||
resourceTracker.initialized[resourceName] = nil
|
|
||||||
end)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Track the new item
|
|
||||||
if type == "cache" then
|
|
||||||
table.insert(resourceTracker.caches[resourceName], data)
|
|
||||||
elseif type == "callback" then
|
|
||||||
table.insert(resourceTracker.callbacks[resourceName], data)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param name string
|
|
||||||
---@param compare fun():any
|
|
||||||
---@param waitTime integer | nil
|
|
||||||
---@return CacheEntry | nil
|
|
||||||
function Cache.Create(name, compare, waitTime)
|
|
||||||
assert(name, "Cache name is required.")
|
|
||||||
assert(compare, "Comparison function is required.")
|
|
||||||
if type(waitTime) ~= "number" then
|
|
||||||
waitTime = nil
|
|
||||||
end
|
|
||||||
local _name = tostring(name)
|
|
||||||
local cache = Cache.Caches[_name]
|
|
||||||
if cache and cache.Compare == compare then
|
|
||||||
debugPrint(_name .. " already exists with the same comparison function.")
|
|
||||||
return cache
|
|
||||||
end
|
|
||||||
local ok, result = pcall(compare)
|
|
||||||
if not ok then
|
|
||||||
debugPrint("Error creating cache '" .. _name .. "': " .. tostring(result))
|
|
||||||
return nil
|
|
||||||
end
|
|
||||||
---@type CacheEntry
|
|
||||||
local newCache = {
|
|
||||||
Name = _name,
|
|
||||||
Compare = compare,
|
|
||||||
WaitTime = waitTime, -- can be nil
|
|
||||||
LastChecked = nil,
|
|
||||||
OnChange = {},
|
|
||||||
Value = result
|
|
||||||
}
|
|
||||||
|
|
||||||
-- Track the cache with its resource
|
|
||||||
trackResource(GetInvokingResource(), "cache", _name)
|
|
||||||
|
|
||||||
Cache.Caches[_name] = newCache
|
|
||||||
|
|
||||||
debugPrint(_name .. " created with initial value: " .. tostring(result))
|
|
||||||
for _, onChange in pairs(newCache.OnChange) do
|
|
||||||
onChange(newCache.Value, 0)
|
|
||||||
end
|
|
||||||
StartLoop()
|
|
||||||
return newCache
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param name string
|
|
||||||
---@return any
|
|
||||||
function Cache.Get(name)
|
|
||||||
assert(name, "Cache name is required.")
|
|
||||||
local _name = tostring(name)
|
|
||||||
local cache = Cache.Caches[_name]
|
|
||||||
return cache and cache.Value or nil
|
|
||||||
end
|
|
||||||
|
|
||||||
--- This add a callback to the cache entry that will be called when the value changes.
|
|
||||||
--- The callback will be called with the new value and the old value.
|
|
||||||
--- you can call the value again to delete the callback.
|
|
||||||
---@param name string
|
|
||||||
---@param onChange fun(new:any, old:any)
|
|
||||||
function Cache.OnChange(name, onChange)
|
|
||||||
assert(name, "Cache name is required.")
|
|
||||||
local _name = tostring(name)
|
|
||||||
local cache = Cache.Caches[_name]
|
|
||||||
assert(cache, "Cache with name '" .. _name .. "' does not exist.")
|
|
||||||
|
|
||||||
local id = Id.CreateUniqueId(Cache.Caches[_name]?.OnChange)
|
|
||||||
-- Figure out which resource is trying to register this callback
|
|
||||||
local invokingResource = GetInvokingResource()
|
|
||||||
if not invokingResource then return end
|
|
||||||
-- Add the new callback to our list
|
|
||||||
local callbackIndex = id
|
|
||||||
cache.OnChange[callbackIndex] = onChange
|
|
||||||
|
|
||||||
-- Track the callback with its resource
|
|
||||||
trackResource(GetInvokingResource(), "callback", {
|
|
||||||
cacheName = _name,
|
|
||||||
index = callbackIndex
|
|
||||||
})
|
|
||||||
|
|
||||||
debugPrint(("Added new OnChange callback to cache '%s' from resource '%s'"):format(_name, invokingResource))
|
|
||||||
return callbackIndex
|
|
||||||
end
|
|
||||||
|
|
||||||
function Cache.RemoveOnChange(name, id)
|
|
||||||
assert(name, "Cache name is required.")
|
|
||||||
local _name = tostring(name)
|
|
||||||
local cache = Cache.Caches[_name]
|
|
||||||
assert(cache, "Cache with name '" .. _name .. "' does not exist.")
|
|
||||||
if cache.OnChange[id] then
|
|
||||||
cache.OnChange[id] = nil
|
|
||||||
debugPrint("Removed OnChange callback from cache '" .. _name .. "' with ID: " .. id)
|
|
||||||
else
|
|
||||||
debugPrint("No OnChange callback found with ID: " .. id .. " in cache '" .. _name .. "'")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param name string
|
|
||||||
function Cache.Remove(name)
|
|
||||||
assert(name, "Cache name is required.")
|
|
||||||
local _name = tostring(name)
|
|
||||||
local cache = Cache.Caches[_name]
|
|
||||||
if cache then
|
|
||||||
Cache.Caches[_name] = nil
|
|
||||||
debugPrint(_name .. " removed from cache.")
|
|
||||||
if next(Cache.Caches) == nil then
|
|
||||||
Cache.LoopRunning = false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
---@param name string
|
|
||||||
---@param newValue any
|
|
||||||
function Cache.Update(name, newValue)
|
|
||||||
assert(name, "Cache name is required.")
|
|
||||||
local _name = tostring(name)
|
|
||||||
local cache = Cache.Caches[_name]
|
|
||||||
assert(cache, "Cache with name '" .. _name .. "' does not exist.")
|
|
||||||
local oldValue = cache.Value
|
|
||||||
if oldValue ~= newValue then
|
|
||||||
cache.Value = newValue
|
|
||||||
for _, onChange in pairs(cache.OnChange) do
|
|
||||||
onChange(newValue, oldValue)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
return Cache
|
|
||||||
@@ -50,9 +50,7 @@ if not IsDuplicityVersion() then goto client end
|
|||||||
|
|
||||||
cLib.SQL = SQL or Require("lib/sql/server/sqlHandler.lua")
|
cLib.SQL = SQL or Require("lib/sql/server/sqlHandler.lua")
|
||||||
cLib.Logs = Logs or Require("lib/logs/server/logs.lua")
|
cLib.Logs = Logs or Require("lib/logs/server/logs.lua")
|
||||||
cLib.Cache = Cache or Require("lib/cache/shared/cache.lua")
|
|
||||||
cLib.Marker = Marker or Require("lib/markers/server/server.lua")
|
cLib.Marker = Marker or Require("lib/markers/server/server.lua")
|
||||||
cLib.Particle = Particle or Require("lib/particles/server/particles.lua")
|
|
||||||
cLib.Shell = Shells or Require("lib/shells/server/shells.lua")
|
cLib.Shell = Shells or Require("lib/shells/server/shells.lua")
|
||||||
cLib.Entity = ServerEntity or Require("lib/entities/server/server_entity.lua")
|
cLib.Entity = ServerEntity or Require("lib/entities/server/server_entity.lua")
|
||||||
|
|
||||||
@@ -69,7 +67,6 @@ cLib.PlaceableObject = ObjectPlacer or Require("lib/placers/client/placeable_obj
|
|||||||
cLib.Raycast = Raycast or Require("lib/raycast/client/raycast.lua")
|
cLib.Raycast = Raycast or Require("lib/raycast/client/raycast.lua")
|
||||||
cLib.Point = Point or Require("lib/points/client/points.lua")
|
cLib.Point = Point or Require("lib/points/client/points.lua")
|
||||||
cLib.Particle = Particle or Require("lib/particles/client/particles.lua")
|
cLib.Particle = Particle or Require("lib/particles/client/particles.lua")
|
||||||
cLib.Cache = Cache or Require("lib/cache/client/cache.lua")
|
|
||||||
cLib.Marker = Marker or Require("lib/markers/client/markers.lua")
|
cLib.Marker = Marker or Require("lib/markers/client/markers.lua")
|
||||||
cLib.Anim = Anim or Require("lib/anim/client/client.lua")
|
cLib.Anim = Anim or Require("lib/anim/client/client.lua")
|
||||||
cLib.Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua")
|
cLib.Cutscene = Cutscene or Require("lib/cutscenes/client/cutscene.lua")
|
||||||
|
|||||||
@@ -92,32 +92,6 @@ function Particle.Stop(particle)
|
|||||||
Particles[tostring(particle)] = nil
|
Particles[tostring(particle)] = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
RegisterNetEvent("community_bridge:Client:Particle", function(data)
|
|
||||||
if not data then return end
|
|
||||||
Particle.Create(data)
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent("community_bridge:Client:ParticleBulk", function(datas)
|
|
||||||
if not datas then return end
|
|
||||||
for _, data in pairs(datas) do
|
|
||||||
Particle.Create(data)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent("community_bridge:Client:ParticleRemove", function(id)
|
|
||||||
local particle = Particles[id]
|
|
||||||
if not particle then return end
|
|
||||||
Particle.Stop(id)
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent("community_bridge:Client:ParticleRemoveBulk", function(ids)
|
|
||||||
for _, id in pairs(ids) do
|
|
||||||
Particle.Stop(id)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength)
|
function Particle.CreateOnEntity(dict, ptfx, entity, offset, rot, scale, color, looped, loopLength)
|
||||||
LoadPtfxAsset(dict)
|
LoadPtfxAsset(dict)
|
||||||
UseParticleFxAssetNextCall(dict)
|
UseParticleFxAssetNextCall(dict)
|
||||||
|
|||||||
@@ -1,72 +0,0 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
|
||||||
|
|
||||||
Particles = {}
|
|
||||||
Particle = Particles or {}
|
|
||||||
|
|
||||||
function Particle.New(data)
|
|
||||||
assert(data, "Particle data is nil")
|
|
||||||
assert(data.dict, "Invalid particle data. Must contain string dict.")
|
|
||||||
assert(data.ptfx, "Invalid particle data. Must contain string ptfx.")
|
|
||||||
|
|
||||||
local _id = data.id or Bridge.Ids.CreateUniqueId(Particles)
|
|
||||||
data = {
|
|
||||||
id = _id,
|
|
||||||
dict = data.dict,
|
|
||||||
ptfx = data.ptfx,
|
|
||||||
position = data.position or vector3(0.0, 0.0, 0.0),
|
|
||||||
rotation = data.rotation or vector3(0, 0, 0),
|
|
||||||
size = data.size or 1.0,
|
|
||||||
color = data.color or vector3(255, 255, 255),
|
|
||||||
looped = data.looped or false,
|
|
||||||
loopLength = data.loopLength or nil,
|
|
||||||
}
|
|
||||||
Particles[_id] = data
|
|
||||||
return data
|
|
||||||
end
|
|
||||||
|
|
||||||
function Particle.Destroy(id)
|
|
||||||
if not id or not Particles[id] then return end
|
|
||||||
Particles[id] = nil
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
|
|
||||||
function Particle.Create(data)
|
|
||||||
local particleData = Particle.New(data)
|
|
||||||
if not particleData then return end
|
|
||||||
TriggerClientEvent("community_bridge:Client:Particle", -1, particleData)
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
function Particle.Remove(id)
|
|
||||||
if not Particle.Destroy(id) then return end
|
|
||||||
TriggerClientEvent("community_bridge:Client:ParticleRemove", -1, id)
|
|
||||||
end
|
|
||||||
|
|
||||||
function Particle.CreateBulk(datas)
|
|
||||||
if not datas then return end
|
|
||||||
local toClient = {}
|
|
||||||
for k, v in pairs(datas) do
|
|
||||||
local data = Particle.New(v)
|
|
||||||
table.insert(toClient, data)
|
|
||||||
end
|
|
||||||
TriggerClientEvent("community_bridge:Client:ParticleBulk", -1, toClient)
|
|
||||||
return toClient
|
|
||||||
end
|
|
||||||
|
|
||||||
function Particle.RemoveBulk(ids)
|
|
||||||
if not ids then return end
|
|
||||||
local toClient = {}
|
|
||||||
for k, v in pairs(ids) do
|
|
||||||
local id = v
|
|
||||||
if type(v) == "table" then
|
|
||||||
id = v.id
|
|
||||||
end
|
|
||||||
Particle.Destroy(id)
|
|
||||||
table.insert(toClient, id)
|
|
||||||
end
|
|
||||||
TriggerClientEvent("community_bridge:Client:ParticleRemoveBulk", -1, toClient)
|
|
||||||
return ids
|
|
||||||
end
|
|
||||||
|
|
||||||
return Particle
|
|
||||||
@@ -40,7 +40,7 @@ end
|
|||||||
---@return number|nil
|
---@return number|nil
|
||||||
function Utility.CreateProp(model, coords, heading, networked)
|
function Utility.CreateProp(model, coords, heading, networked)
|
||||||
local loaded, hash = ensureModelLoaded(model)
|
local loaded, hash = ensureModelLoaded(model)
|
||||||
if not loaded then return nil, print("^6 Model was unable to load "..tostring(model).." ^0") end
|
if not loaded then return nil, print("^6 community_bridge model was unable to load "..tostring(model).." ^0") end
|
||||||
local propEntity = CreateObject(hash, coords.x, coords.y, coords.z, networked, false, false)
|
local propEntity = CreateObject(hash, coords.x, coords.y, coords.z, networked, false, false)
|
||||||
SetEntityHeading(propEntity, heading)
|
SetEntityHeading(propEntity, heading)
|
||||||
SetModelAsNoLongerNeeded(hash)
|
SetModelAsNoLongerNeeded(hash)
|
||||||
@@ -64,7 +64,7 @@ end
|
|||||||
---@return number|nil, table
|
---@return number|nil, table
|
||||||
function Utility.CreateVehicle(model, coords, heading, networked)
|
function Utility.CreateVehicle(model, coords, heading, networked)
|
||||||
local loaded, hash = ensureModelLoaded(model)
|
local loaded, hash = ensureModelLoaded(model)
|
||||||
if not loaded then return nil, {}, print("^6 Model was unable to load "..tostring(model).." ^0") end
|
if not loaded then return nil, {}, print("^6 community_bridge model was unable to load "..tostring(model).." ^0") end
|
||||||
local vehicle = CreateVehicle(hash, coords.x, coords.y, coords.z, heading, networked, false)
|
local vehicle = CreateVehicle(hash, coords.x, coords.y, coords.z, heading, networked, false)
|
||||||
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
|
SetVehicleHasBeenOwnedByPlayer(vehicle, true)
|
||||||
SetVehicleNeedsToBeHotwired(vehicle, false)
|
SetVehicleNeedsToBeHotwired(vehicle, false)
|
||||||
@@ -82,7 +82,7 @@ end
|
|||||||
---@return number|nil
|
---@return number|nil
|
||||||
function Utility.CreatePed(model, coords, heading, networked, settings)
|
function Utility.CreatePed(model, coords, heading, networked, settings)
|
||||||
local loaded, hash = ensureModelLoaded(model)
|
local loaded, hash = ensureModelLoaded(model)
|
||||||
if not loaded then return nil, print("^6 Model was unable to load "..tostring(model).." ^0") end
|
if not loaded then return nil, print("^6 community_bridge model was unable to load "..tostring(model).." ^0") end
|
||||||
local spawnedEntity = CreatePed(0, hash, coords.x, coords.y, coords.z, heading, networked, false)
|
local spawnedEntity = CreatePed(0, hash, coords.x, coords.y, coords.z, heading, networked, false)
|
||||||
SetModelAsNoLongerNeeded(hash)
|
SetModelAsNoLongerNeeded(hash)
|
||||||
spawnedPeds[tostring(spawnedEntity)] = true
|
spawnedPeds[tostring(spawnedEntity)] = true
|
||||||
@@ -174,7 +174,7 @@ end
|
|||||||
---@param blip number
|
---@param blip number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Utility.RemoveBlip(blip)
|
function Utility.RemoveBlip(blip)
|
||||||
if not blipIDs[tostring(blip)] then return false, print("^6 No blip to remove with matching ID ^0") end
|
if not blipIDs[tostring(blip)] then return false end
|
||||||
RemoveBlip(blipIDs[tostring(blip)])
|
RemoveBlip(blipIDs[tostring(blip)])
|
||||||
blipIDs[tostring(blip)] = nil
|
blipIDs[tostring(blip)] = nil
|
||||||
return true
|
return true
|
||||||
@@ -298,8 +298,6 @@ function Utility.HelpText(text, duration)
|
|||||||
EndTextCommandDisplayHelp(0, false, true, duration or 5000)
|
EndTextCommandDisplayHelp(0, false, true, duration or 5000)
|
||||||
end
|
end
|
||||||
|
|
||||||
local doingstuff = false
|
|
||||||
|
|
||||||
---Show a floating help text in the world
|
---Show a floating help text in the world
|
||||||
---@param text string The text to show
|
---@param text string The text to show
|
||||||
---@param coords table The coords to show the message at
|
---@param coords table The coords to show the message at
|
||||||
@@ -452,20 +450,24 @@ function Utility.GetClosestVehicle(coords, distanceScope, includePlayerVeh)
|
|||||||
return vehicleEntity, vehicleCoords, vehicleNetID
|
return vehicleEntity, vehicleCoords, vehicleNetID
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Deprecated point functions (no changes)
|
-- Deprecated point functions (no changes) 12/14/25
|
||||||
function Utility.RegisterPoint(pointID, pointCoords, pointDistance, _onEnter, _onExit)
|
function Utility.RegisterPoint(pointID, pointCoords, pointDistance, _onEnter, _onExit)
|
||||||
|
print("^6 community_bridge ^: ^3Utility.RegisterPoint is deprecated. Please use Point.Register instead. ^0")
|
||||||
return Point.Register(pointID, pointCoords, pointDistance, nil, _onEnter, _onExit)
|
return Point.Register(pointID, pointCoords, pointDistance, nil, _onEnter, _onExit)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Utility.GetPointById(pointID)
|
function Utility.GetPointById(pointID)
|
||||||
|
print("^6 community_bridge ^: ^3Utility.GetPointById is deprecated. Please use Point.Get instead. ^0")
|
||||||
return Point.Get(pointID)
|
return Point.Get(pointID)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Utility.GetActivePoints()
|
function Utility.GetActivePoints()
|
||||||
|
print("^6 community_bridge ^: ^3Utility.GetActivePoints is deprecated. Please use Point.GetAll instead. ^0")
|
||||||
return Point.GetAll()
|
return Point.GetAll()
|
||||||
end
|
end
|
||||||
|
|
||||||
function Utility.RemovePoint(pointID)
|
function Utility.RemovePoint(pointID)
|
||||||
|
print("^6 community_bridge ^: ^3Utility.RemovePoint is deprecated. Please use Point.Remove instead. ^0")
|
||||||
return Point.Remove(pointID)
|
return Point.Remove(pointID)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Jy het nie genoeg geld om hierdie item te koop nie",
|
"NotEnoughMoney": "Jy het nie genoeg geld om hierdie item te koop nie",
|
||||||
"Input": "Hoeveelheid Invoer",
|
"Input": "Hoeveelheid Invoer",
|
||||||
"PurchaseAmount": "Aankoop Hoeveelheid",
|
"PurchaseAmount": "Aankoop Hoeveelheid",
|
||||||
"PurchasedItem": "Jy het gekoop ",
|
"PurchasedItem": "Jy het gekoop %s %s",
|
||||||
"PurchaseFailed": "Aankoop het misluk, inventaris vol",
|
"PurchaseFailed": "Aankoop het misluk, inventaris vol",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Bevestig Aankoop",
|
"Confirm": "Bevestig Aankoop",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "ليس لديك ما يكفي من المال لشراء هذا العنصر",
|
"NotEnoughMoney": "ليس لديك ما يكفي من المال لشراء هذا العنصر",
|
||||||
"Input": "إدخال الكمية",
|
"Input": "إدخال الكمية",
|
||||||
"PurchaseAmount": "كمية الشراء",
|
"PurchaseAmount": "كمية الشراء",
|
||||||
"PurchasedItem": "لقد قمت بشراء ",
|
"PurchasedItem": "لقد قمت بشراء %s %s",
|
||||||
"PurchaseFailed": "فشل الشراء، المخزون ممتلئ",
|
"PurchaseFailed": "فشل الشراء، المخزون ممتلئ",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "تأكيد الشراء",
|
"Confirm": "تأكيد الشراء",
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
{
|
||||||
|
"Shops": {
|
||||||
|
"NotEnoughMoney": "Нямате достатъчно пари, за да купите този артикул",
|
||||||
|
"Input": "Въвеждане на количество",
|
||||||
|
"PurchaseAmount": "Количество за покупка",
|
||||||
|
"PurchasedItem": "Закупихте %s %s",
|
||||||
|
"PurchaseFailed": "Покупката е неуспешна, инвентарът е пълен",
|
||||||
|
"CurrencySymbol": "%s лв.",
|
||||||
|
"Confirm": "Потвърдете покупката",
|
||||||
|
"AreYouSure": "Сигурни ли сте, че искате да закупите %s",
|
||||||
|
"PayByCash": "Плащане на %s в брой",
|
||||||
|
"PayByCard": "Плащане на %s с карта",
|
||||||
|
"CardIcon": "fa-solid fa-building-columns",
|
||||||
|
"CashIcon": "fa-solid fa-money-bill-wave",
|
||||||
|
"ShopIcon": "fa-solid fa-basket-shopping",
|
||||||
|
"ShopName": "Име на магазина"
|
||||||
|
},
|
||||||
|
"Notifications": {
|
||||||
|
"PlaceholderTitle": "Известие"
|
||||||
|
},
|
||||||
|
"clipboard": {
|
||||||
|
"copy": "Копирано в клипборда"
|
||||||
|
},
|
||||||
|
"input": {
|
||||||
|
"submit_text": "Изпрати"
|
||||||
|
},
|
||||||
|
"placeable_object": {
|
||||||
|
"no_prop_defined": "Не сте дефинирали обект за поставяне",
|
||||||
|
"cant_place_here": "Не можете да поставите този обект тук",
|
||||||
|
"place_object_place": "[E] Поставяне \n",
|
||||||
|
"place_object_cancel": "[X] Отказ \n",
|
||||||
|
"place_object_scroll_up": "[Превъртане нагоре] Завъртане надясно \n",
|
||||||
|
"place_object_scroll_down": "[Превъртане надолу] Завъртане наляво \n",
|
||||||
|
"object_place": "[%s] Поставяне \n",
|
||||||
|
"object_cancel": "[%s] Отказ \n",
|
||||||
|
"object_scroll_up": "[%s] Завъртане надясно \n",
|
||||||
|
"object_scroll_down": "[%s] Завъртане наляво \n",
|
||||||
|
"rotate_left": "Завъртане наляво",
|
||||||
|
"rotate_right": "Завъртане надясно",
|
||||||
|
"rotate_clockwise": "[%s] Завъртане по часовниковата стрелка \n",
|
||||||
|
"rotate_counter_clockwise": "[%s] Завъртане обратно на часовниковата стрелка \n",
|
||||||
|
"depth_modifier": "[%s] Модификатор на дълбочината \n"
|
||||||
|
},
|
||||||
|
"target": {
|
||||||
|
"interact": "[E] Взаимодействие",
|
||||||
|
"title": "Опции",
|
||||||
|
"description": "Няма описание"
|
||||||
|
}
|
||||||
|
}
|
||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Nemáte dostatek peněz na koupi této položky",
|
"NotEnoughMoney": "Nemáte dostatek peněz na koupi této položky",
|
||||||
"Input": "Zadání množství",
|
"Input": "Zadání množství",
|
||||||
"PurchaseAmount": "Množství nákupu",
|
"PurchaseAmount": "Množství nákupu",
|
||||||
"PurchasedItem": "Zakoupili jste ",
|
"PurchasedItem": "Zakoupili jste %s %s",
|
||||||
"PurchaseFailed": "Nákup se nezdařil, inventář je plný",
|
"PurchaseFailed": "Nákup se nezdařil, inventář je plný",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Potvrdit nákup",
|
"Confirm": "Potvrdit nákup",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Du har ikke nok penge til at købe denne vare",
|
"NotEnoughMoney": "Du har ikke nok penge til at købe denne vare",
|
||||||
"Input": "Mængde input",
|
"Input": "Mængde input",
|
||||||
"PurchaseAmount": "Købs mængde",
|
"PurchaseAmount": "Købs mængde",
|
||||||
"PurchasedItem": "Du har købt ",
|
"PurchasedItem": "Du har købt %s %s",
|
||||||
"PurchaseFailed": "Køb mislykkedes, inventar fuldt",
|
"PurchaseFailed": "Køb mislykkedes, inventar fuldt",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Bekræft køb",
|
"Confirm": "Bekræft køb",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Sie haben nicht genug Geld, um diesen Artikel zu kaufen",
|
"NotEnoughMoney": "Sie haben nicht genug Geld, um diesen Artikel zu kaufen",
|
||||||
"Input": "Mengen-Eingabe",
|
"Input": "Mengen-Eingabe",
|
||||||
"PurchaseAmount": "Kaufmenge",
|
"PurchaseAmount": "Kaufmenge",
|
||||||
"PurchasedItem": "Sie haben gekauft ",
|
"PurchasedItem": "Sie haben gekauft %s %s",
|
||||||
"PurchaseFailed": "Kauf fehlgeschlagen, Inventar voll",
|
"PurchaseFailed": "Kauf fehlgeschlagen, Inventar voll",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Kauf bestätigen",
|
"Confirm": "Kauf bestätigen",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Δεν έχετε αρκετά χρήματα για να αγοράσετε αυτό το αντικείμενο",
|
"NotEnoughMoney": "Δεν έχετε αρκετά χρήματα για να αγοράσετε αυτό το αντικείμενο",
|
||||||
"Input": "Εισαγωγή ποσότητας",
|
"Input": "Εισαγωγή ποσότητας",
|
||||||
"PurchaseAmount": "Ποσότητα αγοράς",
|
"PurchaseAmount": "Ποσότητα αγοράς",
|
||||||
"PurchasedItem": "Αγοράσατε ",
|
"PurchasedItem": "Αγοράσατε %s %s",
|
||||||
"PurchaseFailed": "Η αγορά απέτυχε, το αποθέμα είναι γεμάτο",
|
"PurchaseFailed": "Η αγορά απέτυχε, το αποθέμα είναι γεμάτο",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Επιβεβαίωση αγοράς",
|
"Confirm": "Επιβεβαίωση αγοράς",
|
||||||
|
|||||||
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Ye don't have enough booty to plunder this here item",
|
"NotEnoughMoney": "Ye don't have enough booty to plunder this here item",
|
||||||
"Input": "Amount o' Booty",
|
"Input": "Amount o' Booty",
|
||||||
"PurchaseAmount": "Plunder Quantity",
|
"PurchaseAmount": "Plunder Quantity",
|
||||||
"PurchasedItem": "Ye Have Plundered ",
|
"PurchasedItem": "Ye Have Plundered %s %s",
|
||||||
"PurchaseFailed": "Plunder failed, yer hold be full",
|
"PurchaseFailed": "Plunder failed, yer hold be full",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Aye, Plunder!",
|
"Confirm": "Aye, Plunder!",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "You don't have enough money to buy this item",
|
"NotEnoughMoney": "You don't have enough money to buy this item",
|
||||||
"Input": "Amount Input",
|
"Input": "Amount Input",
|
||||||
"PurchaseAmount": "Purchase Quantity",
|
"PurchaseAmount": "Purchase Quantity",
|
||||||
"PurchasedItem": "You Have Purchased ",
|
"PurchasedItem": "You Have Purchased %s %s",
|
||||||
"PurchaseFailed": "Purchase failed, inventory full",
|
"PurchaseFailed": "Purchase failed, inventory full",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Confirm Purchase",
|
"Confirm": "Confirm Purchase",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "No tienes suficiente dinero para comprar este artículo",
|
"NotEnoughMoney": "No tienes suficiente dinero para comprar este artículo",
|
||||||
"Input": "Entrada de cantidad",
|
"Input": "Entrada de cantidad",
|
||||||
"PurchaseAmount": "Cantidad de compra",
|
"PurchaseAmount": "Cantidad de compra",
|
||||||
"PurchasedItem": "Has comprado ",
|
"PurchasedItem": "Has comprado %s %s",
|
||||||
"PurchaseFailed": "Compra fallida, inventario lleno",
|
"PurchaseFailed": "Compra fallida, inventario lleno",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Confirmar compra",
|
"Confirm": "Confirmar compra",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Sinulla ei ole tarpeeksi rahaa ostaaksesi tätä tuotetta",
|
"NotEnoughMoney": "Sinulla ei ole tarpeeksi rahaa ostaaksesi tätä tuotetta",
|
||||||
"Input": "Määrän syöttö",
|
"Input": "Määrän syöttö",
|
||||||
"PurchaseAmount": "Ostomäärä",
|
"PurchaseAmount": "Ostomäärä",
|
||||||
"PurchasedItem": "Olet ostanut ",
|
"PurchasedItem": "Olet ostanut %s %s",
|
||||||
"PurchaseFailed": "Osto epäonnistui, varasto täynnä",
|
"PurchaseFailed": "Osto epäonnistui, varasto täynnä",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Vahvista osto",
|
"Confirm": "Vahvista osto",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Vous n'avez pas assez d'argent pour acheter cet article",
|
"NotEnoughMoney": "Vous n'avez pas assez d'argent pour acheter cet article",
|
||||||
"Input": "Saisie de quantité",
|
"Input": "Saisie de quantité",
|
||||||
"PurchaseAmount": "Quantité d'achat",
|
"PurchaseAmount": "Quantité d'achat",
|
||||||
"PurchasedItem": "Vous avez acheté ",
|
"PurchasedItem": "Vous avez acheté %s %s",
|
||||||
"PurchaseFailed": "Achat échoué, inventaire plein",
|
"PurchaseFailed": "Achat échoué, inventaire plein",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Confirmer l'achat",
|
"Confirm": "Confirmer l'achat",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "इस वस्तु को खरीदने के लिए आपके पास पर्याप्त पैसे नहीं हैं",
|
"NotEnoughMoney": "इस वस्तु को खरीदने के लिए आपके पास पर्याप्त पैसे नहीं हैं",
|
||||||
"Input": "मात्रा इनपुट",
|
"Input": "मात्रा इनपुट",
|
||||||
"PurchaseAmount": "खरीदारी की मात्रा",
|
"PurchaseAmount": "खरीदारी की मात्रा",
|
||||||
"PurchasedItem": "आपने खरीदा है ",
|
"PurchasedItem": "आपने खरीदा है %s %s",
|
||||||
"PurchaseFailed": "खरीदारी विफल, इन्वेंटरी भरी हुई है",
|
"PurchaseFailed": "खरीदारी विफल, इन्वेंटरी भरी हुई है",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "खरीदारी की पुष्टि करें",
|
"Confirm": "खरीदारी की पुष्टि करें",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Nemate dovoljno novca za kupnju ovog predmeta",
|
"NotEnoughMoney": "Nemate dovoljno novca za kupnju ovog predmeta",
|
||||||
"Input": "Unos količine",
|
"Input": "Unos količine",
|
||||||
"PurchaseAmount": "Količina kupnje",
|
"PurchaseAmount": "Količina kupnje",
|
||||||
"PurchasedItem": "Kupili ste ",
|
"PurchasedItem": "Kupili ste %s %s",
|
||||||
"PurchaseFailed": "Kupnja nije uspjela, inventar pun",
|
"PurchaseFailed": "Kupnja nije uspjela, inventar pun",
|
||||||
"CurrencySymbol": "%s kn",
|
"CurrencySymbol": "%s kn",
|
||||||
"Confirm": "Potvrdi kupnju",
|
"Confirm": "Potvrdi kupnju",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Nincs elég pénzed ennek a tételnek a megvásárlásához",
|
"NotEnoughMoney": "Nincs elég pénzed ennek a tételnek a megvásárlásához",
|
||||||
"Input": "Mennyiség bevitel",
|
"Input": "Mennyiség bevitel",
|
||||||
"PurchaseAmount": "Vásárlási mennyiség",
|
"PurchaseAmount": "Vásárlási mennyiség",
|
||||||
"PurchasedItem": "Megvásároltad ",
|
"PurchasedItem": "Megvásároltad %s %s",
|
||||||
"PurchaseFailed": "Vásárlás sikertelen, leltár tele",
|
"PurchaseFailed": "Vásárlás sikertelen, leltár tele",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Vásárlás megerősítése",
|
"Confirm": "Vásárlás megerősítése",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Non hai abbastanza denaro per comprare questo articolo",
|
"NotEnoughMoney": "Non hai abbastanza denaro per comprare questo articolo",
|
||||||
"Input": "Inserimento quantità",
|
"Input": "Inserimento quantità",
|
||||||
"PurchaseAmount": "Quantità di acquisto",
|
"PurchaseAmount": "Quantità di acquisto",
|
||||||
"PurchasedItem": "Hai acquistato ",
|
"PurchasedItem": "Hai acquistato %s %s",
|
||||||
"PurchaseFailed": "Acquisto fallito, inventario pieno",
|
"PurchaseFailed": "Acquisto fallito, inventario pieno",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Conferma acquisto",
|
"Confirm": "Conferma acquisto",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "このアイテムを購入するのに十分なお金がありません",
|
"NotEnoughMoney": "このアイテムを購入するのに十分なお金がありません",
|
||||||
"Input": "数量入力",
|
"Input": "数量入力",
|
||||||
"PurchaseAmount": "購入数量",
|
"PurchaseAmount": "購入数量",
|
||||||
"PurchasedItem": "購入しました ",
|
"PurchasedItem": "購入しました %s %s",
|
||||||
"PurchaseFailed": "購入に失敗しました、インベントリがいっぱいです",
|
"PurchaseFailed": "購入に失敗しました、インベントリがいっぱいです",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "購入を確認",
|
"Confirm": "購入を確認",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "이 아이템을 구매할 돈이 부족합니다",
|
"NotEnoughMoney": "이 아이템을 구매할 돈이 부족합니다",
|
||||||
"Input": "수량 입력",
|
"Input": "수량 입력",
|
||||||
"PurchaseAmount": "구매 수량",
|
"PurchaseAmount": "구매 수량",
|
||||||
"PurchasedItem": "구매했습니다 ",
|
"PurchasedItem": "구매했습니다 %s %s",
|
||||||
"PurchaseFailed": "구매 실패, 인벤토리가 가득 찼습니다",
|
"PurchaseFailed": "구매 실패, 인벤토리가 가득 찼습니다",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "구매 확인",
|
"Confirm": "구매 확인",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Neturite pakankamai pinigų šiam daiktui nusipirkti",
|
"NotEnoughMoney": "Neturite pakankamai pinigų šiam daiktui nusipirkti",
|
||||||
"Input": "Kiekio įvestis",
|
"Input": "Kiekio įvestis",
|
||||||
"PurchaseAmount": "Pirkimo kiekis",
|
"PurchaseAmount": "Pirkimo kiekis",
|
||||||
"PurchasedItem": "Jūs nusipirkote ",
|
"PurchasedItem": "Jūs nusipirkote %s %s",
|
||||||
"PurchaseFailed": "Pirkimas nepavyko, inventorius pilnas",
|
"PurchaseFailed": "Pirkimas nepavyko, inventorius pilnas",
|
||||||
"CurrencySymbol": "%s €",
|
"CurrencySymbol": "%s €",
|
||||||
"Confirm": "Patvirtinti pirkimą",
|
"Confirm": "Patvirtinti pirkimą",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Je hebt niet genoeg geld om dit item te kopen",
|
"NotEnoughMoney": "Je hebt niet genoeg geld om dit item te kopen",
|
||||||
"Input": "Hoeveelheid invoer",
|
"Input": "Hoeveelheid invoer",
|
||||||
"PurchaseAmount": "Aankoop hoeveelheid",
|
"PurchaseAmount": "Aankoop hoeveelheid",
|
||||||
"PurchasedItem": "Je hebt gekocht ",
|
"PurchasedItem": "Je hebt gekocht %s %s",
|
||||||
"PurchaseFailed": "Aankoop mislukt, inventaris vol",
|
"PurchaseFailed": "Aankoop mislukt, inventaris vol",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Aankoop bevestigen",
|
"Confirm": "Aankoop bevestigen",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Du har ikke nok penger til å kjøpe denne varen",
|
"NotEnoughMoney": "Du har ikke nok penger til å kjøpe denne varen",
|
||||||
"Input": "Mengde inndata",
|
"Input": "Mengde inndata",
|
||||||
"PurchaseAmount": "Kjøpsmengde",
|
"PurchaseAmount": "Kjøpsmengde",
|
||||||
"PurchasedItem": "Du har kjøpt ",
|
"PurchasedItem": "Du har kjøpt %s %s",
|
||||||
"PurchaseFailed": "Kjøp mislyktes, inventar fullt",
|
"PurchaseFailed": "Kjøp mislyktes, inventar fullt",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Bekreft kjøp",
|
"Confirm": "Bekreft kjøp",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Nie masz wystarczająco pieniędzy, aby kupić ten przedmiot",
|
"NotEnoughMoney": "Nie masz wystarczająco pieniędzy, aby kupić ten przedmiot",
|
||||||
"Input": "Wprowadzanie ilości",
|
"Input": "Wprowadzanie ilości",
|
||||||
"PurchaseAmount": "Ilość zakupu",
|
"PurchaseAmount": "Ilość zakupu",
|
||||||
"PurchasedItem": "Kupiłeś ",
|
"PurchasedItem": "Kupiłeś %s %s",
|
||||||
"PurchaseFailed": "Zakup nieudany, ekwipunek pełny",
|
"PurchaseFailed": "Zakup nieudany, ekwipunek pełny",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Potwierdź zakup",
|
"Confirm": "Potwierdź zakup",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Você não tem dinheiro suficiente para comprar este item",
|
"NotEnoughMoney": "Você não tem dinheiro suficiente para comprar este item",
|
||||||
"Input": "Entrada de quantidade",
|
"Input": "Entrada de quantidade",
|
||||||
"PurchaseAmount": "Quantidade de compra",
|
"PurchaseAmount": "Quantidade de compra",
|
||||||
"PurchasedItem": "Você comprou ",
|
"PurchasedItem": "Você comprou %s %s",
|
||||||
"PurchaseFailed": "Compra falhou, inventário cheio",
|
"PurchaseFailed": "Compra falhou, inventário cheio",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Confirmar compra",
|
"Confirm": "Confirmar compra",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Nu ai destui bani să cumperi acest articol",
|
"NotEnoughMoney": "Nu ai destui bani să cumperi acest articol",
|
||||||
"Input": "Introducere cantitate",
|
"Input": "Introducere cantitate",
|
||||||
"PurchaseAmount": "Cantitate de cumpărare",
|
"PurchaseAmount": "Cantitate de cumpărare",
|
||||||
"PurchasedItem": "Ai cumpărat ",
|
"PurchasedItem": "Ai cumpărat %s %s",
|
||||||
"PurchaseFailed": "Achiziție eșuată, inventar plin",
|
"PurchaseFailed": "Achiziție eșuată, inventar plin",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Confirmă cumpărarea",
|
"Confirm": "Confirmă cumpărarea",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "У вас недостаточно денег для покупки этого предмета",
|
"NotEnoughMoney": "У вас недостаточно денег для покупки этого предмета",
|
||||||
"Input": "Ввод количества",
|
"Input": "Ввод количества",
|
||||||
"PurchaseAmount": "Количество покупки",
|
"PurchaseAmount": "Количество покупки",
|
||||||
"PurchasedItem": "Вы купили ",
|
"PurchasedItem": "Вы купили %s %s",
|
||||||
"PurchaseFailed": "Покупка не удалась, инвентарь полон",
|
"PurchaseFailed": "Покупка не удалась, инвентарь полон",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Подтвердить покупку",
|
"Confirm": "Подтвердить покупку",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Du har inte tillräckligt med pengar för att köpa denna vara",
|
"NotEnoughMoney": "Du har inte tillräckligt med pengar för att köpa denna vara",
|
||||||
"Input": "Mängd inmatning",
|
"Input": "Mängd inmatning",
|
||||||
"PurchaseAmount": "Inköpsmängd",
|
"PurchaseAmount": "Inköpsmängd",
|
||||||
"PurchasedItem": "Du har köpt ",
|
"PurchasedItem": "Du har köpt %s %s",
|
||||||
"PurchaseFailed": "Köp misslyckades, inventarium fullt",
|
"PurchaseFailed": "Köp misslyckades, inventarium fullt",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Bekräfta köp",
|
"Confirm": "Bekräfta köp",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "คุณไม่มีเงินเพียงพอที่จะซื้อสิ่งนี้",
|
"NotEnoughMoney": "คุณไม่มีเงินเพียงพอที่จะซื้อสิ่งนี้",
|
||||||
"Input": "ป้อนจำนวน",
|
"Input": "ป้อนจำนวน",
|
||||||
"PurchaseAmount": "จำนวนที่ซื้อ",
|
"PurchaseAmount": "จำนวนที่ซื้อ",
|
||||||
"PurchasedItem": "คุณได้ซื้อ ",
|
"PurchasedItem": "คุณได้ซื้อ %s %s",
|
||||||
"PurchaseFailed": "การซื้อล้มเหลว คลังเต็ม",
|
"PurchaseFailed": "การซื้อล้มเหลว คลังเต็ม",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "ยืนยันการซื้อ",
|
"Confirm": "ยืนยันการซื้อ",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "Bu öğeyi satın almak için yeterli paranız yok",
|
"NotEnoughMoney": "Bu öğeyi satın almak için yeterli paranız yok",
|
||||||
"Input": "Miktar girişi",
|
"Input": "Miktar girişi",
|
||||||
"PurchaseAmount": "Satın alma miktarı",
|
"PurchaseAmount": "Satın alma miktarı",
|
||||||
"PurchasedItem": "Satın aldınız ",
|
"PurchasedItem": "Satın aldınız %s %s",
|
||||||
"PurchaseFailed": "Satın alma başarısız, envanter dolu",
|
"PurchaseFailed": "Satın alma başarısız, envanter dolu",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "Satın almayı onayla",
|
"Confirm": "Satın almayı onayla",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "您没有足够的钱购买此物品",
|
"NotEnoughMoney": "您没有足够的钱购买此物品",
|
||||||
"Input": "数量输入",
|
"Input": "数量输入",
|
||||||
"PurchaseAmount": "购买数量",
|
"PurchaseAmount": "购买数量",
|
||||||
"PurchasedItem": "您已购买 ",
|
"PurchasedItem": "您已购买 %s %s",
|
||||||
"PurchaseFailed": "购买失败,库存已满",
|
"PurchaseFailed": "购买失败,库存已满",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "确认购买",
|
"Confirm": "确认购买",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "您沒有足夠的錢購買此物品",
|
"NotEnoughMoney": "您沒有足夠的錢購買此物品",
|
||||||
"Input": "數量輸入",
|
"Input": "數量輸入",
|
||||||
"PurchaseAmount": "購買數量",
|
"PurchaseAmount": "購買數量",
|
||||||
"PurchasedItem": "您已購買 ",
|
"PurchasedItem": "你已購買 %s %s",
|
||||||
"PurchaseFailed": "購買失敗,庫存已滿",
|
"PurchaseFailed": "購買失敗,庫存已滿",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "確認購買",
|
"Confirm": "確認購買",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "您沒有足夠的錢購買此物品",
|
"NotEnoughMoney": "您沒有足夠的錢購買此物品",
|
||||||
"Input": "數量輸入",
|
"Input": "數量輸入",
|
||||||
"PurchaseAmount": "購買數量",
|
"PurchaseAmount": "購買數量",
|
||||||
"PurchasedItem": "您已購買 ",
|
"PurchasedItem": "你已購買 %s %s",
|
||||||
"PurchaseFailed": "購買失敗,庫存已滿",
|
"PurchaseFailed": "購買失敗,庫存已滿",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "確認購買",
|
"Confirm": "確認購買",
|
||||||
|
|||||||
+1
-1
@@ -3,7 +3,7 @@
|
|||||||
"NotEnoughMoney": "您没有足够的钱购买此物品",
|
"NotEnoughMoney": "您没有足够的钱购买此物品",
|
||||||
"Input": "数量输入",
|
"Input": "数量输入",
|
||||||
"PurchaseAmount": "购买数量",
|
"PurchaseAmount": "购买数量",
|
||||||
"PurchasedItem": "您已购买 ",
|
"PurchasedItem": "您已购买 %s %s",
|
||||||
"PurchaseFailed": "购买失败,库存已满",
|
"PurchaseFailed": "购买失败,库存已满",
|
||||||
"CurrencySymbol": "$ %s",
|
"CurrencySymbol": "$ %s",
|
||||||
"Confirm": "确认购买",
|
"Confirm": "确认购买",
|
||||||
|
|||||||
@@ -1,33 +1,34 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
Clothing = Clothing or {}
|
Clothing = Clothing or {}
|
||||||
|
|
||||||
ClothingBackup = {}
|
|
||||||
Callback = Callback or Require("lib/callback/shared/callback.lua")
|
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.
|
---This will get the name of the in use resource.
|
||||||
---@return string
|
---@return string
|
||||||
Clothing.GetResourceName = function()
|
function Clothing.GetResourceName()
|
||||||
return 'default'
|
return 'default'
|
||||||
end
|
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
|
---Get the skin data of a ped
|
||||||
---@param entity number
|
---@param entity number
|
||||||
---@return table
|
---@return table
|
||||||
function Clothing.GetAppearance(entity)
|
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 model = GetEntityModel(entity)
|
||||||
local skinData = { model = model, components = {}, props = {} }
|
local skinData = { model = model, components = {}, props = {} }
|
||||||
for i = 0, 11 do
|
for i = 0, 11 do
|
||||||
@@ -38,17 +39,10 @@ function Clothing.GetAppearance(entity)
|
|||||||
table.insert(skinData.props,
|
table.insert(skinData.props,
|
||||||
{ prop_id = i, drawable = GetPedPropIndex(entity, i), texture = GetPedPropTextureIndex(entity, i) })
|
{ prop_id = i, drawable = GetPedPropIndex(entity, i), texture = GetPedPropTextureIndex(entity, i) })
|
||||||
end
|
end
|
||||||
|
ClothingBackup = skinData
|
||||||
return skinData
|
return skinData
|
||||||
end
|
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()
|
Callback.Register('community_bridge:cb:GetAppearance', function()
|
||||||
local ped = PlayerPedId()
|
local ped = PlayerPedId()
|
||||||
if not ped or not DoesEntityExist(ped) then return end
|
if not ped or not DoesEntityExist(ped) then return end
|
||||||
@@ -57,101 +51,45 @@ Callback.Register('community_bridge:cb:GetAppearance', function()
|
|||||||
end)
|
end)
|
||||||
|
|
||||||
---Apply skin data to a ped
|
---Apply skin data to a ped
|
||||||
---@param entity number
|
---@param ped number
|
||||||
---@param skinData table
|
---@param skinData table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Clothing.SetAppearance(entity, skinData)
|
function Clothing.SetAppearance(ped, skinData)
|
||||||
for k, v in pairs(skinData.components or {}) do
|
for k, v in pairs(skinData.components or {}) do
|
||||||
if v.component_id then
|
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
|
||||||
end
|
end
|
||||||
for k, v in pairs(skinData.props or {}) do
|
for k, v in pairs(skinData.props or {}) do
|
||||||
if v.prop_id then
|
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
|
||||||
end
|
end
|
||||||
|
ClothingBackup = nil
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return the peds components to the previously stored components
|
---This will return the peds components to the previously stored components
|
||||||
|
---@param ped number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Clothing.RestoreAppearance = function(entity)
|
Clothing.RestoreAppearance = function(ped)
|
||||||
Clothing.SetAppearance(entity, ClothingBackup)
|
Clothing.SetAppearance(ped, ClothingBackup)
|
||||||
return true
|
return true
|
||||||
end
|
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)
|
RegisterNetEvent('community_bridge:client:SetAppearance', function(data)
|
||||||
|
if source ~= 65535 then return end
|
||||||
Clothing.SetAppearance(PlayerPedId(), data)
|
Clothing.SetAppearance(PlayerPedId(), data)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('community_bridge:client:GetAppearance', function()
|
RegisterNetEvent('community_bridge:client:GetAppearance', function()
|
||||||
|
if source ~= 65535 then return end
|
||||||
Clothing.GetAppearance(PlayerPedId())
|
Clothing.GetAppearance(PlayerPedId())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
RegisterNetEvent('community_bridge:client:RestoreAppearance', function()
|
RegisterNetEvent('community_bridge:client:RestoreAppearance', function()
|
||||||
|
if source ~= 65535 then return end
|
||||||
Clothing.RestoreAppearance(PlayerPedId())
|
Clothing.RestoreAppearance(PlayerPedId())
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- RegisterCommand("clothing:enabledebug", function(source, args, rawCommand)
|
return Clothing
|
||||||
-- Clothing.ToggleDebugging()
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
-- RegisterCommand("clothing:copy", function(source, args, rawCommand)
|
|
||||||
-- Clothing.CopyAppearanceToClipboard()
|
|
||||||
-- end)
|
|
||||||
|
|
||||||
|
|
||||||
return Clothing
|
|
||||||
@@ -3,23 +3,32 @@ Clothing = Clothing or {}
|
|||||||
Clothing.LastAppearance = Clothing.LastAppearance or {}
|
Clothing.LastAppearance = Clothing.LastAppearance or {}
|
||||||
Callback = Callback or Require("lib/callback/shared/callback.lua")
|
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.
|
---This will get the name of the in use resource.
|
||||||
---@return string
|
---@return string
|
||||||
Clothing.GetResourceName = function()
|
Clothing.GetResourceName = function()
|
||||||
return 'default'
|
return 'default'
|
||||||
end
|
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)
|
function Clothing.GetAppearance(src)
|
||||||
return Callback.Trigger('community_bridge:cb:GetAppearance', src)
|
return Callback.Trigger('community_bridge:cb:GetAppearance', src)
|
||||||
end
|
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)
|
local strSrc = tostring(src)
|
||||||
Clothing.LastAppearance[strSrc] = Clothing.GetAppearance(src)
|
Clothing.LastAppearance[strSrc] = Clothing.GetAppearance(src)
|
||||||
TriggerClientEvent('community_bridge:client:SetAppearance', src, data)
|
TriggerClientEvent('community_bridge:client:SetAppearance', src, data)
|
||||||
@@ -34,29 +43,10 @@ function Clothing.SetAppearanceExt(src, data)
|
|||||||
Clothing.SetAppearance(src, tbl)
|
Clothing.SetAppearance(src, tbl)
|
||||||
end
|
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)
|
TriggerClientEvent('community_bridge:client:RestoreAppearance', src)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
return Clothing
|
||||||
-- 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
|
|
||||||
@@ -146,6 +146,13 @@ function Clothing.OpenMenu(src)
|
|||||||
TriggerClientEvent('esx_skin:openMenu', src)
|
TriggerClientEvent('esx_skin:openMenu', src)
|
||||||
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)
|
||||||
|
|
||||||
|
|
||||||
---Event handler for when a player loads into the server
|
---Event handler for when a player loads into the server
|
||||||
---Caches the player's appearance data
|
---Caches the player's appearance data
|
||||||
AddEventHandler('community_bridge:Server:OnPlayerLoaded', function(src)
|
AddEventHandler('community_bridge:Server:OnPlayerLoaded', function(src)
|
||||||
@@ -175,10 +182,4 @@ AddEventHandler('onResourceStart', function(resource)
|
|||||||
Clothing.Players[strSrc] = Clothing.GetAppearance(src)
|
Clothing.Players[strSrc] = Clothing.GetAppearance(src)
|
||||||
end
|
end
|
||||||
end
|
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)
|
|
||||||
@@ -1,11 +1,8 @@
|
|||||||
--[[This module is incomplete]]--
|
Dialogue = {}
|
||||||
|
|
||||||
|
|
||||||
local promises = {}
|
local promises = {}
|
||||||
local activeDialogue = nil
|
local activeDialogue = nil
|
||||||
local pendingCameraDestroy = false
|
local pendingCameraDestroy = false
|
||||||
Dialogue = {}
|
|
||||||
|
|
||||||
local cam = nil
|
local cam = nil
|
||||||
local npc = nil
|
local npc = nil
|
||||||
|
|
||||||
@@ -25,7 +22,7 @@ function Dialogue.Close(name)
|
|||||||
Wait(200) -- Small delay to allow new dialogue to open
|
Wait(200) -- Small delay to allow new dialogue to open
|
||||||
if pendingCameraDestroy and not activeDialogue then
|
if pendingCameraDestroy and not activeDialogue then
|
||||||
-- No new dialogue opened, safe to destroy camera
|
-- No new dialogue opened, safe to destroy camera
|
||||||
RenderScriptCams(false, 1, 1000, 1, 0)
|
RenderScriptCams(false, true, 1000, true, false)
|
||||||
SetCamActive(cam, false)
|
SetCamActive(cam, false)
|
||||||
DestroyCam(cam, false)
|
DestroyCam(cam, false)
|
||||||
cam = nil
|
cam = nil
|
||||||
@@ -38,7 +35,10 @@ end
|
|||||||
--- Open a dialogue with the player
|
--- Open a dialogue with the player
|
||||||
---@param name string
|
---@param name string
|
||||||
---@param dialogue 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)
|
function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSelected)
|
||||||
assert(name, "Name is required")
|
assert(name, "Name is required")
|
||||||
assert(dialogue, "Dialogue is required")
|
assert(dialogue, "Dialogue is required")
|
||||||
@@ -53,14 +53,12 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
|
|||||||
pendingCameraDestroy = false
|
pendingCameraDestroy = false
|
||||||
activeDialogue = name
|
activeDialogue = name
|
||||||
|
|
||||||
-- camera magic!
|
|
||||||
if entity then
|
if entity then
|
||||||
Wait(500)
|
Wait(500)
|
||||||
local endLocation = GetOffsetFromEntityInWorldCoords(entity, offset.x, offset.y + 2.0, offset.z)
|
local endLocation = GetOffsetFromEntityInWorldCoords(entity, offset.x, offset.y + 2.0, offset.z)
|
||||||
local pedHeading = GetEntityHeading(entity)
|
local pedHeading = GetEntityHeading(entity) -- Get position in front of ped based on their heading
|
||||||
-- 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
|
local camAngle = (pedHeading + 180.0) % 360.0
|
||||||
SetCamRot(cam, rotationOffset.x, rotationOffset.y, camAngle + rotationOffset.z, 2)
|
SetCamRot(cam, rotationOffset.x, rotationOffset.y, camAngle + rotationOffset.z, 2)
|
||||||
SetCamCoord(cam, endLocation.x, endLocation.y, endLocation.z)
|
SetCamCoord(cam, endLocation.x, endLocation.y, endLocation.z)
|
||||||
@@ -75,7 +73,6 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
|
|||||||
})
|
})
|
||||||
SetNuiFocus(true, true)
|
SetNuiFocus(true, true)
|
||||||
|
|
||||||
|
|
||||||
local prom = promise.new()
|
local prom = promise.new()
|
||||||
local wrappedFunction = function(selected)
|
local wrappedFunction = function(selected)
|
||||||
SetNuiFocus(false, false)
|
SetNuiFocus(false, false)
|
||||||
@@ -87,7 +84,6 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
|
|||||||
return Citizen.Await(prom)
|
return Citizen.Await(prom)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
RegisterNuiCallback("dialogue:SelectOption", function(data)
|
RegisterNuiCallback("dialogue:SelectOption", function(data)
|
||||||
local promis = promises[data.name]
|
local promis = promises[data.name]
|
||||||
if not promis then return end
|
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).
|
---@description This will get the name of the framework being used (if a supported framework).
|
||||||
---@return string
|
---@return string
|
||||||
Framework.GetFrameworkName = function()
|
Framework.GetFrameworkName = function()
|
||||||
print("This is depricated, please use Framework.GetResourceName() instead.")
|
--print("This is depricated, please use Framework.GetResourceName() instead.")
|
||||||
return Framework.GetResourceName()
|
return Framework.GetResourceName()
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -108,7 +108,7 @@ end
|
|||||||
---@return string
|
---@return string
|
||||||
---@return string
|
---@return string
|
||||||
Framework.GetPlayerJob = function()
|
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()
|
local jobData = Framework.GetPlayerJobData()
|
||||||
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ local cachedItemList = nil
|
|||||||
--- @description This will return the name of the framework in use
|
--- @description This will return the name of the framework in use
|
||||||
--- @return string
|
--- @return string
|
||||||
Framework.GetFrameworkName = function()
|
Framework.GetFrameworkName = function()
|
||||||
print("This is deprecated, please use Framework.GetResourceName() instead.")
|
--print("This is deprecated, please use Framework.GetResourceName() instead.")
|
||||||
return Framework.GetResourceName()
|
return Framework.GetResourceName()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ end
|
|||||||
---@return string
|
---@return string
|
||||||
---@return string
|
---@return string
|
||||||
Framework.GetPlayerJob = function()
|
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()
|
local jobData = Framework.GetPlayerJobData()
|
||||||
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -372,7 +372,7 @@ end
|
|||||||
---@return string | string | string | number | nil
|
---@return string | string | string | number | nil
|
||||||
---@return string | string | string | number | nil
|
---@return string | string | string | number | nil
|
||||||
Framework.GetPlayerJob = function(src)
|
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)
|
local jobData = Framework.GetPlayerJobData(src)
|
||||||
if not jobData then return end
|
if not jobData then return end
|
||||||
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeLevel
|
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeLevel
|
||||||
|
|||||||
@@ -107,7 +107,7 @@ end
|
|||||||
---@return string
|
---@return string
|
||||||
---@return string
|
---@return string
|
||||||
Framework.GetPlayerJob = function()
|
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()
|
local jobData = Framework.GetPlayerJobData()
|
||||||
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
return jobData.jobName, jobData.jobLabel, jobData.gradeName, jobData.gradeRank
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -357,7 +357,7 @@ Framework.GetPlayerJob = function(src)
|
|||||||
local player = Framework.GetPlayer(src)
|
local player = Framework.GetPlayer(src)
|
||||||
if not player then return end
|
if not player then return end
|
||||||
local playerData = player.PlayerData
|
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
|
return playerData.job.name, playerData.job.label, playerData.job.grade.name, playerData.job.grade.level
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -5,6 +5,8 @@ Notify.GetResourceName = function()
|
|||||||
return "default"
|
return "default"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification
|
---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification
|
||||||
---12/13/25
|
---12/13/25
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -12,7 +14,8 @@ end
|
|||||||
---@param time number
|
---@param time number
|
||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotify = function(message, _type, time)
|
Notify.SendNotify = function(message, _type, time)
|
||||||
return Notify.SendNotification(nil, message, _type, time)
|
time = time or 3000
|
||||||
|
return Framework.Notify(message, nil, time)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will send a notify message of the type and time passed
|
---This will send a notify message of the type and time passed
|
||||||
|
|||||||
@@ -5,6 +5,10 @@ Notify.GetResourceName = function()
|
|||||||
return "default"
|
return "default"
|
||||||
end
|
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
|
---DEPRICATED: PLEASE SWITCH TO Notify.SendNotification
|
||||||
---12/13/25
|
---12/13/25
|
||||||
---@param src number
|
---@param src number
|
||||||
@@ -27,7 +31,7 @@ end
|
|||||||
Notify.SendNotification = function(src, title, message, _type, time, props)
|
Notify.SendNotification = function(src, title, message, _type, time, props)
|
||||||
time = time or 3000
|
time = time or 3000
|
||||||
if not title then
|
if not title then
|
||||||
title = Bridge.Language.Locale("Notifications.PlaceholderTitle")
|
title = placeHolderText
|
||||||
end
|
end
|
||||||
TriggerClientEvent('community_bridge:Client:Notify', src, title, message, _type, time, props)
|
TriggerClientEvent('community_bridge:Client:Notify', src, title, message, _type, time, props)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -9,6 +9,15 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -18,7 +27,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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)
|
return exports['brutal_notify']:SendAlert(title, message, time, _type or "success", false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,25 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -17,7 +36,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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
|
if _type == "error" or _type == "info" then
|
||||||
_type = tostring(1)
|
_type = tostring(1)
|
||||||
elseif _type == "success" then
|
elseif _type == "success" then
|
||||||
|
|||||||
@@ -9,6 +9,16 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -18,7 +28,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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' })
|
return exports.lation_ui:notify({ title = title, message = message, type = _type or "success", duration = time, position = 'top-right' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,17 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -17,7 +28,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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"
|
_type = _type or "inform"
|
||||||
return exports['mythic_notify']:SendAlert(_type, message, time)
|
return exports['mythic_notify']:SendAlert(_type, message, time)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -17,7 +27,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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)
|
return exports['okokNotify']:Alert(title, message, time, _type or "Success", false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -17,7 +27,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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' })
|
return exports.ox_lib:notify({ title = title, description = message, type = _type or "success", duration = time, position = 'top-right' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -17,7 +27,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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' })
|
return exports['pNotify']:SendNotification({ title = title, text = message, type = _type or "success", timeout = time, layout = 'centerRight' })
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,15 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -17,7 +26,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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})
|
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
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -17,7 +27,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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"
|
_type = _type or "info"
|
||||||
return exports['t-notify']:Alert({ title = title, style = _type, message = message, duration = time, })
|
return exports['t-notify']:Alert({ title = title, style = _type, message = message, duration = time, })
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -8,6 +8,16 @@ Notify.GetResourceName = function()
|
|||||||
return resourceName
|
return resourceName
|
||||||
end
|
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
|
---This will send a notify message of the type and time passed
|
||||||
---@param title string
|
---@param title string
|
||||||
---@param message string
|
---@param message string
|
||||||
@@ -17,7 +27,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotification = function(title, message, _type, time, props)
|
Notify.SendNotification = function(title, message, _type, time, props)
|
||||||
time = time or 3000
|
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"
|
_type = _type or "info"
|
||||||
return exports.wasabi_notify:notify(_type, message, time, _type)
|
return exports.wasabi_notify:notify(_type, message, time, _type)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ Shops = Shops or {}
|
|||||||
local registeredShops = {}
|
local registeredShops = {}
|
||||||
|
|
||||||
local Language = Language or Require("modules/locales/shared.lua")
|
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
|
---This can open a shop for the client
|
||||||
---@param src number
|
---@param src number
|
||||||
@@ -51,23 +51,23 @@ Shops.CompleteCheckout = function(src, shopName, item, amount, account)
|
|||||||
end
|
end
|
||||||
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 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 totalCost = tonumber(itemData.price) * amount
|
||||||
local balance = Framework.GetAccountBalance(src, account)
|
local balance = Framework.GetAccountBalance(src, account)
|
||||||
if not balance then return end
|
if not balance then return end
|
||||||
if balance <= 0 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, locales('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
|
if not Framework.RemoveAccountBalance(src, account, totalCost) then return end
|
||||||
|
|
||||||
local success = Inventory.AddItem(src, itemData.name, amount)
|
local success = Inventory.AddItem(src, itemData.name, amount)
|
||||||
if not success then
|
if not success then
|
||||||
Framework.AddAccountBalance(src, account, totalCost)
|
Framework.AddAccountBalance(src, account, totalCost)
|
||||||
return Notify.SendNotify(src, locales('Shops.PurchaseFailed'), "error", 5000)
|
return Notify.SendNotify(src, locale('Shops.PurchaseFailed'), "error", 5000)
|
||||||
end
|
end
|
||||||
|
|
||||||
local itemLabel = Inventory.GetItemInfo(itemData.name).label or itemData.name
|
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
|
end
|
||||||
|
|
||||||
---This is an internal event to complete a checkout, complete with multiple validations. Please do not use this event directly.
|
---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
|
---@diagnostic disable: duplicate-set-field
|
||||||
Skills = Skills or {}
|
Skills = Skills or {}
|
||||||
|
|
||||||
XP_CACHE = {}
|
local cachedXp = {}
|
||||||
|
|
||||||
-- Calculate XP required for a level using RuneScape algorithm (with caching)
|
function Skills.GetResourceName()
|
||||||
Skills.GetXPForLevel = function(level)
|
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 not level or level < 1 then return 0 end
|
||||||
if level == 1 then return 0 end -- Level 1 requires 0 XP
|
if level == 1 then return 0 end -- Level 1 requires 0 XP
|
||||||
|
|
||||||
-- Check cache first
|
if cachedXp[level] then return cachedXp[level] end
|
||||||
if XP_CACHE[level] then
|
|
||||||
return XP_CACHE[level]
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Calculate and cache
|
|
||||||
local xp = 0
|
local xp = 0
|
||||||
for n = 1, level - 1 do
|
for n = 1, level - 1 do
|
||||||
xp = xp + math.floor(n + 300 * (2 ^ (n / 7)))
|
xp = xp + math.floor(n + 300 * (2 ^ (n / 7)))
|
||||||
end
|
end
|
||||||
local result = math.floor(xp / 4)
|
local result = math.floor(xp / 4)
|
||||||
XP_CACHE[level] = result
|
cachedXp[level] = result
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create a skill (for initialization)
|
---Create a skill (for initialization)
|
||||||
Skills.Create = function(name, maxLevel, baseXP)
|
---@param name string
|
||||||
|
---@param maxLevel number
|
||||||
|
---@param baseXP number
|
||||||
|
---@return table
|
||||||
|
function Skills.Create(name, maxLevel, baseXP)
|
||||||
if not name then return end
|
if not name then return end
|
||||||
Skills.All[name] = { name = name, maxLevel = maxLevel or 99, baseXP = baseXP or 50 }
|
Skills.All[name] = { name = name, maxLevel = maxLevel or 99, baseXP = baseXP or 50 }
|
||||||
return Skills.All[name]
|
return Skills.All[name]
|
||||||
end
|
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))
|
return math.floor(baseXP * (1 + playerLevel * 0.05))
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get XP required to complete the current level
|
-- 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 not level or level < 1 then return 0 end
|
||||||
if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP
|
if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP
|
||||||
return Skills.GetXPForLevel(level)
|
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)
|
---This will get the skill level of the passed skill name. (returns 1 if not found)
|
||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@return number
|
---@return number
|
||||||
Skills.GetSkillLevel = function(skillName)
|
function Skills.GetSkillLevel(skillName)
|
||||||
if not skillName then return 0 end
|
if not skillName then return 0 end
|
||||||
local plyrSkills = Bridge.Framework.GetPlayerMetaData("community_bridge_skills")
|
local plyrSkills = Bridge.Framework.GetPlayerMetaData("community_bridge_skills")
|
||||||
if not plyrSkills or not plyrSkills[skillName] then return 1 end
|
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)
|
---This will get the skill xp of the passed skill name. (returns 1 if not found)
|
||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@return number
|
---@return number
|
||||||
Skills.GetXP = function(skillName)
|
function Skills.GetXP(skillName)
|
||||||
if not skillName then return 0 end
|
if not skillName then return 0 end
|
||||||
local plyrSkills = Bridge.Framework.GetPlayerMetaData("community_bridge_skills")
|
local plyrSkills = Bridge.Framework.GetPlayerMetaData("community_bridge_skills")
|
||||||
if not plyrSkills or not plyrSkills[skillName] then return 1 end
|
if not plyrSkills or not plyrSkills[skillName] then return 1 end
|
||||||
return plyrSkills[skillName].currentXP or 1
|
return plyrSkills[skillName].currentXP or 1
|
||||||
end
|
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
|
return Skills
|
||||||
@@ -3,31 +3,39 @@ Skills = Skills or {}
|
|||||||
Skills.All = Skills.All or {}
|
Skills.All = Skills.All or {}
|
||||||
|
|
||||||
-- XP Cache for performance
|
-- XP Cache for performance
|
||||||
local XP_CACHE = {}
|
local cachedXp = {}
|
||||||
|
|
||||||
-- Default skill object: currentXP (0 to required), level
|
-- 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
|
-- Helper function to get or create a skill object
|
||||||
|
---@param src number
|
||||||
|
---@param skillName string
|
||||||
|
---@return table
|
||||||
local function getOrCreateSkill(src, skillName)
|
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 {}
|
local playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
|
||||||
if not playerSkills[skillName] then
|
if not playerSkills[skillName] then
|
||||||
playerSkills[skillName] = table.clone(DEFAULT_SKILL)
|
playerSkills[skillName] = table.clone(defaultSkills)
|
||||||
end
|
end
|
||||||
|
|
||||||
return playerSkills[skillName]
|
return playerSkills[skillName]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Calculate XP required for a level using RuneScape algorithm (with caching)
|
---Calculate XP required for a level using RuneScape algorithm (with caching)
|
||||||
Skills.GetXPForLevel = function(level)
|
---@param level number
|
||||||
|
---@return number
|
||||||
|
function Skills.GetXPForLevel(level)
|
||||||
if not level or level < 1 then return 0 end
|
if not level or level < 1 then return 0 end
|
||||||
if level == 1 then return 0 end -- Level 1 requires 0 XP
|
if level == 1 then return 0 end -- Level 1 requires 0 XP
|
||||||
|
|
||||||
-- Check cache first
|
-- Check cache first
|
||||||
if XP_CACHE[level] then
|
if cachedXp[level] then
|
||||||
return XP_CACHE[level]
|
return cachedXp[level]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Calculate and cache
|
-- Calculate and cache
|
||||||
@@ -36,30 +44,44 @@ Skills.GetXPForLevel = function(level)
|
|||||||
xp = xp + math.floor(n + 300 * (2 ^ (n / 7)))
|
xp = xp + math.floor(n + 300 * (2 ^ (n / 7)))
|
||||||
end
|
end
|
||||||
local result = math.floor(xp / 4)
|
local result = math.floor(xp / 4)
|
||||||
XP_CACHE[level] = result
|
cachedXp[level] = result
|
||||||
|
|
||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Create a skill (for initialization)
|
-- Create a skill (for initialization)
|
||||||
Skills.Create = function(name, maxLevel, baseXP)
|
---@param name string
|
||||||
if not name then return end
|
---@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 }
|
Skills.All[name] = { name = name, maxLevel = maxLevel or 99, baseXP = baseXP or 50 }
|
||||||
return Skills.All[name]
|
return Skills.All[name]
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Get player's current level
|
-- 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
|
if not src or not skillName then return 1 end
|
||||||
local skill = getOrCreateSkill(src, skillName)
|
local skill = getOrCreateSkill(src, skillName)
|
||||||
return skill.level or 1
|
return skill.level or 1
|
||||||
end
|
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))
|
return math.floor(baseXP * (1 + playerLevel * 0.05))
|
||||||
end
|
end
|
||||||
-- Get current XP (0 to required XP for current level)
|
-- 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
|
if not src or not skillName then return 0 end
|
||||||
local skill = getOrCreateSkill(src, skillName)
|
local skill = getOrCreateSkill(src, skillName)
|
||||||
local currentXP = skill.currentXP or 0
|
local currentXP = skill.currentXP or 0
|
||||||
@@ -67,17 +89,21 @@ Skills.GetXP = function(src, skillName)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Get XP required to complete the current level
|
-- 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 not level or level < 1 then return 0 end
|
||||||
if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP
|
if level == 1 then return 83 end -- Level 1 to 2 requires 83 XP
|
||||||
return Skills.GetXPForLevel(level)
|
return Skills.GetXPForLevel(level)
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Add XP and handle level ups
|
-- Add XP and handle level ups
|
||||||
Skills.AddXP = function(src, skillName, xp)
|
---@param src number
|
||||||
if not src or not skillName then
|
---@param skillName string
|
||||||
return false
|
---@param xp number
|
||||||
end
|
---@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
|
if not xp or xp <= 0 then
|
||||||
xp = Skills.GetScaledXP(50, Skills.GetSkillLevel(src, skillName))
|
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 playerSkills = Framework.GetPlayerMetadata(src, "community_bridge_skills") or {}
|
||||||
local skill = playerSkills[skillName]
|
local skill = playerSkills[skillName]
|
||||||
if not skill then
|
if not skill then
|
||||||
skill = table.clone(DEFAULT_SKILL)
|
skill = table.clone(defaultSkills)
|
||||||
playerSkills[skillName] = skill
|
playerSkills[skillName] = skill
|
||||||
end
|
end
|
||||||
|
|
||||||
local oldLevel = skill.level or 1
|
local oldLevel = skill.level or 1
|
||||||
local currentXP = skill.currentXP or 0
|
local currentXP = skill.currentXP or 0
|
||||||
-- Add XP
|
|
||||||
currentXP = currentXP + xp
|
|
||||||
|
|
||||||
|
currentXP = currentXP + xp
|
||||||
|
|
||||||
local xpNeeded = Skills.GetXPRequiredForLevel(oldLevel + 1)
|
local xpNeeded = Skills.GetXPRequiredForLevel(oldLevel + 1)
|
||||||
if currentXP >= xpNeeded then
|
if currentXP >= xpNeeded then
|
||||||
@@ -112,11 +137,15 @@ Skills.AddXP = function(src, skillName, xp)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Set skill level directly (resets currentXP to 0)
|
-- 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
|
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 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)
|
level = math.min(math.max(1, level), 99)
|
||||||
skill.level = level
|
skill.level = level
|
||||||
@@ -128,11 +157,15 @@ Skills.SetSkillLevel = function(src, skillName, level)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Set current XP directly
|
-- 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
|
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 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
|
skill.currentXP = xp
|
||||||
playerSkills[skillName] = skill
|
playerSkills[skillName] = skill
|
||||||
@@ -141,17 +174,4 @@ Skills.SetXP = function(src, skillName, xp)
|
|||||||
return true
|
return true
|
||||||
end
|
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
|
return Skills
|
||||||
@@ -13,7 +13,7 @@ end
|
|||||||
---This will return the skill level of the passed skill name.
|
---This will return the skill level of the passed skill name.
|
||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@return number
|
---@return number
|
||||||
Skills.GetSkillLevel = function(skillName)
|
function Skills.GetSkillLevel(skillName)
|
||||||
local skillData = exports.evolent_skills:getSkillLevel(skillName)
|
local skillData = exports.evolent_skills:getSkillLevel(skillName)
|
||||||
return skillData or 0
|
return skillData or 0
|
||||||
end
|
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.
|
---This will get the name of the Skills system being used.
|
||||||
---@return string
|
---@return string
|
||||||
Skills.GetResourceName = function()
|
function Skills.GetResourceName()
|
||||||
return resourceName
|
return resourceName
|
||||||
end
|
end
|
||||||
---This will return the skill level of the passed skill name.
|
---This will return the skill level of the passed skill name.
|
||||||
---@param src number
|
---@param src number
|
||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@return number
|
---@return number
|
||||||
Skills.GetSkillLevel = function(src, skillName)
|
function Skills.GetSkillLevel(src, skillName)
|
||||||
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
||||||
return skillData or 0
|
return skillData or 0
|
||||||
end
|
end
|
||||||
@@ -24,7 +24,7 @@ end
|
|||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@param amount number
|
---@param amount number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Skills.AddXp = function(src, skillName, amount)
|
function Skills.AddXp(src, skillName, amount)
|
||||||
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
||||||
if not skillData then return false, print("Skill not found") end
|
if not skillData then return false, print("Skill not found") end
|
||||||
if not Skills.All[skillName] then
|
if not Skills.All[skillName] then
|
||||||
@@ -39,7 +39,7 @@ end
|
|||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@param amount number
|
---@param amount number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Skills.RemoveXp = function(src, skillName, amount)
|
function Skills.RemoveXp(src, skillName, amount)
|
||||||
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
local skillData = exports.evolent_skills:getSkillLevel(src, skillName)
|
||||||
if not skillData then return false, print("Skill not found") end
|
if not skillData then return false, print("Skill not found") end
|
||||||
exports.evolent_skills:removeXp(src, skillName, amount)
|
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.
|
---This will return the name of the Skills system being used.
|
||||||
---@return string
|
---@return string
|
||||||
Skills.GetResourceName = function()
|
function Skills.GetResourceName()
|
||||||
return resourceName
|
return resourceName
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return the skill level of the passed skill name.
|
---This will return the skill level of the passed skill name.
|
||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@return number
|
---@return number
|
||||||
Skills.GetSkillLevel = function(skillName)
|
function Skills.GetSkillLevel(skillName)
|
||||||
local skillData = exports.OT_skills:getSkill(skillName)
|
local skillData = exports.OT_skills:getSkill(skillName)
|
||||||
return skillData.level or 0
|
return skillData.level or 0
|
||||||
end
|
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.
|
---This will return the name of the Skills system being used.
|
||||||
---@return string
|
---@return string
|
||||||
Skills.GetResourceName = function()
|
function Skills.GetResourceName()
|
||||||
return resourceName
|
return resourceName
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ end
|
|||||||
---@param src number
|
---@param src number
|
||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@return number
|
---@return number
|
||||||
Skills.GetSkillLevel = function(src, skillName)
|
function Skills.GetSkillLevel(src, skillName)
|
||||||
local skillData = exports.OT_skills:getSkill(src, skillName)
|
local skillData = exports.OT_skills:getSkill(src, skillName)
|
||||||
return skillData.level or 0
|
return skillData.level or 0
|
||||||
end
|
end
|
||||||
@@ -25,7 +25,7 @@ end
|
|||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@param amount number
|
---@param amount number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Skills.AddXp = function(src, skillName, amount)
|
function Skills.AddXp(src, skillName, amount)
|
||||||
local skillData = exports.OT_skills:getSkill(src, skillName)
|
local skillData = exports.OT_skills:getSkill(src, skillName)
|
||||||
if not skillData then return false, print("Skill not found") end
|
if not skillData then return false, print("Skill not found") end
|
||||||
if not Skills.All[skillName] then
|
if not Skills.All[skillName] then
|
||||||
@@ -40,7 +40,7 @@ end
|
|||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@param amount number
|
---@param amount number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Skills.RemoveXp = function(src, skillName, amount)
|
function Skills.RemoveXp(src, skillName, amount)
|
||||||
local skillData = exports.OT_skills:getSkill(src, skillName)
|
local skillData = exports.OT_skills:getSkill(src, skillName)
|
||||||
if not skillData then return false, print("Skill not found") end
|
if not skillData then return false, print("Skill not found") end
|
||||||
exports.OT_skills:removeXP(src, skillName, amount)
|
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.
|
---This will get the name of the Skills system being used.
|
||||||
---@return string
|
---@return string
|
||||||
Skills.GetResourceName = function()
|
function Skills.GetResourceName()
|
||||||
return resourceName
|
return resourceName
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return the skill level of the passed skill name.
|
---This will return the skill level of the passed skill name.
|
||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@return number
|
---@return number
|
||||||
Skills.GetSkillLevel = function(skillName)
|
function Skills.GetSkillLevel(skillName)
|
||||||
local skillData = exports.pickle_xp:GetLevel(skillName)
|
local skillData = exports.pickle_xp:GetLevel(skillName)
|
||||||
return skillData or 0
|
return skillData or 0
|
||||||
end
|
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.
|
---This will get the name of the Skills system being used.
|
||||||
---@return string
|
---@return string
|
||||||
Skills.GetResourceName = function()
|
function Skills.GetResourceName()
|
||||||
return resourceName
|
return resourceName
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -15,7 +15,7 @@ end
|
|||||||
---@param src number
|
---@param src number
|
||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@return number
|
---@return number
|
||||||
Skills.GetSkillLevel = function(src, skillName)
|
function Skills.GetSkillLevel(src, skillName)
|
||||||
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
||||||
return skillData or 0
|
return skillData or 0
|
||||||
end
|
end
|
||||||
@@ -25,15 +25,11 @@ end
|
|||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@param amount number
|
---@param amount number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Skills.AddXp = function(src, skillName, amount)
|
function Skills.AddXp(src, skillName, amount)
|
||||||
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
||||||
if not skillData then return false, print("Skill not found") end
|
if not skillData then return false, print("^6 Skill "..skillName.." not found ^0 ") end
|
||||||
if not Skills.All[skillName] then
|
if not Skills.All[skillName] then Skills.All[skillName] = Skills.Create(skillName, 99, 50) end
|
||||||
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
|
|
||||||
exports.pickle_xp:AddPlayerXP(src, skillName, amount)
|
exports.pickle_xp:AddPlayerXP(src, skillName, amount)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
@@ -43,7 +39,7 @@ end
|
|||||||
---@param skillName string
|
---@param skillName string
|
||||||
---@param amount number
|
---@param amount number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Skills.RemoveXp = function(src, skillName, amount)
|
function Skills.RemoveXp(src, skillName, amount)
|
||||||
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName)
|
||||||
if not skillData then return false, print("Skill not found") end
|
if not skillData then return false, print("Skill not found") end
|
||||||
exports.pickle_xp:RemovePlayerXP(src, skillName, amount)
|
exports.pickle_xp:RemovePlayerXP(src, skillName, amount)
|
||||||
|
|||||||
@@ -2,16 +2,21 @@
|
|||||||
Target = Target or {}
|
Target = Target or {}
|
||||||
Ids = Ids or Require("lib/utility/shared/ids.lua")
|
Ids = Ids or Require("lib/utility/shared/ids.lua")
|
||||||
|
|
||||||
|
local InteractIds = {}
|
||||||
|
|
||||||
local function warnUser()
|
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.")
|
print("Currently Only Targeting Is Supported By Community Bridge, You Are Using A Resource That Requires The Target Module To Be Used.")
|
||||||
end
|
end
|
||||||
local InteractIds = {}
|
|
||||||
|
|
||||||
Target.GetCanInteract = function(id)
|
function Target.GetResourceName()
|
||||||
|
return "default"
|
||||||
|
end
|
||||||
|
|
||||||
|
function Target.GetCanInteract(id)
|
||||||
return InteractIds[id]
|
return InteractIds[id]
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.CreateCanInteract = function(cb)
|
function Target.CreateCanInteract(cb)
|
||||||
if not cb then return end
|
if not cb then return end
|
||||||
local id = Ids.CreateUniqueId(InteractIds)
|
local id = Ids.CreateUniqueId(InteractIds)
|
||||||
InteractIds[id] = {
|
InteractIds[id] = {
|
||||||
@@ -22,7 +27,7 @@ Target.CreateCanInteract = function(cb)
|
|||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.CanInteract = function(id, ...)
|
function Target.CanInteract(id, ...)
|
||||||
local interactData = InteractIds[id]
|
local interactData = InteractIds[id]
|
||||||
if not interactData then return true end
|
if not interactData then return true end
|
||||||
if interactData.ableToInteract == -1 then
|
if interactData.ableToInteract == -1 then
|
||||||
@@ -36,7 +41,7 @@ Target.CanInteract = function(id, ...)
|
|||||||
return interactData.ableToInteract > 0
|
return interactData.ableToInteract > 0
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.FixOptions = function(options)
|
function Target.FixOptions(options)
|
||||||
for k, v in pairs(options) do
|
for k, v in pairs(options) do
|
||||||
local action = v.onSelect or v.action
|
local action = v.onSelect or v.action
|
||||||
local select = function(entityOrData)
|
local select = function(entityOrData)
|
||||||
@@ -57,19 +62,19 @@ Target.FixOptions = function(options)
|
|||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.AddGlobalPlayer = function(options)
|
function Target.AddGlobalPlayer(options)
|
||||||
warnUser()
|
warnUser()
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.AddGlobalVehicle = function(options)
|
function Target.AddGlobalVehicle(options)
|
||||||
warnUser()
|
warnUser()
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.RemoveGlobalVehicle = function(options)
|
function Target.RemoveGlobalVehicle(options)
|
||||||
warnUser()
|
warnUser()
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.AddLocalEntity = function(entities, _options)
|
function Target.AddLocalEntity(entities, _options)
|
||||||
local fixedOptions = Target.FixOptions(_options)
|
local fixedOptions = Target.FixOptions(_options)
|
||||||
if type(entities) == "string" or type(entities) == "number" then
|
if type(entities) == "string" or type(entities) == "number" then
|
||||||
entities = { entities }
|
entities = { entities }
|
||||||
@@ -117,11 +122,11 @@ Target.AddLocalEntity = function(entities, _options)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.AddModel = function(models, options)
|
function Target.AddModel(models, options)
|
||||||
warnUser()
|
warnUser()
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.AddBoxZone = function(name, coords, size, heading, options)
|
function Target.AddBoxZone(name, coords, size, heading, options)
|
||||||
local fixedOptions = Target.FixOptions(options)
|
local fixedOptions = Target.FixOptions(options)
|
||||||
local id = Ids.RandomString()
|
local id = Ids.RandomString()
|
||||||
local title = Bridge.Language.Locale("target.title")
|
local title = Bridge.Language.Locale("target.title")
|
||||||
@@ -162,24 +167,20 @@ Target.AddBoxZone = function(name, coords, size, heading, options)
|
|||||||
end)
|
end)
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.RemoveGlobalPlayer = function()
|
function Target.RemoveGlobalPlayer()
|
||||||
warnUser()
|
warnUser()
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.RemoveLocalEntity = function(entity)
|
function Target.RemoveLocalEntity(entity)
|
||||||
warnUser()
|
warnUser()
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.RemoveModel = function(model)
|
function Target.RemoveModel(model)
|
||||||
warnUser()
|
warnUser()
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.RemoveZone = function(name)
|
function Target.RemoveZone(name)
|
||||||
warnUser()
|
warnUser()
|
||||||
end
|
end
|
||||||
|
|
||||||
Target.GetResourceName = function()
|
|
||||||
return "default"
|
|
||||||
end
|
|
||||||
|
|
||||||
return Target
|
return Target
|
||||||
@@ -4,12 +4,9 @@ if GetResourceState(resourceName) == 'missing' then return end
|
|||||||
|
|
||||||
Target = Target or {}
|
Target = Target or {}
|
||||||
local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false
|
local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false
|
||||||
|
|
||||||
local ox_target = exports.ox_target
|
local ox_target = exports.ox_target
|
||||||
local targetZones = {}
|
local targetZones = {}
|
||||||
|
|
||||||
Target = Target or {}
|
|
||||||
|
|
||||||
Target.GetResourceName = function()
|
Target.GetResourceName = function()
|
||||||
return "ox_target"
|
return "ox_target"
|
||||||
end
|
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.
|
---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
|
---@param options table
|
||||||
---@return table
|
---@return table
|
||||||
Target.FixOptions = function(options)
|
function Target.FixOptions(options)
|
||||||
for _, v in pairs(options) do
|
for _, v in pairs(options) do
|
||||||
local action = v.onSelect or v.action
|
local action = v.onSelect or v.action
|
||||||
if not action then
|
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.
|
---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
|
---@param bool boolean
|
||||||
Target.DisableTargeting = function(bool)
|
function Target.DisableTargeting(bool)
|
||||||
ox_target:disableTargeting(bool)
|
ox_target:disableTargeting(bool)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add target options to players.
|
---This will add target options to players.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddGlobalPlayer = function(options)
|
function Target.AddGlobalPlayer(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addGlobalPlayer(options)
|
ox_target:addGlobalPlayer(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all players.
|
---This will remove target options from all players.
|
||||||
Target.RemoveGlobalPlayer = function()
|
function Target.RemoveGlobalPlayer()
|
||||||
ox_target:removeGlobalPlayer()
|
ox_target:removeGlobalPlayer()
|
||||||
end
|
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.
|
---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
|
---@param options table
|
||||||
Target.AddGlobalPed = function(options)
|
function Target.AddGlobalPed(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addGlobalPed(options)
|
ox_target:addGlobalPed(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
|
---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
|
---@param options any
|
||||||
Target.RemoveGlobalPed = function(options)
|
function Target.RemoveGlobalPed(options)
|
||||||
ox_target:removeGlobalPed(options)
|
ox_target:removeGlobalPed(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add taget options to all vehicles.
|
---This will add taget options to all vehicles.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddGlobalVehicle = function(options)
|
function Target.AddGlobalVehicle(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addGlobalVehicle(options)
|
ox_target:addGlobalVehicle(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all vehicles.
|
---This will remove target options from all vehicles.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.RemoveGlobalVehicle = function(options)
|
function Target.RemoveGlobalVehicle(options)
|
||||||
local assembledLables = {}
|
local assembledLables = {}
|
||||||
for k, v in pairs(options) do
|
for k, v in pairs(options) do
|
||||||
table.insert(assembledLables, v.name)
|
table.insert(assembledLables, v.name)
|
||||||
@@ -99,7 +96,7 @@ end
|
|||||||
---This will generate targets on non networked entites with the passed options.
|
---This will generate targets on non networked entites with the passed options.
|
||||||
---@param entities number | table
|
---@param entities number | table
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddLocalEntity = function(entities, options)
|
function Target.AddLocalEntity(entities, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addLocalEntity(entities, options)
|
ox_target:addLocalEntity(entities, options)
|
||||||
end
|
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.
|
---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 entities table
|
||||||
---@param optionNames string | table | nil
|
---@param optionNames string | table | nil
|
||||||
Target.RemoveLocalEntity = function(entities, optionNames)
|
function Target.RemoveLocalEntity(entities, optionNames)
|
||||||
ox_target:removeLocalEntity(entities, optionNames)
|
ox_target:removeLocalEntity(entities, optionNames)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add a networked entity to the target system.
|
---This will add a networked entity to the target system.
|
||||||
---@param netids table | number
|
---@param netids table | number
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddNetworkedEntity = function(netids, options)
|
function Target.AddNetworkedEntity(netids, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addEntity(netids, options)
|
ox_target:addEntity(netids, options)
|
||||||
end
|
end
|
||||||
@@ -122,21 +119,21 @@ end
|
|||||||
---This will remove a networked entity from the target system.
|
---This will remove a networked entity from the target system.
|
||||||
---@param netids table | number
|
---@param netids table | number
|
||||||
---@param optionNames string
|
---@param optionNames string
|
||||||
Target.RemoveNetworkedEntity = function(netids, optionNames)
|
function Target.RemoveNetworkedEntity(netids, optionNames)
|
||||||
ox_target:removeEntity(netids, optionNames)
|
ox_target:removeEntity(netids, optionNames)
|
||||||
end
|
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.
|
---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 models number | table
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddModel = function(models, options)
|
function Target.AddModel(models, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
ox_target:addModel(models, options)
|
ox_target:addModel(models, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all specified models.
|
---This will remove target options from all specified models.
|
||||||
---@param model number
|
---@param model number
|
||||||
Target.RemoveModel = function(model)
|
function Target.RemoveModel(model)
|
||||||
ox_target:removeModel(model)
|
ox_target:removeModel(model)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -146,7 +143,7 @@ end
|
|||||||
---@param size table
|
---@param size table
|
||||||
---@param heading number
|
---@param heading number
|
||||||
---@param options table
|
---@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 {})
|
options = Target.FixOptions(options or {})
|
||||||
if not next(options) then return end
|
if not next(options) then return end
|
||||||
local target = ox_target:addBoxZone({
|
local target = ox_target:addBoxZone({
|
||||||
@@ -165,7 +162,7 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@param radius number
|
---@param radius number
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddSphereZone = function(name, coords, radius, options, debug)
|
function Target.AddSphereZone(name, coords, radius, options, debug)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
local target = ox_target:addSphereZone({
|
local target = ox_target:addSphereZone({
|
||||||
coords = coords,
|
coords = coords,
|
||||||
@@ -180,7 +177,7 @@ end
|
|||||||
|
|
||||||
---This will remove target options from a specific zone.
|
---This will remove target options from a specific zone.
|
||||||
---@param name string
|
---@param name string
|
||||||
Target.RemoveZone = function(name)
|
function Target.RemoveZone(name)
|
||||||
if not name then return end
|
if not name then return end
|
||||||
for _, data in pairs(targetZones) do
|
for _, data in pairs(targetZones) do
|
||||||
if data.name == name then
|
if data.name == name then
|
||||||
|
|||||||
@@ -5,18 +5,14 @@ if GetResourceState("ox_target") ~= 'missing' then return end
|
|||||||
|
|
||||||
Target = Target or {}
|
Target = Target or {}
|
||||||
local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false
|
local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false
|
||||||
|
|
||||||
local targetZones = {}
|
local targetZones = {}
|
||||||
|
|
||||||
Target = Target or {}
|
|
||||||
|
|
||||||
local qb_target = exports['qb-target']
|
local qb_target = exports['qb-target']
|
||||||
|
|
||||||
Target.GetResourceName = function()
|
function Target.GetResourceName()
|
||||||
return "qb-target"
|
return "qb-target"
|
||||||
end
|
end
|
||||||
|
|
||||||
function GetLargestDistance(data)
|
local function getLargestDistance(data)
|
||||||
local largestDistance = -1
|
local largestDistance = -1
|
||||||
for _, v in pairs(data) do
|
for _, v in pairs(data) do
|
||||||
if v.distance and v.distance > largestDistance then
|
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.
|
---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
|
---@param options table
|
||||||
---@return table
|
---@return table
|
||||||
Target.FixOptions = function(options)
|
function Target.FixOptions(options)
|
||||||
for k, v in pairs(options) do
|
for k, v in pairs(options) do
|
||||||
local action = v.onSelect or v.action
|
local action = v.onSelect or v.action
|
||||||
local select = action and function(entityOrData)
|
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.
|
---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
|
---@param bool boolean
|
||||||
Target.DisableTargeting = function(bool)
|
function Target.DisableTargeting(bool)
|
||||||
qb_target:AllowTargeting(not bool)
|
qb_target:AllowTargeting(not bool)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add target options to players.
|
---This will add target options to players.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddGlobalPlayer = function(options)
|
function Target.AddGlobalPlayer(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
qb_target:AddGlobalPlayer({
|
qb_target:AddGlobalPlayer({
|
||||||
options = options,
|
options = options,
|
||||||
distance = GetLargestDistance(options)
|
distance = getLargestDistance(options)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all players.
|
---This will remove target options from all players.
|
||||||
Target.RemoveGlobalPlayer = function()
|
function Target.RemoveGlobalPlayer()
|
||||||
qb_target:RemoveGlobalPlayer()
|
qb_target:RemoveGlobalPlayer()
|
||||||
end
|
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.
|
---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
|
---@param options table
|
||||||
Target.AddGlobalPed = function(options)
|
function Target.AddGlobalPed(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
qb_target:AddGlobalPed({
|
qb_target:AddGlobalPed({
|
||||||
options = options,
|
options = options,
|
||||||
distance = GetLargestDistance(options)
|
distance = getLargestDistance(options)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
|
---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
|
---@param options any
|
||||||
Target.RemoveGlobalPed = function(options)
|
function Target.RemoveGlobalPed(options)
|
||||||
qb_target:RemoveGlobalPed(options)
|
qb_target:RemoveGlobalPed(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add taget options to all vehicles.
|
---This will add taget options to all vehicles.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddGlobalVehicle = function(options)
|
function Target.AddGlobalVehicle(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
qb_target:AddGlobalVehicle({
|
qb_target:AddGlobalVehicle({
|
||||||
options = options,
|
options = options,
|
||||||
distance = GetLargestDistance(options)
|
distance = getLargestDistance(options)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add a networked entity to the target system.
|
---This will add a networked entity to the target system.
|
||||||
---@param netids table | number
|
---@param netids table | number
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddNetworkedEntity = function(netids, options)
|
function Target.AddNetworkedEntity(netids, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
qb_target:AddTargetEntity(netids, options)
|
qb_target:AddTargetEntity(netids, options)
|
||||||
end
|
end
|
||||||
@@ -118,13 +114,13 @@ end
|
|||||||
---This will remove a networked entity from the target system.
|
---This will remove a networked entity from the target system.
|
||||||
---@param netids table | number
|
---@param netids table | number
|
||||||
---@param optionNames string
|
---@param optionNames string
|
||||||
Target.RemoveNetworkedEntity = function(netids, optionNames)
|
function Target.RemoveNetworkedEntity(netids, optionNames)
|
||||||
qb_target:RemoveTargetEntity(netids, optionNames)
|
qb_target:RemoveTargetEntity(netids, optionNames)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all vehicles.
|
---This will remove target options from all vehicles.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.RemoveGlobalVehicle = function(options)
|
function Target.RemoveGlobalVehicle(options)
|
||||||
local assembledLables = {}
|
local assembledLables = {}
|
||||||
for k, v in pairs(options) do
|
for k, v in pairs(options) do
|
||||||
table.insert(assembledLables, v.label)
|
table.insert(assembledLables, v.label)
|
||||||
@@ -135,35 +131,35 @@ end
|
|||||||
---This will generate targets on non networked entites with the passed options.
|
---This will generate targets on non networked entites with the passed options.
|
||||||
---@param entities number | table
|
---@param entities number | table
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddLocalEntity = function(entities, options)
|
function Target.AddLocalEntity(entities, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
qb_target:AddTargetEntity(entities, {
|
qb_target:AddTargetEntity(entities, {
|
||||||
options = options,
|
options = options,
|
||||||
distance = GetLargestDistance(options)
|
distance = getLargestDistance(options)
|
||||||
})
|
})
|
||||||
end
|
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.
|
---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 entity number | table
|
||||||
---@param labels string | table | nil
|
---@param labels string | table | nil
|
||||||
Target.RemoveLocalEntity = function(entity, labels)
|
function Target.RemoveLocalEntity(entity, labels)
|
||||||
qb_target:RemoveTargetEntity(entity, labels)
|
qb_target:RemoveTargetEntity(entity, labels)
|
||||||
end
|
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.
|
---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 models number | table
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddModel = function(models, options, distance)
|
function Target.AddModel(models, options, distance)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
qb_target:AddTargetModel(models, {
|
qb_target:AddTargetModel(models, {
|
||||||
options = options,
|
options = options,
|
||||||
distance = GetLargestDistance(options),
|
distance = getLargestDistance(options),
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all specified models.
|
---This will remove target options from all specified models.
|
||||||
---@param model number
|
---@param model number
|
||||||
Target.RemoveModel = function(model)
|
function Target.RemoveModel(model)
|
||||||
qb_target:RemoveTargetModel(model)
|
qb_target:RemoveTargetModel(model)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -173,7 +169,7 @@ end
|
|||||||
---@param size table
|
---@param size table
|
||||||
---@param heading number
|
---@param heading number
|
||||||
---@param options table
|
---@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)
|
options = Target.FixOptions(options)
|
||||||
if not next(options) then return end
|
if not next(options) then return end
|
||||||
qb_target:AddBoxZone(name, coords, size.x, size.y, {
|
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),
|
maxZ = coords.z + (size.z * 0.5),
|
||||||
}, {
|
}, {
|
||||||
options = options,
|
options = options,
|
||||||
distance = GetLargestDistance(options),
|
distance = getLargestDistance(options),
|
||||||
})
|
})
|
||||||
table.insert(targetZones, { name = name, creator = GetInvokingResource() })
|
table.insert(targetZones, { name = name, creator = GetInvokingResource() })
|
||||||
return name
|
return name
|
||||||
@@ -195,14 +191,14 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@param radius number
|
---@param radius number
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddSphereZone = function(name, coords, radius, options, debug)
|
function Target.AddSphereZone(name, coords, radius, options, debug)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
qb_target:AddCircleZone(name, coords, radius, {
|
qb_target:AddCircleZone(name, coords, radius, {
|
||||||
name = name,
|
name = name,
|
||||||
debugPoly = targetDebug or debug,
|
debugPoly = targetDebug or debug,
|
||||||
}, {
|
}, {
|
||||||
options = options,
|
options = options,
|
||||||
distance = GetLargestDistance(options),
|
distance = getLargestDistance(options),
|
||||||
})
|
})
|
||||||
table.insert(targetZones, { name = name, creator = GetInvokingResource() })
|
table.insert(targetZones, { name = name, creator = GetInvokingResource() })
|
||||||
return name
|
return name
|
||||||
@@ -210,7 +206,7 @@ end
|
|||||||
|
|
||||||
---This will remove target options from a specific zone.
|
---This will remove target options from a specific zone.
|
||||||
---@param name string
|
---@param name string
|
||||||
Target.RemoveZone = function(name)
|
function Target.RemoveZone(name)
|
||||||
if not name then return end
|
if not name then return end
|
||||||
for _, data in pairs(targetZones) do
|
for _, data in pairs(targetZones) do
|
||||||
if data.name == name then
|
if data.name == name then
|
||||||
|
|||||||
@@ -3,22 +3,20 @@ local resourceName = "sleepless_interact"
|
|||||||
if GetResourceState(resourceName) == 'missing' then return end
|
if GetResourceState(resourceName) == 'missing' then return end
|
||||||
if GetResourceState("ox_target") == 'started' then return end
|
if GetResourceState("ox_target") == 'started' then return end
|
||||||
|
|
||||||
local targetDebug = false
|
local targetDebug = BridgeSharedConfig and BridgeSharedConfig.DebugLevel == 2 or false
|
||||||
local function detectDebugEnabled()
|
|
||||||
if BridgeSharedConfig.DebugLevel == 2 then targetDebug = true end
|
|
||||||
end
|
|
||||||
|
|
||||||
detectDebugEnabled()
|
|
||||||
|
|
||||||
local sleepless_interact = exports.sleepless_interact
|
local sleepless_interact = exports.sleepless_interact
|
||||||
local targetZones = {}
|
local targetZones = {}
|
||||||
|
|
||||||
Target = Target or {}
|
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.
|
---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
|
---@param options table
|
||||||
---@return table
|
---@return table
|
||||||
Target.FixOptions = function(options)
|
function Target.FixOptions(options)
|
||||||
for k, v in pairs(options) do
|
for k, v in pairs(options) do
|
||||||
local action = v.onSelect or v.action
|
local action = v.onSelect or v.action
|
||||||
local select = function(entityOrData)
|
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.
|
---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
|
---@param bool boolean
|
||||||
Target.DisableTargeting = function(bool) -- someone disabled this mistakenly
|
function Target.DisableTargeting(bool) -- someone disabled this mistakenly
|
||||||
sleepless_interact:disableInteract(bool)
|
sleepless_interact:disableInteract(bool)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add target options to players.
|
---This will add target options to players.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddGlobalPlayer = function(options)
|
function Target.AddGlobalPlayer(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
sleepless_interact:addGlobalPlayer(options)
|
sleepless_interact:addGlobalPlayer(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all players.
|
---This will remove target options from all players.
|
||||||
Target.RemoveGlobalPlayer = function()
|
function Target.RemoveGlobalPlayer()
|
||||||
sleepless_interact:removeGlobalPlayer()
|
sleepless_interact:removeGlobalPlayer()
|
||||||
end
|
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.
|
---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
|
---@param options table
|
||||||
Target.AddGlobalPed = function(options)
|
function Target.AddGlobalPed(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
sleepless_interact:addGlobalPed(options)
|
sleepless_interact:addGlobalPed(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all peds. This is useful for when you want to remove target options from all peds.
|
---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
|
---@param options any
|
||||||
Target.RemoveGlobalPed = function(options)
|
function Target.RemoveGlobalPed(options)
|
||||||
sleepless_interact:removeGlobalPed(options)
|
sleepless_interact:removeGlobalPed(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will add taget options to all vehicles.
|
---This will add taget options to all vehicles.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddGlobalVehicle = function(options)
|
function Target.AddGlobalVehicle(options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
sleepless_interact:addGlobalVehicle(options)
|
sleepless_interact:addGlobalVehicle(options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all vehicles.
|
---This will remove target options from all vehicles.
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.RemoveGlobalVehicle = function(options)
|
function Target.RemoveGlobalVehicle(options)
|
||||||
local assembledLables = {}
|
local assembledLables = {}
|
||||||
for k, v in pairs(options) do
|
for k, v in pairs(options) do
|
||||||
table.insert(assembledLables, v.name)
|
table.insert(assembledLables, v.name)
|
||||||
@@ -91,7 +89,7 @@ end
|
|||||||
---This will add a networked entity to the target system.
|
---This will add a networked entity to the target system.
|
||||||
---@param netids table | number
|
---@param netids table | number
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddNetworkedEntity = function(netids, options)
|
function Target.AddNetworkedEntity(netids, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
sleepless_interact:addEntity(netids, options)
|
sleepless_interact:addEntity(netids, options)
|
||||||
end
|
end
|
||||||
@@ -99,14 +97,14 @@ end
|
|||||||
---This will remove a networked entity from the target system.
|
---This will remove a networked entity from the target system.
|
||||||
---@param netids table | number
|
---@param netids table | number
|
||||||
---@param optionNames string
|
---@param optionNames string
|
||||||
Target.RemoveNetworkedEntity = function(netids, optionNames)
|
function Target.RemoveNetworkedEntity(netids, optionNames)
|
||||||
sleepless_interact:removeEntity(netids, optionNames)
|
sleepless_interact:removeEntity(netids, optionNames)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will generate targets on non networked entites with the passed options.
|
---This will generate targets on non networked entites with the passed options.
|
||||||
---@param entities number | table
|
---@param entities number | table
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddLocalEntity = function(entities, options)
|
function Target.AddLocalEntity(entities, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
sleepless_interact:addLocalEntity(entities, options)
|
sleepless_interact:addLocalEntity(entities, options)
|
||||||
end
|
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.
|
---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 entity number | table
|
||||||
---@param labels string | table | nil
|
---@param labels string | table | nil
|
||||||
Target.RemoveLocalEntity = function(entity, labels)
|
function Target.RemoveLocalEntity(entity, labels)
|
||||||
sleepless_interact:removeLocalEntity(entity, labels)
|
sleepless_interact:removeLocalEntity(entity, labels)
|
||||||
end
|
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.
|
---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 models number | table
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddModel = function(models, options)
|
function Target.AddModel(models, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
sleepless_interact:addModel(models, options)
|
sleepless_interact:addModel(models, options)
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will remove target options from all specified models.
|
---This will remove target options from all specified models.
|
||||||
---@param model number
|
---@param model number
|
||||||
Target.RemoveModel = function(model)
|
function Target.RemoveModel(model)
|
||||||
sleepless_interact:removeModel(model)
|
sleepless_interact:removeModel(model)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -138,7 +136,7 @@ end
|
|||||||
---@param size table
|
---@param size table
|
||||||
---@param heading number
|
---@param heading number
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddBoxZone = function(name, coords, size, heading, options)
|
function Target.AddBoxZone(name, coords, size, heading, options)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
local target = sleepless_interact:addCoords({
|
local target = sleepless_interact:addCoords({
|
||||||
coords = coords,
|
coords = coords,
|
||||||
@@ -153,7 +151,7 @@ end
|
|||||||
---@param coords table
|
---@param coords table
|
||||||
---@param radius number
|
---@param radius number
|
||||||
---@param options table
|
---@param options table
|
||||||
Target.AddSphereZone = function(name, coords, radius, options, debug)
|
function Target.AddSphereZone(name, coords, radius, options, debug)
|
||||||
options = Target.FixOptions(options)
|
options = Target.FixOptions(options)
|
||||||
local target = sleepless_interact:addSphereZone({
|
local target = sleepless_interact:addSphereZone({
|
||||||
coords = coords,
|
coords = coords,
|
||||||
@@ -168,7 +166,7 @@ end
|
|||||||
|
|
||||||
---This will remove target options from a specific zone.
|
---This will remove target options from a specific zone.
|
||||||
---@param name string
|
---@param name string
|
||||||
Target.RemoveZone = function(name)
|
function Target.RemoveZone(name)
|
||||||
for _, data in pairs(targetZones) do
|
for _, data in pairs(targetZones) do
|
||||||
if data.name == name then
|
if data.name == name then
|
||||||
sleepless_interact:removeCoords(data.id)
|
sleepless_interact:removeCoords(data.id)
|
||||||
@@ -188,8 +186,4 @@ AddEventHandler('onResourceStop', function(resource)
|
|||||||
targetZones = {}
|
targetZones = {}
|
||||||
end)
|
end)
|
||||||
|
|
||||||
Target.GetResourceName = function()
|
|
||||||
return "sleepless_interact"
|
|
||||||
end
|
|
||||||
|
|
||||||
return Target
|
return Target
|
||||||
Reference in new issue
Block a user