• God mode error
    7 replies, posted
Hi, I was wondering if someone could help me. I got help off banna lord on creating a admin on duty class for darkrp which spawns with god mode, and it worked but then i wanted to create a superadmin on duty class and i used the same code but changed the team name and now for some reason the admin on duty class doesnt have god mode but the superadmin on duty class does. Heres the codes ive used: sv_godmode.lua: [code]hook.Add( "PlayerSpawn", "SPAWN:God", function( ply ) if( ply:Team( ) == TEAM_ADMIN ) then ply:GodEnable( ) end end ) hook.Add( "PlayerSpawn", "SPAWN:God", function( ply ) if( ply:Team( ) == TEAM_SUPERADMIN ) then ply:GodEnable( ) end end )[/code] player.lua:( I put this after the function meta:ChangeTeam(t, force) rp arrest function) [code] if( t == TEAM_ADMIN) then self:GodEnable() else self:GodDisable() end if( t == TEAM_SUPERADMIN) then self:GodEnable() else self:GodDisable() end[/code] Shared.lua: [code]TEAM_ADMIN = AddExtraTeam("Admin on Duty", Color(255, 0, 0, 255), "models/player/combine_super_soldier.mdl", [[For Admin Use Only!, Use this class to check keypads, prop bases, etc. Make sure everyone plays by the rules.]], {""}, "admin", 5, 0, 0, false) TEAM_SUPERADMIN = AddExtraTeam("Superadmin on Duty", Color(255, 0, 153, 255), "models/player/combine_super_soldier.mdl", [[(Superadmin Only) Use this class for admin use only, do not use for personal use. Use your keypad cracker to check for false keypads.]], {""}, "superadmin", 0, 0, 2, false)[/code]
You don't need to keep using "if's" you can just do: [lua] if( t == TEAM_ADMIN) then self:GodEnable() else self:GodDisable() elseif( t == TEAM_SUPERADMIN) then self:GodEnable() else self:GodDisable() end [/lua]
When i use that code to replace my current code it stops me from changing class and makes you unagsigned [editline]6th September 2011[/editline] When i use that code to replace my current code it stops me from changing class and makes you unagsigned
First, you have two hooks with the same name, one overrides another. Just put it in the same file, like that. [lua]hook.Add( "PlayerSpawn", "SPAWN:God", function( ply ) if( ply:Team( ) == TEAM_ADMIN ) then ply:GodEnable( ) elseif ( ply:Team( ) == TEAM_SUPERADMIN ) then ply:GodEnable( ) end end )[/lua] Also, I'm not sure if this is necessary, since you said only Superadmin God-Mode works, and that must be because your Admin God-Mode hook gets overriden by Superadmin God-Mode. [lua] if( t == TEAM_ADMIN) then self:GodEnable() else self:GodDisable() end if( t == TEAM_SUPERADMIN) then self:GodEnable() else self:GodDisable() end [/lua] I think that can be removed, since I think that the player is re-spawned when he changes class (Without changing position).
Ive put in your hook code and remove the code in the player.lua file and it still doesnt work. The code in the player.lua was there so that the admin gets the god mode as soon as they change class instead of having to respawn first.
[QUOTE=Persious;32145995]You don't need to keep using "if's" you can just do: [lua] if( t == TEAM_ADMIN) then self:GodEnable() else self:GodDisable() elseif( t == TEAM_SUPERADMIN) then self:GodEnable() else self:GodDisable() end [/lua][/QUOTE] Couldnt you just do; [lua] if( t == TEAM_ADMIN or t == TEAM_SUPERADMIN) then self:GodEnable() else self:GodDisable() end [/lua]
Yeh that works thanks, you have to use Arrays hook for the sv_godmode.lua file and then moosef's if statement for the player.lua Thanks Guys
No problem, hope your problem is fixed :D
Sorry, you need to Log In to post a reply to this thread.