General > Developers Corner
ULibCommandCalled not being called?
Adult:
Title says it all. Here's the full script.
--- Code: ----- 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 )
--- End code ---
I've spent almost two hours trying to get this working. I have no idea why it's not.
Thanks in advance.
JamminR:
Quick overview, you have two hook add's with the same unique name.
One will overwrite the other, with only Lua knows what consequences.
"PVP_Mod" can't be applied to both hooks (playersay and ULibCommandCalled)
Maybe rename the playersay PVP_Mod_say and the ULibCommandCalled to PVP_Mod_ULXGodfix
Other than that, fix it, we'll go from there.
Adult:
hm, makes sense, but still didn't fix it. :L
JamminR:
Any server/console errors, at startup or command execution?
I take it you're not seeing 'please work' at all when running ULX commands (god or otherwise, you should see something)?
Adult:
--- Quote from: JamminR on January 21, 2013, 04:09:32 PM ---Any server/console errors, at startup or command execution?
--- End quote ---
None at all, really strange.
--- Quote from: JamminR on January 21, 2013, 04:09:32 PM ---I take it you're not seeing 'please work' at all when running ULX commands (god or otherwise, you should see something)?
--- End quote ---
Correct, sir. ( I mean, no, I'm not seeing it. )
Navigation
[0] Message Index
[#] Next page
Go to full version