• 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+ AddEvent Issue!

manuloku

New Member
Joined
Nov 12, 2008
Messages
31
Reaction score
4
Well, I have a little problem working with my script...

All it do is transform a wall into a door and after some seconds (in script i put 3) it transform back to a wall..

The script works correctly, BUT when i put some trash into the opened door, it transform back into the wall, but the trash remains stacked over the wall...

How can I clean the tile and only after that, transform back to the wall?


Sorry for my very bad english... Hope you guys understand what i'm saying!

Here's the script i did:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)

    local katanaDoor = Tile(32177, 32148, 11)
    local transfPos = Position(32177, 32148, 11)
    if item.itemid == 3670 then
        katanaDoor:getPosition():sendMagicEffect(CONST_ME_POFF)
        katanaDoor:getItemById(1025):transform(1210)
            Item(item.uid):transform(3668)
        addEvent(function(pillarPos)
        local test = katanaDoor:getItemById(1210)
        local test2 = katanaDoor:getItemById(1211)
        if test then
            test:remove()
            Game.createItem(1025, 1, pillarPos)
            else
            test2:remove()
            Game.createItem(1025, 1, pillarPos)
            end
            pillarPos:sendMagicEffect(CONST_ME_POFF)
            Item(item.uid):transform(3670)
        end, 3000, katanaDoor:getPosition())
    elseif item.itemid == 3668 then
        return false
    end
    return true
end
 
Solution
Well, I have a little problem working with my script...

All it do is transform a wall into a door and after some seconds (in script i put 3) it transform back to a wall..

The script works correctly, BUT when i put some trash into the opened door, it transform back into the wall, but the trash remains stacked over the wall...

How can I clean the tile and only after that, transform back to the wall?


Sorry for my very bad english... Hope you guys understand what i'm saying!

Here's the script i did:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)

    local katanaDoor = Tile(32177, 32148, 11)
    local transfPos = Position(32177, 32148, 11)
    if item.itemid == 3670 then...
Well, I have a little problem working with my script...

All it do is transform a wall into a door and after some seconds (in script i put 3) it transform back to a wall..

The script works correctly, BUT when i put some trash into the opened door, it transform back into the wall, but the trash remains stacked over the wall...

How can I clean the tile and only after that, transform back to the wall?


Sorry for my very bad english... Hope you guys understand what i'm saying!

Here's the script i did:

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)

    local katanaDoor = Tile(32177, 32148, 11)
    local transfPos = Position(32177, 32148, 11)
    if item.itemid == 3670 then
        katanaDoor:getPosition():sendMagicEffect(CONST_ME_POFF)
        katanaDoor:getItemById(1025):transform(1210)
            Item(item.uid):transform(3668)
        addEvent(function(pillarPos)
        local test = katanaDoor:getItemById(1210)
        local test2 = katanaDoor:getItemById(1211)
        if test then
            test:remove()
            Game.createItem(1025, 1, pillarPos)
            else
            test2:remove()
            Game.createItem(1025, 1, pillarPos)
            end
            pillarPos:sendMagicEffect(CONST_ME_POFF)
            Item(item.uid):transform(3670)
        end, 3000, katanaDoor:getPosition())
    elseif item.itemid == 3668 then
        return false
    end
    return true
end

Lua:
local function removeRubbish(pillarPos)
    local myTile = Tile(pillarPos)
    local itemsTile = myTile:getItems()
   
    for k, v in pairs(itemsTile) do
        v:remove()
    end
   
    return true
end

function onUse(cid, item, fromPosition, itemEx, toPosition, isHotkey)
    local katanaDoor = Tile(32177, 32148, 11)
    local transfPos = Position(32177, 32148, 11)
   
    if item.itemid == 3670 then
        katanaDoor:getPosition():sendMagicEffect(CONST_ME_POFF)
        katanaDoor:getItemById(1025):transform(1210)
        Item(item.uid):transform(3668)
       
        addEvent(function(pillarPos)
        local test = katanaDoor:getItemById(1210)
        local test2 = katanaDoor:getItemById(1211)
        if test then
            test:remove()
            removeRubbish(pillarPos) --- executing function here
            Game.createItem(1025, 1, pillarPos)
        else
            test2:remove()
            removeRubbish(pillarPos) --- executing function here
            Game.createItem(1025, 1, pillarPos)
            end
            pillarPos:sendMagicEffect(CONST_ME_POFF)
            Item(item.uid):transform(3670)
        end, 3000, katanaDoor:getPosition())
       
    elseif item.itemid == 3668 then
        return false
    end
   
    return true
end

should work :)
 
Solution
@mackerel Omg, I Love you! It worked perfectly! One more question... I tried to put sound at where the wall transform into wall... like a message in orange.. *clank* or something like that... Tried to use transfPos:SendTextMessage but always say that its a nil value... it's possible to do that? or only messages on player?

i mean... like this
Code:
katanaDoor:getPosition():sendMagicEffect(CONST_ME_POFF)
but with text message...
 
@mackerel Omg, I Love you! It worked perfectly! One more question... I tried to put sound at where the wall transform into wall... like a message in orange.. *clank* or something like that... Tried to use transfPos:SendTextMessage but always say that its a nil value... it's possible to do that? or only messages on player?

i mean... like this
Code:
katanaDoor:getPosition():sendMagicEffect(CONST_ME_POFF)
but with text message...
Have a look at this thread
TFS 1.0 Talking TP Signs
 
@mackerel Omg, I Love you! It worked perfectly! One more question... I tried to put sound at where the wall transform into wall... like a message in orange.. *clank* or something like that... Tried to use transfPos:SendTextMessage but always say that its a nil value... it's possible to do that? or only messages on player?

i mean... like this
Code:
katanaDoor:getPosition():sendMagicEffect(CONST_ME_POFF)
but with text message...
add this to data/lib/core/position.lua
Lua:
function Position.sendText(self, text)
    local specs = Game.getSpectators(self, false, true, 7, 7, 8, 8)
    for x = 1, #specs do
        specs[x]:say(text, TALKTYPE_MONSTER_SAY, false, nil, self)
    end
end
then in your code:
katanaDoor:getPosition():sendText("*clank*")
 
Back
Top