• 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 Daily quest chest help

MadMOOK

Hoo
Joined
Apr 20, 2011
Messages
802
Reaction score
43
Ok, my teleport opens and they run into new area... at the end is a chest that they use for reward.
If they just so happen to run back in before teleport closes they can keep using the chest... how do i fix that??
The first time they use chest it says they used it 0 times. the second it says 3000 times. lol I dont know whats wrong with this
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
pos = {x=999, y=999, z=7}    -------position teleported to by chest
local time = 1000
local time = getPlayerStorageValue(cid, 13543)
local daily = getPlayerStorageValue(cid, 13542)
    if (daily == -1) then
            daily = 0
    end
    if getPlayerStorageValue(cid, 13542) - os.time() <= 0 then
        doPlayerAddItem(cid, 8305, 1)
        time = 3000
        setPlayerStorageValue(cid, 13542, time)
        doTeleportThing(cid,pos)
        setPlayerStorageValue(cid, 13543, daily+1)
        exhaustion.set(cid, storage, time)
        local time = getPlayerStorageValue(cid, 13543)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You done your " .. daily .. " Hulk daily. You got 1 perfect upgrade stone.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must wait 5 hours to get your daily quest. Next avaiable will be at: " .. os.date("%H:%M:%S", getPlayerStorageValue(cid, 13542)) .. ".")
    end
    return true
end

Fixed version
Code:
--credits to Leon Zawo
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = {x=999, y=999, z=7}
    local daily = getPlayerStorageValue(cid, 13543)
    if (daily == -1) then
            daily = 0
    end
    if getPlayerStorageValue(cid, 13542) - os.time() <= 0 then
        doPlayerAddItem(cid, 8305, 1)
        setPlayerStorageValue(cid, 13542, os.time() + 1 * 24 * 60 * 60 * 1000)
        doTeleportThing(cid,pos)
        setPlayerStorageValue(cid, 13543, daily+1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You done your " .. getPlayerStorageValue(cid, 13543) .. " Hulk daily. You got 1 perfect upgrade stone.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must wait 5 hours to get your daily quest. Next available will be at: " .. os.date("%H:%M:%S", getPlayerStorageValue(cid, 13542)) .. ".")
    end
return true
end
@Leon Zawo
 
Last edited:
O, remake of my old script.. Where are credits?! XD

Change:
local time = getPlayerStorageValue(cid, 13543)

To:
local daily = getPlayerStorageValue(cid, 13543)

This should fix the number of times you have used this chest.

Problem 2:
WTF, what did you do with timer..? xD

NEVERMIND., take whole script..:
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local pos = {x=999, y=999, z=7}
    local daily = getPlayerStorageValue(cid, 13543)
    if (daily == -1) then
            daily = 0
    end
    if getPlayerStorageValue(cid, 13542) - os.time() <= 0 then
        doPlayerAddItem(cid, 8305, 1)
        setPlayerStorageValue(cid, 13542, os.time() + 1 * 24 * 60 * 60 * 1000)
        doTeleportThing(cid,pos)
        setPlayerStorageValue(cid, 13543, daily+1)
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You done your " .. getPlayerStorageValue(cid, 13543) .. " Hulk daily. You got 1 perfect upgrade stone.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must wait 5 hours to get your daily quest. Next avaiable will be at: " .. os.date("%H:%M:%S", getPlayerStorageValue(cid, 13542)) .. ".")
    end
return true
end

Remember to reset storages.
 

Similar threads

Back
Top