• Godmode + Noclip for a specific job
    7 replies, posted
  • 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" [lua]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) [/lua]
  • Do ply:GodEnable() in the job spawn function. [QUOTE=bloodmasked;52131752]could just set health to 9999[/QUOTE] dumb x1
  • [QUOTE=tgandrew2468;52131758]Do ply:GodEnable(true) in the job spawn function. dumb x1[/QUOTE] How do I do that?
  • Avatar of TheVac
  • [QUOTE=Foxvox;52132063]How do I do that?[/QUOTE] 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)[/CODE]
  • [QUOTE=TheVac;52132351]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)[/CODE][/QUOTE] Still feel like it's easier to do this inside the job codenz. [code]PlayerSpawn = function(ply) ply:GodEnable() end,[/code] 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)[/code] @lua/autorun/server
  • So, eh, how should I put this whole codes together now and where should I put them? Bit confused
  • Avatar of andreblue
  • Do not forget to throw a 0 second timer to run on the next tick as sometimes the player is not fully alive.