• 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] Understanding Storages

Something like this?
The creaturescript to create the teleport is this one:

Code:
local tpId = 12509
local tps = {
        ["Grand Ferumbras"] = {pos = {x=870, y=1389, z=12}, toPos = {x=898, y=1366, z=12}, time = 20},
}

function removeTp(tp)
        local t = getTileItemById(tp.pos, tpId)
        if t then
                doRemoveItem(t.uid, 1)
                doSendMagicEffect(tp.pos, CONST_ME_POFF)
        end
end

function onDeath(cid)
        local tp = tps[getCreatureName(cid)]
        if tp then
                doCreateTeleport(tpId, tp.toPos, tp.pos)
                doCreatureSay(cid, "El teleport para salir de este lugar desaparecerá en "..tp.time.." segundos.", TALKTYPE_ORANGE_1)
                addEvent(removeTp, tp.time*1000, tp)
        end
        return TRUE
end
How can I give an ActionID to the teleport created?

Then, the onStep function that you are talking about would be this one?
Code:
function onStepIn(cid, item, pos)
if isPlayer(cid) == TRUE then
if (item.actionid == XXXX) then
doPlayerSetStorage(cid,2526,1)
end
end

?
 
Something like this?
The creaturescript to create the teleport is this one:

Code:
local tpId = 12509
local tps = {
        ["Grand Ferumbras"] = {pos = {x=870, y=1389, z=12}, toPos = {x=898, y=1366, z=12}, time = 20},
}

function removeTp(tp)
        local t = getTileItemById(tp.pos, tpId)
        if t then
                doRemoveItem(t.uid, 1)
                doSendMagicEffect(tp.pos, CONST_ME_POFF)
        end
end

function onDeath(cid)
        local tp = tps[getCreatureName(cid)]
        if tp then
                doCreateTeleport(tpId, tp.toPos, tp.pos)
                doCreatureSay(cid, "El teleport para salir de este lugar desaparecerá en "..tp.time.." segundos.", TALKTYPE_ORANGE_1)
                addEvent(removeTp, tp.time*1000, tp)
        end
        return TRUE
end
How can I give an ActionID to the teleport created?

Then, the onStep function that you are talking about would be this one?
Code:
function onStepIn(cid, item, pos)
if isPlayer(cid) == TRUE then
if (item.actionid == XXXX) then
doPlayerSetStorage(cid,2526,1)
end
end

?

The onStepIn() function is correct, please use
Lua:
 tags to tag your scripts.
As for setting an aID to the teleport, use this type of function:
[code=lua]
doSetItemActionId(doCreateTeleport(tpId, tp.toPos, tp.pos).uid, xxx)
xxx being your aID.
You should also remove your other doCreateTeleport() line, since this one will do just that.
 
Last edited:
Forgot I had this tutorial. I noticed quite a few mistakes here.
I should update all of my tutorials sometime soon.
 
Have one question, in what file i can set global storage on server start (like default value)
 
Back
Top