1. Post #1

    April 2017
    6 Posts
    I want to create a godmode and noclip script which automatically gives the user if he joins the specific user group, as example Staff On Duty. It should automatically give the Staff which is on duty their god mode and noclip. I have no idea what is wrong with my code, I would really appreciate if someone could help me. And btw I'm pretty bad in lua due the fact I just started. I put the lua in "autorun"


    adminJobs = { ["TEAM_STAFF"] = true }
    hook.Add( "PlayerNoClip", "noclipThing", function( ply )
    	return ply:Team() == TEAM_STAFF
    end )
    hook.Add("PlayerShouldTakeDamage", "godmodeAdmin", function(ply, ent)
        return not (ply:Team() == TEAM_STAFF)
    end) 
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Switzerland Show Events Funny Funny x 1 (list)

  2. Post #2

    August 2016
    84 Posts
    could just set health to 9999
    Reply With Quote Edit / Delete Reply Windows 10 Chrome New Zealand Show Events Disagree Disagree x 1 (list)

  3. Post #3
    Dennab
    January 2005
    47 Posts
    Do ply:GodEnable() in the job spawn function.

    could just set health to 9999
    dumb x1
    Reply With Quote Edit / Delete Reply Linux Chrome United States Show Events Dumb Dumb x 4 (list)

  4. Post #4

    April 2017
    6 Posts
    Do ply:GodEnable(true) in the job spawn function.



    dumb x1
    How do I do that?
    Reply With Quote Edit / Delete Reply Windows 10 Chrome Switzerland Show Events Dumb Dumb x 1 (list)

  5. Post #5
    TheVac's Avatar
    January 2016
    34 Posts
    How do I do that?
    So do you want them to have noclip and godmode when they spawn and for their duration of the job?

    Code:
    function darkrpAdminJobThing(pl, oldteam, newteam)
    
    	if newteam == <TEAM_NAME> then
    		
    		pl:GodEnable()
    		pl:SetMoveType(MOVETYPE_NOCLIP)
    		pl:SetNotSolid(true)
    
    	elseif oldteam == <TEAM_NAME> then
    	
    		pl:GodDisable()
    		pl:SetMoveType(MOVETYPE_WALK)
    		pl:SetNotSolid(false)
    	
    	end
    	
    		
    end
    hook.Add("OnPlayerChangedTeam", "Dark deathmatch kiddie control", darkrpAdminJobThing)

  6. Post #6
    Dennab
    January 2005
    47 Posts
    So do you want them to have noclip and godmode when they spawn and for their duration of the job?

    Code:
    function darkrpAdminJobThing(pl, oldteam, newteam)
    
    	if newteam == <TEAM_NAME> then
    		
    		pl:GodEnable()
    		pl:SetMoveType(MOVETYPE_NOCLIP)
    		pl:SetNotSolid(true)
    
    	elseif oldteam == <TEAM_NAME> then
    	
    		pl:GodDisable()
    		pl:SetMoveType(MOVETYPE_WALK)
    		pl:SetNotSolid(false)
    	
    	end
    	
    		
    end
    hook.Add("OnPlayerChangedTeam", "Dark deathmatch kiddie control", darkrpAdminJobThing)
    Still feel like it's easier to do this inside the job codenz.

    Code:
    PlayerSpawn = function(ply) ply:GodEnable() end,
    Pretty sure god automatically disables when you change teams, if not then I guess the above example works better. If you have players killed on job switch then it'll for sure be disabled on the job change.

    As for noclip, in the above example the player will automatically be stuck in noclip for the entire time of being that job.

    Code:
    hook.Add("PlayerNoClip", "StaffJobNoClip", function(ply) if ply:Team() == TEAM_FUN_KILLER then return true end end)
    @lua/autorun/server

  7. Post #7

    April 2017
    6 Posts
    So, eh, how should I put this whole codes together now and where should I put them?
    Bit confused

  8. Post #8
    andreblue's Avatar
    August 2011
    275 Posts
    Do not forget to throw a 0 second timer to run on the next tick as sometimes the player is not fully alive.