• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Lua onStep setGlobalStorageValue

MadMOOK

Hoo
Joined
Apr 20, 2011
Messages
802
Reaction score
44
Is this what I would use to set storage to keep players out of magic teleporter for x amount of time?
If so how would i do that?
 
Works fine for me, but you can also do it with the positions based on uniqueid in a table instead of in the teleports.
Code:
local config = {
   [9001] = {x = 94, y = 117, z = 7},
   [9002] = {x = 94, y = 118, z = 7},
   [9003] = {x = 94, y = 119, z = 7},
   [9004] = {x = 94, y = 110, z = 7},
   [9005] = {x = 94, y = 109, z = 7},
   [9006] = {x = 94, y = 108, z = 7},
   [9007] = {x = 94, y = 107, z = 7},
   [9008] = {x = 94, y = 114, z = 7},
   [9009] = {x = 94, y = 115, z = 7},
   [9010] = {x = 94, y = 116, z = 7},
   [9011] = {x = 94, y = 117, z = 7}
}

local storage = 9853
local time = 30 -- time in seconds

function onStepIn(cid, item, position, fromPosition)
     if item.actionid == 0 or not config[item.uid] then
         return true
     end

     if globalexhaustion.check(storage + item.actionid) then
         doTeleportThing(cid, fromPosition)
         doPlayerSendCancel(cid, "You need to wait "..globalexhaustion.get(storage + item.actionid).." seconds before you can enter here again.")
         return true
     end
     doTeleportThing(cid, config[item.uid])
     globalexhaustion.set(storage + item.actionid, time)
     return true
end
 
No, but if that was wrong you would get a nil value error.
Did you already tried it with the positions based on uniqueids like I posted?
 
try this

Code:
local storage = 9853
local time = 300 -- time in seconds

local function denied(var)
    doTeleportThing(var.cid, var.tp)
end

function onStepIn(cid, item, position, fromPosition)
    if item.actionid == 0 then
        return true
    end

    if globalexhaustion.check(storage + item.actionid) then
        local var = {cid = cid, tp = fromPosition}
        addEvent(denied, 0, var)
        doPlayerSendCancel(cid, "You need to wait "..globalexhaustion.get(storage + item.actionid).." seconds before entering this instance.")
        return true
    end
    globalexhaustion.set(storage + item.actionid, time)
    return true
end
 
With this script (also tested)
Works fine for me, but you can also do it with the positions based on uniqueid in a table instead of in the teleports.
Code:
local config = {
   [9001] = {x = 94, y = 117, z = 7},
   [9002] = {x = 94, y = 118, z = 7},
   [9003] = {x = 94, y = 119, z = 7},
   [9004] = {x = 94, y = 110, z = 7},
   [9005] = {x = 94, y = 109, z = 7},
   [9006] = {x = 94, y = 108, z = 7},
   [9007] = {x = 94, y = 107, z = 7},
   [9008] = {x = 94, y = 114, z = 7},
   [9009] = {x = 94, y = 115, z = 7},
   [9010] = {x = 94, y = 116, z = 7},
   [9011] = {x = 94, y = 117, z = 7}
}

local storage = 9853
local time = 30 -- time in seconds

function onStepIn(cid, item, position, fromPosition)
     if item.actionid == 0 or not config[item.uid] then
         return true
     end

     if globalexhaustion.check(storage + item.actionid) then
         doTeleportThing(cid, fromPosition)
         doPlayerSendCancel(cid, "You need to wait "..globalexhaustion.get(storage + item.actionid).." seconds before you can enter here again.")
         return true
     end
     doTeleportThing(cid, config[item.uid])
     globalexhaustion.set(storage + item.actionid, time)
     return true
end
You have to add the uniqueids to the teleports and the actionids, the teleports can't have a teleport position (so you can also just use ghost charms).
If you added it with itemid, make sure this itemid is not already added in movements.xml for an other script.
 
You don't need to add the uniqueids in movements.xml.
You can add the actionids, but you can also just use add it with the itemid instead (just make sure this itemid is not added already in movements.xml for an other script).
 
KSmHvB.png

rJmy-R.png

BmuaEC.png


movements.xml
Code:
<movevent type="StepIn" itemid="1387" event="script" value="exhausttel.lua"/>

You can also just use a ghost charm instead of a real teleport.

What happens when you step on the teleport?
 
What is a ghost charm? Lol!
Nothing happens when i step on tp, i do not wish to use itemid because, this is one of many instance type quests i am creating
 
QklqKp.png

Teleports without position, so they just look like teleports.

It also works when you add the actionids in movements.xml btw, it's just with itemid you have to add less.
 
Back
Top