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

Lua Clicks problem Dont understand

nevix

Tunzodus.net
Joined
Mar 31, 2010
Messages
356
Reaction score
62
Location
Lithuanian
When normal player click on item nothing happinned:

n0O2_N.png



When GM preesed on item:

7ZcL2f.png



Here my script:

Code:
local t = {
sec = 10,
sec2 = 5,
portal = {x = 32346, y = 32224, z = 7},
itemid = 11796,
active = 1,
cooldown = 10,
storage = 15004
}

function onUse(cid, item, fromPosition, itemEx, toPosition)



local infostorage = getPlayerStorageValue(cid, 15000)

if getPlayerStorageValue(cid, t.storage) >= os.time() then


doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Wait ".. getPlayerStorageValue(cid, t.storage) - os.time().." Sec. Until you can use again.")

else

setPlayerStorageValue(cid, t.storage, os.time() + t.cooldown)

if (infostorage == 1) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Portal has been opened for 10 seconds.")

local portalwhere = {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z}
local portal = doCreateItem(t.itemid,1,portalwhere)

doSetItemActionId(portal, 20001)
addEvent(function()
doRemoveItem(getTileItemById(portalwhere, t.itemid).uid)
end,
t.sec * 1000)
end

if (infostorage == 0) then

doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Portal has been opened for 10 seconds.")

local portalwhere = {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z}
local portal = doCreateItem(t.itemid,1,portalwhere)

doSetItemActionId(portal, 20001)


addEvent(function()
doRemoveItem(getTileItemById(portalwhere, t.itemid).uid)
end,
t.sec * 1000)
end


end



return true
end


Please help :)
 
GM's does not have any exhaustion.

Seems like they had on 1.0
 
Last edited:
Code:
local t = {
    sec = 10,
    sec2 = 5,
    portal = {x = 32346, y = 32224, z = 7},
    itemid = 11796,
    active = 1,
    cooldown = 10,
    storage = 15004
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local infostorage = getPlayerStorageValue(cid, 15000)
    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 use again.")
    end

    --[[if (infostorage == 1) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Portal has been opened for 10 seconds.")
        local portalwhere = {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z}
        local portal = doCreateItem(t.itemid,1,portalwhere)
        doSetItemActionId(portal, 20001)
        addEvent(function() doRemoveItem(getTileItemById(portalwhere, t.itemid).uid) end, t.sec * 1000)
    end]]
      
    --if (infostorage == 0) then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Portal has been opened for 10 seconds.")
        local portalwhere = {x = getCreaturePosition(cid).x, y = getCreaturePosition(cid).y-1, z = getCreaturePosition(cid).z}
        local portal = doCreateItem(t.itemid,1,portalwhere)
        doSetItemActionId(portal, 20001)
        addEvent(function() doRemoveItem(getTileItemById(portalwhere, t.itemid).uid) end, t.sec * 1000)
    --end
  
    setPlayerStorageValue(cid, t.storage, os.time() + t.cooldown)
    return true
end
 
Well, I added comment tags around the storage check and moved the location of setPlayerStorageValue only. :p
 
Back
Top