mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-16 05:57:35 +00:00
fix type of setting when save
This commit is contained in:
parent
f0e8c1efb5
commit
f8b2531667
|
@ -26,11 +26,17 @@ end
|
||||||
|
|
||||||
function gmInte.saveSetting(setting, value)
|
function gmInte.saveSetting(setting, value)
|
||||||
// save this in data/gmod_integration/setting.json but first check if variable is valid
|
// save this in data/gmod_integration/setting.json but first check if variable is valid
|
||||||
if !gmInte.config[setting] then
|
if gmInte.config[setting] == nil then
|
||||||
gmInte.log("Unknown Setting")
|
gmInte.log("Unknown Setting")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
|
// Boolean
|
||||||
|
if (value == "true") then value = true end
|
||||||
|
if (value == "false") then value = false end
|
||||||
|
// Number
|
||||||
|
if (tonumber(value) != nil) then value = tonumber(value) end
|
||||||
|
|
||||||
gmInte.config[setting] = value
|
gmInte.config[setting] = value
|
||||||
file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true))
|
file.Write("gm_integration/config.json", util.TableToJSON(gmInte.config, true))
|
||||||
gmInte.log("Setting Saved")
|
gmInte.log("Setting Saved")
|
||||||
|
@ -38,6 +44,7 @@ end
|
||||||
|
|
||||||
function gmInte.playerConnect(data)
|
function gmInte.playerConnect(data)
|
||||||
if (data.bot == 1) then return end
|
if (data.bot == 1) then return end
|
||||||
|
|
||||||
data.steam = util.SteamIDTo64(data.networkid)
|
data.steam = util.SteamIDTo64(data.networkid)
|
||||||
|
|
||||||
gmInte.post("/server/user/connect", data)
|
gmInte.post("/server/user/connect", data)
|
||||||
|
@ -64,7 +71,7 @@ function gmInte.playerSay(ply, text, team)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.userFinishConnect(ply)
|
function gmInte.userFinishConnect(ply)
|
||||||
if (!gmInte.plyValid(ply)) then return end
|
if (!gmInte.plyValid(ply) || ply:IsBot()) then return end
|
||||||
|
|
||||||
gmInte.post("/server/user/finishConnect",
|
gmInte.post("/server/user/finishConnect",
|
||||||
{
|
{
|
||||||
|
@ -74,9 +81,14 @@ function gmInte.userFinishConnect(ply)
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.sendStatus()
|
function gmInte.serverShutDown()
|
||||||
|
gmInte.post("/server/shutdown")
|
||||||
|
end
|
||||||
|
|
||||||
|
function gmInte.sendStatus(start)
|
||||||
gmInte.post("/server/status",
|
gmInte.post("/server/status",
|
||||||
{
|
{
|
||||||
|
["start"] = start || false,
|
||||||
["hostname"] = GetHostName(),
|
["hostname"] = GetHostName(),
|
||||||
["ip"] = game.GetIPAddress(),
|
["ip"] = game.GetIPAddress(),
|
||||||
["port"] = GetConVar("hostport"):GetInt(),
|
["port"] = GetConVar("hostport"):GetInt(),
|
||||||
|
@ -88,13 +100,17 @@ function gmInte.sendStatus()
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function gmInte.serverStart()
|
||||||
|
gmInte.sendStatus(true)
|
||||||
|
end
|
||||||
|
|
||||||
// every 5 minutes
|
// every 5 minutes
|
||||||
timer.Create("gmInte.sendStatus", 300, 0, function()
|
timer.Create("gmInte.sendStatus", 300, 0, function()
|
||||||
gmInte.sendStatus()
|
gmInte.sendStatus()
|
||||||
end)
|
end)
|
||||||
|
|
||||||
function gmInte.playerChangeName(ply, old, new)
|
function gmInte.playerChangeName(ply, old, new)
|
||||||
if (!gmInte.plyValid(ply)) then return end
|
if (!gmInte.plyValid(ply) || ply:IsBot()) then return end
|
||||||
|
|
||||||
gmInte.post("/server/user/changeName",
|
gmInte.post("/server/user/changeName",
|
||||||
{
|
{
|
||||||
|
@ -106,7 +122,7 @@ function gmInte.playerChangeName(ply, old, new)
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.playerDisconnected(ply)
|
function gmInte.playerDisconnected(ply)
|
||||||
if (!gmInte.plyValid(ply)) then return end
|
if (!gmInte.plyValid(ply) || ply:IsBot()) then return end
|
||||||
|
|
||||||
gmInte.post("/server/user/disconnect",
|
gmInte.post("/server/user/disconnect",
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in New Issue
Block a user