TFS 1.X+ Talkaction script

gubbo123

Member
Joined
Aug 15, 2017
Messages
91
Best answers
1
Reaction score
2
Code:
function onSay(player, words, param)
    local position = player:getPosition()
    local tile = Tile(position)
    local house = tile and tile:getHouse()
    if house == nil then
        player:sendCancelMessage("You are not inside a house.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    if house:getOwnerGuid() ~= player:getGuid() then
        player:sendCancelMessage("You are not the owner of this house.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    house:setOwnerGuid(0)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully left your house.")
    position:sendMagicEffect(CONST_ME_POFF)
    return false
end


how can i do to not execute the Talkaction script if the player don't have a determinated storage? do a check, if the player don't have the storage de talkaction no work.
 

roriscrave

Intermediate OT User
Joined
Dec 7, 2011
Messages
628
Best answers
17
Reaction score
74
how can i do to not execute the Talkaction script if the player don't have a determinated storage? do a check, if the player don't have the storage de talkaction no work.
Lua:
local storage = 100
local value = 1
function onSay(player, words, param)
    local position = player:getPosition()
    local tile = Tile(position)
    local house = tile and tile:getHouse()
    if player:getStorageValue(storage) ~= value then
        player:sendCancelMessage("You dont have a storage.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    if house == nil then
        player:sendCancelMessage("You are not inside a house.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    if house:getOwnerGuid() ~= player:getGuid() then
        player:sendCancelMessage("You are not the owner of this house.")
        position:sendMagicEffect(CONST_ME_POFF)
        return false
    end

    house:setOwnerGuid(0)
    player:sendTextMessage(MESSAGE_INFO_DESCR, "You have successfully left your house.")
    position:sendMagicEffect(CONST_ME_POFF)
    return false
end
100 is a storage
1 is a value of a storage that player neeeed
 
Top