diff --git a/fxmanifest.lua b/fxmanifest.lua index 82f0d80..0976de4 100644 --- a/fxmanifest.lua +++ b/fxmanifest.lua @@ -4,7 +4,7 @@ lua54 'yes' use_experimental_fxv2_oal 'yes' 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.' -version '0.5.1' +version '0.5.2' shared_scripts { '@ox_lib/init.lua', @@ -29,6 +29,7 @@ server_scripts { 'modules/shops/**/server.lua', 'modules/notify/**/server.lua', 'modules/housing/**/server.lua', + 'modules/skills/**/server.lua', 'init.lua', } @@ -53,6 +54,7 @@ client_scripts { 'modules/shops/**/client.lua', 'modules/housing/**/client.lua', 'modules/accessibility/client.lua', + 'modules/skills/**/client.lua', 'init.lua', } diff --git a/init.lua b/init.lua index 7de247a..c7d3a07 100644 --- a/init.lua +++ b/init.lua @@ -69,6 +69,7 @@ Bridge.RegisterModule("LA", cLib.LA) Bridge.RegisterModule("Perlin", cLib.Perlin) Bridge.RegisterModule("Actions", cLib.Actions) Bridge.RegisterModule("Cache", cLib.Cache) +Bridge.RegisterModule("Skills", Skills) exports('Bridge', function() diff --git a/modules/skills/OT_skills/client.lua b/modules/skills/OT_skills/client.lua new file mode 100644 index 0000000..cac7757 --- /dev/null +++ b/modules/skills/OT_skills/client.lua @@ -0,0 +1,15 @@ +Skills = Skills or {} +local resourceName = "OT_skills" +local configValue = BridgeSharedConfig.Skills +if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetResourceName = function() + return resourceName +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetSkillLevel = function(skillName) + local skillData = exports.OT_skills:getSkill(skillName) + return skillData.level or 0 +end \ No newline at end of file diff --git a/modules/skills/OT_skills/server.lua b/modules/skills/OT_skills/server.lua new file mode 100644 index 0000000..c5be3f1 --- /dev/null +++ b/modules/skills/OT_skills/server.lua @@ -0,0 +1,29 @@ +Skills = Skills or {} +local resourceName = "OT_skills" +local configValue = BridgeSharedConfig.Skills +if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetResourceName = function() + return resourceName +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetSkillLevel = function(src, skillName) + local skillData = exports.OT_skills:getSkill(src, skillName) + return skillData.level or 0 +end + +Skills.AddXp = function(src, skillName, amount) + local skillData = exports.OT_skills:getSkill(src, skillName) + if not skillData then return false, print("Skill not found") end + exports.OT_skills:addXP(src, skillName, amount) + return true +end + +Skills.RemoveXp = function(src, skillName, amount) + local skillData = exports.OT_skills:getSkill(src, skillName) + if not skillData then return false, print("Skill not found") end + exports.OT_skills:removeXP(src, skillName, amount) + return true +end \ No newline at end of file diff --git a/modules/skills/_default/client.lua b/modules/skills/_default/client.lua new file mode 100644 index 0000000..9b26b0a --- /dev/null +++ b/modules/skills/_default/client.lua @@ -0,0 +1,15 @@ +Skills = Skills or {} + +local function warnUser() + print("Currently only a few skill systems are supported by Community Bridge, you are using a resource that requires the skills module to be used.") +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetResourceName = function() + return "none" +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetSkillLevel = function(skillName) + return 0, warnUser() +end \ No newline at end of file diff --git a/modules/skills/_default/server.lua b/modules/skills/_default/server.lua new file mode 100644 index 0000000..a5ae846 --- /dev/null +++ b/modules/skills/_default/server.lua @@ -0,0 +1,25 @@ +Skills = Skills or {} + +local function warnUser() + print("Currently only a few skill systems are supported by Community Bridge, you are using a resource that requires the skills module to be used.") +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetResourceName = function() + return "none" +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetSkillLevel = function(src, skillName) + return 0, warnUser() +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.AddXp = function(src, skillName, amount) + return false, warnUser() +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.RemoveXp = function(src, skillName, amount) + return false, warnUser() +end \ No newline at end of file diff --git a/modules/skills/evolent_skills/client.lua b/modules/skills/evolent_skills/client.lua new file mode 100644 index 0000000..7ee1e0f --- /dev/null +++ b/modules/skills/evolent_skills/client.lua @@ -0,0 +1,15 @@ +Skills = Skills or {} +local resourceName = "evolent_skills" +local configValue = BridgeSharedConfig.Skills +if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetResourceName = function() + return resourceName +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetSkillLevel = function(skillName) + local skillData = exports.evolent_skills:getSkillLevel(skillName) + return skillData or 0 +end \ No newline at end of file diff --git a/modules/skills/evolent_skills/server.lua b/modules/skills/evolent_skills/server.lua new file mode 100644 index 0000000..05f960a --- /dev/null +++ b/modules/skills/evolent_skills/server.lua @@ -0,0 +1,31 @@ +Skills = Skills or {} +local resourceName = "evolent_skills" +local configValue = BridgeSharedConfig.Skills +if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetResourceName = function() + return resourceName +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetSkillLevel = function(src, skillName) + local skillData = exports.evolent_skills:getSkillLevel(src, skillName) + return skillData or 0 +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.AddXp = function(src, skillName, amount) + local skillData = exports.evolent_skills:getSkillLevel(src, skillName) + if not skillData then return false, print("Skill not found") end + exports.evolent_skills:addXp(src, skillName, amount) + return true +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.RemoveXp = function(src, skillName, amount) + local skillData = exports.evolent_skills:getSkillLevel(src, skillName) + if not skillData then return false, print("Skill not found") end + exports.evolent_skills:removeXp(src, skillName, amount) + return true +end \ No newline at end of file diff --git a/modules/skills/pickle_xp/client.lua b/modules/skills/pickle_xp/client.lua new file mode 100644 index 0000000..c21f010 --- /dev/null +++ b/modules/skills/pickle_xp/client.lua @@ -0,0 +1,15 @@ +Skills = Skills or {} +local resourceName = "pickle_xp" +local configValue = BridgeSharedConfig.Skills +if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetResourceName = function() + return resourceName +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetSkillLevel = function(skillName) + local skillData = exports.OT_skills:GetLevel(skillName) + return skillData or 0 +end \ No newline at end of file diff --git a/modules/skills/pickle_xp/server.lua b/modules/skills/pickle_xp/server.lua new file mode 100644 index 0000000..b7234f3 --- /dev/null +++ b/modules/skills/pickle_xp/server.lua @@ -0,0 +1,29 @@ +Skills = Skills or {} +local resourceName = "pickle_xp" +local configValue = BridgeSharedConfig.Skills +if (configValue == "auto" and GetResourceState(resourceName) ~= "started") or (configValue ~= "auto" and configValue ~= resourceName) then return end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetResourceName = function() + return resourceName +end + +---@diagnostic disable-next-line: duplicate-set-field +Skills.GetSkillLevel = function(src, skillName) + local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName) + return skillData or 0 +end + +Skills.AddXp = function(src, skillName, amount) + local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName) + if not skillData then return false, print("Skill not found") end + exports.pickle_xp:AddPlayerXP(src, skillName, amount) + return true +end + +Skills.RemoveXp = function(src, skillName, amount) + local skillData = exports.pickle_xp:GetPlayerLevel(src, skillName) + if not skillData then return false, print("Skill not found") end + exports.pickle_xp:RemovePlayerXP(src, skillName, amount) + return true +end \ No newline at end of file diff --git a/settings/sharedConfig.lua b/settings/sharedConfig.lua index 7fe6461..e65d424 100644 --- a/settings/sharedConfig.lua +++ b/settings/sharedConfig.lua @@ -2,5 +2,6 @@ BridgeSharedConfig = {} BridgeSharedConfig.Lang = "auto" -- Change this to your preferred language (must match the locale file name ex. en or fr etc) BridgeSharedConfig.DebugLevel = 0 -- Change this to your Debug level, 0 for none, 1 for some, 2 for all data BridgeSharedConfig.Phone = "auto" -- [ auto | qs-smartphone | lb-phone | gksphone] +BridgeSharedConfig.Skills = "auto" -- [ auto | OT_skills | evolent_skills | pickle_xp] return BridgeSharedConfig \ No newline at end of file