• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua PVP Optional useable Item tfs 1.4

Kawaki69

Member
Joined
Mar 4, 2022
Messages
72
Reaction score
8
Was searching around the forum for hours but I couldn't find it if someone can do it will be much appreciated for the community and a helpful for the starters. A simple item is written on onUse if you clicked one time it turns off your PVP and if you clicked once again it turns on your PVP.
Preview:- Click
"you have turned off your PVP system" and if someone looks at you it says "PVP OFF"
the another click
"you have turned on your PVP system" and if someone looks at you it says "PVP ON".
Using tfs 1.4.1
 
Last edited:
Solution
now no description like nothing happened but it works i can't attack the target and this error appear
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onTargetCombat
C:\Users\angelica\Desktop\server\data\scripts\batman.lua:30: attempt to index local 'self' (a nil value)
stack traceback:
        [C]: in function '__index'
        C:\Users\angelica\Desktop\server\data\scripts\batman.lua:30: in function <C:\Users\angelica\Desktop\server\data\scripts\batman.lua:29>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function <...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:123>

msg me private to avoid spamming the thread
Post automatically merged:
...
why not use the combat mode module of the client there on github are a few repos with the system
on my server i did remove the full attack, full defense, and balance fighting mode and use those button for the pvp mode
 
why not use the combat mode module of the client there on github are a few repos with the system
on my server i did remove the full attack, full defense, and balance fighting mode and use those button for the pvp mode
I think I'm not interested in editing the client etc... i have a tiny PVP server :> and I'm using the cipsoft one.
 
pvp.png


Introduced skull system described in Skull System (https://tibia.fandom.com/wiki/Skull_System)


just search and you will find it really easy
Post automatically merged:

i just disabled the green skull and the orange skull and so you can just select pvp mode on or off, white-red.
Post automatically merged:

also if you want just a easy thing you got something like this

 
@Kawaki69
1651584265292.png

1651584276837.png

data/scripts/batman.lua
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 self:isMonster() or target:isMonster() then
        return true
    end
    if target:getStorageValue(4500) == 1 or self: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 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()
-------------------------------------------------------------------------

-------------------------------------------------------------------------
 
Last edited:
@Kawaki69
View attachment 67530

View attachment 67531

data/scripts/batman.lua
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 self:isMonster() or target:isMonster() then
        return true
    end
    if target:getStorageValue(4500) == 1 or self: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 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
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

ec:register()
-------------------------------------------------------------------------

-------------------------------------------------------------------------
Thanks very much levai also thanks for understanding me god bless you buddy.
Post automatically merged:

@Kawaki69
View attachment 67530

View attachment 67531

data/scripts/batman.lua
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 self:isMonster() or target:isMonster() then
        return true
    end
    if target:getStorageValue(4500) == 1 or self: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 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
    self:sendTextMessage(MESSAGE_INFO_DESCR, description)
end

ec:register()
-------------------------------------------------------------------------

-------------------------------------------------------------------------
This error appears
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onTargetCombat
...angelica\Desktop\server\data\scripts\creaturescripts\batman.lua:30: attempt to index local 'self' (a nil value)
stack traceback:
        [C]: in function '__index'
        ...angelica\Desktop\server\data\scripts\creaturescripts\batman.lua:30: in function <...angelica\Desktop\server\data\scripts\creaturescripts\batman.lua:29>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function <...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:123>
edit: another errors
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua:8>

Lua Script Error: [Event Interface]
data/events/scripts/player.lua:Player@onLook
...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: attempt to concatenate local 'description' (a nil value)
stack traceback:
        [C]: in function '__concat'
        ...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:7: in function <...Desktop\server\data\scripts\eventcallbacks\player\cool.lua:3>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function 'EventCallback'
        data/events/scripts/player.lua:11: in function <data/events/scripts/player.lua
and this when i look into myself it doesn't show any states or the other attrbiutes like level and another things always shows pvp off
1651593640599.png
 
Last edited:
retry script
updated
this error pop up and it doesn't show the description
1651604852242.png
Code:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onTargetCombat
C:\Users\angelica\Desktop\server\data\scripts\batman.lua:30: attempt to index local 'self' (a nil value)
stack traceback:
        [C]: in function '__index'
        C:\Users\angelica\Desktop\server\data\scripts\batman.lua:30: in function <C:\Users\angelica\Desktop\server\data\scripts\batman.lua:29>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function <...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:123>
 
remove
Lua:
self:isMonster() or
Code:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onTargetCombat
C:\Users\angelica\Desktop\server\data\scripts\batman.lua:33: attempt to call method 'getStorageValue' (a nil value)
stack traceback:
        [C]: in function 'getStorageValue'
        C:\Users\angelica\Desktop\server\data\scripts\batman.lua:33: in function <C:\Users\angelica\Desktop\server\data\scripts\batman.lua:29>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function <...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:123>
        [C]: at 0x7ff7f4b8a000

Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onTargetCombat
C:\Users\angelica\Desktop\server\data\scripts\batman.lua:33: attempt to call method 'getStorageValue' (a nil value)
stack traceback:
        [C]: in function 'getStorageValue'
        C:\Users\angelica\Desktop\server\data\scripts\batman.lua:33: in funcver\data\scripts\batman.lua:33: in function <Ction <C:\Users\angelica\Desktop\server\data\scripts\batman.lua:29>
 
add it back sorry
now no description like nothing happened but it works i can't attack the target and this error appear
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onTargetCombat
C:\Users\angelica\Desktop\server\data\scripts\batman.lua:30: attempt to index local 'self' (a nil value)
stack traceback:
        [C]: in function '__index'
        C:\Users\angelica\Desktop\server\data\scripts\batman.lua:30: in function <C:\Users\angelica\Desktop\server\data\scripts\batman.lua:29>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function <...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:123>
 
now no description like nothing happened but it works i can't attack the target and this error appear
Lua:
Lua Script Error: [Event Interface]
data/events/scripts/creature.lua:Creature@onTargetCombat
C:\Users\angelica\Desktop\server\data\scripts\batman.lua:30: attempt to index local 'self' (a nil value)
stack traceback:
        [C]: in function '__index'
        C:\Users\angelica\Desktop\server\data\scripts\batman.lua:30: in function <C:\Users\angelica\Desktop\server\data\scripts\batman.lua:29>
        ...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:127: in function <...rs\angelica\Desktop\server\data\scripts/lib\event_callbacks.lua:123>

msg me private to avoid spamming the thread
Post automatically merged:

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()
-------------------------------------------------------------------------

-------------------------------------------------------------------------
 
Last edited:
Solution
msg me private to avoid spamming the thread
Post automatically merged:

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()
-------------------------------------------------------------------------

-------------------------------------------------------------------------
Thanks very much levi <3 you da best
 
pvp.png

just FYI, this "pvp mode" is the "new" tibia pvp called "open pvp" (and it sux), and it is not implemented in any ot engine I suppose. slavi dodo might have coded it thought, but we all know what happened
 
Back
Top