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

Stop an action event with movement

Lucas Durais

New Member
Joined
Jan 13, 2017
Messages
40
Reaction score
1
Hello guys

My problem is: I'm using a full carpet that transforms into a small carpet and starts an event.
In 10 seconds, it will transform to the original full carpet. But if you step in one tile, it will transform the item I used to the original id before the event.

That way, if another player uses the full carpet after the first player and before the event starts, he will not be able to step on the tile before the event transforms the small carpet to the full carpet.

I need to stop the event from happening as soon as the player steps on the tile.

My stepIn script is like this:
Code:
local carpetPosition = Position(32953, 31466, 6)

function onStepIn(player, item, position, fromPosition)
    if not player then
        return true
    end
    
    if item.itemid == 9625 then
    if Tile(carpetPosition):getItemById(9622)  then
            return true
            end
        elseif Tile(carpetPosition):getItemById(9623) and Tile({ x=32953, y=31465, z=6}):getItemById(9625) then
        player:teleportTo(Position(32953, 31465, 7))
        Tile({ x=32953, y=31465, z=6}):getItemById(9625):transform(9624)
        Tile({ x=32953, y=31466, z=6}):getItemById(9623):transform(9622)   
        
        
        end
    
    return true
    end

And the onUse script like this:

Code:
local carpetPosition = Position(32953, 31466, 6)
local trapPosition = Position(32953, 31465, 6)

local function transformCarpet()
    local teleportcarpet = Tile(carpetPosition):getItemById(9623)
    if not teleportcarpet then
        return
    end

    teleportcarpet:transform(9622)
    teleportcarpet:setUniqueId(61001)
end

local function transformTrap()
    local teleporttrap = Tile(trapPosition):getItemById(9625)
    teleporttrap:transform(9624)
    teleporttrap:setUniqueId(61000)
end   

local function chargingText(cid, text, position)
    local player = Player(cid)
    player:say(text, TALKTYPE_MONSTER_SAY, false, player, position)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
        if item.uid == 61000 then
        if item.itemid == 9624 then
        local trapClosed = Tile({ x=32953, y=31465, z=6}):getItemById(9624)
        if trapClosed then
        trapClosed:transform(9625)
        addEvent(chargingText, (1) * 1, player.uid, 'Screeeeeeech', toPosition)
        end
        end               
                
        elseif item.uid == 61001 then
        if item.itemid == 9622 then
        local carpetFull = Tile({ x=32953, y=31466, z=6}):getItemById(9622)
        if carpetFull then
        carpetFull:transform(9623)
        addEvent(transformTrap, 1 * 10 * 999)
        addEvent(transformCarpet, 1 * 10 * 1000)
            
    end
    end
    end
    
        return true
        end
 
stopEvent(event_id)

make an event id like this..

event_1 = addEvent(function, time, params)
stopEvent(event_1)
 
I really thought that the stopEvent function only worked inside the same script.

I did what u said and it worked.
Thanks
One of the bigger changes in 1.0+ servers is that the Lua environment was merged together for everything.
In 0.3.7 for example, I'd most likely use a global storage to check instead. But in 1.0+since all is merged, you can use stopEvent basically anywhere.
 
Back
Top