Merge pull request #140 from TheOrderFivem/dev
feat: major system refactor, feature patches, and compatibility improvements
This commit is contained in:
81 files changed
+1443
-900
No files matched your search
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
+2
-2
@@ -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.11.1'
|
version '0.11.2'
|
||||||
|
|
||||||
shared_scripts {
|
shared_scripts {
|
||||||
'@ox_lib/init.lua',
|
'@ox_lib/init.lua',
|
||||||
@@ -25,7 +25,7 @@ server_scripts {
|
|||||||
'modules/inventory/**/server.lua',
|
'modules/inventory/**/server.lua',
|
||||||
'modules/doorlock/**/server.lua',
|
'modules/doorlock/**/server.lua',
|
||||||
'modules/phone/**/server.lua',
|
'modules/phone/**/server.lua',
|
||||||
'modules/managment/**/server.lua',
|
'modules/banking/**/server.lua',
|
||||||
'modules/dispatch/**/server.lua',
|
'modules/dispatch/**/server.lua',
|
||||||
'modules/clothing/**/server.lua',
|
'modules/clothing/**/server.lua',
|
||||||
'modules/shops/**/server.lua',
|
'modules/shops/**/server.lua',
|
||||||
|
|||||||
@@ -90,6 +90,7 @@ end)
|
|||||||
-- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄
|
-- ▄█▀ █▄▄ █▀▄ ▀▄▀ █▄▄ █▀▄
|
||||||
if not IsDuplicityVersion() then goto client end
|
if not IsDuplicityVersion() then goto client end
|
||||||
Bridge.RegisterModule('Version', Version)
|
Bridge.RegisterModule('Version', Version)
|
||||||
|
Bridge.RegisterModule('Banking', Banking)
|
||||||
|
|
||||||
-- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀
|
-- ▄▀▀ █ █ ██▀ █▄ █ ▀█▀
|
||||||
-- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █
|
-- ▀▄▄ █▄▄ █ █▄▄ █ ▀█ █
|
||||||
|
|||||||
Vendored
+6
-26
@@ -3,33 +3,22 @@ local PlayerPedId = PlayerPedId
|
|||||||
local GetVehiclePedIsIn = GetVehiclePedIsIn
|
local GetVehiclePedIsIn = GetVehiclePedIsIn
|
||||||
local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers
|
local GetVehicleMaxNumberOfPassengers = GetVehicleMaxNumberOfPassengers
|
||||||
local GetPedInVehicleSeat = GetPedInVehicleSeat
|
local GetPedInVehicleSeat = GetPedInVehicleSeat
|
||||||
local GetPlayerServerId = GetPlayerServerId
|
|
||||||
local GetSelectedPedWeapon = GetSelectedPedWeapon
|
local GetSelectedPedWeapon = GetSelectedPedWeapon
|
||||||
local PlayerId = PlayerId
|
|
||||||
|
|
||||||
|
|
||||||
-- Comparison functions for client-side state
|
|
||||||
|
|
||||||
--- Get the player's ped ID
|
|
||||||
---@return integer
|
|
||||||
function GetPed()
|
|
||||||
return PlayerPedId()
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get the vehicle the player is in, if any
|
--- Get the vehicle the player is in, if any
|
||||||
---@return integer | nil
|
---@return integer | nil
|
||||||
function GetVehicle()
|
function GetVehicle()
|
||||||
local ped = Cache.Get("Ped") -- Use cached ped for efficiency
|
local ped = PlayerPedId()
|
||||||
if not ped then return end -- Or handle error/default case
|
if not ped then return end
|
||||||
return GetVehiclePedIsIn(ped, false)
|
return GetVehiclePedIsIn(ped, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Get the seat of the player in the vehicle if the vehicle is occupied
|
--- Get the seat of the player in the vehicle if the vehicle is occupied
|
||||||
---@return integer | nil
|
---@return integer | nil
|
||||||
function GetVehicleSeat()
|
function GetVehicleSeat()
|
||||||
local vehicle = Cache.Get("Vehicle")
|
local vehicle = GetVehicle()
|
||||||
if not vehicle then return end
|
if not vehicle then return end
|
||||||
local ped = Cache.Get("Ped")
|
local ped = PlayerPedId()
|
||||||
if not ped then return end
|
if not ped then return end
|
||||||
for i = -1, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do
|
for i = -1, GetVehicleMaxNumberOfPassengers(vehicle) - 1 do
|
||||||
if ped == GetPedInVehicleSeat(vehicle, i) then
|
if ped == GetPedInVehicleSeat(vehicle, i) then
|
||||||
@@ -38,26 +27,17 @@ function GetVehicleSeat()
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
---Get The Server ID of the player
|
|
||||||
---@return integer | nil
|
|
||||||
function GetServerId()
|
|
||||||
local ped <const> = PlayerId()
|
|
||||||
if not ped then return end -- Return unarmed hash if no ped
|
|
||||||
return GetPlayerServerId(ped)
|
|
||||||
end
|
|
||||||
|
|
||||||
--- Get the current weapon of the player
|
--- Get the current weapon of the player
|
||||||
--- @return integer | nil
|
--- @return integer | nil
|
||||||
function GetWeapon()
|
function GetWeapon()
|
||||||
local ped = Cache.Get("Ped")
|
local ped = PlayerPedId()
|
||||||
if not ped then return end -- Return unarmed hash if no ped
|
if not ped then return end -- Return unarmed hash if no ped
|
||||||
return GetSelectedPedWeapon(ped)
|
return GetSelectedPedWeapon(ped)
|
||||||
end
|
end
|
||||||
|
|
||||||
Cache.Create("Ped", GetPed, 1000) -- Check ped every second (adjust as needed)
|
Cache.Create("Ped", PlayerPedId, 1000) -- Check ped every second (adjust as needed)
|
||||||
Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms
|
Cache.Create("Vehicle", GetVehicle, 500) -- Check vehicle every 500ms
|
||||||
Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms
|
Cache.Create("Seat", GetVehicleSeat, 500) -- Check if in vehicle every 500ms
|
||||||
Cache.Create("Weapon", GetWeapon , 250) -- Check weapon every 250ms
|
Cache.Create("Weapon", GetWeapon , 250) -- Check weapon every 250ms
|
||||||
Cache.Create("ServerId", GetServerId, 1000) -- Check server ID every second
|
|
||||||
|
|
||||||
return Cache
|
return Cache
|
||||||
Vendored
+2
-5
@@ -128,11 +128,8 @@ local function trackResource(resourceName, type, data)
|
|||||||
for _, cb in ipairs(resourceTracker.callbacks[resourceName] or {}) do
|
for _, cb in ipairs(resourceTracker.callbacks[resourceName] or {}) do
|
||||||
local targetCache = Cache.Caches[cb.cacheName]
|
local targetCache = Cache.Caches[cb.cacheName]
|
||||||
if targetCache then
|
if targetCache then
|
||||||
table.remove(targetCache.OnChange, cb.index)
|
targetCache.OnChange[cb.index] = nil
|
||||||
debugPrint(("Removed OnChange callback from cache '%s' - resource '%s' stopped"):format(
|
debugPrint(("Removed callback '%s' from cache '%s' - resource '%s' stopped"):format(cb.index, cb.cacheName, resourceName))
|
||||||
cb.cacheName,
|
|
||||||
resourceName
|
|
||||||
))
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -9,18 +9,15 @@ ClientEntity = {} -- Renamed from BaseEntity
|
|||||||
local function SpawnEntity(entityData)
|
local function SpawnEntity(entityData)
|
||||||
entityData = entityData and entityData.args
|
entityData = entityData and entityData.args
|
||||||
if entityData.spawned and DoesEntityExist(entityData.spawned) then return end -- Already spawned
|
if entityData.spawned and DoesEntityExist(entityData.spawned) then return end -- Already spawned
|
||||||
-- for k, v in pairs(entityData.args) do
|
local loaded, model = Utility.LoadModel(entityData.model)
|
||||||
-- print(string.format("SpawnEntity %s: %s", k, v))
|
if not loaded then
|
||||||
-- end
|
|
||||||
local model = entityData.model and type(entityData.model) == 'string' and GetHashKey(entityData.model) or entityData.model
|
|
||||||
if model and not Utility.LoadModel(model) then
|
|
||||||
print(string.format("[ClientEntity] Failed to load model %s for entity %s", entityData.model, entityData.id))
|
print(string.format("[ClientEntity] Failed to load model %s for entity %s", entityData.model, entityData.id))
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
local entity = nil
|
local entity = nil
|
||||||
local coords = entityData.coords
|
local coords = entityData.coords
|
||||||
local rotation = entityData.rotation or vector3(0.0, 0.0, 0.0) -- Default rotation if not provided
|
local rotation = entityData.rotation or vector3(0.0, 0.0, entityData.heading or 0.0) -- Default rotation if not provided
|
||||||
|
|
||||||
if entityData.entityType == 'object' then
|
if entityData.entityType == 'object' then
|
||||||
entity = CreateObject(model, coords.x, coords.y, coords.z, false, false, false)
|
entity = CreateObject(model, coords.x, coords.y, coords.z, false, false, false)
|
||||||
@@ -41,23 +38,26 @@ local function SpawnEntity(entityData)
|
|||||||
SetModelAsNoLongerNeeded(model)
|
SetModelAsNoLongerNeeded(model)
|
||||||
end
|
end
|
||||||
if entityData.OnSpawn then
|
if entityData.OnSpawn then
|
||||||
entityData.OnSpawn(entityData)
|
pcall(function (...)
|
||||||
|
return entityData.OnSpawn(entityData)
|
||||||
|
end)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local function RemoveEntity(entityData)
|
local function RemoveEntity(entityData)
|
||||||
entityData = entityData and entityData.args or entityData
|
entityData = entityData and entityData.args or entityData
|
||||||
if not entityData then return end
|
if not entityData then return end
|
||||||
ClientEntityActions.StopAction(entityData.id)
|
if entityData.OnRemove then
|
||||||
|
pcall(function (...)
|
||||||
|
return entityData.OnRemove(entityData)
|
||||||
|
end)
|
||||||
|
end
|
||||||
if entityData.spawned and DoesEntityExist(entityData.spawned) then
|
if entityData.spawned and DoesEntityExist(entityData.spawned) then
|
||||||
local entityHandle = entityData.spawned
|
local entityHandle = entityData.spawned
|
||||||
entityData.spawned = nil
|
entityData.spawned = nil
|
||||||
SetEntityAsMissionEntity(entityHandle, false, false)
|
SetEntityAsMissionEntity(entityHandle, true, true)
|
||||||
DeleteEntity(entityHandle)
|
DeleteEntity(entityHandle)
|
||||||
end
|
end
|
||||||
if entityData.OnRemove then
|
|
||||||
entityData.OnRemove(entityData)
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
--- Registers an entity received from the server and sets up proximity spawning.
|
--- Registers an entity received from the server and sets up proximity spawning.
|
||||||
@@ -177,6 +177,37 @@ function ClientEntity.OnCreate(_type, func)
|
|||||||
table.insert(ClientEntity.OnCreates[_type], func)
|
table.insert(ClientEntity.OnCreates[_type], func)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function ClientEntity.SetOnSpawn(id, func)
|
||||||
|
local entityData = Entities[id]
|
||||||
|
if not entityData then
|
||||||
|
print(string.format("[ClientEntity] SetOnSpawn: Entity %s does not exist", id))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
entityData.OnSpawn = func
|
||||||
|
end
|
||||||
|
|
||||||
|
function ClientEntity.SetOnRemove(id, func)
|
||||||
|
local entityData = Entities[id]
|
||||||
|
if not entityData then
|
||||||
|
print(string.format("[ClientEntity] SetOnRemove: Entity %s does not exist", id))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
entityData.OnRemove = func
|
||||||
|
end
|
||||||
|
|
||||||
|
function ClientEntity.UpdateCoords(id, coords)
|
||||||
|
local entityData = Entities[id]
|
||||||
|
if not entityData then
|
||||||
|
print(string.format("[ClientEntity] UpdateCoords: Entity %s does not exist", id))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
entityData.coords = coords
|
||||||
|
Point.UpdateCoords(id, coords)
|
||||||
|
if entityData.spawned and DoesEntityExist(entityData.spawned) then
|
||||||
|
SetEntityCoords(entityData.spawned, coords.x, coords.y, coords.z, false, false, false, true)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
-- Network Event Handlers
|
-- Network Event Handlers
|
||||||
RegisterNetEvent("community_bridge:client:CreateEntity", function(entityData)
|
RegisterNetEvent("community_bridge:client:CreateEntity", function(entityData)
|
||||||
ClientEntity.Create(entityData)
|
ClientEntity.Create(entityData)
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ end
|
|||||||
function ServerEntity.Create(id, entityType, model, coords, rotation, meta)
|
function ServerEntity.Create(id, entityType, model, coords, rotation, meta)
|
||||||
local self = ServerEntity.New(id, entityType, model, coords, rotation, meta)
|
local self = ServerEntity.New(id, entityType, model, coords, rotation, meta)
|
||||||
if not self then
|
if not self then
|
||||||
print("Failed to create entity with ID: " .. tostring(id))
|
-- print("Failed to create entity with ID: " .. tostring(id))
|
||||||
return nil
|
return nil
|
||||||
end
|
end
|
||||||
TriggerClientEvent("community_bridge:client:CreateEntity", -1, self)
|
TriggerClientEvent("community_bridge:client:CreateEntity", -1, self)
|
||||||
@@ -68,7 +68,7 @@ end
|
|||||||
-- @param data table The data fields to update.
|
-- @param data table The data fields to update.
|
||||||
function ServerEntity.Update(id, data)
|
function ServerEntity.Update(id, data)
|
||||||
local entity = Entities[id]
|
local entity = Entities[id]
|
||||||
print("Updating entity: ", id, entity)
|
-- print("Updating entity: ", id, entity)
|
||||||
if not entity then return false end
|
if not entity then return false end
|
||||||
|
|
||||||
for key, value in pairs(data) do
|
for key, value in pairs(data) do
|
||||||
@@ -84,7 +84,7 @@ end
|
|||||||
-- @param actionName string The name of the action to trigger (must match a function in ClientEntityActions).
|
-- @param actionName string The name of the action to trigger (must match a function in ClientEntityActions).
|
||||||
-- @param ... any Additional arguments for the action function.
|
-- @param ... any Additional arguments for the action function.
|
||||||
function ServerEntity.TriggerAction(entityId, actionName, endPosition, ...)
|
function ServerEntity.TriggerAction(entityId, actionName, endPosition, ...)
|
||||||
print("Triggering action: ", entityId, actionName, ...)
|
-- print("Triggering action: ", entityId, actionName, ...)
|
||||||
local entity = Entities[entityId]
|
local entity = Entities[entityId]
|
||||||
if not entity then
|
if not entity then
|
||||||
print(string.format("[ServerEntity] Attempted to trigger action '%s' on non-existent entity %s", actionName, entityId))
|
print(string.format("[ServerEntity] Attempted to trigger action '%s' on non-existent entity %s", actionName, entityId))
|
||||||
|
|||||||
+2
-1
@@ -47,6 +47,7 @@ cLib = {
|
|||||||
Math = Math or Require("lib/utility/shared/math.lua"),
|
Math = Math or Require("lib/utility/shared/math.lua"),
|
||||||
LA = LA or Require("lib/utility/shared/la.lua"),
|
LA = LA or Require("lib/utility/shared/la.lua"),
|
||||||
Perlin = Perlin or Require("lib/utility/shared/perlin.lua"),
|
Perlin = Perlin or Require("lib/utility/shared/perlin.lua"),
|
||||||
|
-- Zones = Poly or Require("lib/zones/shared/zones.lua"),
|
||||||
-- Action = Action or Require("lib/entities/shared/actions.lua"),
|
-- Action = Action or Require("lib/entities/shared/actions.lua"),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -71,7 +72,7 @@ cLib.Placeable = Placeable or Require("lib/placers/client/object_placer.lua")
|
|||||||
cLib.Utility = Utility or Require("lib/utility/client/utility.lua")
|
cLib.Utility = Utility or Require("lib/utility/client/utility.lua")
|
||||||
cLib.PlaceableObject = ObjectPlacer or Require("lib/placers/client/placeable_object.lua")
|
cLib.PlaceableObject = ObjectPlacer or Require("lib/placers/client/placeable_object.lua")
|
||||||
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/pointsv2.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.Cache = Cache or Require("lib/cache/client/cache.lua")
|
||||||
cLib.ClientEntity = ClientEntity or Require("lib/entities/client/client_entity.lua")
|
cLib.ClientEntity = ClientEntity or Require("lib/entities/client/client_entity.lua")
|
||||||
|
|||||||
@@ -55,5 +55,61 @@ Logs.Send = function(src, message)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local embeds = {}
|
||||||
|
Logs.Notify = function(src, url, image, message)
|
||||||
|
if not src or not message then return end
|
||||||
|
local logType = LogSystem or "built-in"
|
||||||
|
if logType == "built-in" then
|
||||||
|
embeds[url] = embeds[url] or {}
|
||||||
|
local embed = embeds[url].embed or {}
|
||||||
|
local firstName, lastName = Framework.GetPlayerName(src)
|
||||||
|
|
||||||
|
table.insert(embed, {
|
||||||
|
color = "15769093",
|
||||||
|
title = GetInvokingResource(),
|
||||||
|
-- url = 'https://discord.gg/Gm6rYEXUsn',
|
||||||
|
thumbnail = { url = LogoForEmbed },
|
||||||
|
fields = {
|
||||||
|
{
|
||||||
|
name = '**Player ID**',
|
||||||
|
value = src,
|
||||||
|
inline = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = '**Player Identifier**',
|
||||||
|
value = Framework.GetPlayerIdentifier(src),
|
||||||
|
inline = true,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name = 'Log Message',
|
||||||
|
value = "```"..message.."```",
|
||||||
|
inline = false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
timestamp = os.date('!%Y-%m-%dT%H:%M:%S'),
|
||||||
|
footer = {
|
||||||
|
text = "Community_Bridge | ",
|
||||||
|
icon_url = 'https://avatars.githubusercontent.com/u/192999457?s=400&u=da632e8f64c85def390cfd1a73c3b664d6882b38&v=4',
|
||||||
|
},
|
||||||
|
})
|
||||||
|
embeds[url].embed = embed
|
||||||
|
if embeds[url].inProgress then return end
|
||||||
|
embeds[url].inProgress = true
|
||||||
|
SetTimeout(5000, function()
|
||||||
|
PerformHttpRequest(url, function(err, text, headers) end, 'POST', json.encode({
|
||||||
|
username = string.format("%s %s", firstName, lastName),
|
||||||
|
avatar_url = image or 'https://avatars.githubusercontent.com/u/192999457?s=400&u=da632e8f64c85def390cfd1a73c3b664d6882b38&v=4',
|
||||||
|
embeds = embeds[url].embed
|
||||||
|
}), { ['Content-Type']= 'application/json' })
|
||||||
|
embeds[url].inProgress = false
|
||||||
|
end)
|
||||||
|
elseif logType == "qb" then
|
||||||
|
return TriggerEvent('qb-log:server:CreateLog', GetCurrentResourceName(), GetCurrentResourceName(), 'green', message)
|
||||||
|
elseif logType == "ox_lib" then
|
||||||
|
return lib.logger(src, GetCurrentResourceName(), message)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
exports('Logs', Logs)
|
exports('Logs', Logs)
|
||||||
return Logs
|
return Logs
|
||||||
@@ -8,7 +8,7 @@ function Particle.New(data)
|
|||||||
assert(data.dict, "Invalid particle data. Must contain string dict.")
|
assert(data.dict, "Invalid particle data. Must contain string dict.")
|
||||||
assert(data.ptfx, "Invalid particle data. Must contain string ptfx.")
|
assert(data.ptfx, "Invalid particle data. Must contain string ptfx.")
|
||||||
|
|
||||||
local _id = data.id or id.CreateUniqueId(Particles)
|
local _id = data.id or Bridge.Ids.CreateUniqueId(Particles)
|
||||||
data = {
|
data = {
|
||||||
id = _id,
|
id = _id,
|
||||||
dict = data.dict,
|
dict = data.dict,
|
||||||
|
|||||||
@@ -36,6 +36,7 @@ Placeable.PlaceObject = function(object, distance, snapToGround, allowedMats, of
|
|||||||
local propObject = type(object) == 'string' and joaat(object) or object
|
local propObject = type(object) == 'string' and joaat(object) or object
|
||||||
local heading = 0.0
|
local heading = 0.0
|
||||||
local checkDist = distance or 10.0
|
local checkDist = distance or 10.0
|
||||||
|
local ped = PlayerPedId()
|
||||||
|
|
||||||
Utility.LoadModel(propObject)
|
Utility.LoadModel(propObject)
|
||||||
|
|
||||||
@@ -60,7 +61,7 @@ Placeable.PlaceObject = function(object, distance, snapToGround, allowedMats, of
|
|||||||
end
|
end
|
||||||
|
|
||||||
SetEntityCoords(activePlacementProp, coords.x, coords.y, coords.z, false, false, false, false)
|
SetEntityCoords(activePlacementProp, coords.x, coords.y, coords.z, false, false, false, false)
|
||||||
local distCheck = #(GetEntityCoords(cache.ped) - coords)
|
local distCheck = #(GetEntityCoords(ped) - coords)
|
||||||
SetEntityHeading(activePlacementProp, heading)
|
SetEntityHeading(activePlacementProp, heading)
|
||||||
|
|
||||||
if snapToGround then
|
if snapToGround then
|
||||||
|
|||||||
@@ -44,6 +44,15 @@ local state = {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local placementText = {
|
||||||
|
string.format(locale('placeable_object.object_place'), Utility.GetCommandKey('+place_object')),
|
||||||
|
string.format(locale('placeable_object.object_cancel'), Utility.GetCommandKey('+cancel_placement')),
|
||||||
|
string.format(locale('placeable_object.rotate_clockwise'), Utility.GetCommandKey('+scroll_up')),
|
||||||
|
string.format(locale('placeable_object.rotate_counter_clockwise'), Utility.GetCommandKey('+scroll_down')),
|
||||||
|
string.format(locale('placeable_object.depth_modifier'), Utility.GetCommandKey('+depth_modifier'))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
-- Command handlers for key mappings
|
-- Command handlers for key mappings
|
||||||
RegisterCommand('+place_object', function()
|
RegisterCommand('+place_object', function()
|
||||||
if state.isPlacing then
|
if state.isPlacing then
|
||||||
@@ -554,15 +563,14 @@ local function placementLoop()
|
|||||||
state.keys.placeObject = false -- Reset the key state
|
state.keys.placeObject = false -- Reset the key state
|
||||||
local canPlace = checkMaterialAndBoundary()
|
local canPlace = checkMaterialAndBoundary()
|
||||||
if canPlace then
|
if canPlace then
|
||||||
Wait(100)
|
|
||||||
local coords = GetEntityCoords(state.currentEntity)
|
local coords = GetEntityCoords(state.currentEntity)
|
||||||
if not state.settings.allowVertical or state.snapToGround then
|
-- if not state.settings.allowVertical or state.snapToGround then
|
||||||
local groundZ, _z = GetGroundZFor_3dCoord(coords.x, coords.y, coords.z + 50, false)
|
-- local groundZ, _z = GetGroundZFor_3dCoord(coords.x, coords.y, coords.z + 50, false)
|
||||||
if groundZ then
|
-- if groundZ then
|
||||||
coords = vector3(coords.x, coords.y, _z)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
-- end
|
||||||
|
-- end
|
||||||
|
coords = vector3(coords.x, coords.y, coords.z - 0.2) -- Adjust Z to ground level
|
||||||
local rotation = GetEntityRotation(state.currentEntity)
|
local rotation = GetEntityRotation(state.currentEntity)
|
||||||
if state.promise then
|
if state.promise then
|
||||||
state.promise:resolve({
|
state.promise:resolve({
|
||||||
@@ -616,15 +624,15 @@ local function placementLoop()
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Show help text for placement controls
|
-- Show help text for placement controls
|
||||||
local placementText = {
|
-- local placementText = {
|
||||||
string.format(locale('placeable_object.place_object_place'), Bridge.Utility.GetCommandKey('+place_object')),
|
-- string.format(locale('placeable_object.place_object_place'), Bridge.Utility.GetCommandKey('+place_object')),
|
||||||
string.format(locale('placeable_object.place_object_cancel'), Bridge.Utility.GetCommandKey('+cancel_placement')),
|
-- string.format(locale('placeable_object.place_object_cancel'), Bridge.Utility.GetCommandKey('+cancel_placement')),
|
||||||
-- string.format(locale('placeable_object.rotate_left'), Bridge.Utility.GetCommandKey('+rotate_left')),
|
-- -- string.format(locale('placeable_object.rotate_left'), Bridge.Utility.GetCommandKey('+rotate_left')),
|
||||||
-- string.format(locale('placeable_object.rotate_right'), Bridge.Utility.GetCommandKey('+rotate_right')),
|
-- -- string.format(locale('placeable_object.rotate_right'), Bridge.Utility.GetCommandKey('+rotate_right')),
|
||||||
string.format(locale('placeable_object.place_object_scroll_up'), Bridge.Utility.GetCommandKey('+scroll_up')),
|
-- string.format(locale('placeable_object.place_object_scroll_up'), Bridge.Utility.GetCommandKey('+scroll_up')),
|
||||||
string.format(locale('placeable_object.place_object_scroll_down'), Bridge.Utility.GetCommandKey('+scroll_down')),
|
-- string.format(locale('placeable_object.place_object_scroll_down'), Bridge.Utility.GetCommandKey('+scroll_down')),
|
||||||
string.format(locale('placeable_object.depth_modifier'), Bridge.Utility.GetCommandKey('+depth_modifier'))
|
-- string.format(locale('placeable_object.depth_modifier'), Bridge.Utility.GetCommandKey('+depth_modifier'))
|
||||||
}
|
-- }
|
||||||
Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText))
|
Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText))
|
||||||
|
|
||||||
-- -- Draw entity bounding box
|
-- -- Draw entity bounding box
|
||||||
@@ -644,18 +652,24 @@ end
|
|||||||
---@param model - Model name or hash
|
---@param model - Model name or hash
|
||||||
---@param settings - Configuration table:
|
---@param settings - Configuration table:
|
||||||
--[[
|
--[[
|
||||||
depth (3.0): Starting distance from player,
|
{
|
||||||
allowVertical (false): Enable height controls,
|
depth = 3.0, -- Starting distance from player
|
||||||
allowMovement (false): Enable WASD mode,
|
allowVertical = false, -- Enable height controls (Q/E, Alt to toggle ground snap)
|
||||||
disableSphere (false): Hide position indicator,
|
allowMovement = false, -- Enable WASD movement mode
|
||||||
boundary: Area restriction {min = vector3(), max = vector3()},
|
allowNormal = false, -- Allow switching back to normal mode from movement
|
||||||
allowedMats: Surface materials {"concrete", "grass"},
|
disableSphere = false, -- Hide position indicator sphere
|
||||||
depthStep (0.1): Step size for depth adjustment,
|
drawBoundary = false, -- Draw boundary box/polygon
|
||||||
rotationStep (0.5): Step size for rotation,
|
drawInBoundary = false, -- Draw entity outline (green/red) based on boundary/material
|
||||||
heightStep (0.5): Step size for height adjustment,
|
boundary = nil, -- Area restriction (box: {min=vector3(), max=vector3()}, polygon: {points={...}, minZ, maxZ})
|
||||||
movementStep (0.1): Step size for normal movement,
|
allowedMats = nil, -- Allowed surface materials (e.g. {"concrete", "grass"})
|
||||||
movementStepFast (0.5): Step size for fast movement (with shift),
|
customCheck = nil, -- Custom function(pos, entity, settings) -> bool
|
||||||
maxDepth (50.0): Maximum distance from player,
|
depthStep = 0.1, -- Step size for depth adjustment (scroll + modifier)
|
||||||
|
rotationStep = 0.5, -- Step size for rotation (scroll)
|
||||||
|
heightStep = 0.5, -- Step size for height adjustment (Q/E)
|
||||||
|
movementStep = 0.1, -- Step size for WASD movement
|
||||||
|
movementStepFast = 0.5, -- Step size for fast movement (WASD + Shift)
|
||||||
|
maxDepth = 5.0, -- Maximum distance from player
|
||||||
|
}
|
||||||
--]]
|
--]]
|
||||||
---@returns Promise with: {entity, coords, heading, placed, cancelled}
|
---@returns Promise with: {entity, coords, heading, placed, cancelled}
|
||||||
--[[
|
--[[
|
||||||
@@ -724,15 +738,6 @@ function PlaceableObject.Create(model, settings)
|
|||||||
state.isPlacing = true
|
state.isPlacing = true
|
||||||
|
|
||||||
-- Show help text for placement controls
|
-- Show help text for placement controls
|
||||||
local placementText = {
|
|
||||||
string.format(locale('placeable_object.place_object_place'), Bridge.Utility.GetCommandKey('+place_object')),
|
|
||||||
string.format(locale('placeable_object.place_object_cancel'), Bridge.Utility.GetCommandKey('+cancel_placement')),
|
|
||||||
-- string.format(locale('placeable_object.rotate_left'), Bridge.Utility.GetCommandKey('+rotate_left')),
|
|
||||||
-- string.format(locale('placeable_object.rotate_right'), Bridge.Utility.GetCommandKey('+rotate_right')),
|
|
||||||
string.format(locale('placeable_object.place_object_scroll_up'), Bridge.Utility.GetCommandKey('+scroll_up')),
|
|
||||||
string.format(locale('placeable_object.place_object_scroll_down'), Bridge.Utility.GetCommandKey('+scroll_down')),
|
|
||||||
string.format(locale('placeable_object.depth_modifier'), Bridge.Utility.GetCommandKey('+depth_modifier'))
|
|
||||||
}
|
|
||||||
Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText))
|
Bridge.Notify.ShowHelpText(type(placementText) == 'table' and table.concat(placementText))
|
||||||
|
|
||||||
placementLoop()
|
placementLoop()
|
||||||
|
|||||||
+223
-223
@@ -1,255 +1,255 @@
|
|||||||
-- Grid-based point system
|
-- -- Grid-based point system
|
||||||
Point = {}
|
-- Point = {}
|
||||||
local ActivePoints = {}
|
-- local ActivePoints = {}
|
||||||
local GridCells = {}
|
-- local GridCells = {}
|
||||||
local LoopStarted = false
|
-- local LoopStarted = false
|
||||||
local insidePoints = {}
|
-- local insidePoints = {}
|
||||||
local data = {} -- 👈 Move this outside the function
|
-- local data = {} -- 👈 Move this outside the function
|
||||||
|
|
||||||
-- Grid configuration
|
-- -- Grid configuration
|
||||||
local GRID_SIZE = 500.0 -- Size of each grid cell
|
-- local GRID_SIZE = 500.0 -- Size of each grid cell
|
||||||
local CELL_BUFFER = 1 -- Number of adjacent cells to check
|
-- local CELL_BUFFER = 1 -- Number of adjacent cells to check
|
||||||
|
|
||||||
-- Consider adding these optimizations
|
-- -- Consider adding these optimizations
|
||||||
local ADAPTIVE_WAIT = true -- Adjust wait time based on player speed
|
-- local ADAPTIVE_WAIT = false -- Adjust wait time based on player speed
|
||||||
|
|
||||||
---This is an internal function, do not call this externally
|
-- ---This is an internal function, do not call this externally
|
||||||
function Point.GetCellKey(coords)
|
-- function Point.GetCellKey(coords)
|
||||||
local cellX = math.floor(coords.x / GRID_SIZE)
|
-- local cellX = math.floor(coords.x / GRID_SIZE)
|
||||||
local cellY = math.floor(coords.y / GRID_SIZE)
|
-- local cellY = math.floor(coords.y / GRID_SIZE)
|
||||||
return cellX .. ":" .. cellY
|
-- return cellX .. ":" .. cellY
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---This is an internal function, do not call this externally
|
-- ---This is an internal function, do not call this externally
|
||||||
function Point.RegisterInGrid(point)
|
-- function Point.RegisterInGrid(point)
|
||||||
local cellKey = Point.GetCellKey(point.coords)
|
-- local cellKey = Point.GetCellKey(point.coords)
|
||||||
|
|
||||||
-- Initialize cell if it doesn't exist
|
-- -- Initialize cell if it doesn't exist
|
||||||
GridCells[cellKey] = GridCells[cellKey] or {
|
-- GridCells[cellKey] = GridCells[cellKey] or {
|
||||||
points = {},
|
-- points = {},
|
||||||
count = 0
|
-- count = 0
|
||||||
}
|
-- }
|
||||||
|
|
||||||
-- Add point to cell
|
-- -- Add point to cell
|
||||||
GridCells[cellKey].points[point.id] = point
|
-- GridCells[cellKey].points[point.id] = point
|
||||||
GridCells[cellKey].count = GridCells[cellKey].count + 1
|
-- GridCells[cellKey].count = GridCells[cellKey].count + 1
|
||||||
|
|
||||||
-- Store cell reference in point
|
-- -- Store cell reference in point
|
||||||
point.cellKey = cellKey
|
-- point.cellKey = cellKey
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---This is an internal function, do not call this externally
|
-- ---This is an internal function, do not call this externally
|
||||||
function Point.UpdateInGrid(point, oldCellKey)
|
-- function Point.UpdateInGrid(point, oldCellKey)
|
||||||
-- Remove from old cell if cell key changed
|
-- -- Remove from old cell if cell key changed
|
||||||
if oldCellKey and oldCellKey ~= point.cellKey then
|
-- if oldCellKey and oldCellKey ~= point.cellKey then
|
||||||
if GridCells[oldCellKey] and GridCells[oldCellKey].points[point.id] then
|
-- if GridCells[oldCellKey] and GridCells[oldCellKey].points[point.id] then
|
||||||
GridCells[oldCellKey].points[point.id] = nil
|
-- GridCells[oldCellKey].points[point.id] = nil
|
||||||
GridCells[oldCellKey].count = GridCells[oldCellKey].count - 1
|
-- GridCells[oldCellKey].count = GridCells[oldCellKey].count - 1
|
||||||
|
|
||||||
-- Clean up empty cells
|
-- -- Clean up empty cells
|
||||||
if GridCells[oldCellKey].count <= 0 then
|
-- if GridCells[oldCellKey].count <= 0 then
|
||||||
GridCells[oldCellKey] = nil
|
-- GridCells[oldCellKey] = nil
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
-- Add to new cell
|
-- -- Add to new cell
|
||||||
Point.RegisterInGrid(point)
|
-- Point.RegisterInGrid(point)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---Gets nearby cells based on the coords
|
-- ---Gets nearby cells based on the coords
|
||||||
---@param coords table
|
-- ---@param coords table
|
||||||
---@return table
|
-- ---@return table
|
||||||
function Point.GetNearbyCells(coords)
|
-- function Point.GetNearbyCells(coords)
|
||||||
local cellX = math.floor(coords.x / GRID_SIZE)
|
-- local cellX = math.floor(coords.x / GRID_SIZE)
|
||||||
local cellY = math.floor(coords.y / GRID_SIZE)
|
-- local cellY = math.floor(coords.y / GRID_SIZE)
|
||||||
local nearbyCells = {}
|
-- local nearbyCells = {}
|
||||||
|
|
||||||
-- Get current and adjacent cells
|
-- -- Get current and adjacent cells
|
||||||
for x = cellX - CELL_BUFFER, cellX + CELL_BUFFER do
|
-- for x = cellX - CELL_BUFFER, cellX + CELL_BUFFER do
|
||||||
for y = cellY - CELL_BUFFER, cellY + CELL_BUFFER do
|
-- for y = cellY - CELL_BUFFER, cellY + CELL_BUFFER do
|
||||||
local key = x .. ":" .. y
|
-- local key = x .. ":" .. y
|
||||||
if GridCells[key] then
|
-- if GridCells[key] then
|
||||||
table.insert(nearbyCells, key)
|
-- table.insert(nearbyCells, key)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
return nearbyCells
|
-- return nearbyCells
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---Returns all points in the same cell as the given point
|
-- ---Returns all points in the same cell as the given point
|
||||||
---This will require you to pass the point object
|
-- ---This will require you to pass the point object
|
||||||
---@param point table
|
-- ---@param point table
|
||||||
---@return table
|
-- ---@return table
|
||||||
function Point.CheckPointsInSameCell(point)
|
-- function Point.CheckPointsInSameCell(point)
|
||||||
local cellKey = point.cellKey
|
-- local cellKey = point.cellKey
|
||||||
if not GridCells[cellKey] then return {} end
|
-- if not GridCells[cellKey] then return {} end
|
||||||
|
|
||||||
local nearbyPoints = {}
|
-- local nearbyPoints = {}
|
||||||
for id, otherPoint in pairs(GridCells[cellKey].points) do
|
-- for id, otherPoint in pairs(GridCells[cellKey].points) do
|
||||||
if id ~= point.id then
|
-- if id ~= point.id then
|
||||||
local distance = #(point.coords - otherPoint.coords)
|
-- local distance = #(point.coords - otherPoint.coords)
|
||||||
if distance < (point.distance + otherPoint.distance) then
|
-- if distance < (point.distance + otherPoint.distance) then
|
||||||
nearbyPoints[id] = otherPoint
|
-- nearbyPoints[id] = otherPoint
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
return nearbyPoints
|
-- return nearbyPoints
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---Internal function that starts the loop. Do not call this function directly.
|
-- ---Internal function that starts the loop. Do not call this function directly.
|
||||||
function Point.StartLoop()
|
-- function Point.StartLoop()
|
||||||
if LoopStarted then return false end
|
-- if LoopStarted then return false end
|
||||||
LoopStarted = true
|
-- LoopStarted = true
|
||||||
-- Remove the "local data = {}" line from here
|
-- -- Remove the "local data = {}" line from here
|
||||||
CreateThread(function()
|
-- CreateThread(function()
|
||||||
while LoopStarted do
|
-- while LoopStarted do
|
||||||
local playerPed = PlayerPedId()
|
-- local playerPed = PlayerPedId()
|
||||||
while playerPed == -1 do
|
-- while playerPed == -1 do
|
||||||
Wait(100)
|
-- Wait(100)
|
||||||
playerPed = PlayerPedId()
|
-- playerPed = PlayerPedId()
|
||||||
end
|
-- end
|
||||||
local playerCoords = GetEntityCoords(playerPed)
|
-- local playerCoords = GetEntityCoords(playerPed)
|
||||||
local targetsExist = false
|
-- local targetsExist = false
|
||||||
local playerCellKey = Point.GetCellKey(playerCoords)
|
-- local playerCellKey = Point.GetCellKey(playerCoords)
|
||||||
local nearbyCells = Point.GetNearbyCells(playerCoords)
|
-- local nearbyCells = Point.GetNearbyCells(playerCoords)
|
||||||
|
|
||||||
local playerSpeed = GetEntitySpeed(playerPed)
|
-- local playerSpeed = GetEntitySpeed(playerPed)
|
||||||
local maxWeight = 1000
|
-- local maxWeight = 1000
|
||||||
local waitTime = ADAPTIVE_WAIT and math.max(maxWeight/10, maxWeight - playerSpeed * maxWeight/10) or maxWeight
|
-- local waitTime = ADAPTIVE_WAIT and math.max(maxWeight/10, maxWeight - playerSpeed * maxWeight/10) or maxWeight
|
||||||
-- Process only points in nearby cells
|
-- -- Process only points in nearby cells
|
||||||
for _, cellKey in ipairs(nearbyCells) do
|
-- for _, cellKey in ipairs(nearbyCells) do
|
||||||
if GridCells[cellKey] then
|
-- if GridCells[cellKey] then
|
||||||
for id, point in pairs(GridCells[cellKey].points) do
|
-- for id, point in pairs(GridCells[cellKey].points) do
|
||||||
targetsExist = true
|
-- targetsExist = true
|
||||||
|
|
||||||
-- Update entity position if needed
|
-- -- Update entity position if needed
|
||||||
local oldCellKey = point.cellKey
|
-- local oldCellKey = point.cellKey
|
||||||
if point.isEntity then
|
-- if point.isEntity then
|
||||||
point.coords = GetEntityCoords(point.target)
|
-- point.coords = GetEntityCoords(point.target)
|
||||||
point.cellKey = Point.GetCellKey(point.coords)
|
-- point.cellKey = Point.GetCellKey(point.coords)
|
||||||
Point.UpdateInGrid(point, oldCellKey)
|
-- Point.UpdateInGrid(point, oldCellKey)
|
||||||
end
|
-- end
|
||||||
local coords = point.coords and vector3(point.coords.x, point.coords.y, point.coords.z) or vector3(0, 0, 0)
|
-- local coords = point.coords and vector3(point.coords.x, point.coords.y, point.coords.z) or vector3(0, 0, 0)
|
||||||
local distance = #(playerCoords - coords)
|
-- local distance = #(playerCoords - coords)
|
||||||
--local distance = #(playerCoords - point.coords)
|
-- --local distance = #(playerCoords - point.coords)
|
||||||
|
|
||||||
-- Check if player entered/exited the point
|
-- -- Check if player entered/exited the point
|
||||||
if distance < point.distance then
|
-- if distance < point.distance then
|
||||||
if not point.inside then
|
-- if not point.inside then
|
||||||
point.inside = true
|
-- point.inside = true
|
||||||
data[point.id] = data[point.id] or point.args or {}
|
-- data[point.id] = data[point.id] or point.args or {}
|
||||||
data[point.id] = point.onEnter(point, data[point.id])
|
-- data[point.id] = point.onEnter(point, data[point.id])
|
||||||
insidePoints[point.id] = point
|
-- insidePoints[point.id] = point
|
||||||
end
|
-- end
|
||||||
-- Modified main loop exit handler
|
-- -- Modified main loop exit handler
|
||||||
elseif point.inside then
|
-- elseif point.inside then
|
||||||
point.inside = false
|
-- point.inside = false
|
||||||
data[point.id] = data[point.id] or point.args or {}
|
-- data[point.id] = data[point.id] or point.args or {}
|
||||||
local result = point.onExit(point, data[point.id])
|
-- local result = point.onExit(point, data[point.id])
|
||||||
data[point.id] = result ~= nil and result or data[point.id] -- ← Use consistent fallback
|
-- data[point.id] = result ~= nil and result or data[point.id] -- ← Use consistent fallback
|
||||||
point.args = data[point.id] -- ← Update point.args to match data[point.id]
|
-- point.args = data[point.id] -- ← Update point.args to match data[point.id]
|
||||||
insidePoints[point.id] = nil
|
-- insidePoints[point.id] = nil
|
||||||
end
|
-- end
|
||||||
|
|
||||||
if point.onNearby then
|
-- -- if point.onNearby then
|
||||||
point.onNearby(GridCells[cellKey]?.points, waitTime)
|
-- -- point.onNearby(GridCells[cellKey]?.points, waitTime)
|
||||||
end
|
-- -- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
for id, insidepoint in pairs(insidePoints) do
|
-- for id, insidepoint in pairs(insidePoints) do
|
||||||
local pos = insidepoint.coords and vector3(insidepoint.coords.x, insidepoint.coords.y, insidepoint.coords.z) or vector3(0, 0, 0)
|
-- local pos = insidepoint.coords and vector3(insidepoint.coords.x, insidepoint.coords.y, insidepoint.coords.z) or vector3(0, 0, 0)
|
||||||
local dist = #(playerCoords - pos)
|
-- local dist = #(playerCoords - pos)
|
||||||
if dist > insidepoint.distance then
|
-- if dist > insidepoint.distance then
|
||||||
insidepoint.inside = false
|
-- insidepoint.inside = false
|
||||||
data[insidepoint.id] = data[insidepoint.id] or insidepoint.args or {}
|
-- data[insidepoint.id] = data[insidepoint.id] or insidepoint.args or {}
|
||||||
local result = insidepoint.onExit(insidepoint, data[insidepoint.id])
|
-- local result = insidepoint.onExit(insidepoint, data[insidepoint.id])
|
||||||
data[insidepoint.id] = result ~= nil and result or data[insidepoint.id]
|
-- data[insidepoint.id] = result ~= nil and result or data[insidepoint.id]
|
||||||
insidepoint.args = data[insidepoint.id] -- ← Keep data in sync
|
-- insidepoint.args = data[insidepoint.id] -- ← Keep data in sync
|
||||||
insidePoints[insidepoint.id] = nil
|
-- insidePoints[insidepoint.id] = nil
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
Wait(waitTime) -- Faster updates when moving quickly
|
-- Wait(waitTime) -- Faster updates when moving quickly
|
||||||
end
|
-- end
|
||||||
end)
|
-- end)
|
||||||
return true
|
-- return true
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---Create a point based on a vector or entityID
|
-- ---Create a point based on a vector or entityID
|
||||||
---@param id string
|
-- ---@param id string
|
||||||
---@param target number || vector3
|
-- ---@param target number || vector3
|
||||||
---@param distance number
|
-- ---@param distance number
|
||||||
---@param _onEnter function
|
-- ---@param _onEnter function
|
||||||
---@param _onExit function
|
-- ---@param _onExit function
|
||||||
---@param _onNearby function
|
-- ---@param _onNearby function
|
||||||
---@param data self
|
-- ---@param data self
|
||||||
---@return table
|
-- ---@return table
|
||||||
function Point.Register(id, target, distance, args, _onEnter, _onExit, _onNearby)
|
-- function Point.Register(id, target, distance, args, _onEnter, _onExit, _onNearby)
|
||||||
local isEntity = type(target) == "number"
|
-- local isEntity = type(target) == "number"
|
||||||
local coords = isEntity and GetEntityCoords(target) or target
|
-- local coords = isEntity and GetEntityCoords(target) or target
|
||||||
|
|
||||||
local self = {}
|
-- local self = {}
|
||||||
self.id = id
|
-- self.id = id
|
||||||
self.target = target -- Store entity ID or Vector3
|
-- self.target = target -- Store entity ID or Vector3
|
||||||
self.isEntity = isEntity
|
-- self.isEntity = isEntity
|
||||||
self.coords = coords
|
-- self.coords = coords
|
||||||
self.distance = distance
|
-- self.distance = distance
|
||||||
self.onEnter = _onEnter or function() end
|
-- self.onEnter = _onEnter or function() end
|
||||||
self.onExit = _onExit or function() end
|
-- self.onExit = _onExit or function() end
|
||||||
self.onNearby = _onNearby or function() end
|
-- self.onNearby = _onNearby or function() end
|
||||||
self.inside = false -- Track if player is inside
|
-- self.inside = false -- Track if player is inside
|
||||||
self.args = args or {}
|
-- self.args = args or {}
|
||||||
|
|
||||||
ActivePoints[id] = self
|
-- ActivePoints[id] = self
|
||||||
Point.RegisterInGrid(self)
|
-- Point.RegisterInGrid(self)
|
||||||
Point.StartLoop()
|
-- Point.StartLoop()
|
||||||
return self
|
-- return self
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---Remove an exsisting point by its id
|
-- ---Remove an exsisting point by its id
|
||||||
---@param id string
|
-- ---@param id string
|
||||||
function Point.Remove(id)
|
-- function Point.Remove(id)
|
||||||
local point = ActivePoints[id]
|
-- local point = ActivePoints[id]
|
||||||
if point then
|
-- if point then
|
||||||
local cellKey = point.cellKey
|
-- local cellKey = point.cellKey
|
||||||
if GridCells[cellKey] and GridCells[cellKey].points[id] then
|
-- if GridCells[cellKey] and GridCells[cellKey].points[id] then
|
||||||
GridCells[cellKey].points[id] = nil
|
-- GridCells[cellKey].points[id] = nil
|
||||||
GridCells[cellKey].count = GridCells[cellKey].count - 1
|
-- GridCells[cellKey].count = GridCells[cellKey].count - 1
|
||||||
|
|
||||||
if GridCells[cellKey].count <= 0 then
|
-- if GridCells[cellKey].count <= 0 then
|
||||||
GridCells[cellKey] = nil
|
-- GridCells[cellKey] = nil
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
ActivePoints[id] = nil
|
-- ActivePoints[id] = nil
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---Returnes a point by its id
|
-- ---Returnes a point by its id
|
||||||
---@param id string
|
-- ---@param id string
|
||||||
---@return table
|
-- ---@return table
|
||||||
function Point.Get(id)
|
-- function Point.Get(id)
|
||||||
return ActivePoints[id]
|
-- return ActivePoints[id]
|
||||||
end
|
-- end
|
||||||
|
|
||||||
function Point.UpdateCoords(id, coords)
|
-- function Point.UpdateCoords(id, coords)
|
||||||
local point = ActivePoints[id]
|
-- local point = ActivePoints[id]
|
||||||
if point then
|
-- if point then
|
||||||
point.coords = coords
|
-- point.coords = coords
|
||||||
local oldCellKey = point.cellKey
|
-- local oldCellKey = point.cellKey
|
||||||
point.cellKey = Point.GetCellKey(coords)
|
-- point.cellKey = Point.GetCellKey(coords)
|
||||||
Point.UpdateInGrid(point, oldCellKey)
|
-- Point.UpdateInGrid(point, oldCellKey)
|
||||||
end
|
-- end
|
||||||
end
|
-- end
|
||||||
|
|
||||||
---Returns all points
|
-- ---Returns all points
|
||||||
---@return table
|
-- ---@return table
|
||||||
function Point.GetAll()
|
-- function Point.GetAll()
|
||||||
return ActivePoints
|
-- return ActivePoints
|
||||||
end
|
-- end
|
||||||
|
|
||||||
return Point
|
-- return Point
|
||||||
@@ -0,0 +1,143 @@
|
|||||||
|
|
||||||
|
local GRIDE_SIZE_X = 8968.83 / 2
|
||||||
|
local GRIDE_SIZE_Y = 126200.40 / 2
|
||||||
|
local CELL_SIZE = 500
|
||||||
|
|
||||||
|
local Grid = {}
|
||||||
|
Grid.Generated = false
|
||||||
|
local Grids = {}
|
||||||
|
Point = {}
|
||||||
|
Point.All = {}
|
||||||
|
|
||||||
|
function Grid.Generate()
|
||||||
|
if Grid.Generated then return end
|
||||||
|
Grid.Generated = true
|
||||||
|
local numOfCellsX = math.ceil(GRIDE_SIZE_X / CELL_SIZE)
|
||||||
|
local numOfCellsY = math.ceil(GRIDE_SIZE_Y / CELL_SIZE)
|
||||||
|
|
||||||
|
for x = -numOfCellsX, numOfCellsX do
|
||||||
|
Grids[x] = {}
|
||||||
|
for y = -numOfCellsY, numOfCellsY do
|
||||||
|
Grids[x][y] = {}
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function Grid.GetCellId(coords)
|
||||||
|
local cellX = math.floor(coords.x / CELL_SIZE) + 1
|
||||||
|
local cellY = math.floor(coords.y / CELL_SIZE) + 1
|
||||||
|
return string.format("%d_%d", cellX, cellY)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Grid.GetCellByCoords(coords)
|
||||||
|
local cellX = math.floor(coords.x / CELL_SIZE) + 1
|
||||||
|
local cellY = math.floor(coords.y / CELL_SIZE) + 1
|
||||||
|
return Grids[cellX][cellY]
|
||||||
|
end
|
||||||
|
|
||||||
|
local Points = {}
|
||||||
|
Points.Started = false
|
||||||
|
function Point.StartLoop()
|
||||||
|
if Points.Started then return end
|
||||||
|
Points.Started = true
|
||||||
|
|
||||||
|
CreateThread(function()
|
||||||
|
while Points.Started do
|
||||||
|
local playerPed = PlayerPedId()
|
||||||
|
if playerPed ~= -1 then
|
||||||
|
local coords = GetEntityCoords(playerPed)
|
||||||
|
local cell = Grid.GetCellByCoords(coords)
|
||||||
|
for _, point in pairs(cell or {}) do
|
||||||
|
if point.isEntity then
|
||||||
|
local entity = point.target
|
||||||
|
if DoesEntityExist(entity) then
|
||||||
|
local entityCoords = GetEntityCoords(entity)
|
||||||
|
local distance = #(coords - entityCoords)
|
||||||
|
if distance < point.distance then
|
||||||
|
if not point.inside then
|
||||||
|
point.inside = true
|
||||||
|
point.args = point?.onEnter(point, point.args) or point.args
|
||||||
|
end
|
||||||
|
elseif point.inside then
|
||||||
|
point.inside = false
|
||||||
|
point.args = point?.onExit(point, point.args) or point.args
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
local distance = #(vector3(coords.x, coords.y, coords.z) - vector3(point.coords.x, point.coords.y, point.coords.z))
|
||||||
|
if distance < point.distance then
|
||||||
|
if not point.inside then
|
||||||
|
point.inside = true
|
||||||
|
point.args = point?.onEnter(point, point.args) or point.args
|
||||||
|
end
|
||||||
|
elseif point.inside then
|
||||||
|
point.inside = false
|
||||||
|
point.args = point?.onExit(point, point.args) or point.args
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
Wait(1000)
|
||||||
|
end
|
||||||
|
end)
|
||||||
|
end
|
||||||
|
|
||||||
|
function Point.Register(id, target, distance, args, _onEnter, _onExit)
|
||||||
|
local isEntity = type(target) == "number"
|
||||||
|
local coords = isEntity and GetEntityCoords(target) or target
|
||||||
|
Grid.Generate()
|
||||||
|
local self = {}
|
||||||
|
self.id = id
|
||||||
|
self.target = target -- Store entity ID or Vector3
|
||||||
|
self.isEntity = isEntity
|
||||||
|
self.coords = coords
|
||||||
|
self.distance = distance
|
||||||
|
self.onEnter = _onEnter or function() end
|
||||||
|
self.onExit = _onExit or function() end
|
||||||
|
self.inside = false -- Track if player is inside
|
||||||
|
self.args = args or {}
|
||||||
|
local grid = Grid.GetCellByCoords(coords)
|
||||||
|
grid[id] = self
|
||||||
|
Point.All[id] = self
|
||||||
|
Point.StartLoop()
|
||||||
|
return self
|
||||||
|
end
|
||||||
|
|
||||||
|
function Point.Remove(id)
|
||||||
|
local point = Point.All[id]
|
||||||
|
if not point then return false end
|
||||||
|
|
||||||
|
-- Remove from grid
|
||||||
|
local grid = Grid.GetCellByCoords(point.coords)
|
||||||
|
if grid then
|
||||||
|
grid[point.id] = nil
|
||||||
|
end
|
||||||
|
|
||||||
|
Point.All[id] = nil
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function Point.Get(id)
|
||||||
|
return Point.All[id]
|
||||||
|
end
|
||||||
|
|
||||||
|
function Point.UpdateCoords(id, coords)
|
||||||
|
local point = Point.All[id]
|
||||||
|
if not point then return end
|
||||||
|
|
||||||
|
local newGrid = Grid.GetCellByCoords(coords)
|
||||||
|
if not newGrid or newGrid[point.id] then return end
|
||||||
|
local oldGrid = Grid.GetCellByCoords(point.coords)
|
||||||
|
if oldGrid then
|
||||||
|
oldGrid[point.id] = nil
|
||||||
|
end
|
||||||
|
point.coords = coords
|
||||||
|
newGrid[point.id] = point
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
|
||||||
|
function Point.GetAll()
|
||||||
|
return Point.All
|
||||||
|
end
|
||||||
|
|
||||||
|
return Point
|
||||||
+83
-132
@@ -1,11 +1,9 @@
|
|||||||
---@class Utility
|
|
||||||
Utility = Utility or {}
|
Utility = Utility or {}
|
||||||
local blipIDs = {}
|
local blipIDs = {}
|
||||||
local spawnedPeds = {}
|
local spawnedPeds = {}
|
||||||
|
|
||||||
Locales = Locales or Require('modules/locales/shared.lua')
|
Locales = Locales or Require('modules/locales/shared.lua')
|
||||||
|
Point = Point or Require('lib/points/client/pointsv2.lua')
|
||||||
-- === Local Helpers ===
|
|
||||||
|
|
||||||
---Get the hash of a model (string or number)
|
---Get the hash of a model (string or number)
|
||||||
---@param model string|number
|
---@param model string|number
|
||||||
@@ -22,6 +20,7 @@ end
|
|||||||
---@return boolean, number
|
---@return boolean, number
|
||||||
local function ensureModelLoaded(model)
|
local function ensureModelLoaded(model)
|
||||||
local hash = getModelHash(model)
|
local hash = getModelHash(model)
|
||||||
|
if HasModelLoaded(hash) then return true, hash end
|
||||||
if not IsModelValid(hash) and not IsModelInCdimage(hash) then return false, hash end
|
if not IsModelValid(hash) and not IsModelInCdimage(hash) then return false, hash end
|
||||||
RequestModel(hash)
|
RequestModel(hash)
|
||||||
local count = 0
|
local count = 0
|
||||||
@@ -32,84 +31,6 @@ local function ensureModelLoaded(model)
|
|||||||
return HasModelLoaded(hash), hash
|
return HasModelLoaded(hash), hash
|
||||||
end
|
end
|
||||||
|
|
||||||
---Add a text entry if possible
|
|
||||||
---@param key string
|
|
||||||
---@param text string
|
|
||||||
local function addTextEntryOnce(key, text)
|
|
||||||
if not AddTextEntry then return end
|
|
||||||
AddTextEntry(key, text)
|
|
||||||
end
|
|
||||||
|
|
||||||
---Create a blip safely and store its reference
|
|
||||||
---@param coords vector3
|
|
||||||
---@param sprite number
|
|
||||||
---@param color number
|
|
||||||
---@param scale number
|
|
||||||
---@param label string
|
|
||||||
---@param shortRange boolean
|
|
||||||
---@param displayType number
|
|
||||||
---@return number
|
|
||||||
local function safeAddBlip(coords, sprite, color, scale, label, shortRange, displayType)
|
|
||||||
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
|
|
||||||
SetBlipSprite(blip, sprite or 8)
|
|
||||||
SetBlipColour(blip, color or 3)
|
|
||||||
SetBlipScale(blip, scale or 0.8)
|
|
||||||
SetBlipDisplay(blip, displayType or 2)
|
|
||||||
SetBlipAsShortRange(blip, shortRange)
|
|
||||||
addTextEntryOnce(label, label)
|
|
||||||
BeginTextCommandSetBlipName(label)
|
|
||||||
EndTextCommandSetBlipName(blip)
|
|
||||||
table.insert(blipIDs, blip)
|
|
||||||
return blip
|
|
||||||
end
|
|
||||||
|
|
||||||
---Create a entiyty blip safely and store its reference
|
|
||||||
---@param entity number
|
|
||||||
---@param sprite number
|
|
||||||
---@param color number
|
|
||||||
---@param scale number
|
|
||||||
---@param label string
|
|
||||||
---@param shortRange boolean
|
|
||||||
---@param displayType number
|
|
||||||
---@return number
|
|
||||||
local function safeAddEntityBlip(entity, sprite, color, scale, label, shortRange, displayType)
|
|
||||||
local blip = AddBlipForEntity(entity)
|
|
||||||
SetBlipSprite(blip, sprite or 8)
|
|
||||||
SetBlipColour(blip, color or 3)
|
|
||||||
SetBlipScale(blip, scale or 0.8)
|
|
||||||
SetBlipDisplay(blip, displayType or 2)
|
|
||||||
SetBlipAsShortRange(blip, shortRange)
|
|
||||||
ShowHeadingIndicatorOnBlip(blip, true)
|
|
||||||
addTextEntryOnce(label, label)
|
|
||||||
BeginTextCommandSetBlipName(label)
|
|
||||||
EndTextCommandSetBlipName(blip)
|
|
||||||
table.insert(blipIDs, blip)
|
|
||||||
return blip
|
|
||||||
end
|
|
||||||
|
|
||||||
---Remove a blip safely from the stored list
|
|
||||||
---@param blip number
|
|
||||||
---@return boolean
|
|
||||||
local function safeRemoveBlip(blip)
|
|
||||||
for i, storedBlip in ipairs(blipIDs) do
|
|
||||||
if storedBlip == blip then
|
|
||||||
RemoveBlip(storedBlip)
|
|
||||||
table.remove(blipIDs, i)
|
|
||||||
return true
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
|
|
||||||
---Add a text entry if possible (shortcut)
|
|
||||||
---@param text string
|
|
||||||
local function safeAddTextEntry(text)
|
|
||||||
if not AddTextEntry then return end
|
|
||||||
AddTextEntry(text, text)
|
|
||||||
end
|
|
||||||
|
|
||||||
-- === Public Utility Functions ===
|
|
||||||
|
|
||||||
---Create a prop with the given model and coordinates
|
---Create a prop with the given model and coordinates
|
||||||
---@param model string|number
|
---@param model string|number
|
||||||
---@param coords vector3
|
---@param coords vector3
|
||||||
@@ -147,11 +68,7 @@ function Utility.CreateVehicle(model, coords, heading, networked)
|
|||||||
SetVehicleNeedsToBeHotwired(vehicle, false)
|
SetVehicleNeedsToBeHotwired(vehicle, false)
|
||||||
SetVehRadioStation(vehicle, "OFF")
|
SetVehRadioStation(vehicle, "OFF")
|
||||||
SetModelAsNoLongerNeeded(hash)
|
SetModelAsNoLongerNeeded(hash)
|
||||||
return vehicle, {
|
return vehicle, {networkid = NetworkGetNetworkIdFromEntity(vehicle) or 0,coords = GetEntityCoords(vehicle),heading = GetEntityHeading(vehicle),}
|
||||||
networkid = NetworkGetNetworkIdFromEntity(vehicle) or 0,
|
|
||||||
coords = GetEntityCoords(vehicle),
|
|
||||||
heading = GetEntityHeading(vehicle),
|
|
||||||
}
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Create a ped with the given model and coordinates
|
---Create a ped with the given model and coordinates
|
||||||
@@ -166,7 +83,7 @@ function Utility.CreatePed(model, coords, heading, networked, settings)
|
|||||||
if not loaded then return nil, Prints and Prints.Error and Prints.Error("Model Has Not Loaded") end
|
if not loaded then return nil, Prints and Prints.Error and Prints.Error("Model Has Not Loaded") 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)
|
||||||
table.insert(spawnedPeds, spawnedEntity)
|
spawnedPeds[tostring(spawnedEntity)] = true
|
||||||
return spawnedEntity
|
return spawnedEntity
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -174,7 +91,7 @@ end
|
|||||||
---@param text string
|
---@param text string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Utility.StartBusySpinner(text)
|
function Utility.StartBusySpinner(text)
|
||||||
safeAddTextEntry(text)
|
AddTextEntry(text, text)
|
||||||
BeginTextCommandBusyString(text)
|
BeginTextCommandBusyString(text)
|
||||||
AddTextComponentSubstringPlayerName(text)
|
AddTextComponentSubstringPlayerName(text)
|
||||||
EndTextCommandBusyString(0)
|
EndTextCommandBusyString(0)
|
||||||
@@ -201,7 +118,17 @@ end
|
|||||||
---@param displayType number
|
---@param displayType number
|
||||||
---@return number
|
---@return number
|
||||||
function Utility.CreateBlip(coords, sprite, color, scale, label, shortRange, displayType)
|
function Utility.CreateBlip(coords, sprite, color, scale, label, shortRange, displayType)
|
||||||
return safeAddBlip(coords, sprite, color, scale, label, shortRange, displayType)
|
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
|
||||||
|
SetBlipSprite(blip, sprite or 8)
|
||||||
|
SetBlipColour(blip, color or 3)
|
||||||
|
SetBlipScale(blip, scale or 0.8)
|
||||||
|
SetBlipDisplay(blip, displayType or 2)
|
||||||
|
SetBlipAsShortRange(blip, shortRange)
|
||||||
|
AddTextEntry(label, label)
|
||||||
|
BeginTextCommandSetBlipName(label)
|
||||||
|
EndTextCommandSetBlipName(blip)
|
||||||
|
blipIDs[tostring(blip)] = blip
|
||||||
|
return blip
|
||||||
end
|
end
|
||||||
|
|
||||||
---Create a blip on the provided entity
|
---Create a blip on the provided entity
|
||||||
@@ -214,28 +141,42 @@ end
|
|||||||
---@param displayType number
|
---@param displayType number
|
||||||
---@return number
|
---@return number
|
||||||
function Utility.CreateEntityBlip(entity, sprite, color, scale, label, shortRange, displayType)
|
function Utility.CreateEntityBlip(entity, sprite, color, scale, label, shortRange, displayType)
|
||||||
return safeAddEntityBlip(entity, sprite, color, scale, label, shortRange, displayType)
|
local blip = AddBlipForEntity(entity)
|
||||||
|
SetBlipSprite(blip, sprite or 8)
|
||||||
|
SetBlipColour(blip, color or 3)
|
||||||
|
SetBlipScale(blip, scale or 0.8)
|
||||||
|
SetBlipDisplay(blip, displayType or 2)
|
||||||
|
SetBlipAsShortRange(blip, shortRange)
|
||||||
|
ShowHeadingIndicatorOnBlip(blip, true)
|
||||||
|
AddTextEntry(label, label)
|
||||||
|
BeginTextCommandSetBlipName(label)
|
||||||
|
EndTextCommandSetBlipName(blip)
|
||||||
|
blipIDs[tostring(blip)] = blip
|
||||||
|
return blip
|
||||||
end
|
end
|
||||||
|
|
||||||
---Remove a blip if it exists
|
---Remove a blip if it exists
|
||||||
---@param blip number
|
---@param blip number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Utility.RemoveBlip(blip)
|
function Utility.RemoveBlip(blip)
|
||||||
return safeRemoveBlip(blip)
|
if not blipIDs[tostring(blip)] then return false, print("NO BLIP BY ID") end
|
||||||
|
RemoveBlip(blipIDs[tostring(blip)])
|
||||||
|
blipIDs[tostring(blip)] = nil
|
||||||
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---Load a model into memory
|
---Load a model into memory
|
||||||
---@param model string|number
|
---@param model string|number
|
||||||
---@return boolean
|
---@return boolean, number
|
||||||
function Utility.LoadModel(model)
|
function Utility.LoadModel(model)
|
||||||
local loaded = ensureModelLoaded(model)
|
return ensureModelLoaded(model)
|
||||||
return loaded
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Request an animation dictionary
|
---Request an animation dictionary
|
||||||
---@param dict string
|
---@param dict string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Utility.RequestAnimDict(dict)
|
function Utility.RequestAnimDict(dict)
|
||||||
|
if HasAnimDictLoaded(dict) then return true end
|
||||||
RequestAnimDict(dict)
|
RequestAnimDict(dict)
|
||||||
local count = 0
|
local count = 0
|
||||||
while not HasAnimDictLoaded(dict) and count < 30000 do
|
while not HasAnimDictLoaded(dict) and count < 30000 do
|
||||||
@@ -249,18 +190,12 @@ end
|
|||||||
---@param entity number
|
---@param entity number
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Utility.RemovePed(entity)
|
function Utility.RemovePed(entity)
|
||||||
local success = false
|
if not spawnedPeds[tostring(entity)] then return false end
|
||||||
if DoesEntityExist(entity) then
|
spawnedPeds[tostring(entity)] = nil
|
||||||
DeleteEntity(entity)
|
if not DoesEntityExist(entity) then return false end
|
||||||
end
|
SetEntityAsMissionEntity(entity, true, true)
|
||||||
for i, storedEntity in ipairs(spawnedPeds) do
|
DeleteEntity(entity)
|
||||||
if storedEntity == entity then
|
return true
|
||||||
table.remove(spawnedPeds, i)
|
|
||||||
success = true
|
|
||||||
break
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return success
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Show a native input menu and return the result
|
---Show a native input menu and return the result
|
||||||
@@ -270,7 +205,7 @@ end
|
|||||||
function Utility.NativeInputMenu(text, length)
|
function Utility.NativeInputMenu(text, length)
|
||||||
local maxLength = Math and Math.Clamp and Math.Clamp(length, 1, 50) or math.min(math.max(length or 10, 1), 50)
|
local maxLength = Math and Math.Clamp and Math.Clamp(length, 1, 50) or math.min(math.max(length or 10, 1), 50)
|
||||||
local menuText = text or 'enter text'
|
local menuText = text or 'enter text'
|
||||||
safeAddTextEntry(menuText)
|
AddTextEntry(menuText, menuText)
|
||||||
DisplayOnscreenKeyboard(1, menuText, "", "", "", "", "", maxLength)
|
DisplayOnscreenKeyboard(1, menuText, "", "", "", "", "", maxLength)
|
||||||
while (UpdateOnscreenKeyboard() == 0) do
|
while (UpdateOnscreenKeyboard() == 0) do
|
||||||
DisableAllControlActions(0)
|
DisableAllControlActions(0)
|
||||||
@@ -313,10 +248,12 @@ end
|
|||||||
---Reload the player's skin and remove attached objects
|
---Reload the player's skin and remove attached objects
|
||||||
---@return boolean
|
---@return boolean
|
||||||
function Utility.ReloadSkin()
|
function Utility.ReloadSkin()
|
||||||
local skinData = Utility.GetEntitySkinData(cache.ped)
|
local ped = PlayerPedId()
|
||||||
Utility.SetEntitySkinData(cache.ped, skinData)
|
local skinData = Utility.GetEntitySkinData(ped)
|
||||||
for _, props in pairs(GetGamePool("CObject")) do
|
Utility.SetEntitySkinData(ped, skinData)
|
||||||
if IsEntityAttachedToEntity(cache.ped, props) then
|
local poolObject = GetGamePool("CObject")
|
||||||
|
for _, props in pairs(poolObject) do
|
||||||
|
if IsEntityAttachedToEntity(ped, props) then
|
||||||
SetEntityAsMissionEntity(props, true, true)
|
SetEntityAsMissionEntity(props, true, true)
|
||||||
DeleteObject(props)
|
DeleteObject(props)
|
||||||
DeleteEntity(props)
|
DeleteEntity(props)
|
||||||
@@ -329,11 +266,25 @@ end
|
|||||||
---@param text string
|
---@param text string
|
||||||
---@param duration number
|
---@param duration number
|
||||||
function Utility.HelpText(text, duration)
|
function Utility.HelpText(text, duration)
|
||||||
safeAddTextEntry(text)
|
AddTextEntry(text, text)
|
||||||
BeginTextCommandDisplayHelp(text)
|
BeginTextCommandDisplayHelp(text)
|
||||||
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
|
||||||
|
---@param text string The text to show
|
||||||
|
---@param coords table The coords to show the message at
|
||||||
|
---@return nil
|
||||||
|
function Utility.FloatingHelpText(text, coords)
|
||||||
|
AddTextEntry("community_bridge_"..text, text)
|
||||||
|
SetFloatingHelpTextWorldPosition(1, coords.x, coords.y, coords.z)
|
||||||
|
SetFloatingHelpTextStyle(1, 1, 2, -1, 3, 0)
|
||||||
|
BeginTextCommandDisplayHelp("community_bridge_"..text)
|
||||||
|
EndTextCommandDisplayHelp(2, false, false, 100)
|
||||||
|
end
|
||||||
|
|
||||||
---Draw 3D help text in the world
|
---Draw 3D help text in the world
|
||||||
---@param coords vector3
|
---@param coords vector3
|
||||||
---@param text string
|
---@param text string
|
||||||
@@ -343,10 +294,10 @@ function Utility.Draw3DHelpText(coords, text, scale)
|
|||||||
if onScreen then
|
if onScreen then
|
||||||
SetTextScale(scale or 0.35, scale or 0.35)
|
SetTextScale(scale or 0.35, scale or 0.35)
|
||||||
SetTextFont(4)
|
SetTextFont(4)
|
||||||
SetTextProportional(1)
|
SetTextProportional(true)
|
||||||
SetTextColour(255, 255, 255, 215)
|
SetTextColour(255, 255, 255, 215)
|
||||||
SetTextEntry("STRING")
|
SetTextEntry("STRING")
|
||||||
SetTextCentre(1)
|
SetTextCentre(true)
|
||||||
AddTextComponentString(text)
|
AddTextComponentString(text)
|
||||||
DrawText(x, y)
|
DrawText(x, y)
|
||||||
local factor = (string.len(text)) / 370
|
local factor = (string.len(text)) / 370
|
||||||
@@ -357,7 +308,7 @@ end
|
|||||||
---Show a native notification
|
---Show a native notification
|
||||||
---@param text string
|
---@param text string
|
||||||
function Utility.NotifyText(text)
|
function Utility.NotifyText(text)
|
||||||
safeAddTextEntry(text)
|
AddTextEntry(text, text)
|
||||||
SetNotificationTextEntry(text)
|
SetNotificationTextEntry(text)
|
||||||
DrawNotification(false, true)
|
DrawNotification(false, true)
|
||||||
end
|
end
|
||||||
@@ -367,6 +318,7 @@ end
|
|||||||
---@param conditionFunction function|nil
|
---@param conditionFunction function|nil
|
||||||
---@param afterTeleportFunction function|nil
|
---@param afterTeleportFunction function|nil
|
||||||
function Utility.TeleportPlayer(coords, conditionFunction, afterTeleportFunction)
|
function Utility.TeleportPlayer(coords, conditionFunction, afterTeleportFunction)
|
||||||
|
local ped = PlayerPedId()
|
||||||
if conditionFunction ~= nil then
|
if conditionFunction ~= nil then
|
||||||
if not conditionFunction() then
|
if not conditionFunction() then
|
||||||
return
|
return
|
||||||
@@ -374,18 +326,16 @@ function Utility.TeleportPlayer(coords, conditionFunction, afterTeleportFunction
|
|||||||
end
|
end
|
||||||
DoScreenFadeOut(2500)
|
DoScreenFadeOut(2500)
|
||||||
Wait(2500)
|
Wait(2500)
|
||||||
SetEntityCoords(cache.ped, coords.x, coords.y, coords.z, false, false, false, false)
|
SetEntityCoords(ped, coords.x, coords.y, coords.z, false, false, false, false)
|
||||||
if coords.w then
|
if coords.w then SetEntityHeading(ped, coords.w) end
|
||||||
SetEntityHeading(cache.ped, coords.w)
|
FreezeEntityPosition(ped, true)
|
||||||
end
|
|
||||||
FreezeEntityPosition(cache.ped, true)
|
|
||||||
local count = 0
|
local count = 0
|
||||||
while not HasCollisionLoadedAroundEntity(cache.ped) and count <= 30000 do
|
while not HasCollisionLoadedAroundEntity(ped) and count <= 30000 do
|
||||||
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
RequestCollisionAtCoord(coords.x, coords.y, coords.z)
|
||||||
Wait(0)
|
Wait(0)
|
||||||
count = count + 1
|
count = count + 1
|
||||||
end
|
end
|
||||||
FreezeEntityPosition(cache.ped, false)
|
FreezeEntityPosition(ped, false)
|
||||||
DoScreenFadeIn(1000)
|
DoScreenFadeIn(1000)
|
||||||
if afterTeleportFunction ~= nil then
|
if afterTeleportFunction ~= nil then
|
||||||
afterTeleportFunction()
|
afterTeleportFunction()
|
||||||
@@ -407,8 +357,8 @@ end
|
|||||||
function Utility.GetClosestPlayer(coords, distanceScope, includeMe)
|
function Utility.GetClosestPlayer(coords, distanceScope, includeMe)
|
||||||
local players = GetActivePlayers()
|
local players = GetActivePlayers()
|
||||||
local closestPlayer = 0
|
local closestPlayer = 0
|
||||||
local selfPed = cache.ped
|
local selfPed = PlayerPedId()
|
||||||
local selfCoords = coords or GetEntityCoords(cache.ped)
|
local selfCoords = coords or GetEntityCoords(selfPed)
|
||||||
local closestDistance = distanceScope or 5
|
local closestDistance = distanceScope or 5
|
||||||
|
|
||||||
for _, player in ipairs(players) do
|
for _, player in ipairs(players) do
|
||||||
@@ -435,12 +385,13 @@ function Utility.GetClosestVehicle(coords, distanceScope, includePlayerVeh)
|
|||||||
local vehicleEntity = nil
|
local vehicleEntity = nil
|
||||||
local vehicleNetID = nil
|
local vehicleNetID = nil
|
||||||
local vehicleCoords = nil
|
local vehicleCoords = nil
|
||||||
local selfCoords = coords or GetEntityCoords(cache.ped)
|
local ped = PlayerPedId()
|
||||||
|
local selfCoords = coords or GetEntityCoords(ped)
|
||||||
local closestDistance = distanceScope or 5
|
local closestDistance = distanceScope or 5
|
||||||
local includeMyVeh = includePlayerVeh or false
|
local includeMyVeh = includePlayerVeh or false
|
||||||
local gamePoolVehicles = GetGamePool("CVehicle")
|
local gamePoolVehicles = GetGamePool("CVehicle")
|
||||||
|
|
||||||
local playerVehicle = IsPedInAnyVehicle(cache.ped, false) and GetVehiclePedIsIn(cache.ped, false) or 0
|
local playerVehicle = IsPedInAnyVehicle(ped, false) and GetVehiclePedIsIn(ped, false) or 0
|
||||||
|
|
||||||
for i = 1, #gamePoolVehicles do
|
for i = 1, #gamePoolVehicles do
|
||||||
local thisVehicle = gamePoolVehicles[i]
|
local thisVehicle = gamePoolVehicles[i]
|
||||||
@@ -460,8 +411,8 @@ function Utility.GetClosestVehicle(coords, distanceScope, includePlayerVeh)
|
|||||||
end
|
end
|
||||||
|
|
||||||
-- Deprecated point functions (no changes)
|
-- Deprecated point functions (no changes)
|
||||||
function Utility.RegisterPoint(pointID, pointCoords, pointDistance, _onEnter, _onExit, _nearby)
|
function Utility.RegisterPoint(pointID, pointCoords, pointDistance, _onEnter, _onExit)
|
||||||
return Point.Register(pointID, pointCoords, pointDistance, nil, _onEnter, _onExit, _nearby)
|
return Point.Register(pointID, pointCoords, pointDistance, nil, _onEnter, _onExit)
|
||||||
end
|
end
|
||||||
|
|
||||||
function Utility.GetPointById(pointID)
|
function Utility.GetPointById(pointID)
|
||||||
@@ -625,13 +576,13 @@ end
|
|||||||
AddEventHandler('onResourceStop', function(resource)
|
AddEventHandler('onResourceStop', function(resource)
|
||||||
if resource ~= GetCurrentResourceName() then return end
|
if resource ~= GetCurrentResourceName() then return end
|
||||||
for _, blip in pairs(blipIDs) do
|
for _, blip in pairs(blipIDs) do
|
||||||
if blip and DoesBlipExist(blip) then
|
if blip and DoesBlipExist(tonumber(blip)) then
|
||||||
RemoveBlip(blip)
|
RemoveBlip(tonumber(blip))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
for _, ped in pairs(spawnedPeds) do
|
for _, ped in pairs(spawnedPeds) do
|
||||||
if ped and DoesEntityExist(ped) then
|
if ped and DoesEntityExist(tonumber(ped)) then
|
||||||
DeleteEntity(ped)
|
DeleteEntity(tonumber(ped))
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
|
|||||||
+2
-2
@@ -30,8 +30,8 @@
|
|||||||
"place_object_scroll_down": "[Scroll Down] Turn left \n",
|
"place_object_scroll_down": "[Scroll Down] Turn left \n",
|
||||||
"object_place": "[%s] Place \n",
|
"object_place": "[%s] Place \n",
|
||||||
"object_cancel": "[%s] Cancel \n",
|
"object_cancel": "[%s] Cancel \n",
|
||||||
"object_scroll_up": "[%s] Turn right \n",
|
"rotate_clockwise": "[%s] Rotate Clockwise \n",
|
||||||
"object_scroll_down": "[%s] Turn left \n",
|
"rotate_counter_clockwise": "[%s] Rotate Counter-Clockwise \n",
|
||||||
"depth_modifier": "[%s] Depth Control Modifier \n"
|
"depth_modifier": "[%s] Depth Control Modifier \n"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"Shops": {
|
||||||
|
"NotEnoughMoney": "Nemate dovoljno novca za kupnju ovog predmeta",
|
||||||
|
"Input": "Unos količine",
|
||||||
|
"PurchaseAmount": "Količina kupnje",
|
||||||
|
"PurchasedItem": "Kupili ste ",
|
||||||
|
"CurrencySymbol": "%s kn",
|
||||||
|
"Confirm": "Potvrdi kupnju",
|
||||||
|
"AreYouSure": "Jeste li sigurni da želite kupiti %s",
|
||||||
|
"PayByCash": "Platite %s gotovinom",
|
||||||
|
"PayByCard": "Platite %s karticom",
|
||||||
|
"CardIcon": "fa-solid fa-building-columns",
|
||||||
|
"CashIcon": "fa-solid fa-money-bill-wave",
|
||||||
|
"ShopIcon": "fa-solid fa-basket-shopping",
|
||||||
|
"ShopName": "Naziv trgovine"
|
||||||
|
},
|
||||||
|
"UNITTEST": {
|
||||||
|
"UNITTESTA": "Ja sam %s %s",
|
||||||
|
"locale-unit-test": "Ovo je test string"
|
||||||
|
},
|
||||||
|
"clipboard": {
|
||||||
|
"copy": "Kopirano u međuspremnik"
|
||||||
|
},
|
||||||
|
"placeable_object": {
|
||||||
|
"no_prop_defined": "Niste definirali nijedan objekt za postavljanje",
|
||||||
|
"cant_place_here": "Ne možete postaviti ovaj objekt ovdje",
|
||||||
|
"place_object_place": "[E] Postavi \n",
|
||||||
|
"place_object_cancel": "[X] Otkažи \n",
|
||||||
|
"place_object_scroll_up": "[Scroll Up] Okreni desno \n",
|
||||||
|
"place_object_scroll_down": "[Scroll Down] Okreni lijevo \n",
|
||||||
|
"object_place": "[%s] Postavi \n",
|
||||||
|
"object_cancel": "[%s] Otkažи \n",
|
||||||
|
"object_scroll_up": "[%s] Okreni desno \n",
|
||||||
|
"object_scroll_down": "[%s] Okreni lijevo \n",
|
||||||
|
"depth_modifier": "[%s] Modifikator kontrole dubine \n"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,37 @@
|
|||||||
|
{
|
||||||
|
"Shops": {
|
||||||
|
"NotEnoughMoney": "Neturite pakankamai pinigų šiam daiktui nusipirkti",
|
||||||
|
"Input": "Kiekio įvestis",
|
||||||
|
"PurchaseAmount": "Pirkimo kiekis",
|
||||||
|
"PurchasedItem": "Jūs nusipirkote ",
|
||||||
|
"CurrencySymbol": "%s €",
|
||||||
|
"Confirm": "Patvirtinti pirkimą",
|
||||||
|
"AreYouSure": "Ar tikrai norite nusipirkti %s",
|
||||||
|
"PayByCash": "Sumokėti %s grynaisiais",
|
||||||
|
"PayByCard": "Sumokėti %s kortele",
|
||||||
|
"CardIcon": "fa-solid fa-building-columns",
|
||||||
|
"CashIcon": "fa-solid fa-money-bill-wave",
|
||||||
|
"ShopIcon": "fa-solid fa-basket-shopping",
|
||||||
|
"ShopName": "Parduotuvės pavadinimas"
|
||||||
|
},
|
||||||
|
"UNITTEST": {
|
||||||
|
"UNITTESTA": "Aš esu %s %s",
|
||||||
|
"locale-unit-test": "Tai yra testavimo eilutė"
|
||||||
|
},
|
||||||
|
"clipboard": {
|
||||||
|
"copy": "Nukopijuota į iškarpinę"
|
||||||
|
},
|
||||||
|
"placeable_object": {
|
||||||
|
"no_prop_defined": "Nenurodėte jokio objekto, kurį reikia pastatyti",
|
||||||
|
"cant_place_here": "Čia negalite pastatyti šio objekto",
|
||||||
|
"place_object_place": "[E] Pastatyti \n",
|
||||||
|
"place_object_cancel": "[X] Atšaukti \n",
|
||||||
|
"place_object_scroll_up": "[Slinkti aukštyn] Pasukti dešinėn \n",
|
||||||
|
"place_object_scroll_down": "[Slinkti žemyn] Pasukti kairėn \n",
|
||||||
|
"object_place": "[%s] Pastatyti \n",
|
||||||
|
"object_cancel": "[%s] Atšaukti \n",
|
||||||
|
"rotate_clockwise": "[%s] Sukti pagal laikrodžio rodyklę \n",
|
||||||
|
"rotate_counter_clockwise": "[%s] Sukti prieš laikrodžio rodyklę \n",
|
||||||
|
"depth_modifier": "[%s] Gylio kontrolės modifikatorius \n"
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,16 +1,16 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'default'
|
return 'default'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
return 0, print("The resource you are using does not support this function.")
|
return 0, print("The resource you are using does not support this function.")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -19,7 +19,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, reason)
|
Banking.AddAccountMoney = function(account, amount, reason)
|
||||||
return false, print("The resource you are using does not support this function.")
|
return false, print("The resource you are using does not support this function.")
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -28,8 +28,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, reason)
|
Banking.RemoveAccountMoney = function(account, amount, reason)
|
||||||
return false, print("The resource you are using does not support this function.")
|
return false, print("The resource you are using does not support this function.")
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('fd_banking') == 'missing' then return end
|
if GetResourceState('fd_banking') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
local fd_banking = exports['fd_banking']
|
local fd_banking = exports['fd_banking']
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'fd_banking'
|
return 'fd_banking'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
return fd_banking:GetAccount(account)
|
return fd_banking:GetAccount(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, reason)
|
Banking.AddAccountMoney = function(account, amount, reason)
|
||||||
return fd_banking:AddMoney(account, amount, reason)
|
return fd_banking:AddMoney(account, amount, reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, reason)
|
Banking.RemoveAccountMoney = function(account, amount, reason)
|
||||||
return fd_banking:RemoveMoney(account, amount, reason)
|
return fd_banking:RemoveMoney(account, amount, reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
+6
-6
@@ -1,19 +1,19 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('kartik-banking') == 'missing' then return end
|
if GetResourceState('kartik-banking') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
local kartik = exports['kartik-banking']
|
local kartik = exports['kartik-banking']
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'kartik-banking'
|
return 'kartik-banking'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
local balance = kartik:GetAccountMoney(account)
|
local balance = kartik:GetAccountMoney(account)
|
||||||
return balance or 0
|
return balance or 0
|
||||||
end
|
end
|
||||||
@@ -23,7 +23,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, reason)
|
Banking.AddAccountMoney = function(account, amount, reason)
|
||||||
return kartik:AddAccountMoney(account, amount, reason)
|
return kartik:AddAccountMoney(account, amount, reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, reason)
|
Banking.RemoveAccountMoney = function(account, amount, reason)
|
||||||
return kartik:RemoveAccountMoney(account, amount, reason)
|
return kartik:RemoveAccountMoney(account, amount, reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('okokBanking') == 'missing' then return end
|
if GetResourceState('okokBanking') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
local okokBanking = exports['okokBanking']
|
local okokBanking = exports['okokBanking']
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'okokBanking'
|
return 'okokBanking'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
return okokBanking:GetAccount(account)
|
return okokBanking:GetAccount(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, _)
|
Banking.AddAccountMoney = function(account, amount, _)
|
||||||
return okokBanking:AddMoney(account, amount)
|
return okokBanking:AddMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, _)
|
Banking.RemoveAccountMoney = function(account, amount, _)
|
||||||
return okokBanking:RemoveMoney(account, amount)
|
return okokBanking:RemoveMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('qb-banking') == 'missing' then return end
|
if GetResourceState('qb-banking') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
local qbBanking = exports['qb-banking']
|
local qbBanking = exports['qb-banking']
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'qb-banking'
|
return 'qb-banking'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
return qbBanking:GetAccountBalance(account)
|
return qbBanking:GetAccountBalance(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, reason)
|
Banking.AddAccountMoney = function(account, amount, reason)
|
||||||
return qbBanking:AddMoney(account, amount, reason)
|
return qbBanking:AddMoney(account, amount, reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, reason)
|
Banking.RemoveAccountMoney = function(account, amount, reason)
|
||||||
return qbBanking:RemoveMoney(account, amount, reason)
|
return qbBanking:RemoveMoney(account, amount, reason)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
+6
-6
@@ -1,19 +1,19 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('Renewed-Banking') == 'missing' then return end
|
if GetResourceState('Renewed-Banking') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
local renewed = exports['Renewed-Banking']
|
local renewed = exports['Renewed-Banking']
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'Renewed-Banking'
|
return 'Renewed-Banking'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
return renewed:getAccountMoney(account)
|
return renewed:getAccountMoney(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, _)
|
Banking.AddAccountMoney = function(account, amount, _)
|
||||||
return renewed:addAccountMoney(account, amount)
|
return renewed:addAccountMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, _)
|
Banking.RemoveAccountMoney = function(account, amount, _)
|
||||||
return renewed:removeAccountMoney(account, amount)
|
return renewed:removeAccountMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('tgg-banking') == 'missing' then return end
|
if GetResourceState('tgg-banking') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
local tgg = exports['tgg-banking']
|
local tgg = exports['tgg-banking']
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'tgg-banking'
|
return 'tgg-banking'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
return tgg:GetSocietyAccountMoney(account) or 0
|
return tgg:GetSocietyAccountMoney(account) or 0
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, _)
|
Banking.AddAccountMoney = function(account, amount, _)
|
||||||
return tgg:AddSocietyMoney(account, amount)
|
return tgg:AddSocietyMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, _)
|
Banking.RemoveAccountMoney = function(account, amount, _)
|
||||||
return tgg:RemoveSocietyMoney(account, amount)
|
return tgg:RemoveSocietyMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
@@ -1,19 +1,19 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('tgiann-bank') == 'missing' then return end
|
if GetResourceState('tgiann-bank') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
local tgiann = exports["tgiann-bank"]
|
local tgiann = exports["tgiann-bank"]
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'tgiann-bank'
|
return 'tgiann-bank'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
return tgiann:GetJobAccountBalance(account)
|
return tgiann:GetJobAccountBalance(account)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, _)
|
Banking.AddAccountMoney = function(account, amount, _)
|
||||||
return tgiann:AddJobMoney(account, amount)
|
return tgiann:AddJobMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -31,8 +31,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param _ string
|
---@param _ string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, _)
|
Banking.RemoveAccountMoney = function(account, amount, _)
|
||||||
return tgiann:RemoveJobMoney(account, amount)
|
return tgiann:RemoveJobMoney(account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
+6
-6
@@ -1,19 +1,19 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
if GetResourceState('wasabi_banking') == 'missing' then return end
|
if GetResourceState('wasabi_banking') == 'missing' then return end
|
||||||
Managment = Managment or {}
|
Banking = Banking or {}
|
||||||
|
|
||||||
local wasabi_banking = exports['wasabi_banking']
|
local wasabi_banking = exports['wasabi_banking']
|
||||||
|
|
||||||
---This will get the name of the Managment system being being used.
|
---This will get the name of the Managment system being being used.
|
||||||
---@return string
|
---@return string
|
||||||
Managment.GetManagmentName = function()
|
Banking.GetManagmentName = function()
|
||||||
return 'wasabi_banking'
|
return 'wasabi_banking'
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a number
|
---This will return a number
|
||||||
---@param account string
|
---@param account string
|
||||||
---@return number
|
---@return number
|
||||||
Managment.GetAccountMoney = function(account)
|
Banking.GetAccountMoney = function(account)
|
||||||
local balance = wasabi_banking:GetAccountBalance(account, 'society')
|
local balance = wasabi_banking:GetAccountBalance(account, 'society')
|
||||||
return balance or 0
|
return balance or 0
|
||||||
end
|
end
|
||||||
@@ -23,7 +23,7 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.AddAccountMoney = function(account, amount, reason)
|
Banking.AddAccountMoney = function(account, amount, reason)
|
||||||
return wasabi_banking:AddMoney('society', account, amount)
|
return wasabi_banking:AddMoney('society', account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -32,8 +32,8 @@ end
|
|||||||
---@param amount number
|
---@param amount number
|
||||||
---@param reason string
|
---@param reason string
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Managment.RemoveAccountMoney = function(account, amount, reason)
|
Banking.RemoveAccountMoney = function(account, amount, reason)
|
||||||
return wasabi_banking:RemoveMoney('society', account, amount)
|
return wasabi_banking:RemoveMoney('society', account, amount)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Managment
|
return Banking
|
||||||
@@ -4,8 +4,6 @@ if GetResourceState('rcore_clothing') ~= 'missing' then return end
|
|||||||
|
|
||||||
Clothing = Clothing or {}
|
Clothing = Clothing or {}
|
||||||
|
|
||||||
-- {"glasses_2":0,"shoes_1":70,"dad":0,"shoes_2":2,"pants_1":28,"eye_squint":0,"ears_1":-1,"hair_color_1":61,"eyebrows_6":0,"bodyb_3":-1,"beard_1":11,"complexion_2":0,"arms_2":0,"hair_1":76,"nose_1":0,"blush_2":0,"bracelets_2":0,"blush_1":0,"jaw_2":0,"helmet_1":-1,"eyebrows_3":0,"watches_1":-1,"eyebrows_4":0,"jaw_1":0,"lipstick_1":0,"eyebrows_1":0,"nose_4":0,"age_2":0,"torso_1":23,"hair_2":0,"chin_2":0,"arms":1,"chain_1":22,"nose_2":0,"cheeks_1":2,"tshirt_1":4,"glasses_1":0,"pants_2":3,"lipstick_4":0,"chin_13":0,"beard_4":0,"beard_3":0,"chain_2":2,"cheeks_3":6,"sex":0,"lipstick_3":0,"makeup_1":0,"hair_color_2":29,"mask_2":0,"chin_1":0,"eyebrows_5":0,"bodyb_2":0,"sun_2":0,"watches_2":0,"sun_1":0,"chin_4":0,"nose_3":0,"helmet_2":0,"bags_2":0,"moles_2":0,"mask_1":0,"blemishes_2":0,"chest_1":0,"cheeks_2":-10,"age_1":0,"chest_2":0,"beard_2":10,"torso_2":2,"blush_3":0,"bproof_1":0,"moles_1":0,"chin_3":0,"lip_thickness":-2,"lipstick_2":0,"chest_3":0,"complexion_1":0,"bodyb_4":0,"neck_thickness":0,"bproof_2":0,"makeup_3":0,"tshirt_2":2,"makeup_2":0,"makeup_4":0,"bracelets_1":-1,"decals_2":0,"nose_6":0,"bodyb_1":-1,"bags_1":0,"blemishes_1":0,"decals_1":0,"mom":21,"eyebrows_2":0,"eye_color":0,"skin_md_weight":50,"face_md_weight":50,"nose_5":10,"ears_2":0}
|
|
||||||
|
|
||||||
Components = {}
|
Components = {}
|
||||||
Components.Map = {
|
Components.Map = {
|
||||||
[1] = 'mask', -- componentId
|
[1] = 'mask', -- componentId
|
||||||
@@ -142,63 +140,3 @@ function Clothing.ConvertToDefault(esxClothing)
|
|||||||
local props = Props.ConvertToDefault(esxClothing)
|
local props = Props.ConvertToDefault(esxClothing)
|
||||||
return { components = components, props = props }
|
return { components = components, props = props }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clothing = {}
|
|
||||||
|
|
||||||
-- StoredOldClothing = {}
|
|
||||||
|
|
||||||
-- Clothing.SetAppearance = function(clothingData)
|
|
||||||
-- if GetEntityModel(cache.ped) == `mp_m_freemode_01` then
|
|
||||||
-- clothingData = clothingData.male
|
|
||||||
-- else
|
|
||||||
-- clothingData = clothingData.female
|
|
||||||
-- end
|
|
||||||
-- local repackedTable = {}
|
|
||||||
-- local componentMap = {
|
|
||||||
-- [1] = "mask",
|
|
||||||
-- [3] = "arms",
|
|
||||||
-- [4] = "pants",
|
|
||||||
-- [5] = "bag",
|
|
||||||
-- [6] = "shoes",
|
|
||||||
-- [7] = "accessory",
|
|
||||||
-- [8] = "t-shirt",
|
|
||||||
-- [9] = "vest",
|
|
||||||
-- [10] = "decals",
|
|
||||||
-- [11] = "torso2"
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- local propMap = {
|
|
||||||
-- [0] = "hat",
|
|
||||||
-- [1] = "glass",
|
|
||||||
-- [2] = "ear",
|
|
||||||
-- [6] = "watch",
|
|
||||||
-- [7] = "bracelet"
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- local specialMap = {
|
|
||||||
-- eye_color_id = "eye_color",
|
|
||||||
-- moles_id = "moles",
|
|
||||||
-- ageing_id = "ageing",
|
|
||||||
-- hair_id = "hair",
|
|
||||||
-- face_id = "face"
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- for _, data in pairs(clothingData) do
|
|
||||||
-- if componentMap[data.component_id] then
|
|
||||||
-- repackedTable[componentMap[data.component_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif propMap[data.prop_id] then
|
|
||||||
-- repackedTable[propMap[data.prop_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.eye_color_id] then
|
|
||||||
-- repackedTable[specialMap[data.eye_color_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.moles_id] then
|
|
||||||
-- repackedTable[specialMap[data.moles_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.ageing_id] then
|
|
||||||
-- repackedTable[specialMap[data.ageing_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.hair_id] then
|
|
||||||
-- repackedTable[specialMap[data.hair_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.face_id] then
|
|
||||||
-- repackedTable[specialMap[data.face_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- TriggerEvent('esx-clothing:client:loadOutfit', repackedTable)
|
|
||||||
-- end
|
|
||||||
@@ -18,13 +18,22 @@ function Clothing.GetFullAppearanceData(src)
|
|||||||
|
|
||||||
if Clothing.Players[citId] then return Clothing.Players[citId] end
|
if Clothing.Players[citId] then return Clothing.Players[citId] end
|
||||||
|
|
||||||
local result = MySQL.query.await('SELECT * FROM playerskins WHERE citizenid = ? AND active = ?', { citId, 1 })
|
local result = nil
|
||||||
if result[1] == nil then return end
|
local model = GetEntityModel(GetPlayerPed(src))
|
||||||
|
local skinData = nil
|
||||||
local model = result[1].model
|
local converted = nil
|
||||||
local skinData = json.decode(result[1].skin)
|
if Bridge.Framework.GetFrameworkName() == "es_extended" then
|
||||||
local converted = skinData
|
result = MySQL.query.await('SELECT skin FROM users WHERE identifier = ?', { citId })
|
||||||
|
if not result or not result[1] then return end
|
||||||
|
skinData = json.decode(result[1].skin)
|
||||||
|
converted = skinData
|
||||||
|
else
|
||||||
|
result = MySQL.query.await('SELECT * FROM playerskins WHERE citizenid = ? AND active = ?', { citId, 1 })
|
||||||
|
if not result or not result[1] then return end
|
||||||
|
model = result[1].model
|
||||||
|
skinData = json.decode(result[1].skin)
|
||||||
|
converted = skinData
|
||||||
|
end
|
||||||
-- Store complete data in the cache
|
-- Store complete data in the cache
|
||||||
Clothing.Players[citId] = {
|
Clothing.Players[citId] = {
|
||||||
model = model,
|
model = model,
|
||||||
@@ -156,49 +165,47 @@ Callback.Register('community_bridge:cb:GetAppearance', function(source)
|
|||||||
return Clothing.GetAppearance(src)
|
return Clothing.GetAppearance(src)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
-- All the this below should go in unit tests if we are to continue using them.
|
||||||
RegisterCommand('clothing:debug', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:debug', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.SetAppearance(src, {
|
-- Clothing.SetAppearance(src, {
|
||||||
components = {
|
-- components = {
|
||||||
{ component_id = 1, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 1, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 2, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 2, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 3, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 3, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 4, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 4, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 5, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 5, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 6, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 6, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 7, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 7, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 8, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 8, drawable = math.random(0, 50), texture = 0 },
|
||||||
},
|
-- },
|
||||||
props = {
|
-- props = {
|
||||||
{ prop_id = 3, drawable = 0, texture = 0 },
|
-- { prop_id = 3, drawable = 0, texture = 0 },
|
||||||
{ prop_id = 1, drawable = 0, texture = 0 },
|
-- { prop_id = 1, drawable = 0, texture = 0 },
|
||||||
{ prop_id = 2, drawable = 0, texture = 0 },
|
-- { prop_id = 2, drawable = 0, texture = 0 },
|
||||||
}
|
-- }
|
||||||
}, false, true)
|
-- }, false, true)
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
|
|
||||||
RegisterCommand('clothing:revert', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:revert', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.Revert(src)
|
-- Clothing.Revert(src)
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
|
|
||||||
RegisterCommand('clothing:current', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:current', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
local currentClothing = Clothing.GetAppearance(src)
|
-- local currentClothing = Clothing.GetAppearance(src)
|
||||||
if not currentClothing then return end
|
-- if not currentClothing then return end
|
||||||
print(json.encode(currentClothing, { indent = true }))
|
-- print(json.encode(currentClothing, { indent = true }))
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
RegisterCommand('clothing:openmenu', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:openmenu', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.OpenMenu(src)
|
-- Clothing.OpenMenu(src)
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
|
|
||||||
-- This should be moved into unit tests
|
|
||||||
-- RegisterCommand('clothing:crowley', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:crowley', function(source, args, rawCommand)
|
||||||
-- local src = source
|
-- local src = source
|
||||||
-- Clothing.SetAppearance(src, {
|
-- Clothing.SetAppearance(src, {
|
||||||
|
|||||||
@@ -158,96 +158,96 @@ Callback.Register('community_bridge:cb:GetAppearance', function(source)
|
|||||||
return Clothing.GetAppearance(src)
|
return Clothing.GetAppearance(src)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- The below Should go to unit test
|
-- All the this below should go in unit tests if we are to continue using them.
|
||||||
RegisterCommand('clothing:debug', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:debug', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.SetAppearance(src, {
|
-- Clothing.SetAppearance(src, {
|
||||||
components = {
|
-- components = {
|
||||||
{ component_id = 0, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 0, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 1, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 1, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 2, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 2, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 3, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 3, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 4, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 4, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 5, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 5, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 6, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 6, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 7, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 7, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 8, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 8, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 9, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 9, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 10, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 10, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ component_id = 11, drawable = math.random(0, 50), texture = 0 },
|
-- { component_id = 11, drawable = math.random(0, 50), texture = 0 },
|
||||||
},
|
-- },
|
||||||
props = {
|
-- props = {
|
||||||
{ prop_id = 0, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 0, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 1, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 1, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 2, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 2, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 3, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 3, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 4, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 4, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 5, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 5, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 6, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 6, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 7, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 7, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 8, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 8, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 9, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 9, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 10, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 10, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 11, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 11, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 12, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 12, drawable = math.random(0, 50), texture = 0 },
|
||||||
{ prop_id = 13, drawable = math.random(0, 50), texture = 0 },
|
-- { prop_id = 13, drawable = math.random(0, 50), texture = 0 },
|
||||||
}
|
-- }
|
||||||
}, false, true)
|
-- }, false, true)
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
|
|
||||||
RegisterCommand('clothing:revert', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:revert', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.Revert(src)
|
-- Clothing.Revert(src)
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
|
|
||||||
RegisterCommand('clothing:current', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:current', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
local currentClothing = Clothing.GetAppearance(src)
|
-- local currentClothing = Clothing.GetAppearance(src)
|
||||||
if not currentClothing then return end
|
-- if not currentClothing then return end
|
||||||
print(json.encode(currentClothing, { indent = true }))
|
-- print(json.encode(currentClothing, { indent = true }))
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
RegisterCommand('clothing:openmenu', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:openmenu', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.OpenMenu(src)
|
-- Clothing.OpenMenu(src)
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
|
|
||||||
RegisterCommand('clothing:crowley', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:crowley', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.SetAppearance(src, {
|
-- Clothing.SetAppearance(src, {
|
||||||
components = {
|
-- components = {
|
||||||
{ drawable = 0, texture = 0, component_id = 0 },
|
-- { drawable = 0, texture = 0, component_id = 0 },
|
||||||
{ drawable = 0, texture = 0, component_id = 1 },
|
-- { drawable = 0, texture = 0, component_id = 1 },
|
||||||
{ drawable = 19, texture = 0, component_id = 2 },
|
-- { drawable = 19, texture = 0, component_id = 2 },
|
||||||
{ drawable = 6, texture = 0, component_id = 3 },
|
-- { drawable = 6, texture = 0, component_id = 3 },
|
||||||
{ drawable = 0, texture = 0, component_id = 4 },
|
-- { drawable = 0, texture = 0, component_id = 4 },
|
||||||
{ drawable = 0, texture = 0, component_id = 5 },
|
-- { drawable = 0, texture = 0, component_id = 5 },
|
||||||
{ drawable = 0, texture = 0, component_id = 6 },
|
-- { drawable = 0, texture = 0, component_id = 6 },
|
||||||
{ drawable = 0, texture = 0, component_id = 7 },
|
-- { drawable = 0, texture = 0, component_id = 7 },
|
||||||
{ drawable = 23, texture = 0, component_id = 8 },
|
-- { drawable = 23, texture = 0, component_id = 8 },
|
||||||
{ drawable = 0, texture = 0, component_id = 9 },
|
-- { drawable = 0, texture = 0, component_id = 9 },
|
||||||
{ drawable = 0, texture = 0, component_id = 10 },
|
-- { drawable = 0, texture = 0, component_id = 10 },
|
||||||
{ drawable = 4, texture = 2, component_id = 11 }
|
-- { drawable = 4, texture = 2, component_id = 11 }
|
||||||
},
|
-- },
|
||||||
props = {
|
-- props = {
|
||||||
{ drawable = 27, prop_id = 0, texture = 0 },
|
-- { drawable = 27, prop_id = 0, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 1, texture = 0 },
|
-- { drawable = 0, prop_id = 1, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 2, texture = 0 },
|
-- { drawable = 0, prop_id = 2, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 3, texture = 0 },
|
-- { drawable = 0, prop_id = 3, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 4, texture = 0 },
|
-- { drawable = 0, prop_id = 4, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 5, texture = 0 },
|
-- { drawable = 0, prop_id = 5, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 6, texture = 0 },
|
-- { drawable = 0, prop_id = 6, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 7, texture = 0 },
|
-- { drawable = 0, prop_id = 7, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 8, texture = 0 },
|
-- { drawable = 0, prop_id = 8, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 9, texture = 0 },
|
-- { drawable = 0, prop_id = 9, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 10, texture = 0 },
|
-- { drawable = 0, prop_id = 10, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 11, texture = 0 },
|
-- { drawable = 0, prop_id = 11, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 12, texture = 0 },
|
-- { drawable = 0, prop_id = 12, texture = 0 },
|
||||||
{ drawable = 0, prop_id = 13, texture = 0 }
|
-- { drawable = 0, prop_id = 13, texture = 0 }
|
||||||
|
|
||||||
}
|
-- }
|
||||||
}, false, true)
|
-- }, false, true)
|
||||||
end, false)
|
-- end, false)
|
||||||
@@ -166,47 +166,46 @@ Callback.Register('community_bridge:cb:GetAppearance', function(source)
|
|||||||
return Clothing.GetAppearance(src)
|
return Clothing.GetAppearance(src)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
--[[
|
-- All the this below should go in unit tests if we are to continue using them.
|
||||||
RegisterCommand('clothing:debug', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:debug', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.SetAppearance(src, {
|
-- Clothing.SetAppearance(src, {
|
||||||
components ={
|
-- components ={
|
||||||
{component_id = 1, drawable = math.random(0, 50), texture = 0},
|
-- {component_id = 1, drawable = math.random(0, 50), texture = 0},
|
||||||
{component_id = 2, drawable = math.random(0, 50), texture = 0},
|
-- {component_id = 2, drawable = math.random(0, 50), texture = 0},
|
||||||
{component_id = 3, drawable = math.random(0, 50), texture = 0},
|
-- {component_id = 3, drawable = math.random(0, 50), texture = 0},
|
||||||
{component_id = 4, drawable = math.random(0, 50), texture = 0},
|
-- {component_id = 4, drawable = math.random(0, 50), texture = 0},
|
||||||
{component_id = 5, drawable = math.random(0, 50), texture = 0},
|
-- {component_id = 5, drawable = math.random(0, 50), texture = 0},
|
||||||
{component_id = 6, drawable = math.random(0, 50), texture = 0},
|
-- {component_id = 6, drawable = math.random(0, 50), texture = 0},
|
||||||
{component_id = 7, drawable = math.random(0, 50), texture = 0},
|
-- {component_id = 7, drawable = math.random(0, 50), texture = 0},
|
||||||
{component_id = 8, drawable = math.random(0, 50), texture = 0},
|
-- {component_id = 8, drawable = math.random(0, 50), texture = 0},
|
||||||
},
|
-- },
|
||||||
props = {
|
-- props = {
|
||||||
{prop_id = 3, drawable = 0, texture = 0},
|
-- {prop_id = 3, drawable = 0, texture = 0},
|
||||||
{prop_id = 1, drawable = 0, texture = 0},
|
-- {prop_id = 1, drawable = 0, texture = 0},
|
||||||
{prop_id = 2, drawable = 0, texture = 0},
|
-- {prop_id = 2, drawable = 0, texture = 0},
|
||||||
}
|
-- }
|
||||||
}, false, true)
|
-- }, false, true)
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
|
|
||||||
RegisterCommand('clothing:revert', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:revert', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.Revert(src)
|
-- Clothing.Revert(src)
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
|
|
||||||
RegisterCommand('clothing:current', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:current', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
local currentClothing = Clothing.GetAppearance(src)
|
-- local currentClothing = Clothing.GetAppearance(src)
|
||||||
if not currentClothing then return end
|
-- if not currentClothing then return end
|
||||||
print(json.encode(currentClothing, { indent = true }))
|
-- print(json.encode(currentClothing, { indent = true }))
|
||||||
end, false)
|
-- end, false)
|
||||||
|
|
||||||
RegisterCommand('clothing:openmenu', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:openmenu', function(source, args, rawCommand)
|
||||||
local src = source
|
-- local src = source
|
||||||
Clothing.OpenMenu(src)
|
-- Clothing.OpenMenu(src)
|
||||||
end, false)
|
-- end, false)
|
||||||
--]]
|
|
||||||
|
|
||||||
-- RegisterCommand('clothing:crowley', function(source, args, rawCommand)
|
-- RegisterCommand('clothing:crowley', function(source, args, rawCommand)
|
||||||
-- local src = source
|
-- local src = source
|
||||||
|
|||||||
@@ -126,63 +126,3 @@ function Clothing.ConvertToDefault(qbClothing)
|
|||||||
local props = Props.ConvertToDefault(qbClothing)
|
local props = Props.ConvertToDefault(qbClothing)
|
||||||
return { components = components, props = props }
|
return { components = components, props = props }
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Clothing = {}
|
|
||||||
|
|
||||||
-- StoredOldClothing = {}
|
|
||||||
|
|
||||||
-- Clothing.SetAppearance = function(clothingData)
|
|
||||||
-- if GetEntityModel(cache.ped) == `mp_m_freemode_01` then
|
|
||||||
-- clothingData = clothingData.male
|
|
||||||
-- else
|
|
||||||
-- clothingData = clothingData.female
|
|
||||||
-- end
|
|
||||||
-- local repackedTable = {}
|
|
||||||
-- local componentMap = {
|
|
||||||
-- [1] = "mask",
|
|
||||||
-- [3] = "arms",
|
|
||||||
-- [4] = "pants",
|
|
||||||
-- [5] = "bag",
|
|
||||||
-- [6] = "shoes",
|
|
||||||
-- [7] = "accessory",
|
|
||||||
-- [8] = "t-shirt",
|
|
||||||
-- [9] = "vest",
|
|
||||||
-- [10] = "decals",
|
|
||||||
-- [11] = "torso2"
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- local propMap = {
|
|
||||||
-- [0] = "hat",
|
|
||||||
-- [1] = "glass",
|
|
||||||
-- [2] = "ear",
|
|
||||||
-- [6] = "watch",
|
|
||||||
-- [7] = "bracelet"
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- local specialMap = {
|
|
||||||
-- eye_color_id = "eye_color",
|
|
||||||
-- moles_id = "moles",
|
|
||||||
-- ageing_id = "ageing",
|
|
||||||
-- hair_id = "hair",
|
|
||||||
-- face_id = "face"
|
|
||||||
-- }
|
|
||||||
|
|
||||||
-- for _, data in pairs(clothingData) do
|
|
||||||
-- if componentMap[data.component_id] then
|
|
||||||
-- repackedTable[componentMap[data.component_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif propMap[data.prop_id] then
|
|
||||||
-- repackedTable[propMap[data.prop_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.eye_color_id] then
|
|
||||||
-- repackedTable[specialMap[data.eye_color_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.moles_id] then
|
|
||||||
-- repackedTable[specialMap[data.moles_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.ageing_id] then
|
|
||||||
-- repackedTable[specialMap[data.ageing_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.hair_id] then
|
|
||||||
-- repackedTable[specialMap[data.hair_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- elseif specialMap[data.face_id] then
|
|
||||||
-- repackedTable[specialMap[data.face_id]] = {drawable = data.drawable, texture = data.texture}
|
|
||||||
-- end
|
|
||||||
-- end
|
|
||||||
-- TriggerEvent('qb-clothing:client:loadOutfit', repackedTable)
|
|
||||||
-- end
|
|
||||||
@@ -66,7 +66,6 @@ function Dialogue.Open( name, dialogue, characterOptions, dialogueOptions, onSel
|
|||||||
SetCamCoord(cam, endLocation.x, endLocation.y, endLocation.z)
|
SetCamCoord(cam, endLocation.x, endLocation.y, endLocation.z)
|
||||||
RenderScriptCams(true, true, 1000, true, false)
|
RenderScriptCams(true, true, 1000, true, false)
|
||||||
SetCamActive(cam, true)
|
SetCamActive(cam, true)
|
||||||
|
|
||||||
end
|
end
|
||||||
SendNUIMessage({
|
SendNUIMessage({
|
||||||
type = "open",
|
type = "open",
|
||||||
|
|||||||
@@ -5,15 +5,16 @@ Dispatch = Dispatch or {}
|
|||||||
---@param data table The data to send to the dispatch system.
|
---@param data table The data to send to the dispatch system.
|
||||||
---@return nil
|
---@return nil
|
||||||
Dispatch.SendAlert = function(data)
|
Dispatch.SendAlert = function(data)
|
||||||
|
local ped = PlayerPedId()
|
||||||
TriggerServerEvent('community_bridge:Server:DispatchAlert', {
|
TriggerServerEvent('community_bridge:Server:DispatchAlert', {
|
||||||
sprite = data.blipData.sprite or 161,
|
sprite = data.blipData.sprite or 161,
|
||||||
color = data.blipData.color or 1,
|
color = data.blipData.color or 1,
|
||||||
scale = data.blipData.scale or 0.8,
|
scale = data.blipData.scale or 0.8,
|
||||||
vehicle = data.vehicle or nil,
|
vehicle = data.vehicle or nil,
|
||||||
plate = data.vehicle and GetVehicleNumberPlateText(data.vehicle) or nil,
|
plate = data.vehicle and GetVehicleNumberPlateText(data.vehicle) or nil,
|
||||||
ped = data.ped or cache.ped,
|
ped = data.ped or ped,
|
||||||
pedCoords = data.pedCoords or GetEntityCoords(cache.ped),
|
pedCoords = data.pedCoords or GetEntityCoords(ped),
|
||||||
coords = data.coords or GetEntityCoords(cache.ped),
|
coords = data.coords or GetEntityCoords(ped),
|
||||||
message = data.message or "An Alert Has Been Made",
|
message = data.message or "An Alert Has Been Made",
|
||||||
code = data.code or '10-80',
|
code = data.code or '10-80',
|
||||||
icon = data.icon or 'fas fa-question',
|
icon = data.icon or 'fas fa-question',
|
||||||
|
|||||||
@@ -3,14 +3,15 @@ if GetResourceState('bub-mdt') == 'missing' then return end
|
|||||||
Dispatch = Dispatch or {}
|
Dispatch = Dispatch or {}
|
||||||
|
|
||||||
Dispatch.SendAlert = function(data)
|
Dispatch.SendAlert = function(data)
|
||||||
|
local ped = PlayerPedId()
|
||||||
local alertData = {
|
local alertData = {
|
||||||
code = data.code or '10-80',
|
code = data.code or '10-80',
|
||||||
offense = data.message,
|
offense = data.message,
|
||||||
coords = data.coords or GetEntityCoords(cache.ped),
|
coords = data.coords or GetEntityCoords(ped),
|
||||||
info = { label = data.code or '10-80', icon = data.icon or 'fas fa-question' },
|
info = { label = data.code or '10-80', icon = data.icon or 'fas fa-question' },
|
||||||
blip = data.blipData.sprite or 1,
|
blip = data.blipData.sprite or 1,
|
||||||
isEmergency = data.priority == 1 and true or false,
|
isEmergency = data.priority == 1 and true or false,
|
||||||
blipCoords = data.coords or cache.ped and GetEntityCoords(cache.ped) or { x = 0, y = 0},
|
blipCoords = data.coords or ped and GetEntityCoords(ped) or { x = 0, y = 0},
|
||||||
}
|
}
|
||||||
exports["bub-mdt"]:CustomAlert(alertData)
|
exports["bub-mdt"]:CustomAlert(alertData)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -3,6 +3,7 @@ if GetResourceState('linden_outlawalert') == 'missing' then return end
|
|||||||
Dispatch = Dispatch or {}
|
Dispatch = Dispatch or {}
|
||||||
|
|
||||||
Dispatch.SendAlert = function(data)
|
Dispatch.SendAlert = function(data)
|
||||||
|
local ped = PlayerPedId()
|
||||||
TriggerServerEvent('wf-alerts:svNotify', {
|
TriggerServerEvent('wf-alerts:svNotify', {
|
||||||
dispatchData = {
|
dispatchData = {
|
||||||
displayCode = data.code or '211',
|
displayCode = data.code or '211',
|
||||||
@@ -14,7 +15,7 @@ Dispatch.SendAlert = function(data)
|
|||||||
info = data.message or "Alert"
|
info = data.message or "Alert"
|
||||||
},
|
},
|
||||||
caller = 'Anonymous',
|
caller = 'Anonymous',
|
||||||
coords = data.coords or GetEntityCoords(cache.ped)
|
coords = data.coords or GetEntityCoords(ped)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ Dispatch.SendAlert = function(data)
|
|||||||
model = data.vehicle and (GetDisplayNameFromVehicleModel(GetEntityModel(data.vehicle))) or nil,
|
model = data.vehicle and (GetDisplayNameFromVehicleModel(GetEntityModel(data.vehicle))) or nil,
|
||||||
color = color,
|
color = color,
|
||||||
plate = data.vehicle and GetVehicleNumberPlateText(data.vehicle) or nil,
|
plate = data.vehicle and GetVehicleNumberPlateText(data.vehicle) or nil,
|
||||||
speed = data.vehicle and (GetEntitySpeed(veh) * 3.6)..' kmh' or nil
|
speed = data.vehicle and (GetEntitySpeed(data.vehicle) * 3.6)..' kmh' or nil
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,10 @@
|
|||||||
|
---@diagnostic disable: duplicate-set-field
|
||||||
|
if GetResourceState('piotreq_gpt') == 'missing' then return end
|
||||||
|
Dispatch = Dispatch or {}
|
||||||
|
|
||||||
|
Dispatch.SendAlert = function(data)
|
||||||
|
if not data then return end
|
||||||
|
TriggerServerEvent('community_bridge:Server:piotreq_gpt', data)
|
||||||
|
end
|
||||||
|
|
||||||
|
return Dispatch
|
||||||
@@ -0,0 +1,39 @@
|
|||||||
|
if GetResourceState('piotreq_gpt') == 'missing' then return end
|
||||||
|
Dispatch = Dispatch or {}
|
||||||
|
|
||||||
|
Dispatch.SendAlert = function(src, alertData)
|
||||||
|
-- No clue if this works, but itd be nice to have someone test it.
|
||||||
|
--https://piotreq-scripts.gitbook.io/piotreq-scripts/assets-and-guides/police-mdt/dispatch-system
|
||||||
|
exports['piotreq_gpt']:SendAlert(src, {
|
||||||
|
title = alertData.message or "No message provided",
|
||||||
|
code = alertData.code or '10-80',
|
||||||
|
icon = alertData.icon or 'fa-solid fa-question',
|
||||||
|
info = {
|
||||||
|
{icon = 'fa-solid fa-road', isStreet = true},
|
||||||
|
{icon = alertData.icon or 'fa-solid fa-question', data = alertData.message or "No additional info"},
|
||||||
|
},
|
||||||
|
blip = { -- optional
|
||||||
|
scale = alertData.blipData and alertData.blipData.scale or 1.0,
|
||||||
|
sprite = alertData.blipData and alertData.blipData.sprite or 161,
|
||||||
|
category = 1, -- default 1
|
||||||
|
color = alertData.blipData and alertData.blipData.color or 84,
|
||||||
|
hidden = false, -- default false (hidden on legend)
|
||||||
|
priority = alertData.priority or 5, -- default 5
|
||||||
|
short = true, -- as short range? default true
|
||||||
|
alpha = 200, -- default 255
|
||||||
|
name = alertData.message or "Dispatch Alert"
|
||||||
|
},
|
||||||
|
type = 'normal', -- default normal
|
||||||
|
canAnswer = false, -- default false
|
||||||
|
maxOfficers = 6, -- default 4
|
||||||
|
time = 10,-- 10 minutes, default 5
|
||||||
|
notifyTime = 8000, -- 8 seconds, default 7
|
||||||
|
})
|
||||||
|
end
|
||||||
|
|
||||||
|
RegisterNetEvent('community_bridge:Server:piotreq_gpt', function(data)
|
||||||
|
local src = source
|
||||||
|
Dispatch.SendAlert(src, data)
|
||||||
|
end)
|
||||||
|
|
||||||
|
return Dispatch
|
||||||
@@ -5,27 +5,24 @@ Dispatch = Dispatch or {}
|
|||||||
|
|
||||||
Dispatch.SendAlert = function(data)
|
Dispatch.SendAlert = function(data)
|
||||||
local alertData = {
|
local alertData = {
|
||||||
message = data.message,
|
message = data.message or "No message provided",
|
||||||
code = data.code or '10-80',
|
code = data.code or '10-80',
|
||||||
icon = data.icon or 'fas fa-question',
|
icon = data.icon or 'fas fa-question',
|
||||||
priority = 2,
|
priority = data.priority or 2,
|
||||||
coords = data.coords,
|
coords = data.coords or GetEntityCoords(PlayerPedId()),
|
||||||
vehicle = data.vehicle,
|
vehicle = data.vehicle,
|
||||||
plate = data.plate,
|
plate = data.plate,
|
||||||
alertTime = (data.time or 10000) / 1000,
|
alertTime = data.time and (data.time / 1000) or nil,
|
||||||
alert = {
|
radius = data.blipData and data.blipData.radius or 0,
|
||||||
radius = 0,
|
sprite = data.blipData and data.blipData.sprite or 161,
|
||||||
recipientList = data.jobs,
|
color = data.blipData and data.blipData.color or 84,
|
||||||
sprite = data.blipData.sprite,
|
scale = data.blipData and data.blipData.scale or 1.0,
|
||||||
color = data.blipData.color,
|
length = 2,
|
||||||
scale = data.blipData.scale,
|
sound = "Lose_1st",
|
||||||
length = 2,
|
sound2 = "GTAO_FM_Events_Soundset",
|
||||||
sound = "Lose_1st",
|
offset = false,
|
||||||
sound2 = "GTAO_FM_Events_Soundset",
|
flash = data.blipData and data.blipData.flash or false,
|
||||||
offset = false,
|
jobs = data.jobs or data.job or "police"
|
||||||
flash = false
|
|
||||||
},
|
|
||||||
jobs = data.jobs
|
|
||||||
}
|
}
|
||||||
exports["ps-dispatch"]:CustomAlert(alertData)
|
exports["ps-dispatch"]:CustomAlert(alertData)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -6,10 +6,11 @@ Doorlock = Doorlock or {}
|
|||||||
---This will get the closest door to the ped
|
---This will get the closest door to the ped
|
||||||
---@return string | nil
|
---@return string | nil
|
||||||
Doorlock.GetClosestDoor = function()
|
Doorlock.GetClosestDoor = function()
|
||||||
|
local ped = PlayerPedId()
|
||||||
local closestDoor = exports["qb-doorlock"]:GetClosestDoor()
|
local closestDoor = exports["qb-doorlock"]:GetClosestDoor()
|
||||||
if Table.CheckPopulated(closestDoor) then return closestDoor end
|
if Table.CheckPopulated(closestDoor) then return closestDoor end
|
||||||
local allDoors = exports["qb-doorlock"]:GetDoorList()
|
local allDoors = exports["qb-doorlock"]:GetDoorList()
|
||||||
local pedCoords = GetEntityCoords(cache.ped)
|
local pedCoords = GetEntityCoords(ped)
|
||||||
local door = 0
|
local door = 0
|
||||||
local doorDist = 1000.0
|
local doorDist = 1000.0
|
||||||
for doorID, data in pairs(allDoors) do
|
for doorID, data in pairs(allDoors) do
|
||||||
|
|||||||
@@ -6,8 +6,9 @@ Doorlock = Doorlock or {}
|
|||||||
---This will get the closest door to the ped
|
---This will get the closest door to the ped
|
||||||
---@return string | nil
|
---@return string | nil
|
||||||
Doorlock.GetClosestDoor = function()
|
Doorlock.GetClosestDoor = function()
|
||||||
|
local ped = PlayerPedId()
|
||||||
local allDoors = exports.rcore_doorlock:getLoadedDoors()
|
local allDoors = exports.rcore_doorlock:getLoadedDoors()
|
||||||
local pedCoords = GetEntityCoords(cache.ped)
|
local pedCoords = GetEntityCoords(ped)
|
||||||
local door = 0
|
local door = 0
|
||||||
local doorDist = 1000.0
|
local doorDist = 1000.0
|
||||||
for _, data in pairs(allDoors) do
|
for _, data in pairs(allDoors) do
|
||||||
|
|||||||
@@ -1,3 +1,56 @@
|
|||||||
Framework = Framework or {}
|
Framework = Framework or {}
|
||||||
|
|
||||||
|
local jobsRegisteredTable = {}
|
||||||
|
local invertedJobsRegisteredTable = {}
|
||||||
|
|
||||||
|
---This is an internal function that will be used to retrieve job counts later.
|
||||||
|
---@param jobName string
|
||||||
|
---@return number
|
||||||
|
Framework.GetJobCount = function(jobName)
|
||||||
|
return #jobsRegisteredTable[jobName] or 0
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will return a list of player sources for a given job.
|
||||||
|
---@param jobName string
|
||||||
|
---@return table
|
||||||
|
Framework.GetPlayerSourcesByJob = function(jobName)
|
||||||
|
if not jobsRegisteredTable[jobName] then return {} end
|
||||||
|
return jobsRegisteredTable[jobName]
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will update the cached tables for job counts.
|
||||||
|
---This is used to track how many players are in a job.
|
||||||
|
---@param src number
|
||||||
|
---@param jobName string
|
||||||
|
Framework.AddJobCount = function(src, jobName)
|
||||||
|
if not jobsRegisteredTable[jobName] then jobsRegisteredTable[jobName] = {} end
|
||||||
|
if jobsRegisteredTable[jobName][src] then return false end
|
||||||
|
jobsRegisteredTable[jobName][src] = true
|
||||||
|
invertedJobsRegisteredTable[src] = jobName
|
||||||
|
return true, #jobsRegisteredTable[jobName]
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will return the job name for a given source.
|
||||||
|
---This is an internal function that will be used to retrieve job names in situations where player data is unavailable.
|
||||||
|
---@param src number
|
||||||
|
Framework.SearchJobCountBySource = function(src)
|
||||||
|
if not invertedJobsRegisteredTable[src] then return nil end
|
||||||
|
return invertedJobsRegisteredTable[src]
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will remove the job count for a given source.
|
||||||
|
---@param src number
|
||||||
|
---@param jobName string | nil
|
||||||
|
Framework.RemoveJobCount = function(src, jobName)
|
||||||
|
if not jobName then
|
||||||
|
jobName = Framework.SearchJobCountBySource(src)
|
||||||
|
end
|
||||||
|
if not jobName then return false end
|
||||||
|
if not jobsRegisteredTable[jobName] then return false end
|
||||||
|
if not jobsRegisteredTable[jobName][src] then return false end
|
||||||
|
invertedJobsRegisteredTable[src] = nil
|
||||||
|
jobsRegisteredTable[jobName][src] = nil
|
||||||
|
return true, #jobsRegisteredTable[jobName]
|
||||||
|
end
|
||||||
|
|
||||||
return Framework
|
return Framework
|
||||||
@@ -330,24 +330,16 @@ Framework.SetPlayerDuty = function(src, status)
|
|||||||
local xPlayer = Framework.GetPlayer(src)
|
local xPlayer = Framework.GetPlayer(src)
|
||||||
if not xPlayer then return false end
|
if not xPlayer then return false end
|
||||||
local job = xPlayer.getJob()
|
local job = xPlayer.getJob()
|
||||||
if not job.onDuty then return false end
|
if job.name == 'unemployed' then return false end
|
||||||
xPlayer.setJob(job.name, job.grade, status)
|
xPlayer.setJob(job.name, job.grade, status)
|
||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will get a table of player sources that have the specified job name.
|
---This will get a table of player sources that have the specified job name.
|
||||||
---@param job any
|
---@param job string
|
||||||
---@return table
|
---@return table
|
||||||
Framework.GetPlayersByJob = function(job)
|
Framework.GetPlayersByJob = function(job)
|
||||||
local players = GetPlayers()
|
return Framework.GetPlayerSourcesByJob(job) or {}
|
||||||
local playerList = {}
|
|
||||||
for _, src in pairs(players) do
|
|
||||||
local xPlayer = Framework.GetPlayer(src)
|
|
||||||
if xPlayer and xPlayer.getJob().name == job then
|
|
||||||
table.insert(playerList, src)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return playerList
|
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Sets the player's job to the specified name and grade.
|
-- Sets the player's job to the specified name and grade.
|
||||||
@@ -474,6 +466,12 @@ RegisterNetEvent("esx:playerLogout", function(src)
|
|||||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("esx:setJob", function(src, job, lastJob)
|
||||||
|
src = src or source
|
||||||
|
if not job or not lastJob then return end
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerJobChange", src, job.name)
|
||||||
|
end)
|
||||||
|
|
||||||
AddEventHandler("playerDropped", function()
|
AddEventHandler("playerDropped", function()
|
||||||
local src = source
|
local src = source
|
||||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
|
|||||||
@@ -361,18 +361,10 @@ Framework.GetPlayerGang = function(src)
|
|||||||
end
|
end
|
||||||
|
|
||||||
---This will get a table of player sources that have the specified job name.
|
---This will get a table of player sources that have the specified job name.
|
||||||
---@param job any
|
---@param job string
|
||||||
---@return table
|
---@return table
|
||||||
Framework.GetPlayersByJob = function(job)
|
Framework.GetPlayersByJob = function(job)
|
||||||
local playerList = {}
|
return Framework.GetPlayerSourcesByJob(job) or {}
|
||||||
local players = QBCore.Functions.GetPlayers()
|
|
||||||
for _, src in pairs(players) do
|
|
||||||
local player = Framework.GetPlayer(src).PlayerData
|
|
||||||
if player.job.name == job then
|
|
||||||
table.insert(playerList, src)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return playerList
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Depricated: Returns the job name, label, grade name, and grade level of the player.
|
---Depricated: Returns the job name, label, grade name, and grade level of the player.
|
||||||
@@ -572,6 +564,12 @@ RegisterNetEvent("QBCore:Server:OnPlayerUnload", function(src)
|
|||||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("QBCore:Server:OnJobUpdate", function(src, job)
|
||||||
|
src = src or source
|
||||||
|
if not job then return end
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerJobChange", src, job.name)
|
||||||
|
end)
|
||||||
|
|
||||||
AddEventHandler("playerDropped", function()
|
AddEventHandler("playerDropped", function()
|
||||||
local src = source
|
local src = source
|
||||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
|
|||||||
@@ -56,8 +56,7 @@ end
|
|||||||
---@param metadata table | string
|
---@param metadata table | string
|
||||||
---@return table | string | number | boolean
|
---@return table | string | number | boolean
|
||||||
Framework.GetPlayerMetaData = function(metadata)
|
Framework.GetPlayerMetaData = function(metadata)
|
||||||
local playerData = Framework.GetPlayerData()
|
return Framework.GetPlayerData().metadata[metadata]
|
||||||
return playerData.metadata[metadata]
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will send a notification to the player.
|
---This will send a notification to the player.
|
||||||
|
|||||||
@@ -286,18 +286,11 @@ Framework.GetPlayerGang = function(src)
|
|||||||
return player.gang.name
|
return player.gang.name
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will return a table of all players with the specified job.
|
---This will get a table of player sources that have the specified job name.
|
||||||
---@param job string
|
---@param job string
|
||||||
---@return table
|
---@return table
|
||||||
Framework.GetPlayersByJob = function(job)
|
Framework.GetPlayersByJob = function(job)
|
||||||
local playerList = {}
|
return Framework.GetPlayerSourcesByJob(job) or {}
|
||||||
local players = QBox:GetQBPlayers()
|
|
||||||
for src, player in pairs(players) do
|
|
||||||
if player.PlayerData.job.name == job then
|
|
||||||
table.insert(playerList, src)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return playerList
|
|
||||||
end
|
end
|
||||||
|
|
||||||
---Depricated: Returns the job name, label, grade name, and grade level of the player.
|
---Depricated: Returns the job name, label, grade name, and grade level of the player.
|
||||||
@@ -481,6 +474,12 @@ RegisterNetEvent("QBCore:Server:OnPlayerUnload", function(src)
|
|||||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
RegisterNetEvent("QBCore:Server:OnJobUpdate", function(src, job)
|
||||||
|
src = src or source
|
||||||
|
if not job then return end
|
||||||
|
TriggerEvent("community_bridge:Server:OnPlayerJobChange", src, job.name)
|
||||||
|
end)
|
||||||
|
|
||||||
AddEventHandler("playerDropped", function()
|
AddEventHandler("playerDropped", function()
|
||||||
local src = source
|
local src = source
|
||||||
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
TriggerEvent("community_bridge:Server:OnPlayerUnload", src)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
---@diagnostic disable: duplicate-set-field
|
---@diagnostic disable: duplicate-set-field
|
||||||
local resourceName = "LegacyFuel"
|
local resourceName = "LegacyFuel"
|
||||||
if GetResourceState(resourceName) == 'missing' then return end
|
if GetResourceState(resourceName) == 'missing' then return end
|
||||||
|
if GetResourceState("qb-fuel") == 'started' then return end
|
||||||
Fuel = Fuel or {}
|
Fuel = Fuel or {}
|
||||||
|
|
||||||
---This will get the name of the Fuel being used (if a supported Fuel).
|
---This will get the name of the Fuel being used (if a supported Fuel).
|
||||||
|
|||||||
@@ -0,0 +1,29 @@
|
|||||||
|
---@diagnostic disable: duplicate-set-field
|
||||||
|
local resourceName = "qb-fuel"
|
||||||
|
if GetResourceState(resourceName) == 'missing' then return end
|
||||||
|
Fuel = Fuel or {}
|
||||||
|
|
||||||
|
---This will get the name of the Fuel being used (if a supported Fuel).
|
||||||
|
---@return string
|
||||||
|
Fuel.GetResourceName = function()
|
||||||
|
return resourceName
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will get the fuel level of the vehicle.
|
||||||
|
---@param vehicle number The vehicle entity ID.
|
||||||
|
---@return number fuel The fuel level of the vehicle.
|
||||||
|
Fuel.GetFuel = function(vehicle)
|
||||||
|
if not DoesEntityExist(vehicle) then return 0.0 end
|
||||||
|
return exports['qb-fuel']:GetFuel(vehicle)
|
||||||
|
end
|
||||||
|
|
||||||
|
---This will set the fuel level of the vehicle.
|
||||||
|
---@param vehicle number The vehicle entity ID.
|
||||||
|
---@param fuel number The fuel level to set.
|
||||||
|
---@return nil
|
||||||
|
Fuel.SetFuel = function(vehicle, fuel, type)
|
||||||
|
if not DoesEntityExist(vehicle) then return end
|
||||||
|
return exports['qb-fuel']:SetFuel(vehicle, fuel)
|
||||||
|
end
|
||||||
|
|
||||||
|
return Fuel
|
||||||
@@ -8,7 +8,16 @@ Input = {}
|
|||||||
function Input.Open(title, data, isQBFormat, submitText)
|
function Input.Open(title, data, isQBFormat, submitText)
|
||||||
local inputs = data.inputs
|
local inputs = data.inputs
|
||||||
if isQBFormat then
|
if isQBFormat then
|
||||||
return lib.inputDialog(title, QBToOxInput(inputs))
|
local convertedData = {}
|
||||||
|
local returnData = lib.inputDialog(title, QBToOxInput(inputs))
|
||||||
|
for i, v in pairs(inputs) do
|
||||||
|
for k, j in pairs(returnData or {}) do
|
||||||
|
if k == v.name then
|
||||||
|
convertedData[v.name] = j
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return convertedData
|
||||||
else
|
else
|
||||||
return lib.inputDialog(title, data)
|
return lib.inputDialog(title, data)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ function Input.Open(title, data, isQBFormat, submitText)
|
|||||||
for i, v in pairs(input) do
|
for i, v in pairs(input) do
|
||||||
for k, j in pairs(returnData) do
|
for k, j in pairs(returnData) do
|
||||||
if k == v.name then
|
if k == v.name then
|
||||||
convertedData[tonumber(i)] = j
|
convertedData[v.name] = j
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -32,9 +32,14 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
|
print("No get image path for this inventory, using default.")
|
||||||
return "https://avatars.githubusercontent.com/u/47620135"
|
return "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will remove the file extension from the item name if present.
|
||||||
|
---example: "item.png" will become "item"
|
||||||
|
---@param item string
|
||||||
|
---@return string
|
||||||
Inventory.StripPNG = function(item)
|
Inventory.StripPNG = function(item)
|
||||||
if string.find(item, ".png") then
|
if string.find(item, ".png") then
|
||||||
item = string.gsub(item, ".png", "")
|
item = string.gsub(item, ".png", "")
|
||||||
@@ -42,6 +47,17 @@ Inventory.StripPNG = function(item)
|
|||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will remove the file extension from the item name if present.
|
||||||
|
---example: "item.webp" will become "item"
|
||||||
|
---@param item string
|
||||||
|
---@return string
|
||||||
|
Inventory.StripWebp = function(item)
|
||||||
|
if string.find(item, ".webp") then
|
||||||
|
item = string.gsub(item, ".webp", "")
|
||||||
|
end
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
|
||||||
---This will return the entire items table from the inventory.
|
---This will return the entire items table from the inventory.
|
||||||
---@return table
|
---@return table
|
||||||
Inventory.Items = function()
|
Inventory.Items = function()
|
||||||
@@ -52,4 +68,6 @@ Inventory.Items = function()
|
|||||||
return Framework.Shared.Items
|
return Framework.Shared.Items
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -193,4 +193,19 @@ Inventory.StripPNG = function(item)
|
|||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
---This will remove the file extension from the item name if present.
|
||||||
|
---example: "item.webp" will become "item"
|
||||||
|
---@param item string
|
||||||
|
---@return string
|
||||||
|
Inventory.StripWebp = function(item)
|
||||||
|
if string.find(item, ".webp") then
|
||||||
|
item = string.gsub(item, ".webp", "")
|
||||||
|
end
|
||||||
|
return item
|
||||||
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, targetSrc)
|
||||||
|
return false, Prints.Error("OpenPlayerInventory is not implemented in this inventory, because of this we dont have a way to open a players inventory.")
|
||||||
|
end
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -190,4 +190,13 @@ Inventory.GetImagePath = function(item)
|
|||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, target)
|
||||||
|
assert(src, "OpenPlayerInventory: src is required")
|
||||||
|
if not target then
|
||||||
|
target = src
|
||||||
|
end
|
||||||
|
exports['codem-inventory']:OpenInventory(src, target)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -257,4 +257,14 @@ Inventory.Items = function()
|
|||||||
return core:getItemsList()
|
return core:getItemsList()
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, target)
|
||||||
|
assert(src, "OpenPlayerInventory: src is required")
|
||||||
|
if not target then
|
||||||
|
target = src
|
||||||
|
end
|
||||||
|
local identifier = Framework.GetPlayerIdentifier(target)
|
||||||
|
if not identifier then return false end
|
||||||
|
exports.core_inventory:openInventory(src, 'stash-'.. identifier:gsub(':',''), 'stash', nil, nil, true, nil, false)
|
||||||
|
end
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -189,4 +189,14 @@ Inventory.RegisterShop = function(shopTitle, shopInventory, shopCoords, shopGrou
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, target)
|
||||||
|
assert(src, "OpenPlayerInventory: src is required")
|
||||||
|
if not target then
|
||||||
|
target = src
|
||||||
|
end
|
||||||
|
local identifier = Framework.GetPlayerIdentifier(target)
|
||||||
|
if not identifier then return false end
|
||||||
|
exports['jpr-inventory']:OpenInventory(src, identifier)
|
||||||
|
end
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -239,4 +239,12 @@ Inventory.GetImagePath = function(item)
|
|||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, target)
|
||||||
|
assert(src, "OpenPlayerInventory: src is required")
|
||||||
|
if not target then
|
||||||
|
target = src
|
||||||
|
end
|
||||||
|
exports.origen_inventory:OpenInventory(src, "otherplayer", target)
|
||||||
|
end
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -17,6 +17,7 @@ Inventory.Stashes = Inventory.Stashes or {}
|
|||||||
---@param metadata table
|
---@param metadata table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
|
if not ox_inventory:CanCarryItem(src, item, count, metadata) then return false end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
||||||
return ox_inventory:AddItem(src, item, count, metadata)
|
return ox_inventory:AddItem(src, item, count, metadata)
|
||||||
end
|
end
|
||||||
@@ -224,4 +225,12 @@ Inventory.GetItem = function(src, item, metadata)
|
|||||||
return ox_inventory:GetItem(src, item, metadata, false)
|
return ox_inventory:GetItem(src, item, metadata, false)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, target)
|
||||||
|
assert(src, "OpenPlayerInventory: src is required")
|
||||||
|
if not target then
|
||||||
|
target = src
|
||||||
|
end
|
||||||
|
exports.ox_inventory:openInventory('player', target)
|
||||||
|
end
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -21,6 +21,7 @@ end
|
|||||||
---@param metadata table
|
---@param metadata table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
|
if getInventoryNewVersion() then if not qbInventory:CanAddItem(src, item, count) then return false end end
|
||||||
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add', count)
|
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[item], 'add', count)
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
||||||
return qbInventory:AddItem(src, item, count, slot, metadata, 'community_bridge')
|
return qbInventory:AddItem(src, item, count, slot, metadata, 'community_bridge')
|
||||||
@@ -275,4 +276,12 @@ Inventory.RegisterShop = function(shopTitle, shopInventory, shopCoords, shopGrou
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, target)
|
||||||
|
assert(src, "OpenPlayerInventory: src is required")
|
||||||
|
if not target then
|
||||||
|
target = src
|
||||||
|
end
|
||||||
|
exports['qb-inventory']:OpenInventory(src, target)
|
||||||
|
end
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -18,7 +18,7 @@ Inventory.GetItemInfo = function(item)
|
|||||||
stack = itemData.unique or "false",
|
stack = itemData.unique or "false",
|
||||||
weight = itemData.weight or "0",
|
weight = itemData.weight or "0",
|
||||||
description = itemData.description or "none",
|
description = itemData.description or "none",
|
||||||
image = itemData.image or Inventory.GetImagePath(item),
|
image = Inventory.GetImagePath(item),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -233,4 +233,12 @@ Inventory.GetImagePath = function(item)
|
|||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, target)
|
||||||
|
assert(src, "OpenPlayerInventory: src is required")
|
||||||
|
if not target then
|
||||||
|
target = src
|
||||||
|
end
|
||||||
|
exports['qs-inventory']:OpenInventory(src, target)
|
||||||
|
end
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -10,13 +10,14 @@ Inventory = Inventory or {}
|
|||||||
Inventory.GetItemInfo = function(item)
|
Inventory.GetItemInfo = function(item)
|
||||||
local itemData = tgiann:GetItemList()
|
local itemData = tgiann:GetItemList()
|
||||||
if not itemData[item] then return {} end
|
if not itemData[item] then return {} end
|
||||||
|
itemData = itemData[item]
|
||||||
return {
|
return {
|
||||||
name = itemData.name or "Missing Name",
|
name = itemData.name or "Missing Name",
|
||||||
label = itemData.label or "Missing Label",
|
label = itemData.label or "Missing Label",
|
||||||
stack = itemData.unique or "false",
|
stack = itemData.unique or "false",
|
||||||
weight = itemData.weight or "0",
|
weight = itemData.weight or "0",
|
||||||
description = itemData.description or "none",
|
description = itemData.description or "none",
|
||||||
image = itemData.image or Inventory.GetImagePath(item),
|
image = Inventory.GetImagePath(item),
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -39,10 +40,11 @@ end
|
|||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
item = Inventory.StripPNG(item)
|
local pngItem = Inventory.StripPNG(item)
|
||||||
local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item))
|
local webpItem = Inventory.StripWebp(item)
|
||||||
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
|
local pngPath = LoadResourceFile("inventory_images", string.format("/images/%s.png", pngItem))
|
||||||
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
|
local webpPath = LoadResourceFile("inventory_images", string.format("/images/%s.webp", webpItem))
|
||||||
|
local imagePath = pngPath and string.format("nui://inventory_images/images/%s.png", pngItem) or webpPath and string.format("nui://inventory_images/images/%s.webp", webpItem)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -14,6 +14,7 @@ Inventory.Stashes = Inventory.Stashes or {}
|
|||||||
---@param metadata table
|
---@param metadata table
|
||||||
---@return boolean
|
---@return boolean
|
||||||
Inventory.AddItem = function(src, item, count, slot, metadata)
|
Inventory.AddItem = function(src, item, count, slot, metadata)
|
||||||
|
if not tgiann:CanCarryItem(src, item, count) then return false end
|
||||||
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
TriggerClientEvent("community_bridge:client:inventory:updateInventory", src, {action = "add", item = item, count = count, slot = slot, metadata = metadata})
|
||||||
return tgiann:AddItem(src, item, count, slot, metadata, false)
|
return tgiann:AddItem(src, item, count, slot, metadata, false)
|
||||||
end
|
end
|
||||||
@@ -200,18 +201,18 @@ Inventory.ClearStash = function(id, _type)
|
|||||||
return true
|
return true
|
||||||
end
|
end
|
||||||
|
|
||||||
---This will get the image path for an item, it is an alternate option to GetItemInfo. If a image isnt found will revert to community_bridge logo (useful for menus)
|
---This will get the image path for this item, if not found will return placeholder.
|
||||||
---@param item string
|
---@param item string
|
||||||
---@return string
|
---@return string
|
||||||
Inventory.GetImagePath = function(item)
|
Inventory.GetImagePath = function(item)
|
||||||
item = Inventory.StripPNG(item)
|
local pngItem = Inventory.StripPNG(item)
|
||||||
local pngPath = LoadResourceFile("inventory_images", string.format("html/images/%s.png", item))
|
local webpItem = Inventory.StripWebp(item)
|
||||||
local webpPath = LoadResourceFile("inventory_images", string.format("html/images/%s.webp", item))
|
local pngPath = LoadResourceFile("inventory_images", string.format("/images/%s.png", pngItem))
|
||||||
local imagePath = pngPath and string.format("nui://inventory_images/html/images/%s.png", item) or webpPath and string.format("nui://inventory_images/html/images/%s.webp", item)
|
local webpPath = LoadResourceFile("inventory_images", string.format("/images/%s.webp", webpItem))
|
||||||
|
local imagePath = pngPath and string.format("nui://inventory_images/images/%s.png", pngItem) or webpPath and string.format("nui://inventory_images/images/%s.webp", webpItem)
|
||||||
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
return imagePath or "https://avatars.githubusercontent.com/u/47620135"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
---UNUSED:
|
---UNUSED:
|
||||||
---This will return generic item data from the specified inventory, with the items total count.
|
---This will return generic item data from the specified inventory, with the items total count.
|
||||||
---
|
---
|
||||||
@@ -229,4 +230,13 @@ Inventory.GetItem = function(src, item, metadata)
|
|||||||
return item
|
return item
|
||||||
end
|
end
|
||||||
|
|
||||||
|
Inventory.OpenPlayerInventory = function(src, target)
|
||||||
|
assert(src, "OpenPlayerInventory: src is required")
|
||||||
|
if not target then
|
||||||
|
target = src
|
||||||
|
end
|
||||||
|
exports['tgiann-inventory']:OpenInventoryById(src, target)
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
return Inventory
|
return Inventory
|
||||||
@@ -25,7 +25,7 @@ local function QBToOxMenu(id, menu)
|
|||||||
description = v.txt,
|
description = v.txt,
|
||||||
icon = v.icon,
|
icon = v.icon,
|
||||||
args = v.params.args,
|
args = v.params.args,
|
||||||
onSelect = function(selected, secondary, args)
|
onSelect = v.action or function(selected, secondary, args)
|
||||||
local params = menu[id]?.options?[selected]?.params
|
local params = menu[id]?.options?[selected]?.params
|
||||||
if not params then return end
|
if not params then return end
|
||||||
local event = params.event
|
local event = params.event
|
||||||
@@ -56,3 +56,23 @@ end
|
|||||||
GetMenuResourceName = function()
|
GetMenuResourceName = function()
|
||||||
return resourceName
|
return resourceName
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
-- RegisterCommand('menutest', function()
|
||||||
|
-- local test1 = function()
|
||||||
|
-- print("Test 1 executed")
|
||||||
|
-- end
|
||||||
|
|
||||||
|
-- Bridge.Menu.Open({
|
||||||
|
-- title = "test",
|
||||||
|
-- description = "test",
|
||||||
|
-- options = {
|
||||||
|
-- {
|
||||||
|
-- title = "test",
|
||||||
|
-- description = "test",
|
||||||
|
-- icon = "fas fa-box-open",
|
||||||
|
-- onSelect = test1
|
||||||
|
-- },
|
||||||
|
-- }
|
||||||
|
-- })
|
||||||
|
-- end)
|
||||||
@@ -16,7 +16,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotify = function(message, _type, time)
|
Notify.SendNotify = function(message, _type, time)
|
||||||
time = time or 3000
|
time = time or 3000
|
||||||
return exports['brutal_notify']:SendAlert('Notification', message, time, _type, false)
|
return exports['brutal_notify']:SendAlert('Notification', message, time, _type or "success", false)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Notify
|
return Notify
|
||||||
@@ -22,6 +22,8 @@ Notify.SendNotify = function(message, _type, time)
|
|||||||
_type = tostring(2)
|
_type = tostring(2)
|
||||||
elseif _type == "warning" or _type == "warn" then
|
elseif _type == "warning" or _type == "warn" then
|
||||||
_type = tostring(3)
|
_type = tostring(3)
|
||||||
|
else
|
||||||
|
_type = tostring(2) -- Default to 2 if type is not recognized
|
||||||
end
|
end
|
||||||
return exports['FL-Notify']:Notify("Notification", "", message, 5000, tonumber(_type), 0)
|
return exports['FL-Notify']:Notify("Notification", "", message, 5000, tonumber(_type), 0)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotify = function(message, _type, time)
|
Notify.SendNotify = function(message, _type, time)
|
||||||
time = time or 3000
|
time = time or 3000
|
||||||
return exports.lation_ui:notify({ message = message, type = _type, duration = time, position = 'top-right' })
|
return exports.lation_ui:notify({ message = message, type = _type or "success", duration = time, position = 'top-right' })
|
||||||
end
|
end
|
||||||
|
|
||||||
return Notify
|
return Notify
|
||||||
@@ -15,7 +15,7 @@ end
|
|||||||
---@return nil
|
---@return nil
|
||||||
Notify.SendNotify = function(message, _type, time)
|
Notify.SendNotify = function(message, _type, time)
|
||||||
time = time or 3000
|
time = time or 3000
|
||||||
return exports['okokNotify']:Alert('Notification', message, time, _type, false)
|
return exports['okokNotify']:Alert('Notification', message, time, _type or "Success", false)
|
||||||
end
|
end
|
||||||
|
|
||||||
return Notify
|
return Notify
|
||||||
@@ -99,7 +99,7 @@ function ProgressBar.Open(options, cb, isQBInput)
|
|||||||
|
|
||||||
local success = exports.lation_ui:progressBar(options)
|
local success = exports.lation_ui:progressBar(options)
|
||||||
|
|
||||||
if cb then cb(not success) end
|
if cb then cb(success) end
|
||||||
return success
|
return success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ function ProgressBar.Open(options, cb, isQBInput)
|
|||||||
local style = options.style or 'bar'
|
local style = options.style or 'bar'
|
||||||
local success = style == 'circle' and exports.ox_lib:progressCircle(options) or exports.ox_lib:progressBar(options)
|
local success = style == 'circle' and exports.ox_lib:progressCircle(options) or exports.ox_lib:progressBar(options)
|
||||||
|
|
||||||
if cb then cb(not success) end
|
if cb then cb(success) end
|
||||||
return success
|
return success
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ function ProgressBar.Open(options, cb, qbFormat)
|
|||||||
end
|
end
|
||||||
local prom = promise.new()
|
local prom = promise.new()
|
||||||
exports['progressbar']:Progress(options, function(cancelled)
|
exports['progressbar']:Progress(options, function(cancelled)
|
||||||
if cb then cb(not cancelled) end
|
if cb then cb( not cancelled) end
|
||||||
prom:resolve(not cancelled)
|
prom:resolve(not cancelled)
|
||||||
end)
|
end)
|
||||||
return Citizen.Await(prom)
|
return Citizen.Await(prom)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ Shops.CompleteCheckout = function(src, shopName, item, amount, paymentType)
|
|||||||
local mathStuff = tonumber(itemData.price) * tonumber(amount)
|
local mathStuff = tonumber(itemData.price) * tonumber(amount)
|
||||||
if balance < mathStuff then return Notify.SendNotify(src, ilocale('Shops.NotEnoughMoney'), "error", 5000) end
|
if balance < mathStuff then return Notify.SendNotify(src, ilocale('Shops.NotEnoughMoney'), "error", 5000) end
|
||||||
if not Framework.RemoveAccountBalance(src, paymentType, mathStuff) then return end
|
if not Framework.RemoveAccountBalance(src, paymentType, mathStuff) then return end
|
||||||
Inventory.AddItem(src, itemData.name, amount)
|
Inventory.AddItem(src, itemData.name, tonumber(amount))
|
||||||
local itemLabel = Inventory.GetItemInfo(itemData.name).label
|
local itemLabel = Inventory.GetItemInfo(itemData.name).label
|
||||||
Notify.SendNotify(src, ilocale('Shops.PurchasedItem')..itemLabel, "success", 5000)
|
Notify.SendNotify(src, ilocale('Shops.PurchasedItem')..itemLabel, "success", 5000)
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -22,14 +22,25 @@ Target = Target or {}
|
|||||||
Target.FixOptions = function(options)
|
Target.FixOptions = function(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)
|
if not action then
|
||||||
if type(entityOrData) == 'table' then
|
local _type = v.type
|
||||||
return action(entityOrData.entity)
|
if _type and _type == "server" then
|
||||||
|
v.serverEvent = v.event
|
||||||
|
v.event = nil
|
||||||
end
|
end
|
||||||
return action(entityOrData)
|
|
||||||
|
else
|
||||||
|
local select = function(entityOrData)
|
||||||
|
if type(entityOrData) == 'table' then
|
||||||
|
return action(entityOrData.entity)
|
||||||
|
end
|
||||||
|
return action(entityOrData)
|
||||||
|
end
|
||||||
|
v.onSelect = select
|
||||||
|
|
||||||
end
|
end
|
||||||
options[k].onSelect = select
|
v.groups = v.job or v.groups
|
||||||
options[k].groups = v.job or v.groups
|
-- print(json.encode(v))
|
||||||
end
|
end
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
@@ -151,13 +162,13 @@ 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, heading, options)
|
Target.AddSphereZone = function(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,
|
||||||
radius = radius,
|
radius = radius,
|
||||||
name = name,
|
name = name,
|
||||||
debug = targetDebug,
|
debug = targetDebug or debug,
|
||||||
options = options
|
options = options
|
||||||
})
|
})
|
||||||
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
|
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
|
||||||
|
|||||||
@@ -24,14 +24,22 @@ local qb_target = exports['qb-target']
|
|||||||
Target.FixOptions = function(options)
|
Target.FixOptions = function(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 = action and function(entityOrData)
|
||||||
if type(entityOrData) == 'table' then
|
if type(entityOrData) == 'table' then
|
||||||
return action(entityOrData.entity)
|
return action(entityOrData.entity)
|
||||||
end
|
end
|
||||||
return action(entityOrData)
|
return action(entityOrData)
|
||||||
end
|
end
|
||||||
|
if v.serverEvent then
|
||||||
|
v.type = "server"
|
||||||
|
v.event = v.serverEvent
|
||||||
|
elseif v.event then
|
||||||
|
v.type = "client"
|
||||||
|
v.event = v.event
|
||||||
|
end
|
||||||
options[k].action = select
|
options[k].action = select
|
||||||
options[k].job = v.job or v.groups
|
options[k].job = v.job or v.groups
|
||||||
|
options[k].jobType = v.jobType
|
||||||
end
|
end
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
@@ -170,11 +178,11 @@ 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)
|
Target.AddSphereZone = function(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,
|
debugPoly = targetDebug or debug,
|
||||||
}, {
|
}, {
|
||||||
options = options,
|
options = options,
|
||||||
distance = options.distance or 1.5,
|
distance = options.distance or 1.5,
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ Target.FixOptions = function(options)
|
|||||||
return action(entityOrData)
|
return action(entityOrData)
|
||||||
end
|
end
|
||||||
options[k].onSelect = select
|
options[k].onSelect = select
|
||||||
|
options[k].groups = v.job or v.groups
|
||||||
end
|
end
|
||||||
return options
|
return options
|
||||||
end
|
end
|
||||||
@@ -145,13 +146,13 @@ 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, heading, options)
|
Target.AddSphereZone = function(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,
|
||||||
radius = radius,
|
radius = radius,
|
||||||
name = name,
|
name = name,
|
||||||
debug = targetDebug,
|
debug = targetDebug or debug,
|
||||||
options = options
|
options = options
|
||||||
})
|
})
|
||||||
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
|
table.insert(targetZones, { name = name, id = target, creator = GetInvokingResource() })
|
||||||
|
|||||||
@@ -1,36 +1,169 @@
|
|||||||
Version = Version or {}
|
Version = Version or {}
|
||||||
|
|
||||||
---Pass a github username and repo name to check for the latest version of the resource.
|
local function parseVersion(versionString)
|
||||||
---
|
return versionString and versionString:match('%d+%.%d+%.%d+') or versionString
|
||||||
---Tebex is a optional boolean to determine if the message should be for a escrowed resource or not.
|
end
|
||||||
---
|
|
||||||
---Example Version.VersionChecker("TheOrderFivem/community_bridge", false)
|
local function padVersion(version)
|
||||||
---@param repoPath string
|
local parts = {}
|
||||||
---@param tebex boolean | nil
|
for num in version:gmatch("%d+") do
|
||||||
---@return nil
|
table.insert(parts, tonumber(num))
|
||||||
|
end
|
||||||
|
while #parts < 3 do
|
||||||
|
table.insert(parts, 0)
|
||||||
|
end
|
||||||
|
return parts
|
||||||
|
end
|
||||||
|
|
||||||
|
local function compareVersions(v1, v2)
|
||||||
|
local a, b = padVersion(v1), padVersion(v2)
|
||||||
|
for i = 1, 3 do
|
||||||
|
if a[i] < b[i] then
|
||||||
|
return -1
|
||||||
|
elseif a[i] > b[i] then
|
||||||
|
return 1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
|
||||||
|
local function buildPatchNotesUrl(branch, repoPath)
|
||||||
|
local username, reponame = repoPath:match("([^/]+)/([^/]+)")
|
||||||
|
return ('https://raw.githubusercontent.com/%s/%s/%s/resources.json'):format(username, reponame, branch)
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getDownloadUrl(repoPath, isTebex, actualRepoPath)
|
||||||
|
if isTebex then
|
||||||
|
return "https://portal.cfx.re/assets/granted-assets"
|
||||||
|
elseif actualRepoPath then
|
||||||
|
local username, reponame = actualRepoPath:match("([^/]+)/([^/]+)")
|
||||||
|
if username and reponame then return ('https://github.com/%s/%s/releases/latest'):format(username, reponame) end
|
||||||
|
end
|
||||||
|
return nil
|
||||||
|
end
|
||||||
|
|
||||||
|
local function printUpdateAvailable(resource, localVersion, downloadUrl)
|
||||||
|
print(('^1An update is available for %s (current version: %s)\r\n - ^5Please download the latest version from %s^7'):format(resource, localVersion, downloadUrl))
|
||||||
|
end
|
||||||
|
|
||||||
|
local function printPatchNotes(notesToPrint)
|
||||||
|
print('^3Patch Notes:^7')
|
||||||
|
for _, entry in ipairs(notesToPrint) do
|
||||||
|
print(('^2Version %s:^7'):format(entry.version))
|
||||||
|
for _, line in ipairs(entry.notes) do
|
||||||
|
print((' - %s'):format(line))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function validateRepoPath(repoPath)
|
||||||
|
local username, reponame = repoPath:match("([^/]+)/([^/]+)")
|
||||||
|
if not username or not reponame then return false, print('Invalid repository format. Expected format: username/reponame') end
|
||||||
|
return true, username, reponame
|
||||||
|
end
|
||||||
|
|
||||||
|
local function getLocalVersion(resource)
|
||||||
|
local localVersionRaw = GetResourceMetadata(resource, "version", 0)
|
||||||
|
if not localVersionRaw then
|
||||||
|
return nil, print('No version metadata found for resource "%s". Ensure fxmanifest.lua contains a valid version string.'):format(resource)
|
||||||
|
end
|
||||||
|
local version = parseVersion(localVersionRaw)
|
||||||
|
if not version then return nil, print('Invalid version format for resource "%s". Expected format: "x.x.x"'):format(resource) end
|
||||||
|
return version
|
||||||
|
end
|
||||||
|
|
||||||
|
local function processVersions(allVersions, localVersion)
|
||||||
|
local notesToPrint = {}
|
||||||
|
|
||||||
|
for versionStr, notes in pairs(allVersions) do
|
||||||
|
if compareVersions(versionStr, localVersion) > 0 and type(notes) == "table" then
|
||||||
|
table.insert(notesToPrint, { version = versionStr, notes = notes })
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
table.sort(notesToPrint, function(a, b)
|
||||||
|
return compareVersions(a.version, b.version) < 0
|
||||||
|
end)
|
||||||
|
|
||||||
|
return notesToPrint
|
||||||
|
end
|
||||||
|
|
||||||
|
local function fetchPatchNotes(branch, resource, repoPath, localVersion)
|
||||||
|
local url = buildPatchNotesUrl(branch, repoPath)
|
||||||
|
|
||||||
|
PerformHttpRequest(url, function(noteStatus, noteBody)
|
||||||
|
if noteStatus == 200 then
|
||||||
|
local patchData = json.decode(noteBody)
|
||||||
|
if not patchData then return end
|
||||||
|
|
||||||
|
local resourceData = patchData[resource]
|
||||||
|
if resourceData and type(resourceData) == "table" then
|
||||||
|
local actualRepoPath = resourceData.repo or resourceData.actualRepoPath
|
||||||
|
local isTebex = not actualRepoPath -- If no repo path, it's Tebex
|
||||||
|
local allVersions = resourceData.versions or resourceData -- Support both new and old format
|
||||||
|
local notesToPrint = processVersions(allVersions, localVersion)
|
||||||
|
|
||||||
|
if #notesToPrint > 0 then
|
||||||
|
local downloadUrl = getDownloadUrl(repoPath, isTebex, actualRepoPath) or url
|
||||||
|
printUpdateAvailable(resource, localVersion, downloadUrl)
|
||||||
|
printPatchNotes(notesToPrint)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif branch == "main" then
|
||||||
|
-- Fallback to master branch if main doesn't exist
|
||||||
|
fetchPatchNotes("master", resource, repoPath, localVersion)
|
||||||
|
end
|
||||||
|
end, 'GET')
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Pass a github username and repo name to check for the latest version of the resource.
|
||||||
|
--- Tebex is a optional boolean to determine if the message should be for a escrowed resource or not.
|
||||||
|
--- Example: Version.VersionChecker("TheOrderFivem/community_bridge", false)
|
||||||
|
--- @param repoPath string
|
||||||
|
--- @param tebex boolean | nil
|
||||||
|
--- @return nil
|
||||||
function Version.VersionChecker(repoPath, tebex)
|
function Version.VersionChecker(repoPath, tebex)
|
||||||
local username, reponame = repoPath:match("([^/]+)/([^/]+)")
|
local username, reponame = repoPath:match("([^/]+)/([^/]+)")
|
||||||
local resource = reponame and repoPath:match("([^/]+)$")
|
local resource = reponame and repoPath:match("([^/]+)$")
|
||||||
if not username or not reponame or not resource then
|
if not username or not reponame or not resource then return print('^1Invalid repository format. Expected format: "username/reponame"^0') end
|
||||||
return Prints.Error('^1Invalid repository format. Expected format: "username/reponame"^0')
|
|
||||||
end
|
|
||||||
|
|
||||||
local version = GetResourceMetadata(resource, "version", 0):match('%d+%.%d+%.%d+')
|
local version = GetResourceMetadata(resource, "version", 0)
|
||||||
if not version then return end
|
if not version then return end
|
||||||
|
|
||||||
PerformHttpRequest(('https://api.github.com/repos/%s/%s/releases/latest'):format(username, reponame), function(status, response)
|
version = version:match('%d+%.%d+%.%d+')
|
||||||
if status ~= 200 then return end
|
if not version then return end
|
||||||
local latest = json.decode(response).tag_name:match('%d+%.%d+%.%d+')
|
|
||||||
if not latest or latest == version or version:gsub('%D', '') >= latest:gsub('%D', '') then return end
|
|
||||||
|
|
||||||
local url = tebex and "https://portal.cfx.re/assets/granted-assets" or json.decode(response).html_url
|
PerformHttpRequest(('https://api.github.com/repos/%s/%s/releases/latest'):format(username, reponame),
|
||||||
print(('^1An update is available for %s (current version: %s)\r\n - ^5Please download the latest version from %s^7'):format(resource, version, url))
|
function(status, response)
|
||||||
end, 'GET')
|
if status ~= 200 then return end
|
||||||
|
local latest = json.decode(response).tag_name:match('%d+%.%d+%.%d+')
|
||||||
|
if not latest or latest == version or version:gsub('%D', '') >= latest:gsub('%D', '') then return end
|
||||||
|
|
||||||
|
local url = tebex and "https://portal.cfx.re/assets/granted-assets" or json.decode(response).html_url
|
||||||
|
print(('^1An update is available for %s (current version: %s)\r\n - ^5Please download the latest version from %s^7'):format(resource, version, url))
|
||||||
|
end,
|
||||||
|
'GET')
|
||||||
|
end
|
||||||
|
|
||||||
|
--- Advanced version checker with patch notes support
|
||||||
|
--- Reads Tebex information and repo path directly from the resources.json file
|
||||||
|
--- @param repoPath string GitHub repository path for patch notes in format "username/reponame"
|
||||||
|
--- @param resourceName string The actual resource name to check
|
||||||
|
--- @return nil
|
||||||
|
function Version.AdvancedVersionChecker(repoPath, resourceName)
|
||||||
|
local isValid, username, reponame = validateRepoPath(repoPath)
|
||||||
|
if not isValid then return print(('^1[ERROR]^7 %s'):format(username)) end
|
||||||
|
|
||||||
|
local resource = resourceName
|
||||||
|
local localVersion, errorMsg = getLocalVersion(resource)
|
||||||
|
if not localVersion then return print(('^1[ERROR]^7 %s'):format(username)) end
|
||||||
|
fetchPatchNotes("main", resource, repoPath, localVersion)
|
||||||
end
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStart', function(resourceName)
|
AddEventHandler('onResourceStart', function(resourceName)
|
||||||
if GetCurrentResourceName() ~= resourceName then return end
|
if GetCurrentResourceName() ~= resourceName then return end
|
||||||
Version.VersionChecker("TheOrderFivem/community_bridge")
|
-- Version.VersionChecker("TheOrderFivem/community_bridge", false)
|
||||||
|
Version.AdvancedVersionChecker("TheOrderFivem/patchnotes", resourceName)
|
||||||
end)
|
end)
|
||||||
|
|
||||||
return Version
|
return Version
|
||||||
Reference in new issue
Block a user