• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua Only in protection zone

myalitth

New Member
Joined
Jan 13, 2013
Messages
69
Reaction score
3
LUA:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:setSkull(SKULL_NONE)
        player:setSkullTime(0)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
        db.query("UPDATE `player_deaths` SET `unjustified` = 0 WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
        item:remove(1)
    else
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
    end
    return true
end
TFS 1.2 ! Tibia 10.96+
How can i use this only in Protection zone?
Thank you!
 
Last edited:
LUA:
function onUse(player, item, fromPosition, itemEx, toPosition, isHotkey)
    if not player:getTile():hasFlag(TILESTATE_PROTECTIONZONE) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove skulls in protection zone!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false
    end

    if not isInArray({SKULL_RED, SKULL_BLACK}, player:getSkull()) then
        player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "You can only remove red or black skulls!")
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        return false      
    end

    player:setSkull(SKULL_NONE)
    player:setSkullTime(0)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_GREEN)
    player:sendTextMessage(MESSAGE_EVENT_ADVANCE, "Your skull has been removed!")
    db.query("UPDATE `player_deaths` SET `unjustified` = 0 WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
    item:remove(1)
    return true
end

But if it's an item you can use on other players (not only yourself), you should be acting on itemEx (checking if it's a player first) rather than player.
 
Last edited:
So, i've fix your script, and now this works.

Error at #2 line double ::

Yeas, you're right, it should be ":" instead of "::". I've made the change in my original answer for other people who may miss your post. Great it works, just make sure it works as expected if you try to use it on another player / creature / item.
 
I've problem, when i remove skull and kill another player, i get this skull again...
Eg. Red Skull use remove skull = no skull, later kill another player gets red skull again.

Sorry for my english :s
 
I've problem, when i remove skull and kill another player, i get this skull again...
Eg. Red Skull use remove skull = no skull, later kill another player gets red skull again.

Sorry for my english :s

You may try changing this:
LUA:
db.query("UPDATE `player_deaths` SET `unjustified` = 0 WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
to
LUA:
db.query("UPDATE `player_deaths` SET `unjustified` = 0, `mostdamage_unjustified` = 0 WHERE `unjustified` = 1 AND `killed_by` = " .. db.escapeString(player:getName()))
 
Then there must be something else missing. I'm afraid this is where my knowledge ends regarding this. I assume you didn't configure your server to 1 frags for red skull? :)

I also think you should mark this thread as answered and create a new one instead, concerning your new issue (since the original issue is resolved). This would give you better chance to get attention from someone who could have had this sort of issue before.
 
Back
Top