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

StorageValue For 10 sec

Mooosie

mistofdeath.com
Premium User
Joined
Aug 2, 2008
Messages
742
Solutions
2
Reaction score
52
Location
Sweden
How can i make that a storagevalue is availible for 10 seconds and then setstoragevalue to -1?
 
Last edited:
LUA:
--your code

local function storage(cid)
setplayerstoragevalue(cid, 1000, -1) -- or 0
return true
end

addevent(storage, 10000) -- 1000 = 1 sec
return true
end -- writed in browser.
 
No it wont cuz function wont get an argument, that will work.
LUA:
addEvent(setPlayerStorageValue, 1000, cid, 1000, -1) -- calback to function, delay (in ms), callback fun arguments...
 
Instead of adding events, just use the exhaustion lib of the TFS.
LUA:
exhaustion.set(cid, storage, time)
exhaustion.check(cid, storage)

time is in seconds
LUA:
exhaustion.set(cid, 12345, 60)

if the exhaustion has not ended...
LUA:
if exhaustion.check(cid, 12345) then
...etc

if the exhaustion has ended...
LUA:
if not exhaustion.check(cid, 12345) then
...etc
 
Code:
setPlayerStorageValue(cid, 1031, 1) 
addEvent(storage,60000*3,cid) -- 3 min

function storage(cid)
setPlayerStorageValue(cid, 1031, 0) 
end
 
Last edited:
1. Will it work then?
LUA:
setPlayerStorageValue(cid, 1031, 1) 
addEvent(storage,60000*3,cid) -- 3 min

function storage(cid)
setPlayerStorageValue(cid, 1031, 0) 
end
-------------------------------------
2. What about this?
LUA:
addEvent(db.executeQuery, 60000*3, "UPDATE `player_storage` SET `key` = 1031, `value` = -1 WHERE `player_id` = " .. guid .. " LIMIT 1;")
 
Last edited:
LUA:
------Functions------------
local storage = 1033333
local function storage(cid)
setPlayerStorageValue(cid, storage, -1) -- or 0
return true
end
----------Script-----------------
function onUse(cid, item, fromPosition, itemEx, toPosition)
local pos = getCreaturePostion(cid)
	if getPlayerStorageValue(cid, storage) == -1 then
		doCreatureAddHealth(cid, math.random(10,30))
                setPlayerStorageValue(cid, storage, 1)
                doSendMagicEffect(pos, 12)
		addEvent(storage, 10000, cid)
	else
		doPlayerSendCancel(cid, "Wait 10 sec...")
          end
	return true
end

^example like that?
I know how to set exhaustion. that i was wondering was, i am using stacks on weapons so after 10 sec it sets the players stack to 0 XD

AND WHY DOES'NT stopEvent(storage) WORK?!?!
 
Last edited:
LUA:
------Functions------------
local storage = 103333
 
function deleteStorage(cid)
    return isPlayer(cid) and doPlayerSetStorageValue(cid, storage, -1)
end
 
----------Script-----------------
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if getPlayerStorageValue(cid, storage) == -1 then
        doCreatureAddHealth(cid, math.random(10,30), 65535, 256, true)
        doPlayerSetStorageValue(cid, storage, 1)
        doSendMagicEffect(fromPosition, 12)
        addEvent(deleteStorage, 10000, cid)
    else
        doPlayerSendCancel(cid, 'Wait 10 sec...')
    end
    return 1
end
 
Last edited:
Back
Top