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

Solved Teleport DOREMOVEITEM

nevix

Tunzodus.net
Joined
Mar 31, 2010
Messages
356
Reaction score
62
Location
Lithuanian
Whats happining, no errors nothing but item didn't dissapear after function.

Code:
zeCreateTeleportPosition = {x = 32342,y = 32220,z = 7} --Where should the teleport be created?


function startZombie()
    local specs = Game.getSpectators(zeWaitingRoomPos, false, true, 0, zeWaitingRoomRadiusX, 0, zeWaitingRoomRadiusY)
        if Game.getStorageValue(zeJoinedCountGlobalStorage) < zeMinPlayers then
            for i = 1, #specs do
                    specs[i]:teleportTo(specs[i]:getTown():getTemplePosition(), false)
                    specs[i]:setStorageValue(zeJoinStorage, 0)
            end
            resetVariables()
            broadcastMessage('Zombie Event failed to start, because of to little players joined the event!', MESSAGE_STATUS_WARNING)
            doRemoveItem(getTileItemById(zeCreateTeleportPosition, 11798).uid, 1)

            return true
        end
        for i = 1, #specs do
            specs[i]:teleportTo(zeZombieArena)
        end
        broadcastMessage("Zombie Event has started, good luck to all participant.", MESSAGE_STATUS_WARNING)
        Game.setStorageValue(zeStartedGlobalStorage, 2)
        doStartZombieEvasion()
end



But nothing no errors. Help me please solve this
 
Do you get the broadcast message ('Zombie Event failed to start, because of to little players joined the event!')?
What do you see in your console if you add this above doRemoveItem?
Code:
print(getTileItemById(zeCreateTeleportPosition, 11798).uid)
 
my event is created and its created item "Portal" and I want if event dont have enough players this function remove this item. I will show in other what I want:

zeCreateTeleportPosition = {x = 32342,y = 32220,z = 7} --Where should the teleport be created?
<<<<

globalevent:

Code:
dofile('data/zombie_system.lua')




function onThink(interval, lastExecution, thinkInterval)
    if Game.getStorageValue(zeStartedGlobalStorage) < 1 then

        local teleport = Game.createItem(11798, 1, zeCreateTeleportPosition)
        if teleport then
            teleport:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 7000)
        end
       
       
addEvent(function() doRemoveItem(getTileItemById(zeCreateTeleportPosition, 11798).uid) end, 60 * 1000) 
doSendMagicEffect(zeCreateTeleportPosition, CONST_ME_TELEPORT)

        Game.setStorageValue(zeStartedGlobalStorage, 1)
                broadcastMessage('The Zombie Event has started! You have '.. zeWaitMinutes ..' minutes to join!', MESSAGE_STATUS_WARNING)
        addEvent(startZombie, zeWaitMinutes * 60 * 1000)


    end
    return true
end

That item didn't dissapear after 60 seconds.

addEvent(function() doRemoveItem(getTileItemById(zeCreateTeleportPosition, 11798).uid) end, 60 * 1000)
 
Ok, but what if you add the print line I posted above the line where it removes the item, what does it show in your console?
 
Code:
function doRemoveTimeItem(pos, itemid)
     print(pushThing(Tile(pos):getItemById(itemid)).uid)
     return Item(pushThing(Tile(pos):getItemById(itemid)).uid):remove()
end


addEvent(doRemoveTimeItem, 60 * 1000, zeCreateTeleportPosition, 11798)
What do you see in your console if you do it like this?
 
Last edited:
I got error on 19 line mistake:
function argument expected near 'end'

all code:


Code:
dofile('data/zombie_system.lua')




function onThink(interval, lastExecution, thinkInterval)
    if Game.getStorageValue(zeStartedGlobalStorage) < 1 then

        local teleport = Game.createItem(11798, 1, zeCreateTeleportPosition)
        if teleport then
            teleport:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 7000)
        end
      
      

function doRemoveTimeItem(pos, itemid)
   print(pushThing(Tile(pos):getItemById(itemid)).uid)
   return Item(pushThing(Tile(pos):getItemById(itemid)).uid):remove
end

addEvent(doRemoveTimeItem, 60 * 1000, zeCreateTeleportPosition, 11798)


doSendMagicEffect(zeCreateTeleportPosition, CONST_ME_TELEPORT)

        Game.setStorageValue(zeStartedGlobalStorage, 1)
                broadcastMessage('The Zombie Event has started! You have '.. zeWaitMinutes ..' minutes to join!', MESSAGE_STATUS_WARNING)
        addEvent(startZombie, zeWaitMinutes * 60 * 1000)


    end
    return true
end
 
5JciOMTK.png
 
Code:
function doRemoveTimeItem(pos, itemid)
     local item = Item(pushThing(Tile(pos):getItemById(itemid)).uid)
     if item then
         item:remove()
     end
     return true
end
 
uEDd29hC.png


Item after 60 seconds still here.

Code:
dofile('data/zombie_system.lua')




function onThink(interval, lastExecution, thinkInterval)
    if Game.getStorageValue(zeStartedGlobalStorage) < 1 then

        local teleport = Game.createItem(11798, 1, zeCreateTeleportPosition)
        if teleport then
            teleport:setAttribute(ITEM_ATTRIBUTE_UNIQUEID, 7000)
        end
      
      

function doRemoveTimeItem(pos, itemid)
     local item = Item(pushThing(Tile(pos):getItemById(itemid)).uid)
     if item then
         item:remove()
     end
     return true
end

addEvent(doRemoveTimeItem, 60 * 1000, zeCreateTeleportPosition, 11798)


doSendMagicEffect(zeCreateTeleportPosition, CONST_ME_TELEPORT)

        Game.setStorageValue(zeStartedGlobalStorage, 1)
                broadcastMessage('The Zombie Event has started! You have '.. zeWaitMinutes ..' minutes to join!', MESSAGE_STATUS_WARNING)
        addEvent(startZombie, zeWaitMinutes * 60 * 1000)


    end
    return true
end



I have almost simple adevent in my other teleport:
Code:
local t = {
    sec = 10,
    sec2 = 5,
    portal = {x = 32353, y = 32219, z = 7},
    portalwhere = {x = 32353, y = 32219, z = 7},
    itemid = 11798,
    active = 1,
    cooldown = 10,
    storage = 15005
}

function onStepIn(cid, item, position, lastPosition)


    if getPlayerStorageValue(cid, t.storage) >= os.time() then
        return doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Wait ".. getPlayerStorageValue(cid, t.storage) - os.time().." Sec. Until you can walk again.")
    else
  
local portal = doCreateItem(t.itemid,1,t.portalwhere)
doSetItemActionId(portal, 21002)
doSendMagicEffect(t.portalwhere, CONST_ME_TELEPORT)

addEvent(function() doRemoveItem(getTileItemById(t.portalwhere, t.itemid).uid) end, t.sec * 1000)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Teleport created for 10 seconds.")
setPlayerStorageValue(cid, t.storage, os.time() + t.cooldown)

end

return true
end

That script working good and remove item correctly dissapear after 10 seconds
 
I dont know what happined, but I changed

Code:
<movevent event="StepIn" actionid="7000" script="zombie_teleport.lua"/>

And changed code to this:

Code:
local portal = doCreateItem(11798,1,zeCreateTeleportPosition)
doSetItemActionId(portal, 7000)
doSendMagicEffect(zeCreateTeleportPosition, CONST_ME_TELEPORT)
addEvent(function() doRemoveItem(getTileItemById(zeCreateTeleportPosition, 11798).uid) end, 60 * 1000)

Different is I make action id not unique it working perfecly now, anyway thx mate :) SOLVED
 
Back
Top