• Congratulations to the OTLand January Mapping Competition Winner! The grand prize of Otland Premium goes to Andréew.
  • Sign up for February Mapping Competition! The prize includes Otland Premium time.
  • 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!

TFS 1.X+ Talkaction script

gubbo123

New Member
Joined
Aug 15, 2017
Messages
116
Best answers
1
Reaction score
3
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

Well-Known Member
Joined
Dec 7, 2011
Messages
765
Best answers
19
Reaction score
90
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