mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-16 04:17:34 +00:00
adding hint
This commit is contained in:
parent
0f500ae9b4
commit
973ccfa1b0
|
@ -98,6 +98,11 @@ function gmInte.serverShutDown()
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.sendStatus(start)
|
function gmInte.sendStatus(start)
|
||||||
|
if (gmInte.config.id == "" || gmInte.config.token == "") then
|
||||||
|
gmInte.logError("ID or Token is empty: (id: " .. gmInte.config.id .. ", token: " .. (gmInte.config.token == "" && "empty" || "not empty") .. ")")
|
||||||
|
gmInte.logHint("Use 'gmod-integration settings id YOUR_SERVER_ID' and 'gmod-integration settings token YOUR_SERVER_TOKEN' to set your credentials, you can find them on https://gmod-integration.com/guild/servers")
|
||||||
|
return
|
||||||
|
end
|
||||||
gmInte.post("/server/status",
|
gmInte.post("/server/status",
|
||||||
{
|
{
|
||||||
["start"] = start || false,
|
["start"] = start || false,
|
||||||
|
@ -108,7 +113,12 @@ function gmInte.sendStatus(start)
|
||||||
["players"] = #player.GetAll(),
|
["players"] = #player.GetAll(),
|
||||||
["maxplayers"] = game.MaxPlayers(),
|
["maxplayers"] = game.MaxPlayers(),
|
||||||
["gamemode"] = engine.ActiveGamemode()
|
["gamemode"] = engine.ActiveGamemode()
|
||||||
}
|
},
|
||||||
|
function() end,
|
||||||
|
function(code, body, headers)
|
||||||
|
gmInte.logError("Your Credentials are Invalid: (id: " .. gmInte.config.id .. ", token: " .. (gmInte.config.token == "" && "empty" || "not empty") .. ")")
|
||||||
|
gmInte.logHint("Use 'gmod-integration settings id YOUR_SERVER_ID' and 'gmod-integration settings token YOUR_SERVER_TOKEN' to set your credentials, you can find them on https://gmod-integration.com/guild/servers")
|
||||||
|
end
|
||||||
)
|
)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -25,8 +25,11 @@ local function sendHTTP(params)
|
||||||
params.success(code, body, headers)
|
params.success(code, body, headers)
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
gmInte.logError("HTTP Request failed with code " .. code)
|
if (params.failed) then
|
||||||
if (gmInte.debug) then gmInte.logError("HTTP Body: " .. body) end
|
params.failed(code, body, headers)
|
||||||
|
else
|
||||||
|
gmInte.logError("HTTP Request failed with code " .. code)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end,
|
end,
|
||||||
failed = function(error)
|
failed = function(error)
|
||||||
|
@ -35,37 +38,41 @@ local function sendHTTP(params)
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.get(endpoint, onSuccess)
|
function gmInte.get(endpoint, onSuccess, onFailed)
|
||||||
sendHTTP({
|
sendHTTP({
|
||||||
endpoint = endpoint,
|
endpoint = endpoint,
|
||||||
method = "GET",
|
method = "GET",
|
||||||
success = onSuccess
|
success = onSuccess,
|
||||||
|
failed = onFailed
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.post(endpoint, data, onSuccess)
|
function gmInte.post(endpoint, data, onSuccess, onFailed)
|
||||||
sendHTTP({
|
sendHTTP({
|
||||||
endpoint = endpoint,
|
endpoint = endpoint,
|
||||||
method = "POST",
|
method = "POST",
|
||||||
body = util.TableToJSON(data),
|
body = util.TableToJSON(data),
|
||||||
success = onSuccess
|
success = onSuccess,
|
||||||
|
failed = onFailed
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.put(endpoint, data, onSuccess)
|
function gmInte.put(endpoint, data, onSuccess, onFailed)
|
||||||
sendHTTP({
|
sendHTTP({
|
||||||
endpoint = endpoint,
|
endpoint = endpoint,
|
||||||
method = "PUT",
|
method = "PUT",
|
||||||
body = util.TableToJSON(data),
|
body = util.TableToJSON(data),
|
||||||
success = onSuccess
|
success = onSuccess,
|
||||||
|
failed = onFailed
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.delete(endpoint, onSuccess)
|
function gmInte.delete(endpoint, onSuccess, onFailed)
|
||||||
sendHTTP({
|
sendHTTP({
|
||||||
endpoint = endpoint,
|
endpoint = endpoint,
|
||||||
method = "DELETE",
|
method = "DELETE",
|
||||||
success = onSuccess
|
success = onSuccess,
|
||||||
|
failed = onFailed
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -13,4 +13,18 @@ function gmInte.logError(msg, debug)
|
||||||
if (debug && !gmInte.debug) then return end
|
if (debug && !gmInte.debug) then return end
|
||||||
print("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] [Gmod Integration] [ERROR] " .. msg)
|
print("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] [Gmod Integration] [ERROR] " .. msg)
|
||||||
if (debug) then print(debug.traceback()) end
|
if (debug) then print(debug.traceback()) end
|
||||||
|
end
|
||||||
|
|
||||||
|
// Log Warning
|
||||||
|
function gmInte.logWarning(msg, debug)
|
||||||
|
if (debug && !gmInte.debug) then return end
|
||||||
|
print("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] [Gmod Integration] [WARNING] " .. msg)
|
||||||
|
if (debug) then print(debug.traceback()) end
|
||||||
|
end
|
||||||
|
|
||||||
|
// Log Hint
|
||||||
|
function gmInte.logHint(msg, debug)
|
||||||
|
if (debug && !gmInte.debug) then return end
|
||||||
|
print("[" .. os.date("%Y-%m-%d %H:%M:%S") .. "] [Gmod Integration] [HINT] " .. msg)
|
||||||
|
if (debug) then print(debug.traceback()) end
|
||||||
end
|
end
|
Loading…
Reference in New Issue
Block a user