Restricting a console command to the admin group

When using the ULX admin mod, I was wondering how to restrict a console command to a certain user group. I’m trying to create a simple Admin ESP for my server. Yes, I already did a Google search I hate seeming like I waste people’s time.

Is it activated by a concommand you define? If so just do


if (!ply:IsAdmin()) then return; end 

Your question is fairly vague with limited information provided.

I’m using OLD code I found on this Maurits.Tv article. There’s some errors in the code also. [lua]CreateClientConVar( “aesp_enabled”, 0, true, false )
hook.Add( “HUDPaint”, “AESP”, function()

if ConVarExists( "wallhack_enabled" ) and GetConVar("wallhack_enabled"):GetInt() == 1 then

	for k,v in pairs ( player.GetAll() ) do

	local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
	draw.DrawText( v:Name(), "Trebuchet18", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

	end

end

end )

local Name = “”

if v == LocalPlayer() then Name = “” else Name = v:Name() end

hook.Add( “HUDPaint”, “AESP”, function()

for k,v in pairs ( player.GetAll() ) do

	local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
	draw.DrawText( v:Name(), "Trebuchet18", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end )[/lua]

[lua][ERROR] lua/aesp.lua:19: attempt to index global ‘v’ (a nil value)

  1. unknown - lua/aesp.lua:19
    [/lua]

v = nil outside the loop.

So, it should work like this then?
[lua]if (!ply:IsAdmin()) then return; end
CreateClientConVar( “aesp_enabled”, 0, true, false )
hook.Add( “HUDPaint”, “AESP”, function()

if ConVarExists( "wallhack_enabled" ) and GetConVar("wallhack_enabled"):GetInt() == 1 then

	for k,v in pairs ( player.GetAll() ) do

	local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
	draw.DrawText( v:Name(), "Trebuchet18", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

	end

end

end )

local Name = “”

if v == LocalPlayer() then Name = “” else Name = v:Name() end

v = nil

hook.Add( “HUDPaint”, “AESP”, function()

for k,v in pairs ( player.GetAll() ) do

	local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
	draw.DrawText( v:Name(), "Trebuchet18", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end ) [/lua]

No. v is nil. Meaning setting it to nil really doesn’t change anything. Put this


if v == LocalPlayer() then Name = "" else Name = v:Name() end

in your for loop so it looks like this



for k,v in pairs ( player.GetAll() ) do
                if v == LocalPlayer() then Name = "" else Name = v:Name() end
		local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
		draw.DrawText( Name, "Trebuchet18", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )
 
	end

and remove your v = nil part

This is what it looks like now.
[lua]if (!ply:IsAdmin()) then return; end
CreateClientConVar( “aesp_enabled”, 0, true, false )
hook.Add( “HUDPaint”, “AESP”, function()

if ConVarExists( "aesp_enable" ) and GetConVar("aesp_enabled"):GetInt() == 1 then

for k,v in pairs ( player.GetAll() ) do
            if v == LocalPlayer() then Name = "" else Name = v:Name() end
	local Position = ( v:GetPos() + Vector( 0,0,80 ) ):ToScreen()
	draw.DrawText( Name, "Trebuchet18", Position.x, Position.y, Color( 255, 255, 255, 255 ), 1 )

end

end )

local Name = “”

if v == LocalPlayer() then Name = “” else Name = v:Name() end
[/lua]

I get this error.

[lua][ERROR] lua/aesp.lua:13: unexpected symbol near ‘)’

  1. unknown - lua/aesp.lua:0
    [/lua]

Bump?