Code:
local tblSpectators = {};
local tblAdministrators = {};
local tblDefaultGroups = {
"user",
"guest",
"0"
};
local Color = Color;
local Entity = Entity;
local LocalPlayer = LocalPlayer;
local hook = hook;
local table = table;
local surface = surface;
local IsValid = IsValid;
local chat = chat;
local draw = draw;
local strCheatName = "uguuu~~~~ - by konakona~ (https://www.youtube.com/user/INTELINSIDECHANNEL)";
local tblColors = {
white = Color(240, 240, 240, 255),
cheatNameColor = Color(40, 150, 240, 255),
green = Color(150, 240, 50, 255),
red = Color(240, 150, 50, 255)
};
local function DrawString(hFont, bCenter, pointX, pointY, colColor, strText)
draw.SimpleTextOutlined(strText, hFont, pointX, pointY, colColor, bCenter, bCenter, 1, Color(20, 20, 20, 200));
end
hook.Add("DrawOverlay", "ListStuff", function()
local ScrW = surface.ScreenWidth();
DrawString("Default", TEXT_ALIGN_CENTER, (ScrW / 4) * 2, 15, tblColors.green, strCheatName);
local pLocalPlayer = LocalPlayer();
for i = 0, 8192 do -- Highest entity index is 8192, I could use player.GetAll() but do it yourself.
local pEntity = Entity(i);
if (!IsValid(pEntity)) then
continue;
end
if (!pEntity:IsPlayer()) then
continue;
end
-- The following code lists spectators into a table called tblAdministrators.
local strPlayerGroup = pEntity:GetNWString("usergroup"); -- If anyone have a sig to GetNWString please share it, ty
if (!table.HasValue(tblDefaultGroups, strPlayerGroup)) then
if (!table.HasValue(tblAdministrators, pEntity)) then
table.insert(tblAdministrators, pEntity);
-- a new administrator has risen.
chat.AddText(tblColors.cheatNameColor, "[" .. strCheatName .. "] ", tblColors.green, "A new administrator has risen! -> " .. (pEntity:Nick() || "unnamed") .. " (" .. strPlayerGroup .. ")");
end
end
-- The following code lists spectators into a table called tblSpectators.
local pObserverTarget = pEntity:GetObserverTarget();
if (IsValid(pObserverTarget)) then
if (pObserverTarget == pLocalPlayer) then
if (!table.HasValue(tblSpectators, pEntity)) then
table.insert(tblSpectators, pEntity);
-- a new spectator has risen.
chat.AddText(tblColors.cheatNameColor, "[" .. strCheatName .. "] ", tblColors.green, "A new spectator has risen! -> " .. (pEntity:Nick() || "unnamed") .. " (" .. strPlayerGroup .. ")");
end
end
end
end
DrawString("Default", TEXT_ALIGN_CENTER, (ScrW / 4) * 3, 5, tblColors.cheatNameColor, "Spectators:");
for i = 0, #tblSpectators do
local pSpectator = tblSpectators[i];
if (!IsValid(pSpectator)) then
table.remove(tblSpectators, i);
-- chat.AddText(tblColors.cheatNameColor, "[" .. strCheatName .. "] ", tblColors.red, (pSpectator:Nick() || "unnamed") .. " is no longer spectating you. (left server)");
continue;
end
local strPlayerGroup = pSpectator:GetNWString("usergroup"); -- If anyone have a sig to GetNWString please share it, ty
-- draw them here.
DrawString("Default", TEXT_ALIGN_CENTER, (ScrW / 4) * 3, 5 + (i * 10), tblColors.white, (pSpectator:Nick() || "unnamed") .. " (" .. strPlayerGroup .. ")");
local pObserverTarget = pSpectator:GetObserverTarget();
if (!IsValid(pObserverTarget)) then
table.remove(tblSpectators, i);
chat.AddText(tblColors.cheatNameColor, "[" .. strCheatName .. "] ", tblColors.red, (pSpectator:Nick() || "unnamed") .. " is no longer spectating you.");
continue;
end
if (pObserverTarget != pLocalPlayer) then
table.remove(tblSpectators, i);
if (pObserverTarget:IsPlayer()) then
chat.AddText(tblColors.cheatNameColor, "[" .. strCheatName .. "] ", tblColors.red, (pSpectator:Nick() || "unnamed") .. " is no longer spectating you. (now spectating " .. (pObserverTarget:Nick() || "unnamed") .. ")");
else
chat.AddText(tblColors.cheatNameColor, "[" .. strCheatName .. "] ", tblColors.red, (pSpectator:Nick() || "unnamed") .. " is no longer spectating you.");
end
end
end
DrawString("Default", TEXT_ALIGN_CENTER, (ScrW / 4) * 1, 5, tblColors.cheatNameColor, "Administrators:");
for i = 0, #tblAdministrators do
local pAdministrator = tblAdministrators[i];
if (!IsValid(pAdministrator)) then
table.remove(tblAdministrators, i);
-- chat.AddText(tblColors.cheatNameColor, "[" .. strCheatName .. "] ", tblColors.red, "Administrator " .. (pAdministrator:Nick() || "unnamed") .. " has left the server.");
continue;
end
local strPlayerGroup = pAdministrator:GetNWString("usergroup"); -- If anyone have a sig to GetNWString please share it, ty
-- draw them here.
DrawString("Default", TEXT_ALIGN_CENTER, (ScrW / 4) * 1, 5 + (i * 10), tblColors.white, (pAdministrator:Nick() || "unnamed") .. " (" .. strPlayerGroup .. ")");
if (table.HasValue(tblDefaultGroups, strPlayerGroup)) then
--[[table.remove(tblAdministrators, i);
chat.AddText(tblColors.cheatNameColor, "[" .. strCheatName .. "] ", tblColors.red, (pAdministrator:Nick() || "unnamed") .. " is no longer administrator. (now " .. strPlayerGroup .. ")");]]
end
end
end);