Hi. im making a Garrys Mod DarkRP server and i want a admin job so they dont have access to ulx/fadmin and people kill the admin when they say you are getting banned/kicked ect. so what i want is a admin job that have god mode on spawn and when they arent the admin job they dont have god mode. TY
This isn’t a ‘make me’ forum.
This works with a little tweaking;
PlayerLoadout = function( ply ) if ply:IsAdmin() then ply:Kill() --Secret tip: ply:GodEnable() end end
Or something, can’t be bothered to check wiki
[editline]21st August 2014[/editline]
Before coming on these forums and asking for help learn at least a bit about gmod lua: http://forum.facepunch.com/showthread.php?t=1337945
Also this is not a make me forums like the guy said above. Please spend some time with the thread I posted above. I especially recommend cosmicseagull as he goes into a hands on basic tutorial of gmod.
And everyone on here is going to get down on you if you didn’t google it first: http://lmgtfy.com/?q=How+to+google.com
I don’t know exactly how you want it. The way I do it is that everyone gets god-mode until they’re fully in game.
I rewrote IsAdmin to work with my admin system ( admins are NOT admins by traditional means… Basically, an admin is only an admin when “logged in” as an admin… Otherwise they’re a normal player with no more power than anyone else that is playing the game. I did things this way to prevent any accidental abuse of power such as god-mode, etc and to simplify other logic so Admins get god-mode for the entirety of their logged in as admin duration.
Depending on your game-mode you may need to create a hook, or overwrite the function. If you’re writing your own game-mode from scratch, overwrite. If you’re adding a feature to an existing gamemode, hook.
Functions to look at:
function GM:CanPlayerSuicide( _p )
function GM:GetFallDamage( _p, _fallspeed )
function GM:PlayerShouldTakeDamage( _victim, _attacker )
So, mine look like this:
// // Only logged in admins can bite the bullet // function GM:CanPlayerSuicide( _p ) return _p:IsAdmin( ); end // // If a connecting player is thrown off a ledge, they won't take damage ( in my gm this won't be possible anyways ) // function GM:GetFallDamage( _p, _fallspeed ) // People connecting should not take fall damage if ( !_p:IsFullyConnected( ) ) then return 0; end // Admins in admin mode should not take damage if ( _p:IsAdmin( ) ) then return 0; end // Otherwise, we derive fall damage based on the speed at which they fell return math.Clamp( _fallspeed / 8, 10, 200 ); end // // Should players take damage? Not if they're not fully connected and not if they're in admin mode - Josh 'Acecool' Moser // ( IsAdmin returns true only on Admin Character and Active - admins characters CAN'T play the game; it's forced ) // function GM:PlayerShouldTakeDamage( _victim, _attacker ) // People connecting should not take damage if ( !IsValid( _victim ) || !_victim:IsFullyConnected( ) ) then return false; end // Admins in admin mode should not take damage if ( _victim:IsAdmin( ) ) then return false; end // Everyone else takes damage as expected return true; end
Depending how you want to do things ( permanent no-damage, vs only during spawn you’d need to change things )…
IsFullyConnected is a private function which works off my PlayerFullyConnected hook available on my dev base.
It essentially does: return _p.__IsFullyConnected;
by default it is nil, treated as false. When the player Spawns, set the value to true. All of this is server-side. Also, players spawn slightly before they’re in game.
You can look at: function GM:OnEntityCreated( _ent )
or in my dev-base/gamemode/shared/hooks/playerfullyconnected/*.lua to see what I do to ensure player is fully in game: https://bitbucket.org/Acecool/acecooldev_base/src/