How do i create a job in darkrp (etc admin on duty) have noclip but only when they are in that job!!
26 replies, posted
I have been looking on forums for days now trying to figure out how to give noclip in gmod darkrp to a specific job like admin on duty so they can only noclip when on that job.I have got god mode to work when admins go on the job Staff On Duty(TEAM_STAFF).I have been doing this in darkrp modules and have set up a folder and a file in that folder called sh_staffgod.lua and i have the following in it for god mode which is working perfectly.
hook.Add("PlayerShouldTakeDamage", "godmodeAdmin", function(ply, ent)
if (ply:Team() == TEAM_STAFF) then
return false
end
end)
This is what i've tried for the noclip:
hook.Add( "DisableNoClip", "DisableNoClip", function( ply )
if (ply:Team() == TEAM_STAFF) then
return false
end
end)
or
hook.Add( "PlayerNoClip", "noclipThing", function( ply )
return ply:Team() == TEAM_STAFF
end )
I've also tried this for combing god mode and noclip in the same folder but only god mode would work when i went to the job
hook.Add( "PlayerNoClip", "noclipThing", function( ply )
if ( ply:Team() == TEAM_ADMIN ) then
ply:GodEnable()
return true
else
ply:GodDisable()
end
end )
Btw do i disable ulx noclip on the class and when going to the job do i just press v because I've tried disabling no clip for the group and going to the Staff on Duty job(TEAM_STAFF) but when i press v when im in the job it says i've got no permissions.
Any help is much appreciated thanks in advance!!!
umm, I am not quite sure, but try using the hook ULibCommandCalled
[code]hook.Add("ULibCommandCalled", "JobNoclip", function(ply, cmd, args)
if cmd == "ulx noclip" and not ply:Team() == TEAM_ADMIN then return false end
end)[/code]
now make sure they do hold the permissions, they must hold those.
so i put this in darkrp modifications (in addons) and go in to modules and create a file and add this to it.If so I've just done it but it did not work.
No, why the heck would you put it in darkrp modifications...?
You should try ULib Modules or something, never worked with ULib hooks but I can assure you it shouldn't work in darkrp modifications.
Just put this in Ulib modules made a file called it ulib_noclip.init.lua went on server disabled noclip for admins went on my staff on duty job pressed v and it said you do not have permission.Also made a sh.noclip.lua to see if that worked did'nt work either any suggestions?
[editline]31st May 2017[/editline]
all i want is noclip to be disabled when admins are not in the job TEAM_STAFF as i dont want them flying as like a gun dealer abusing their power
If your admins cannot be trusted to follow the simple instruction of "don't noclip unless you're on duty" then maybe they shouldn't be admin?
Anyway, stick this in some a lua file in the lua/autorun directory
[code]
local function JobNoclip(ply)
if !ply:Team() == MY_ADMIN_TEAM_HERE then return false end
end
hook.Add("PlayerNoClip","JobNoclip",JobNoclip)
[/code]
[QUOTE=toastvendor;52298090]If your admins cannot be trusted to follow the simple instruction of "don't noclip unless you're on duty" then maybe they shouldn't be admin?
Anyway, stick this in some a lua file in the lua/autorun directory
[code]
local function JobNoclip(ply)
if !ply:Team() == MY_ADMIN_TEAM_HERE then return false end
end
hook.Add("PlayerNoClip","JobNoclip",JobNoclip)
[/code][/QUOTE]
ULX noclip doesn't use the same system as default noclip, PlayerNoClip will not work.
Its kind of confusing as there are people that say go into darkrpmodifications in addon and do noclip in that modules folder.Found this:
hook.Add("ULibCommandCalled", "restrict command usage when not admin job", function(ply, commandName, args)
if team.GetName(ply:Team()) == cfg_admindutyjob or team.GetName(ply:Team()) == cfg_moddutyjob or ply:CheckGroup(cfg_immunityrank) then
return true
end
for _,v in pairs(cfg_whitelistcommands) do
if string.StartWith(commandName,v) then
return true
end
end
ply:ChatPrint("You cannot execute the following command while roleplaying:")
return false
end)
this guy said he got it working in singleplayer and this guy said he need to "ply can be nil.
You are comapring a string returned by team.GetName with a nil variable.
Add IsValid(ply) check, make sure the hook parameters are actually correct" to get it working in multiplayer.
So i put this in ulib modules right? put TEAM_STAFF for team = and this should work for my TEAM_STAFF.If this code has any thing that should'nt be in it coulld you just tell me what i need to change to get it working.
Tested and works!
Create a file in garrysmod/lua/autorun/server/ e.g. "noclip.lua", put the code inside and edit the team
[CODE]
hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
if ( cmd == "ulx noclip" && ply:Team() == TEAM_CITIZEN ) then
return true
else
return false
end
end)
[/CODE]
What do i call the file in ulib modules
[editline]1st June 2017[/editline]
do you know the way you have to call files like sh.noclip.lua etc could you tell me what you called your ulib mudule file?
Create a file in garrysmod/lua/autorun/server/ e.g. "noclip.lua", put the code inside and edit the team
you only need to do this
1 problem once they goto noclip in job and change job their in noclip still
[editline]1st June 2017[/editline]
also server not showing me in My Owner group now and the ulx adduser command wont work
[editline]1st June 2017[/editline]
pretty much when i do this it make ulx not work like etc jail does'nt do anything,godmode same and no text shows up when clicking command
[editline]1st June 2017[/editline]
btw i would also like certain ranks to be able to ignore this and noclip in any job etc Owner which is me i dont want this to effect my rank
[editline]1st June 2017[/editline]
When this is typed i cant access my !menu and cant adduser through console
local function JobNoclip(ply)
if !ply:Team() == MY_ADMIN_TEAM_HERE then return false end
end
hook.Add("PlayerNoClip","JobNoclip",JobNoclip)
This is the error:
[ERROR] addons/ulib-v2_63/lua/ulib/modules/noclip.lua:2: attempt to call method 'Team' (a nil value)
1. fn - addons/ulib-v2_63/lua/ulib/modules/noclip.lua:2
2. Call - addons/ulib-v2_63/lua/ulib/shared/hook.lua:109
3. execute - addons/ulib-v2_63/lua/ulib/shared/commands.lua:1321
4. unknown - addons/ulib-v2_63/lua/ulib/shared/commands.lua:1351
5. unknown - lua/includes/modules/concommand.lua:54
[CODE]
hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
if ( cmd == "ulx noclip" && ply:Team() == TEAM_CITIZEN ) then
return true
elseif ( cmd == "ulx noclip" && !ply:Team() == TEAM_CITIZEN ) ) then
return false
end
end)
[/CODE]
Try this
nope
[ERROR] addons/ulib-v2_63/lua/ulib/modules/noclip.lua:4: 'then' expected near ')'
1. unknown - addons/ulib-v2_63/lua/ulib/modules/noclip.lua:0
[editline]1st June 2017[/editline]
right fixed that extra ) you put in put the command does nothing.Does'nt disable noclip for people that aren'nt in TEAM_STAFF now
[editline]1st June 2017[/editline]
If anyone know how to only allow noclip in job TEAM_STAFF without effecting ulx please help
-snip-
I have not figured this out yet
Have you tried changing the TEAM names in his code snippet to this:
[code]
hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
if ( cmd == "ulx noclip" && ply:Team() == TEAM_STAFF) then
return false
elseif ( cmd == "ulx noclip" && !ply:Team() == TEAM_STAFF) ) then
return true
end
end)
[/code]
yes
[editline]8th June 2017[/editline]
My job is called TEAM_STAFF
Wtf? now i can noclip in any job but TEAM_STAFF
[editline]8th June 2017[/editline]
oh wait i see why now but is there a way to modify it so only TEAM_STAFFget noclip and everyone else does'nt
hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
if ( cmd == "ulx noclip" && ply:Team() == TEAM_STAFF) then
return false
elseif ( cmd == "ulx noclip" && !ply:Team() == TEAM_STAFF) ) then
return true
end
end)
[editline]8th June 2017[/editline]
and btw can u make it so they can't go on TEAM_STAFF and go in noclip and switch job enabling noclip in that job as they were in it on the job TEAM_STAFF
If you return true then they can use the command. If you return false then they can't use the command.
You are returning false when they're staff on duty. You should be returning true here so they can use the command (Remember ! = not).
You can solve this by swapping the returns.
[CODE]
hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
if ( cmd == "ulx noclip" && ply:Team() == TEAM_STAFF) then
return true
elseif ( cmd == "ulx noclip" && !ply:Team() == TEAM_STAFF) ) then
return false
end
end
[/CODE]
An if statement isn't required here either.
[CODE]cmd == "ulx noclip" && ply:Team() == TEAM_STAFF[/CODE]
is a boolean so we can just return that.
We can simplify this like:
[CODE]hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
return cmd == "ulx noclip" && ply:Team() == TEAM_STAFF
end[/CODE]
hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
if ( cmd == "ulx noclip" && ply:Team() == TEAM_STAFF) then
return true
elseif ( cmd == "ulx noclip" && !ply:Team() == TEAM_STAFF) ) then
return false
end
end
done this command many times does not work
[editline]8th June 2017[/editline]
hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
if ( cmd == "ulx noclip" && ply:Team() == TEAM_CITIZEN ) then
return true
else
return false
end
end)
this works but basically screws up ulx
Sorry my bad I didn't notice it. The second code will break ulx because it's returning false if the command isn't ulx noclip therefore stopping every other command.
Also added a message to the person trying to use the command so they don't think noclip is broken.
[CODE]hook.Add("ULibCommandCalled", "PreventNoclip", function(ply, cmd, args)
if cmd == "ulx noclip" then
return ply:Team() == TEAM_STAFF
end
end)[/CODE]
k right this actually worked but msg still pops up as TEAM_STAFF but does'nt really matter much all i want to know is how do i make it so they can't go on TEAM_STAFF then say to TEAM_CHIEF and have noclip as they had it previously
Assuming you're using DarkRP:
[CODE]hook.Add("OnPlayerChangedTeam", "RemoveNoclipOnJobChange", function(ply, before, after)
if ply:GetMoveType() == MOVETYPE_NOCLIP then
ply:SetMoveType(MOVETYPE_WALK)
end
end)[/CODE]
put this in ulib modules right in new file
Yea or anywhere that will automatically executed.
k thx you really helped out alot
Sorry, you need to Log In to post a reply to this thread.