Here is my code:
PlayerSpawn = function(ply) ply:GodEnable() end,
PlayerDeath = function(ply) ply:GodDisable() end,
Here is full code of the job:
TEAM_CAPTAINJACK = DarkRP.createJob("Captain Jack Harness", {
color = Color(220, 224, 0, 255),
model = {"models/player/jackbauer.mdl"},
description = [[You're Captain Jack Harness, you WERE mortal until Rose Tyler made you an immortal... You do not know what it's like to die fully.]],
weapons = {},
command = "captainjack",
max = 1,
salary = 150,
admin = 0,
vote = false,
hasLicense = false,
candemote = true,
category = "Time Lord Companions",
customCheck = function(ply) return CLIENT or
table.HasValue({"superadmin", "admin", "owner", "vip"}, ply:GetNWString("usergroup"))
end,
CustomCheckFailMsg = "This job is for VIP only!",
PlayerSpawn = function(ply) ply:GodEnable() end,
PlayerDeath = function(ply) ply:GodDisable() end,
})
God mode does not work.
looking at other peoples thread with the same issue, I suppose that you should make sure that babygod is disabled
i'm no expert but GodEnable() says it's run on server side.
Not sure what you are on about, it's not like he is running it on the client? We have the player given with the arg ply inside the function, if that's what you mean
never mind, i didn't read it properly.
Yeah, babygod was enabled going to disable it.
method to make jobs have godmode goto darkrpmodification/lua/modules
create folder called jobgod inside create a lua file and paste the following
function playershouldtakedamage( victim )
if (victim:Team() == TEAM_CAPTAINJACK) then
return false -- do not damage the player
end
end
hook.Add( "PlayerShouldTakeDamage", "captainjackgod", playershouldtakedamage)
Make sure to make your function local.
why
IF you end up running it on the playerspawn hook you need to add a timer as there is a bit where the player isnt actually "alive" thus set a very small timer, and it should fix it
Pollutes the global space - you're only using it for the hook.
Because there is no reason to have it global. Its not being used anywhere else besides that hook. On the off chance that there is another script with a global function playershouldtakedamage then it will override it. Plus there are performance benefits for having it local
https://www.lua.org/pil/4.2.html
Also what confuseth said, if you have babygod enabled, im pretty sure babygod will run and disable godmode after x amount of time after the player has spawned
ok thanks guys :smile:
Thanks guys! I fixed it by disabling babygod.
Sorry, you need to Log In to post a reply to this thread.