Title says it all. Here's the full script.
-- Selective PVP
-- Both attackers and victims must have
-- PVP enabled to do damage.
-- Requires ULib
-- Made by: Adult
-- Chat command
-- !pvp on/off
if CLIENT then return end
local function playerSay( ply, text )
local args = string.Explode( " ", text )
if args[1] ~= "!pvp" then return end
local enabled = ply.pvp
if args[2] == "on" and enabled then
ULib.tsayError( ply, "You're already in PVP mode.", true )
return
end
if args[2] == "off" and not enabled then
ULib.tsayError( ply, "You're not in PVP mode.", true )
return
end
ply.pvp = ( args[2] == "on" and true ) or ( args[2] == "off" and false )
ulx.fancyLogAdmin( ply, false, "#A " .. ( ply.pvp and "entered" or "left" ) .. " PVP mode." )
if ply.ULXHasGod then
ply:GodDisable()
end
end
hook.Add( "PlayerSay", "PVP_Mod", playerSay )
-- Entity damage
local function takeDamage( target, dmgInfo )
if not target:IsPlayer() then return end
if not target.pvp then return end
local attacker = dmgInfo:GetAttacker()
if not attacker:IsPlayer() then return end
if not attacker.pvp then return end
end
hook.Add( "EntityTakeDamage", "PVP_Mod", takeDamage )
-- Modifies ulx god slightly, so it can't be abused.
local function commandCalled( ply, cmd, args )
print( "work please.")
if cmd ~= "ulx god" then return end
if ply.pvp then
ULib.tsayError( ply, "You're in PVP Mode!", true )
return false
end
if args[1].pvp then
ULib.tsayError( ply, "Target is in PVP Mode!", true )
return false
end
end
hook.Add( "ULibCommandCalled", "PVP_Mod", commandCalled )
I've spent almost two hours trying to get this working. I have no idea why it's not.
Thanks in advance.