GodMode

Why wont this work?

[lua]
function enablegodmode(ply, cmd, args)

if ply:HasPriv(ADMIN) then
ply:GodEnable()
Notify(ply, 1, 4 “God Mode Enabled.”)
print (“God Mode Enabled”)
else
Notify(ply, 1, 4, “You must have admin to run this command.”)
print(“You must have admin to run this command.”)
end

end
concommand.Add(“rp_godmode 1”, enablegodmode)

function disablegodmode (ply, cmd, args)
if ply:HasPriv(ADMIN) then
ply:GodDisable()
Notify(ply, 1, 4, “Disabled God Mode”)
print(“Disabled God Mode”)
else
Notify(ply, 1, 4, “You must have admin to run this command.”)
print(“You must have admin to run this command.”)
end
end
concommand.Add(“rp_godmode 0”, disablegodmode)

[/lua]

Any errors?

No…

[lua]
local takedamage = true

concommand.Add(“rp_togglegod”, function( ply )
if ply:IsAdmin() then
takedamage = !takedamage
ply:ChatPrint(“Toggled GodMode!”)
end
end )

hook.Add(“PlayerShouldTakeDamage”, “RP_Godmode”, function()
return takedamage
end )
[/lua]

That toggles god for everyone, not just the player running the command.

Didn’t read the OP properly :psypop:

[lua]
function enablegodmode(ply)

if ply:HasPriv(ADMIN) then
ply:GodEnable()
Notify(ply, 1, 4 “God Mode Enabled.”)
print (“God Mode Enabled”)
else
Notify(ply, 1, 4, “You must have admin to run this command.”)
print(“You must have admin to run this command.”)
end

end

function disablegodmode (ply)
if ply:HasPriv(ADMIN) then
ply:GodDisable()
Notify(ply, 1, 4, “Disabled God Mode”)
print(“Disabled God Mode”)
else
Notify(ply, 1, 4, “You must have admin to run this command.”)
print(“You must have admin to run this command.”)
end
end

function godmode(ply,cmd,args)

if (args[1] == "0") then

    disablegodmode(ply)
else

    enablegodmode(ply)
end

end

concommand.Add(“rp_godmode”,godmode)
[/lua]

Fixed!