mirror of
https://github.com/gmod-integration/lua.git
synced 2025-03-15 22:27:34 +00:00
add: sync roles
This commit is contained in:
parent
015dee7d38
commit
000340cd04
|
@ -2,34 +2,99 @@
|
|||
// Websocket
|
||||
//
|
||||
|
||||
function gmInte.wsSyncRoles(data)
|
||||
local cachedPlayers = {}
|
||||
|
||||
function gmInte.wsPlayerUpdateGroup(data)
|
||||
if (cachedPlayers[steamID64] == data.group) then return end
|
||||
|
||||
data.steamID = util.SteamIDFrom64(data.steamID64)
|
||||
data.group = data.add && data.group || "user"
|
||||
|
||||
cachedPlayers[data.steamID64] = data.group
|
||||
|
||||
local ply = player.GetBySteamID(data.steamID)
|
||||
if (ply:IsValid()) then
|
||||
ply:SetUserGroup(data.role)
|
||||
if (ply && ply:IsValid()) then
|
||||
ply:SetUserGroup(data.group)
|
||||
end
|
||||
|
||||
// ULX
|
||||
if (ULib) then
|
||||
ULib.ucl.addUser(data.steamID, nil, nil, data.role)
|
||||
end
|
||||
|
||||
// FAdmin
|
||||
if (CAMI) then
|
||||
CAMI.PlayerRank(data.steamID64, data.role, "user")
|
||||
ULib.ucl.addUser(data.steamID, nil, nil, data.group)
|
||||
end
|
||||
|
||||
// ServerGuard
|
||||
if (serverguard) then
|
||||
serverguard.player:SetRank(data.steamID64, data.role)
|
||||
local ply = player.GetBySteamID(data.steamID)
|
||||
if (ply) then
|
||||
local rankData = serverguard.ranks:GetRank(data.group)
|
||||
serverguard.player:SetRank(ply, data.group)
|
||||
serverguard.player:SetImmunity(ply, rankData.immunity)
|
||||
serverguard.player:SetTargetableRank(ply, rankData.targetable)
|
||||
serverguard.player:SetBanLimit(ply, rankData.banlimit)
|
||||
else
|
||||
serverguard.player:SetRank(data.steamID, data.group)
|
||||
end
|
||||
end
|
||||
|
||||
// Evolve
|
||||
if (evolve) then
|
||||
evolve:RankPlayer(data.steamID64, data.role)
|
||||
evolve:RankPlayer(data.steamID64, data.group)
|
||||
end
|
||||
|
||||
// SAM
|
||||
if (SAM) then
|
||||
SAM:PlayerSetRank(data.steamID64, data.role)
|
||||
SAM:PlayerSetRank(data.steamID64, data.group)
|
||||
end
|
||||
|
||||
// sam (wtf another one?)
|
||||
if (sam) then
|
||||
sam.player.setRank(data.steamID64, data.group)
|
||||
end
|
||||
|
||||
// xAdmin
|
||||
if (xAdmin) then
|
||||
xAdmin.SetRank(data.steamID64, data.group)
|
||||
end
|
||||
|
||||
// maestro
|
||||
if (maestro) then
|
||||
maestro.userrank(data.steamID64, data.group)
|
||||
end
|
||||
|
||||
// D3A
|
||||
if (D3A) then
|
||||
D3A.Ranks.SetSteamIDRank(data.steamID, data.group)
|
||||
end
|
||||
|
||||
// Mercury
|
||||
if (Mercury) then
|
||||
RunConsoleCommand("hg", "setrank", data.steamID, data.group)
|
||||
end
|
||||
|
||||
// FAdmin
|
||||
if (FAdmin) then
|
||||
RunConsoleCommand("fadmin", "setaccess", data.steamID, data.group)
|
||||
end
|
||||
|
||||
gmInte.log("[Sync Role] Player " .. data.steamID .. " has been updated to group " .. data.group)
|
||||
end
|
||||
|
||||
function gmInte.playerChangeGroup(steamID64, oldGroup, newGroup)
|
||||
if (cachedPlayers[steamID64] == newGroup) then return end
|
||||
cachedPlayers[steamID64] = newGroup
|
||||
|
||||
gmInte.http.post("/players/" .. steamID64 .. "/group", {
|
||||
oldGroup = oldGroup || "user",
|
||||
newGroup = newGroup
|
||||
})
|
||||
end
|
||||
|
||||
hook.Add('CAMI.PlayerUsergroupChanged', 'gmInte:SyncChat:CAMI:PlayerUsergroupChanged', function(ply, old, new)
|
||||
if (ply:IsBot() || !ply:IsValid()) then return end
|
||||
gmInte.playerChangeGroup(ply:SteamID64(), old, new)
|
||||
end)
|
||||
|
||||
hook.Add('CAMI.SteamIDUsergroupChanged', 'gmInte:SyncChat:CAMI:SteamIDUsergroupChanged', function(SteamID64, old, new)
|
||||
if (string.StartWith(SteamID64, "STEAM_")) then SteamID64 = util.SteamIDTo64(SteamID64) end
|
||||
gmInte.playerChangeGroup(SteamID64, old, new)
|
||||
end)
|
Loading…
Reference in New Issue
Block a user