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

Set Storage to players

Wanheda

New Member
Joined
Feb 17, 2016
Messages
44
Solutions
2
Reaction score
4
Hello, I'm trying to add a setPlayerStorageValue with os.time () when using the lever, I've tried several forms and I could not, can anyone help me?

Lua:
local function removeBosst(fromArea1, fromArea2, bossName)
    for x = fromArea1.x, fromArea2.x do
        for y = fromArea1.y, fromArea2.y do
            for z = fromArea1.z, fromArea2.z do
                if(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid > 0) then
                    if(isMonster(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)) then
                        if(string.lower(getCreatureName(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)) == bossName) then
                        doRemoveCreature(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)
                        end
                    end
                end
            end
        end
    end
    return true
end

local function teleportAllPlayersFromAreat(fromArea1, fromArea2, toPos)
    for x = fromArea1.x, fromArea2.x do
        for y = fromArea1.y, fromArea2.y do
            for z = fromArea1.z, fromArea2.z do
                if(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid > 0) then
                    if(isPlayer(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid)) then
                    doTeleportThing(getTopCreature({x = x, y = y, z = z, stackpos = 255}).uid, toPos)
                    end
                end
            end
        end
    end
    return true
end

local function PrepareEnter()
    teleportAllPlayersFromAreat({x=32291,y=32225,z=7},{x=32291,y=32229,z=7},{x=32272,y=32211,z=7})
    removeBosst({x=32268,y=32205,z=7}, {x=32276,y=32213,z=7}, "Rat") --
    Game.createMonster("Rat", {x=32272,y=32209,z=7})
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item.itemid == 9825 or 9826 then
        if getGlobalStorageValue(28082) >= os.time() then
            doPlayerSendTextMessage(player, 19, "You need to wait 5 minutes to use again.")
            return true
        end

        local specs, spec = Game.getSpectators({x=32273,y=32209,z=7}, false, false, 13, 13, 13, 13)
        for i = 1, #specs do
            spec = specs[i]
            if spec:isPlayer() then
                player:sendTextMessage(MESSAGE_STATUS_SMALL, "A team is already inside the quest room.")
                return true
            end

            spec:remove()
        end

        setGlobalStorageValue(28082, os.time()+5*60)
        addEvent(PrepareEnter, 1)
       
    end

    item:transform(item.itemid == 9825 and 9826 or 9825)
    return true
end
 
Where and why you want use player storage? What the purpose of that script?

All I can see:

player can pull the lever if globalstorage let him to and there aren't any players (boss room?). Otherwise the globalstorage storage saves the next timeout and something happen (prepareEnter func, tp players, clear room, spawn boos and shit).

What you want to do then? It seems good. The globalstorage blocks the lever for all players. Where you want to use player storage then?
 
I need a setPlayerStorage at the time they are teleported, so they do not enter the room where that lever is for x hours.
 
This what you mean?
Code:
player:setStorageValue(STORAGEHERE, os.time() + TIMETOWAIT)
 
Back
Top