• 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!

Talkaction TFS 1.3 !wall on / !wall off

Zak.Tibiam

New Member
Joined
Mar 25, 2012
Messages
150
Reaction score
3
Hello Otlanders can any programmer help me create a talkaction for example where i say! Wall on create some grids where is the red line in the attached photo and when i say! Wall off the grids are gone i would like that talkaction for opening my server. Thanks in advance!

grade.png
 
Solution
Can just simply use a toggle instead of on/off, just simply add more pos/id pairs to the table and you're good to go.
Lua:
local walls = {
    {pos = Position(1000, 1000, 7), id = xxxx}
}

function toggleWall()
    local ret = ''
    for _, v in ipairs(walls) do
        local tile = Tile(v.pos)
        local wall = tile:getItemById(v.id)
        if wall then
            wall:remove()
            ret = 'off'
        else
            Game.createItem(v.id, 1, v.pos)
            ret = 'on'
        end
    end
    return ret
end

function onSay(player, words, param)
    if player:getAccountType() < 5 then
        return false
    end
    toggleWall()
    player:sendTextMessage(MESSAGE_STATUS_DESCR, "Wall toggled ".. toggleWall() ..".")...
Can just simply use a toggle instead of on/off, just simply add more pos/id pairs to the table and you're good to go.
Lua:
local walls = {
    {pos = Position(1000, 1000, 7), id = xxxx}
}

function toggleWall()
    local ret = ''
    for _, v in ipairs(walls) do
        local tile = Tile(v.pos)
        local wall = tile:getItemById(v.id)
        if wall then
            wall:remove()
            ret = 'off'
        else
            Game.createItem(v.id, 1, v.pos)
            ret = 'on'
        end
    end
    return ret
end

function onSay(player, words, param)
    if player:getAccountType() < 5 then
        return false
    end
    toggleWall()
    player:sendTextMessage(MESSAGE_STATUS_DESCR, "Wall toggled ".. toggleWall() ..".")
    return false
end

-- <talkaction words="!wall" script="wall_toggle.lua" />
 
Last edited:
Solution
Can just simply use a toggle instead of on/off, just simply add more pos/id pairs to the table and you're good to go.
Lua:
local walls = {
    {pos = Position(1000, 1000, 7), id = xxxx}
}

function toggleWall()
    local ret = ''
    for _, v in ipairs(walls) do
        local tile = Tile(v.pos)
        local wall = tile:getItemById(v.id)
        if wall then
            wall:remove()
            ret = 'off'
        else
            Game.createItem(v.id, 1, pos)
            ret = 'on'
        end
    end
    return ret
end

function onSay(player, words, param)
    if player:getAccountType() < 5 then
        return false
    end
    toggleWall()
    player:sendTextMessage(MESSAGE_STATUS_DESCR, "Wall toggled ".. toggleWall() ".")
    return false
end

-- <talkaction words="!wall" script="wall_toggle.lua" />
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/parede.lua:eek:nSay
attempt to index a nil value
stack traceback:
[C]: in ?
[C]: in function 'createItem'
data/talkactions/scripts/parede.lua:14: in function 'toggleWall'
data/talkactions/scripts/parede.lua:25: in function <data/talkactions/scripts/parede.lua:21>
 
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/parede.lua:eek:nSay
attempt to index a nil value
stack traceback:
[C]: in ?
[C]: in function 'createItem'
data/talkactions/scripts/parede.lua:14: in function 'toggleWall'
data/talkactions/scripts/parede.lua:25: in function <data/talkactions/scripts/parede.lua:21>
Edited the script in my post, re-copy it.
 
Edited the script in my post, re-copy it.
when i say !wall i got this error:

Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/parede.lua:eek:nSay
data/talkactions/scripts/parede.lua:26: attempt to call a string value
stack traceback:
[C]: in ?
data/talkactions/scripts/parede.lua:26: in function <data/talkactions/scripts/parede.lua:21>

@Delusion
 
Last edited:
Edited again, don't double post in order to try to get help, you've been a member for 7 years you should've at least read the rules by now.
 
Edited again, don't double post in order to try to get help, you've been a member for 7 years you should've at least read the rules by now.

my sincere apologies for not knowing how to wait but support is needed thanks for helping me

for now you can just comment the line 26 out
--player:sendTextMessage(MESSAGE_STATUS_DESCR, "Wall toggled ".. toggleWall() ".")

thank you so much for helping me brother
 
Back
Top