• 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 How to set multiple storage to a value?

marek12

Available for sprite works
Joined
Apr 8, 2020
Messages
398
Solutions
4
Reaction score
394
Does any one know how to set multiple storage to a certain value?

For example set storages (1000,1001,1002,1003) to (-1) value

I was trying
local storages = {1000,1001,1002,1003} setPlayerStorageValue(cid, storages, -1)
but it doesn't work :/
 
Solution
Does any one know how to set multiple storage to a certain value?

For example set storages (1000,1001,1002,1003) to (-1) value

I was trying
local storages = {1000,1001,1002,1003} setPlayerStorageValue(cid, storages, -1)
but it doesn't work :/
Lua:
local storages = {1000,1001,1002,1003}
for i = 1, #storages do
    setPlayerStorageValue(cid, storages[i], -1)
end
Does any one know how to set multiple storage to a certain value?

For example set storages (1000,1001,1002,1003) to (-1) value

I was trying
local storages = {1000,1001,1002,1003} setPlayerStorageValue(cid, storages, -1)
but it doesn't work :/
Lua:
local storages = {1000,1001,1002,1003}
for i = 1, #storages do
    setPlayerStorageValue(cid, storages[i], -1)
end
 
Solution
Lua:
local storages = {1000,1001,1002,1003}
for i = 1, #storages do
    setPlayerStorageValue(cid, storages[i], -1)
end
unfortunately doesn't work :/

EDIT: sorry, my bad. I had a "return true" at the end, but when removed it works.
Big thank you! :)

EDIT2: In fact I have placed it in wrong place, haha. Still learning.
 
Last edited:
for someone who want to see the complete working script, here it is :

Lua:
function onSay(cid, words, param)
local storage = {10000,10001,10002,10003,10004}
for i = 1, #storage do
    setPlayerStorageValue(cid, storage[i], 1)
doPlayerSendTextMessage(cid, 22, 'blabla.')
end
return true
end
 
How do i do the same thing but onlogin? i know it might or mut be added inside login.lua i have a list with 1000 lines of storages. is there an easy way to add it as it is at the moment?
list looks like this
Lua:
PlayerStorageKeys = {
    annihilatorReward = 30015,
    promotion = 30018,
    delayLargeSeaShell = 30019,
    firstRod = 30020,
    delayWallMirror = 30021,
    madSheepSummon = 30023,
    crateUsable = 30024,
    afflictedOutfit = 30026,
    afflictedPlagueMask = 30027,
    afflictedPlagueBell = 30028,
    nailCaseUseCount = 30031,
    swampDigging = 30032,
    insectoidCell = 30033,
    vortexTamer = 30034,
    mutatedPumpkin = 30035,
    achievementsBase = 300000,
    achievementsCounter = 20000,
    --Blessings = 50139,
    KawillBlessing = 50139,
    --agregado added
        DeeplingsWorldChange = {
            Questline = 25000,
            FirstStage = 25001,
            SecondStage = 25002,
            ThirdStage = 25003,
obiously is largar much more larger i use orts datapack
 
How do i do the same thing but onlogin?
Lua:
local storages = {10000,10001,10002,10003,10004}

local setStorage = CreatureEvent("setStorage")

function setStorage.onLogin(player)
    for i = 1, #storages do
        player:setStorageValue(storage[i], 1)
    end
    return true
end

setStorage:register()
 
Back
Top