mirror of
https://github.com/gmod-integration/lua.git
synced 2025-06-15 22:53:59 +00:00
refact: migrate the admin hook func to open the menu
This commit is contained in:
parent
deac3ef966
commit
7401c81a86
|
@ -395,6 +395,23 @@ function gmInte.openConfigMenu(data)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function gmInte.openAdminConfig()
|
||||||
|
if !LocalPlayer():gmIntIsAdmin() then
|
||||||
|
gmInte.chatAddText(Color(228, 81, 81), gmInte.getTranslation("chat.missing_permissions", "You do not have permission to do this action."))
|
||||||
|
return
|
||||||
|
end
|
||||||
|
|
||||||
|
gmInte.SendNet("getConfig")
|
||||||
|
end
|
||||||
|
|
||||||
|
function gmInte.showTestConnection(data)
|
||||||
|
if data && data.id then
|
||||||
|
gmInte.chatAddText(Color(89, 194, 89), gmInte.getTranslation("chat.authentication_success", "Successfully Authenticated"), Color(255, 255, 255), gmInte.getTranslation("chat.server_link", ", server linked as {1}.", data.name))
|
||||||
|
else
|
||||||
|
gmInte.chatAddText(Color(228, 81, 81), gmInte.getTranslation("chat.authentication_failed", "Failed to Authenticate"), Color(255, 255, 255), gmInte.getTranslation("chat.server_fail", ", check your ID and Token."))
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
concommand.Add("gmod_integration_admin", function() gmInte.SendNet("getConfig") end)
|
concommand.Add("gmod_integration_admin", function() gmInte.SendNet("getConfig") end)
|
||||||
concommand.Add("gmi_admin", function() gmInte.SendNet("getConfig") end)
|
concommand.Add("gmi_admin", function() gmInte.SendNet("getConfig") end)
|
||||||
hook.Add("OnPlayerChat", "gmInte:OnPlayerChat:AdminCmd", function(ply, strText, bTeamOnly, bPlayerIsDead)
|
hook.Add("OnPlayerChat", "gmInte:OnPlayerChat:AdminCmd", function(ply, strText, bTeamOnly, bPlayerIsDead)
|
||||||
|
|
|
@ -14,92 +14,3 @@ function gmInte.chatAddTextFromTable(data)
|
||||||
|
|
||||||
gmInte.chatAddText(unpack(args))
|
gmInte.chatAddText(unpack(args))
|
||||||
end
|
end
|
||||||
|
|
||||||
function gmInte.showTestConnection(data)
|
|
||||||
if data && data.id then
|
|
||||||
gmInte.chatAddText(Color(89, 194, 89), gmInte.getTranslation("chat.authentication_success", "Successfully Authenticated"), Color(255, 255, 255), gmInte.getTranslation("chat.server_link", ", server linked as {1}.", data.name))
|
|
||||||
else
|
|
||||||
gmInte.chatAddText(Color(228, 81, 81), gmInte.getTranslation("chat.authentication_failed", "Failed to Authenticate"), Color(255, 255, 255), gmInte.getTranslation("chat.server_fail", ", check your ID and Token."))
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function gmInte.openAdminConfig()
|
|
||||||
if !LocalPlayer():gmIntIsAdmin() then
|
|
||||||
gmInte.chatAddText(Color(228, 81, 81), gmInte.getTranslation("chat.missing_permissions", "You do not have permission to do this action."))
|
|
||||||
return
|
|
||||||
end
|
|
||||||
|
|
||||||
gmInte.SendNet("getConfig")
|
|
||||||
end
|
|
||||||
|
|
||||||
hook.Add("HUDPaint", "gmInte:HUD:ShowScreenshotInfo", function()
|
|
||||||
if !gmInte.showScreenshotInfo then return end
|
|
||||||
local screenInfo = {
|
|
||||||
{
|
|
||||||
txt = "Server ID",
|
|
||||||
val = gmInte.config.id
|
|
||||||
},
|
|
||||||
{
|
|
||||||
txt = "SteamID64",
|
|
||||||
val = LocalPlayer():SteamID64()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
txt = "Date",
|
|
||||||
val = os.date("%Y-%m-%d %H:%M:%S")
|
|
||||||
},
|
|
||||||
{
|
|
||||||
txt = "Position",
|
|
||||||
val = function()
|
|
||||||
local pos = LocalPlayer():GetPos()
|
|
||||||
local newPos = ""
|
|
||||||
for i = 1, 3 do
|
|
||||||
newPos = newPos .. math.Round(pos[i])
|
|
||||||
if i < 3 then newPos = newPos .. ", " end
|
|
||||||
end
|
|
||||||
return newPos
|
|
||||||
end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
txt = "Map",
|
|
||||||
val = game.GetMap()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
txt = "Ping",
|
|
||||||
val = LocalPlayer():Ping()
|
|
||||||
},
|
|
||||||
{
|
|
||||||
txt = "FPS",
|
|
||||||
val = function() return math.Round(1 / FrameTime()) end
|
|
||||||
},
|
|
||||||
{
|
|
||||||
txt = "Size",
|
|
||||||
val = ScrW() .. "x" .. ScrH()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
local concatInfo = ""
|
|
||||||
for k, v in pairs(screenInfo) do
|
|
||||||
local val = v.val
|
|
||||||
if type(val) == "function" then val = val() end
|
|
||||||
concatInfo = concatInfo .. v.txt .. ": " .. val
|
|
||||||
if k < #screenInfo then concatInfo = concatInfo .. " - " end
|
|
||||||
end
|
|
||||||
|
|
||||||
draw.SimpleText(concatInfo, "DermaDefault", ScrW() / 2, ScrH() - 15, Color(255, 255, 255, 119), TEXT_ALIGN_CENTER, TEXT_ALIGN_CENTER)
|
|
||||||
end)
|
|
||||||
|
|
||||||
local lastTime = 0
|
|
||||||
local frameTime = 0
|
|
||||||
local fps = 0
|
|
||||||
hook.Add("Think", "gmInte:HUD:CalculateFPS", function()
|
|
||||||
frameTime = RealTime() - lastTime
|
|
||||||
lastTime = RealTime()
|
|
||||||
fps = math.Round(1 / frameTime)
|
|
||||||
end)
|
|
||||||
|
|
||||||
timer.Create("gmInte:HUD:SendFPS", 5, 0, function()
|
|
||||||
LocalPlayer().gmIntFPS = fps
|
|
||||||
gmInte.SendNet("sendFPS", {
|
|
||||||
["fps"] = fps
|
|
||||||
})
|
|
||||||
end)
|
|
Loading…
Reference in New Issue
Block a user