Hello
Title says everything
Have a great day
Tested on TFS 1.4 without any errors right now.
If you have any errors, let me know!
Title says everything
Have a great day
Tested on TFS 1.4 without any errors right now.
If you have any errors, let me know!
Lua:
-------------------------------------------------------------------------
-------------------------------------------------------------------------
local action = Action()
function action.onUse(player, item, fromPosition, target, toPosition, isHotkey)
if not player:getTile():hasFlag(TILESTATE_PROTECTIONZONE) then
player:sendTextMessage(MESSAGE_INFO_DESCR, "You can change your pvp only in protection zone!")
return true
end
if player:getStorageValue(4500) == 1 then
player:setStorageValue(4500, -1)
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have turned on PVP')
else
player:setStorageValue(4500, 1)
player:sendTextMessage(MESSAGE_INFO_DESCR, 'You have turned off PVP')
end
--item:remove()
return true
end
action:id(8920)
action:register()
-------------------------------------------------------------------------
-------------------------------------------------------------------------
local ec = EventCallback
ec.onTargetCombat = function(self, target)
if not self or not target then
return true
end
if self:isMonster() or target:isMonster() then
return true
end
if self:getStorageValue(4500) == 1 or target:getStorageValue(4500) == 1 then
return RETURNVALUE_YOUMAYNOTATTACKTHISCREATURE
end
return RETURNVALUE_NOERROR
end
ec:register()
-------------------------------------------------------------------------
-------------------------------------------------------------------------
local ec = EventCallback
ec.onLook = function(self, thing, position, distance, description)
if not self or not thing then
return description
end
if thing:isMonster() or thing:isItem() then
return description
end
if thing:isPlayer() then
description = description .."\n"
if thing:getStorageValue(4500) == 1 then
description = description .. "PVP OFF"
else
description = description .. "PVP ON"
end
end
return description
end
ec:register()
-------------------------------------------------------------------------
-------------------------------------------------------------------------