Creating Derma = Fail

I’m trying to send a umsg from the server to the client to make a Derma menu…

this is autorun/server/anti_cheat.lua

[lua]require(“gatekeeper”)
include(“echo.lua”)
AddCSLuaFile(“autorun/client/anti_cheat_derma.lua”)

– Let them know
function AntiCheat( ply )
if ply:IsAdmin() and !ply:IsSuperAdmin() then
ply:SetNWInt(“WarningLevel”, 0)
elseif ply:IsSuperAdmin() then
ply:SetNWInt(“WarningLevel”, 0)
else
ply:SetNWInt(“WarningLevel”, 5)
end
umsg.Start(“ACInfo”, ply)
umsg.End()
end
hook.Add( “PlayerInitialSpawn”, “FirstSpawn”, AntiCheat )

function Disagree( um )
local ply = um:ReadEntity()
require(“gatekeeper”)
gatekeeper.Drop(ply:UserID(), “You must agree to the Anti-Cheat system to play here”)
end
usermessage.Hook(“ACDisagree”, Disagree)

require(“slog”)

SLOGBlocked = {
“dump_hooks”,
“soundscape_flush”,
“hammer_update_entity”,
“physics_constraints”,
“physics_debug_entity”,
“physics_select”,
“physics_budget”,
“sv_soundemitter_flush”,
“rr_reloadresponsesystems”,
“sv_soundemitter_filecheck”,
“sv_soundscape_printdebuginfo”,
“dumpentityfactories”,
“dump_globals”,
“dump_entity_sizes”,
“dumpeventqueue”,
“dbghist_addline”,
“dbghist_dump”,
“groundlist”,
“report_simthinklist”,
“report_entities”,
“server_game_time”,
“npc_thinknow”
}

local DontShow = {
“headcrab”,
“say”,
“gmt_”,
“gtower_”,
“gm_”,
“dr_”,
“st_”,
“rp_”,
“rs_”,
“wire_”,
“gms_”,
“status”,
“kill”,
“myinfo”,
“phys_swap”,
“+ass_menu”,
“-ass_menu”,
“explode”,
“suitzoom”,
“feign_death”,
“gm_showhelp”,
“gm_showteam”,
“gm_showspare1”,
“gm_showspare2”,
“+gm_special”,
“-gm_special”,
“vban”,
“vmodenable”,
“se auth”,
“ulib_cl_ready”,
“noclip”,
“kill”,
“undo”,
“jukebox”,
“debugplayer”,
“gmod_undo”,
“cnc”,
“_xgui”,
“xgui”,
“_u”,
“ulib_update_cvar”,
“ulx”
}

function Cmd_RecvCommand(Name, Buffer)
local Ply = false

for k,v in ipairs(player.GetAll()) do
	if IsValid(v) && v:Name() == Name then
		Ply = v
		break
	end
end

// don't bother with any commands executed by a NULL player, including say or crash commands
if !IsValid(Ply) then
	return true
end

local clean = string.Trim(Buffer)
local lower = string.lower(clean)

// don't log these commands
for k,v in ipairs(DontShow) do
	if string.sub(lower, 1, string.len(v)) == string.lower(v) then
		return false
	else
		
	end
end

local name = Ply:Name()
local steamid = Ply:SteamID()
local blocked = false
local printmessage = nil

for k,v in pairs(SLOGBlocked) do
	if lower == v || string.find(lower, v) != nil then
		blocked = true
		printmessage = "#Blocked Command: "..string.format("%s (%s) ran '%s'

", name, steamid, clean)
if Ply:IsAdmin() and !Ply:IsSuperAdmin() then
Ply:SetNWInt(“WarningLevel”, Ply:GetNWInt(“WarningLevel”) + 2)
else
Ply:SetNWInt(“WarningLevel”, 10)
end
break
end
end

local log = string.format("[%s] %s (%s) ran '%s'

“, os.date(”%c"), name, steamid, clean)
AppendLog(string.Replace(steamid, “:”, “_”), log)

if blocked then
	AppendLog("Blocked", log)
	if Ply:GetNWInt("WarningLevel") >= 10 then
		local Banned_SteamID = Ply:SteamID()
		local Banned_Nick = Ply:Nick()
		gatekeeper.Drop(Ply:UserID(), "Banned for 1 day; Warning Level exceeded. You CAN NOT appeal this ban")
		RunConsoleCommand("ulx", "banid", Banned_SteamID, 1440, Banned_Nick .. ": Warning Level exceeded")
	end
else
	printmessage = "#"..log
end

if printmessage then
	for k,v in ipairs(player.GetAll()) do
		if IsValid(v) && v:IsSuperAdmin() then
			if blocked then
				v:PrintMessage(HUD_PRINTTALK, printmessage)
			else
				v:PrintMessage(HUD_PRINTCONSOLE, printmessage)
			end
		end
	end
end

if string.find(lower, "lua_run_cl") &&
 ( string.find(lower, "select v from ratings") ||  string.find(lower, "http") || string.find(lower, "slob") || string.find(lower, "runstring") ) then

	gatekeeper.Drop(Ply:UserID(), "Malicious bind; type 'key_findbinding lua_run_cl' and rebind those keys")
	return true
end

-- ADMIN NOTICES
--AEcho("[" .. os.date("%c") .. "]" .. Ply:Nick() .. " ran '" .. lower .. "'.")

return blocked

end

hook.Add(“SetupMove”, “InfAngleGuard”, function(ply, cmd)
local ang = cmd:GetMoveAngles()

if not (ang.p >= 0 or ang.p <= 0) or not (ang.y >= 0 or ang.y <= 0) or not (ang.r >= 0 or ang.r <= 0) then
	cmd:SetMoveAngles(Angle(0, 0, 0))
	ply:SetEyeAngles(Angle(0, 0, 0))
end

end)[/lua]

autorun/client/anti_cheat_derma.lua

[lua]function ShowAntiCheatInfo()
local F = vgui.Create(“DFrame”)
F:SetSize(400, 175)
F:SetBackgroundBlur(true)
F:ShowCloseButton(false)
F:SetDraggable(false)
F:Center(true)
F:SetTitle(“Anti-Cheat Information”)
F:MakePopup()

-- tabs
local Tabs = vgui.Create( "DPropertySheet", F )
Tabs:SetPos( 5, 25 )
Tabs:SetSize( 390, 125 )

local sheet1 = vgui.Create( "DPanel" )
--local sheet2 = vgui.Create( "DPanel" )

local AI = vgui.Create( "DLabel", sheet1 ) --By putting sheet1 here, you are setting the parent of DLabel to sheet1
if LocalPlayer():IsAdmin() and !LocalPlayer():IsSuperAdmin() then
	local Warning = vgui.Create("DImage", sheet1)
	Warning:SetImage("gui/silkicons/exclamation")
	Warning:SizeToContents()
	AI:SetText("As an admin, you have a higher tolerance for hacking bans.")
elseif LocalPlayer():IsSuperAdmin() then
	local OK = vgui.Create("DImage", sheet1)
	OK:SetImage("gui/silkicons/check_on")
	OK:SizeToContents()
	OK:SetPos( 5, 5 )
	AI:SetText("Since you are a super admin, you can not be banned for hacking.")
else
	local Warning = vgui.Create("DImage", sheet1)
	Warning:SetImage("gui/silkicons/exclamation")
	Warning:SizeToContents()
	AI:SetText("As a client of our server, you get 1 warning before being banned for hacking.")
end
AI:SetColor(Color(0, 0, 0))
AI:SetPos(25, 5)
AI:SizeToContents()

-- about the anti cheat
local About = vgui.Create("DLabel", sheet1)
About:SetText("The Anti-Cheat on this server will give you one chance to save yourself, so if

you accidently press a bind, you’re safe. If you press another cheat bind, or
enter a cheat command, you will be banned for cheating.

You MAY NOT appeal bans from our Anti-Cheat system.")
About:SetColor(Color(0, 0, 0))
About:SizeToContents()
About:SetPos(5, 25)

print("WHAT IS THIS?!")
/*
local SheetItemTwo = vgui.Create( "DCheckBoxLabel" , sheet2 )
SheetItemTwo:SetText( "Use SENTs?" )
SheetItemTwo:SetConVar( "some_convar" )
SheetItemTwo:SetValue( 1 )
SheetItemTwo:SizeToContents()
*/
 
-- I agree button
local Agree = vgui.Create("DButton", F)
Agree:SetText("I agree to the above")
Agree:SetPos(5, 155)
Agree:SetSize(180, 15)
Agree.DoClick = function() F:SetVisible(false) AI:SetVisible(false) Tabs:SetVisible(false) sheet1:SetVisible(false) chat.AddText(Color(255, 255, 255), "Enjoy your stay ", Color(0, 255, 0), LocalPlayer():Nick(), Color(255, 255, 255), "!") chat.PlaySound() RunConsoleCommand("escape") end

-- I do not agree button

local Disagree = vgui.Create("DButton", F)
Disagree:SetText("I do not agree to the above")
Disagree:SetPos(215, 155)
Disagree:SetSize(180, 15)
Disagree.DoClick = function() umsg.Start("ACDisagree", LocalPlayer()) umsg.Entity(LocalPlayer()) umsg.End() end

--You then use the DPanels (sheet1, sheet2) for the AddSheet. All controls (buttons, checkboxes, etc. should be parented to them (sheet1,sheet2) and NOT the DPropertySheet (Tabs)
Tabs:AddSheet( "Information", sheet1, "gui/silkicons/user", false, false, "Anti-Hack Information" )
--Tabs:AddSheet( "About", sheet2, "gui/silkicons/group", false, false, "About the Anti-Hack" )

end
usermessage.Hook(“ACInfo”, ShowAntiCheatInfo)

–chat.AddText(Color(255, 255, 255), "Good afternoon ", Color(0, 255, 0), LocalPlayer():Nick(), Color(255, 255, 255), “! We think it’s only fair if you understand how we feel against hacking, so here’s a nice explanation.”)[/lua]

[autorun\client\anti_cheat_derma.lua:20] attempt to call method ‘IsAdmin’ (a nil value)

Am I missing something? Thanks./

Try, Changing the LocalPlayer: thing to pl or ply and up at the top by the function in parenthesis put pl or ply so like this.

line 20: if pl:IsAdmin() and !pl:IsSuperAdmin() then

function part: function ShowAntiCheatInfo(pl)

I don’t know just a suggestion.

Just tried, same error. Thanks for the response though.

Maybe try making it a client side file.

The second one causing the error is the autorun/client/anti_cheat_derma.lua is clientside

[lua] if ply:IsAdmin() and !ply:IsSuperAdmin() then [/lua]
Why would you do that?

Try it without !ply:IsSuperAdmin()

Because Supers == owners on my server, and they all have ESPs to .

Tried your suggestion, failed. The usermessage is unhanded, and my debug print is never ran.

It seems that IsAdmin() works either shared or server-side, not exclusively client-side.

**[Player.IsAdmin

http://wiki.garrysmod.com/favicon.ico](http://wiki.garrysmod.com/?title=Player.IsAdmin)**

says shared, not sure what you’re getting at sorry

I did a little test where I used the function in a client lua file, and it didn’t work. The same test in a shared function worked (my test message showed up in the client console)

I don’t know. I’m fucking confused.

Wait, what the hell? You got it working by running the clientside file on the client where on the client it doesn’t work and therefor tried again on the client while running as the client?

Seriously, you got it working? How?

Got it. You can’t run the function too early. Apparently it takes a second to load up the info or something.

When I use the function on init, it gives me the same error in OP. If I use it afterwards, it works. Try going in your console and doing “lua_run_cl print(LocalPlayer():IsAdmin())”. It will work.

So what should I do, add a timer?

Maybe do a if(CLIENT) in GM:InitPostEntity() , which is a shared function that runs after everything is loaded up

edit:yeah, I tested it and that works

[LUA]
function GM:InitPostEntity()
if (CLIENT) then
if(LocalPlayer():IsAdmin()) then print(“LOLOLOLOL POOPS”) end
end
end
[/LUA]

edit:assuming this is a gamemode. if not,you probably know this already, but instead of an override you could hook it like the example here

I’m not following how you would incorporate that into the entire script…sorry.

No problem.

What if you replace line 76 in the client-side file:
[Lua]usermessage.Hook(“ACInfo”, ShowAntiCheatInfo) [/Lua]
with:
[Lua]hook.Add( “InitPostEntity”, “ACInfo”, ShowAntiCheatInfo )[/Lua]

Then you could get rid of the ACInfo usermessage @ line 14-15 server-side

assuming that it only needs to run once on initpostentity

First one worked.

If I was gay, I would love you more than I do right now, if possible. <3

hah, glad it worked. I don’t know what the hell I’m doing 99% of the time, but I have a knack for figuring things out

Did any of you read his code?

There is still a massive error. He’s trying to send umsgs to the server from the client, use concommands!

For the gatekeeper part, that’s what I ended up doing.

Although I seriously hate using them.