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

Solved Why exhausted are not working on this script?

1268995

Member
Joined
Sep 9, 2010
Messages
422
Reaction score
13
Hello guys, this a system and i am having problens in an exhausted script.

Take a look:

Code:
local gab = {
exhausted = 2.7, -- Time you are exhausted. by second
storage = 91355 -- Storage used for "exhaust."
}

local config = {
storage = 19333,
chance = 10, --- chance de achar um item ou não
k = 2, --- constante de level.. quanto maior, mais fácil é upar. (a fórmula é level ao quadrado dividido pela constante)
experience = 19334
}


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


(SOME NOT IMPORTANT SCRIPT PART )
(...)

if config.chance >= math.random(1,100) then
if #drops >= 1 then
local item = drops[math.random(1,#drops)]
doPlayerSendTextMessage(cid, 27, "You have found a "..getItemNameById(item)..".")
doPlayerAddItem(cid, item, 1, true)
setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)

end
doSendMagicEffect(toPosition, 3)
setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)

else
doSendMagicEffect(toPosition, 2)
setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)

return true
end
elseif itemEx.itemid == item.itemid then
doPlayerSendTextMessage(cid, 27, "You're currenctly level "..getPlayerStorageValue(cid, config.storage)..".")
else
return false
end
return true
end

Why setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted) are NOT working?

Thanks in advanced.
 
Last edited:
My guess is this.
Code:
exhausted = 2.7
Try an integer instead of a floating point number.

Don't work... i putted 5. Also putted 5000 (to se if it was in miliseconds), and none worked.

I tested and i dont think is having conflict between the two storages:

local gab = {
exhausted = 2.7, -- Time you are exhausted. by second
storage = 91355 -- Storage used for "exhaust."
}

local config = {
storage = 19333,
chance = 10, --- chance de achar um item ou não
k = 2, --- constante de level.. quanto maior, mais fácil é upar. (a fórmula é level ao quadrado dividido pela constante)
experience = 19334
}

Or this 2 storages can conflict with wichother?

EDIT: i found the part of script that add the storage (19333).. it is:

Code:
doPlayerSetStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage)+1)

Have any difference btween doPlayerSetStorageValue and setPlayerStorageValue ?
 
Last edited:
My guess is this.
Code:
exhausted = 2.7
Try an integer instead of a floating point number.

Full script:

Code:
terra = {1304,1305}
levels = {
[-1] = 2229, ---- skull
[0] = 1294, --- small stone
[1] = 3976, --- worm
[10] = 2149, -- Small Emerald
[12] = 2146, -- Small Sapphire
[15] = 2145, -- Small Diamond
[17] = 2150, -- Small Amethyst
[20] = 2147, -- Small Ruby
[25] = 2144, -- Black Pearls
[27] = 2143, -- White Pearls
[30] = 2157, -- Gold Nuggets
[35] = 2156, --- red gem
[36] = 2158, -- blue gem
[37] = 2155, -- green gem
[38] = 2153, -- violet gem
[39] = 2154, -- yellow gem
[40] = 7761, -- small enchanted emerald
[42] = 7759, -- Small Enchanted Sapphiire
[45] = 7762, -- Small Enchanted Amethyst
[50] = 7760, -- Small Enchanted Ruby
[70] = 2177  -- Life Crystal
}

local gab = {
exhausted = 3, -- Time you are exhausted. by second
storage = 91355 -- Storage used for "exhaust."
}

local config = {
storage = 19333,
chance = 10, --- chance de achar um item ou não
k = 2, --- constante de level.. quanto maior, mais fácil é upar. (a fórmula é level ao quadrado dividido pela constante)
experience = 19334
}


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


local drops = {}


function getDrops(cid)
for i= -1,getPlayerStorageValue(cid, config.storage) do
if levels[i] then
table.insert(drops, levels[i])
end
end
return true
end


if isInArray(terra, itemEx.itemid) then
getDrops(cid)
doPlayerSetStorageValue(cid, config.experience, getPlayerStorageValue(cid, config.experience)+1)
local experience = getPlayerStorageValue(cid, config.experience)
if experience >= (8+(getPlayerStorageValue(cid, config.storage)^2))/config.k then
doPlayerSetStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage)+1)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Parabéns, você subiu para o level "..getPlayerStorageValue(cid, config.storage) .." de mineração!")
doPlayerSendTextMessage(cid, 27, "Parabéns, você subiu para o level "..getPlayerStorageValue(cid, config.storage) .." de mineração!")

if getPlayerStorageValue(cid, config.storage) == 50 then
doPlayerSendTextMessage(cid, 20, "For reaching level "..getPlayerStorageValue(cid, config.storage) .." you have been awarded with Mining Helmet.")
doPlayerAddItem(cid, 7497, 1, true)

end
end
if config.chance >= math.random(1,100) then
if #drops >= 1 then
local item = drops[math.random(1,#drops)]
doPlayerSendTextMessage(cid, 27, "You have found a "..getItemNameById(item)..".")
doPlayerAddItem(cid, item, 1, true)
setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)

end
doSendMagicEffect(toPosition, 3)
setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)

else
doSendMagicEffect(toPosition, 2)
setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)

return true
end
elseif itemEx.itemid == item.itemid then
doPlayerSendTextMessage(cid, 27, "You're currenctly level "..getPlayerStorageValue(cid, config.storage)..".")
else
return false
end
return true
end
 
You are only setting the storage, not comparing the storage value with os.time() to see if the time is over.
If the 3 seconds have passed, os.time() will be higher than the storagevalue, in those 3 seconds the storagevalue will be higher.
EDIT: i found the part of script that add the storage (19333).. it is:

Code:
doPlayerSetStorageValue(cid, config.storage, getPlayerStorageValue(cid, config.storage)+1)

Have any difference btween doPlayerSetStorageValue and setPlayerStorageValue ?
No, it's just a name difference. Storage functions aren't called the same in every server, these function names are from different servers.
The reason they both work is because they are set to the function name for your server version in compat.lua (This way scripts from other servers also work on that server).
 
You are only setting the storage, not comparing the storage value with os.time() to see if the time is over.
If the 3 seconds have passed, os.time() will be higher than the storagevalue, in those 3 seconds the storagevalue will be higher.

No, it's just a name difference. Storage functions aren't called the same in every server, these function names are from different servers.
The reason they both work is because they are set to the function name for your server version in compat.lua (This way scripts from other servers also work on that server).

setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)

I am setting player storage with -> os.time + 3 second exhausted. So if my os.time are, for example, 10:47:00, if i add 3 seconds to it the player will have 3 seconds of exhauusted (exhausted until 10:47:03). I Still dont understand why the script are not working, since it works on all my others scripts...
 
Here you can see how it works (using storage with os.time() as exhaustion): https://otland.net/threads/timed-storage-value.232547/page-2#post-2242286

I read what you teach on the link u sent me.

Are you suggesting me to make a checker?

IF yes, how can i do that in my script?

As i said, this exhausted function WORKS on others scriptS without the need of using checkers.

This part works on my other script:

Code:
local gab = {
exhausted = 2.7, -- Time you are exhausted. by second
storage = 91355 -- Storage used for "exhaust."
}

setPlayerStorageValue(cid, gab.storage, os.time() + gab.exhausted)

I get exhausted with this code on my OTHERS SCRIPTS without making checkers.

Maybe OTHER part of the code are messing with it? Really need help.
 
Reading better the link u sent me, i think i really need a checker of storage.. I will see what can i do.
YE, @Limos are ALWAYS RIGHT!

Code:
if (getPlayerStorageValue(cid, gab.storage) > os.time())then
return doPlayerSendCancel(cid,"You must wait more " .. getPlayerStorageValue(cid, gab.storage) - os.time() .. ' seconds.' .. ((getPlayerStorageValue(cid, gab.storage) - os.time()) == 1 and "" or "s") .. ".")
end

This checker maded all work! THANKS! SOLVED!
 
Back
Top