version '0.0.9'
This commit is contained in:
1 parent
4e28ee5793
commit
ce4ea7fca5
8 files changed
+114
-60
No files matched your search
+1
-2
@@ -3,7 +3,7 @@ game 'gta5'
|
|||||||
lua54 'yes'
|
lua54 'yes'
|
||||||
author 'The Order of the Sacred Framework'
|
author 'The Order of the Sacred Framework'
|
||||||
description 'A bridge made for the community to use as a base for their own projects. This bridge will allow a single format to work with nearly all commonly used systems while still offering expandability.'
|
description 'A bridge made for the community to use as a base for their own projects. This bridge will allow a single format to work with nearly all commonly used systems while still offering expandability.'
|
||||||
version '0.0.8'
|
version '0.0.9'
|
||||||
|
|
||||||
shared_scripts {
|
shared_scripts {
|
||||||
'settings/sharedConfig.lua',
|
'settings/sharedConfig.lua',
|
||||||
@@ -42,7 +42,6 @@ client_scripts {
|
|||||||
'modules/progressbars/**/client.lua',
|
'modules/progressbars/**/client.lua',
|
||||||
'modules/clothing/**/client.lua',
|
'modules/clothing/**/client.lua',
|
||||||
'modules/weather/**/client.lua',
|
'modules/weather/**/client.lua',
|
||||||
'modules/points/*.lua',
|
|
||||||
'modules/math/*.lua',
|
'modules/math/*.lua',
|
||||||
'init.lua',
|
'init.lua',
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,25 +24,10 @@ Bridge.Table = Table
|
|||||||
Bridge.Math = Math
|
Bridge.Math = Math
|
||||||
Bridge.Clothing = Clothing
|
Bridge.Clothing = Clothing
|
||||||
Bridge.Progressbar = Progressbar
|
Bridge.Progressbar = Progressbar
|
||||||
Bridge.Helper = Helper
|
Bridge.Utility = Utility
|
||||||
|
Bridge.Prints = Prints
|
||||||
|
Bridge.Table = Table
|
||||||
|
|
||||||
-- Fill the bridge tables with player data.
|
|
||||||
function FillBridgeTables()
|
|
||||||
PlayerLoaded = true
|
|
||||||
PlayerIdentifier = Framework.GetPlayerIdentifier()
|
|
||||||
PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel = Framework.GetPlayerJob()
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Clean the bridge tables.
|
|
||||||
function ClearClientSideVariables()
|
|
||||||
PlayerLoaded = false
|
|
||||||
PlayerIdentifier = nil
|
|
||||||
PlayerJobName = nil
|
|
||||||
PlayerJobLabel = nil
|
|
||||||
PlayerJobGradeName = nil
|
|
||||||
PlayerJobGradeLevel = nil
|
|
||||||
StoredOldClothing = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
for k, v in pairs(Bridge) do
|
for k, v in pairs(Bridge) do
|
||||||
@@ -85,4 +70,23 @@ exports('RegisterCompatibility', RegisterCompatibility)
|
|||||||
|
|
||||||
exports('Bridge', function()
|
exports('Bridge', function()
|
||||||
return Bridge
|
return Bridge
|
||||||
end)
|
end)
|
||||||
|
|
||||||
|
if IsDuplicityVersion() then return end
|
||||||
|
|
||||||
|
function FillBridgeTables()
|
||||||
|
PlayerLoaded = true
|
||||||
|
PlayerIdentifier = Framework.GetPlayerIdentifier()
|
||||||
|
PlayerJobName, PlayerJobLabel, PlayerJobGradeName, PlayerJobGradeLevel = Framework.GetPlayerJob()
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Clean the bridge tables.
|
||||||
|
function ClearClientSideVariables()
|
||||||
|
PlayerLoaded = false
|
||||||
|
PlayerIdentifier = nil
|
||||||
|
PlayerJobName = nil
|
||||||
|
PlayerJobLabel = nil
|
||||||
|
PlayerJobGradeName = nil
|
||||||
|
PlayerJobGradeLevel = nil
|
||||||
|
StoredOldClothing = {}
|
||||||
|
end
|
||||||
@@ -4,7 +4,7 @@ Dispatch = {}
|
|||||||
|
|
||||||
Dispatch.SendAlert = function(data)
|
Dispatch.SendAlert = function(data)
|
||||||
local playerData = exports['cd_dispatch']:GetPlayerInfo()
|
local playerData = exports['cd_dispatch']:GetPlayerInfo()
|
||||||
local randomID = Bridge.Helper.RandomString()
|
local randomID = Utility.CreateUniqueId(nil, 14, nil)
|
||||||
TriggerServerEvent('cd_dispatch:AddNotification', {
|
TriggerServerEvent('cd_dispatch:AddNotification', {
|
||||||
job_table = data.job,
|
job_table = data.job,
|
||||||
coords = data.coords or playerData.coords,
|
coords = data.coords or playerData.coords,
|
||||||
|
|||||||
@@ -1,37 +0,0 @@
|
|||||||
Points = {}
|
|
||||||
local ActivePoints = {}
|
|
||||||
|
|
||||||
Points.RegisterPoint = function(pointCoords, pointDistance, pointOnEnter, pointOnExit)
|
|
||||||
local enterZone = lib.points.new({
|
|
||||||
coords = pointCoords,
|
|
||||||
distance = pointDistance,
|
|
||||||
onEnter = function(self)
|
|
||||||
pointOnEnter(self)
|
|
||||||
end,
|
|
||||||
onExit = function(self)
|
|
||||||
pointOnExit(self)
|
|
||||||
end,
|
|
||||||
})
|
|
||||||
local pointID = Ids.CreateUniqueId(nil, 5, nil)
|
|
||||||
ActivePoints[pointID] = enterZone
|
|
||||||
return enterZone, pointID
|
|
||||||
end
|
|
||||||
|
|
||||||
-- Function to retrieve the enterZone using pointID
|
|
||||||
Points.GetPointById = function(pointID)
|
|
||||||
return ActivePoints[pointID]
|
|
||||||
end
|
|
||||||
|
|
||||||
Points.RemovePoint = function(pointID)
|
|
||||||
local point = ActivePoints[pointID]
|
|
||||||
if point then
|
|
||||||
print("Removing point with ID " .. pointID)
|
|
||||||
point:remove() -- Call the remove method on the point (ensure this method stops all event listeners)
|
|
||||||
ActivePoints[pointID] = nil -- Remove from ActivePoints table
|
|
||||||
print("Point removed successfully.")
|
|
||||||
return true
|
|
||||||
else
|
|
||||||
print("Point with ID " .. pointID .. " not found.")
|
|
||||||
return false
|
|
||||||
end
|
|
||||||
end
|
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
Utility = Utility or {}
|
||||||
|
|
||||||
local activePlacementProp = nil
|
local activePlacementProp = nil
|
||||||
lib.locale()
|
lib.locale()
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
Utility = {}
|
Utility = Utility or {}
|
||||||
local blipIDs = {}
|
local blipIDs = {}
|
||||||
local spawnedPeds = {}
|
local spawnedPeds = {}
|
||||||
|
local ActivePoints = {}
|
||||||
lib.locale()
|
lib.locale()
|
||||||
|
|
||||||
Utility.CreateVehicle = function(model, coords, heading, networked)
|
Utility.CreateVehicle = function(model, coords, heading, networked)
|
||||||
@@ -228,6 +229,42 @@ Utility.GetClosestPlayer = function(coords, distanceScope, includeMe)
|
|||||||
return closestPlayer, closestDistance, GetPlayerServerId(closestPlayer)
|
return closestPlayer, closestDistance, GetPlayerServerId(closestPlayer)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
-- register points
|
||||||
|
Utility.RegisterPoint = function(pointCoords, pointDistance, pointOnEnter, pointOnExit)
|
||||||
|
local enterZone = lib.points.new({
|
||||||
|
coords = pointCoords,
|
||||||
|
distance = pointDistance,
|
||||||
|
onEnter = function(self)
|
||||||
|
pointOnEnter(self)
|
||||||
|
end,
|
||||||
|
onExit = function(self)
|
||||||
|
pointOnExit(self)
|
||||||
|
end,
|
||||||
|
})
|
||||||
|
local pointID = Utility.CreateUniqueId(nil, 5, nil)
|
||||||
|
ActivePoints[pointID] = enterZone
|
||||||
|
return enterZone, pointID
|
||||||
|
end
|
||||||
|
|
||||||
|
-- Function to retrieve the enterZone using pointID
|
||||||
|
Utility.GetPointById = function(pointID)
|
||||||
|
return ActivePoints[pointID]
|
||||||
|
end
|
||||||
|
|
||||||
|
Utility.RemovePoint = function(pointID)
|
||||||
|
local point = ActivePoints[pointID]
|
||||||
|
if point then
|
||||||
|
--print("Removing point with ID " .. pointID)
|
||||||
|
point:remove() -- Call the remove method on the point (ensure this method stops all event listeners)
|
||||||
|
ActivePoints[pointID] = nil -- Remove from ActivePoints table
|
||||||
|
--print("Point removed successfully.")
|
||||||
|
return true
|
||||||
|
else
|
||||||
|
--print("Point with ID " .. pointID .. " not found.")
|
||||||
|
return false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(resource)
|
AddEventHandler('onResourceStop', function(resource)
|
||||||
if resource == GetCurrentResourceName() then
|
if resource == GetCurrentResourceName() then
|
||||||
for _, blip in pairs(blipIDs) do
|
for _, blip in pairs(blipIDs) do
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
Prints = Prints or {}
|
||||||
|
|
||||||
|
local function printMessage(level, color, message)
|
||||||
|
if type(message) == 'table' then
|
||||||
|
message = json.encode(message)
|
||||||
|
end
|
||||||
|
print(color .. '[' .. level .. ']:', message)
|
||||||
|
end
|
||||||
|
|
||||||
|
Prints.info = function(message)
|
||||||
|
printMessage('INFO', '^5', message)
|
||||||
|
end
|
||||||
|
|
||||||
|
Prints.warn = function(message)
|
||||||
|
printMessage('WARN', '^3', message)
|
||||||
|
end
|
||||||
|
|
||||||
|
Prints.error = function(message)
|
||||||
|
printMessage('ERROR', '^1', message)
|
||||||
|
end
|
||||||
|
|
||||||
|
Prints.debug = function(message)
|
||||||
|
printMessage('DEBUG', '^2', message)
|
||||||
|
end
|
||||||
@@ -0,0 +1,25 @@
|
|||||||
|
Utility = Utility or {}
|
||||||
|
-- for unique ids
|
||||||
|
Utility.CreateUniqueId = function(tbl, len, pattern) -- both optional
|
||||||
|
tbl = tbl or {} -- table to check uniqueness. Ids to check against must be the key to the tables value
|
||||||
|
len = len or 8
|
||||||
|
|
||||||
|
local id = ""
|
||||||
|
for i = 1, len do
|
||||||
|
local char = ""
|
||||||
|
if pattern then
|
||||||
|
char = pattern:sub(math.random(1, #pattern), math.random(1, #pattern))
|
||||||
|
else
|
||||||
|
char = math.random(1, 2) == 1 and string.char(math.random(65, 90)) or math.random(0, 9) -- CAP letter and number
|
||||||
|
end
|
||||||
|
id = id .. char
|
||||||
|
end
|
||||||
|
if tbl[id] then
|
||||||
|
return Utility.CreateUniqueId(tbl, len, pattern)
|
||||||
|
end
|
||||||
|
return id
|
||||||
|
end
|
||||||
|
|
||||||
|
Utility.RandomString = function()
|
||||||
|
return Utility.CreateUniqueId(nil, 14, nil)
|
||||||
|
end
|
||||||
Reference in new issue
Block a user