Hi there, I need some help to get my code working:
I'm trying to force the client to use the console command "developer 1" from the server when he's superadmin.
Here is my code:
[QUOTE]function PlayerInitialSpawn( ply )
if (ply:GetUserGroup() == "superadmin") then
ply:ConCommand( "developer 1" )
end
end
hook.Add( "PlayerInitialSpawn", "init_console_admin_S", spawn )[/QUOTE]
Am I making a mistake or is that a protected command from being run remotely ?
Thanks for reading ! :smile:
Put this in a clientside file:
[code]
hook.Add("PlayerInitialSpawn", "init_console_admin_S", function(ply)
if(ply:GetUserGroup()=='superadmin') then
RunConsoleCommand('developer','1')
end
end)
[/code]
[QUOTE]hook.Add("PlayerInitialSpawn", "init_console_admin_S", function(ply)
if(ply:GetUserGroup()=='superadmin') then
RunConsoleCommand('developer','1')
end
end)[/QUOTE]
Not working :/
UP. Anyone ? :rolleyes:
try ply:IsSuperAdmin
Still not working, aww...
Try and use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/IsUserGroup]Player:IsUserGroup[/url]
[QUOTE=mjctechguy;49388348]Try and use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/IsUserGroup]Player:IsUserGroup[/url][/QUOTE]
Same :/
Maybe is, like I said in the initial post, a protected command (for a remote run) ?
[QUOTE=Theo312;49390627]Same :/
Maybe is, like I said in the initial post, a protected command (for a remote run) ?[/QUOTE]
Are you sure the script is in the right file & being ran overall? it should've worked already on ply:IsSuperAdmin()
Try ply:ConCommand("developer 1") instead of RunConsoleCommand
[CODE]timer.Create( "spawnDelay", 6, 1, function()
if ( LocalPlayer():IsUserGroup( "superadmin" ) ) then
RunConsoleCommand('developer','1')
end
end)[/CODE]
As you can see, I've changed the way I'm doing it. Maybe I did a mistake on the code now...
[editline]26th December 2015[/editline]
Huh.
[CODE][ERROR] lua/autorun/client/cl_startup2.lua:3: attempt to call method 'IsUserGroup' (a nil value)
1. unknown - lua/autorun/client/cl_startup2.lua:3[/CODE]
[code]
hook.Add( "PlayerInitialSpawn", "init_console_admin_S", function(ply)
if (LocalPlayer():IsUserGroup( "superadmin" )) then
ply:SendLua("LocalPlayer():ConCommand('developer 1')")
end
end)
[/code]
[QUOTE=The Commander;49391852][code]
hook.Add( "PlayerInitialSpawn", "init_console_admin_S", function(ply)
if (LocalPlayer():IsUserGroup( "superadmin" )) then
ply:SendLua("LocalPlayer():ConCommand('developer 1')")
end
end)
[/code][/QUOTE]
That would make the player run the command every time he joins the server, not just when the rank is given to him.
[QUOTE=FVJohnny;49391966]That would make the player run the command every time he joins the server, not just when the rank is given to him.[/QUOTE]
Yes? The client won't save the convar and therefor it have to run next time the client joins the server.
I'm pretty sure now that's a protected command from being ran remotely, tested all the way to do it without any success. If someone could confirm me what I said is exact...
UP.
[code]
hook.Add( "PlayerInitialSpawn", "RunDev1OnJoin", function( ply )
if ply:IsSuperAdmin() then
ply:ConCommand( "developer 1" )
end
end )
[/code]
Untested but should work, run server side.
Sorry, you need to Log In to post a reply to this thread.