• 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 [SQLite] -=[TFS]=- 0.4 8.60 [ACTION] HOW TO ADD TWO STORAGE

samuel157

/root
Joined
Mar 19, 2010
Messages
447
Solutions
3
Reaction score
49
Location
São Paulo, Brazil
GitHub
Samuel10M
ACTION: 13741
UNIQUE: 18956

Lua:
local storage = 13741
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == -1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce Ganhou Donate Acesso Infinito.")
         setPlayerStorageValue(cid, storage, 1)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Voce ja usou esse item antes.")
     end
     return true
end
 
Solution
add one storage in this script

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
local config={
removeOnUse = "yes" -- remove when use ("yes" or "no")
}
 
local days = 3 -- put how many days the player will have access to this area

local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 18956)
local timenow = os.time()
 
if getPlayerStorageValue(cid, 18956) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
 
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "was added ".. days .." days of access in your character
.")
setPlayerStorageValue(cid, 18956, time)
local quantity = math.floor((getPlayerStorageValue(cid, 18956) - timenow)/(24 * 60 * 60))...
add one storage in this script

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
local config={
removeOnUse = "yes" -- remove when use ("yes" or "no")
}
 
local days = 3 -- put how many days the player will have access to this area

local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 18956)
local timenow = os.time()
 
if getPlayerStorageValue(cid, 18956) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
 
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "was added ".. days .." days of access in your character
.")
setPlayerStorageValue(cid, 18956, time)
local quantity = math.floor((getPlayerStorageValue(cid, 18956) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are ".. quantity .." days of access remaining.")
if (config.removeOnUse == "yes") then
doRemoveItem(item.uid, 1)
end
 
return TRUE
end

in that

12:37 You see a large gem.
ItemID: [9563], ActionID: [13741], UniqueID: [18956].

Lua:
local storage = 18956
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == -1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You Won Donate Infinite Access.")
         setPlayerStorageValue(cid, storage, 1)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've used this item before.")
     end
     return true
end
 
Last edited:
no function
Lua:
local storageA = 13741 -- one storage
local storageB = 18956 -- second storage

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

    if getPlayerStorageValue(cid, storageA) == -1 then
        storageToUse = storageA
    elseif getPlayerStorageValue(cid, storageB) == -1 then
        storageToUse = storageB
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've used these items before.")
        return true
    end

    if getPlayerStorageValue(cid, storageToUse) == -1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've Earned Infinite Access.")
        setPlayerStorageValue(cid, storageToUse, 1)
        doRemoveItem(item.uid, 1)
    else
      
    end

    return true
end

@tobi132
 
add one storage in this script

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
 
local config={
removeOnUse = "yes" -- remove when use ("yes" or "no")
}
 
local days = 3 -- put how many days the player will have access to this area

local daysvalue = days * 24 * 60 * 60
local storageplayer = getPlayerStorageValue(cid, 18956)
local timenow = os.time()
 
if getPlayerStorageValue(cid, 18956) - os.time() <= 0 then
time = timenow + daysvalue
else
time = storageplayer + daysvalue
end
 
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "was added ".. days .." days of access in your character
.")
setPlayerStorageValue(cid, 18956, time)
local quantity = math.floor((getPlayerStorageValue(cid, 18956) - timenow)/(24 * 60 * 60))
doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You are ".. quantity .." days of access remaining.")
if (config.removeOnUse == "yes") then
doRemoveItem(item.uid, 1)
end
 
return TRUE
end

in that

12:37 You see a large gem.
ItemID: [9563], ActionID: [13741], UniqueID: [18956].

Lua:
local storage = 18956
function onUse(cid, item, fromPosition, itemEx, toPosition)
     if getPlayerStorageValue(cid, storage) == -1 then
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You Won Donate Infinite Access.")
         setPlayerStorageValue(cid, storage, 1)
         doRemoveItem(item.uid, 1)
     else
         doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've used this item before.")
     end
     return true
end
If you would like to combine these two scripts and add another storage value, you could modify the code like this:

Lua:
local days = 3 -- how many days the player will have access to this area
local daysvalue = days * 24 * 60 * 60
local storage = 18956
local newStorage = 18957 -- new storage ID


function onUse(cid, item, fromPosition, itemEx, toPosition)
    
    local config={
        removeOnUse = "yes" -- remove when use ("yes" or "no")
    }
    
    local timenow = os.time()
    local storageplayer = getPlayerStorageValue(cid, storage)
    
    -- For existing storage
    if getPlayerStorageValue(cid, storage) - os.time() <= 0 then
        time = timenow + daysvalue
    else
        time = storageplayer + daysvalue
    end
    
    setPlayerStorageValue(cid, storage, time)
    local quantity = math.floor((getPlayerStorageValue(cid, storage) - timenow)/(24 * 60 * 60))
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "was added ".. days .." days of access in your character.")
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have ".. quantity .." days of access remaining.")
    
    -- For new storage
    if getPlayerStorageValue(cid, newStorage) == -1 then
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You Won Donate Infinite Access.")
        setPlayerStorageValue(cid, newStorage, 1)
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've used this item before.")
    end
    
    doSendMagicEffect(getPlayerPosition(cid), math.random(28,30))
    
    if (config.removeOnUse == "yes") then
        doRemoveItem(item.uid, 1)
    end
    
    return true
end

In this modified script, both the existing storage value (18956) and the new one (18957) are checked and updated accordingly. You can change the newStorage ID to any other ID that you'd like to use.
 
Solution
Back
Top