diff --git a/lua/gmod_integration/server/sv_http.lua b/lua/gmod_integration/shared/sh_http.lua similarity index 88% rename from lua/gmod_integration/server/sv_http.lua rename to lua/gmod_integration/shared/sh_http.lua index f6a3b55..da0830c 100644 --- a/lua/gmod_integration/server/sv_http.lua +++ b/lua/gmod_integration/shared/sh_http.lua @@ -2,18 +2,14 @@ // HTTP // - // Variables gmInte.api = 'https://api.gmod-integration.com/' -gmInte.defParams = "&id=" .. gmInte.config.id .. "&token=" .. gmInte.config.token .. "&version=" .. gmInte.version +gmInte.defParams = "&version=" .. gmInte.version // Functions function gmInte.isCodeValid(code) - if code == 200 then - return true - else - return false - end + // if first number is 2 + return string.sub(code, 1, 1) == "2" end function gmInte.httpError(error) @@ -26,7 +22,11 @@ function gmInte.ulrGenerate(endpoint, parameters) for k, v in pairs(parameters) do params = params .. "&" .. k .. "=" .. v end - return gmInte.api .. endpoint .. "?" .. params .. gmInte.defParams + if SERVER then + return gmInte.api .. endpoint .. "?" .. params .. gmInte.defParams .. "&id=" .. gmInte.config.id .. "&token=" .. gmInte.config.token + else + return gmInte.api .. endpoint .. "?" .. params .. gmInte.defParams + end end function gmInte.fetch(endpoint, parameters, onSuccess)