Skip to content
This repository has been archived by the owner on Nov 13, 2024. It is now read-only.

Commit

Permalink
tweak: Auto update tablet URL based on CAD mode
Browse files Browse the repository at this point in the history
  • Loading branch information
Jordan2139 committed Nov 5, 2024
1 parent df92606 commit 6237736
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
17 changes: 17 additions & 0 deletions sonorancad/core/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,23 @@ Config.RegisterPluginConfig = function(pluginName, configs)
table.insert(Plugins, pluginName)
end

--[[
@function getApiMode
@description Returns the API mode for the current server. 0 = Development, 1 = Production
@returns int
]]
function getApiMode()
if Config.mode == nil then
return 1
elseif Config.mode == 'development' then
return 0
else
return 1
end
end

exports('getApiMode', getApiMode())

Config.GetPluginConfig = function(pluginName)
local correctConfig = nil
if Config.plugins[pluginName] ~= nil then
Expand Down
13 changes: 10 additions & 3 deletions tablet/cl_main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,19 @@ Citizen.CreateThread(function()
InitModuleSize("cad")
InitModuleSize("hud")
InitModuleConfig("hud")
local convar = GetConvar("sonorantablet_cadUrl", 'https://sonorancad.com/')
local apiMode = exports['sonorancad']:getApiMode()
local tabletURL = ""
if apiMode == 1 then
tabletURL = "https://sonorancad.com/"
elseif apiMode == 0 then
tabletURL = "https://cad.dev.sonoransoftware.com/"
end
local convar = GetConvar("sonorantablet_cadUrl", tabletURL)
local comId = convar:match("comid=(%w+)")
if comId ~= "" then
SetModuleUrl("cad", GetConvar("sonorantablet_cadUrl", 'https://sonorancad.com/login?comid='..comId), true)
SetModuleUrl("cad", GetConvar("sonorantablet_cadUrl", tabletURL .. 'login?comid='..comId), true)
else
SetModuleUrl("cad", GetConvar("sonorantablet_cadUrl", 'https://sonorancad.com/'), false)
SetModuleUrl("cad", GetConvar("sonorantablet_cadUrl", tabletURL), false)
end

TriggerServerEvent("SonoranCAD::mini:CallSync_S")
Expand Down

0 comments on commit 6237736

Please sign in to comment.