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

OTHIRE (script actions) Double experience 2x, when clicking on the scroll

iuri cobain

New Member
Joined
Jan 1, 2009
Messages
4
Reaction score
0
Hello everything is fine? I hope so... I wanted to make a request, for a script, that when the player clicks on a scroll, it automatically gives 2x experience for 1 hour, for all players. I use the (SERVER OTHIRE) one, I like this engine... If anyone wants to help , I would be very grateful... Success to all of you!!!
 
LUA:
local config = {
    rate = 2.0,
    time = 1, -- Hours of Exp Time
    storage = 20011,
    exhauststorage = 9583,
    exhausttime = 3600 -- time in seconds
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if exhaustion.check(cid, config.exhauststorage) then
        local time = exhaustion.get(cid, config.exhauststorage)
        local hours, minutes, seconds = math.floor(time / 3600), math.floor((time - (math.floor(time / 3600) * 3600)) / 60), time - (math.floor(time / 60) * 60)

        local text
        if time >= 7200 then
            text = "" .. hours .. " hours, " .. minutes .. " minutes and " .. seconds .. " seconds"
        elseif time >= 3600 then
            text = "" .. hours .. " hour, " .. minutes .. " minutes and " .. seconds .. " seconds"
        elseif time >= 60 then
            text = "" .. minutes .. " minutes and " .. seconds .. " seconds"
        else
            text = "" .. seconds .. " seconds"
        end

        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You need to wait " .. text .. " before you can use this again.")
        return true
    end

    local lastUsageTime = getPlayerStorageValue(cid, config.storage) or 0

    if lastUsageTime < os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is double now . It will last for " .. config.time .. " hour.")

        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
        doRemoveItem(item.uid, 1)
        exhaustion.set(cid, config.exhauststorage, config.exhausttime)
    else
        local remainingTime = lastUsageTime - os.time()
        local remainingHours = math.floor(remainingTime / 3600)
        local remainingMinutes = math.floor((remainingTime - (remainingHours * 3600)) / 60)
        local remainingSeconds = remainingTime % 60

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have double experience time left: " .. remainingHours .. " hours, " .. remainingMinutes .. " minutes, and " .. remainingSeconds .. " seconds.")
    end

    return true
end
Post automatically merged:

data/events/player.lua add

Code:
if self:getStorageValue(20011) >= os.time() then
   exp = exp * 2.0
end
Post automatically merged:

<action itemid="id your scroll" script="namescript.lua" />
 
LUA:
local config = {
    rate = 2.0,
    time = 1, -- Hours of Exp Time
    storage = 20011,
    exhauststorage = 9583,
    exhausttime = 3600 -- time in seconds
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    if exhaustion.check(cid, config.exhauststorage) then
        local time = exhaustion.get(cid, config.exhauststorage)
        local hours, minutes, seconds = math.floor(time / 3600), math.floor((time - (math.floor(time / 3600) * 3600)) / 60), time - (math.floor(time / 60) * 60)

        local text
        if time >= 7200 then
            text = "" .. hours .. " hours, " .. minutes .. " minutes and " .. seconds .. " seconds"
        elseif time >= 3600 then
            text = "" .. hours .. " hour, " .. minutes .. " minutes and " .. seconds .. " seconds"
        elseif time >= 60 then
            text = "" .. minutes .. " minutes and " .. seconds .. " seconds"
        else
            text = "" .. seconds .. " seconds"
        end

        doSendMagicEffect(getThingPos(cid), CONST_ME_POFF)
        doPlayerSendCancel(cid, "You need to wait " .. text .. " before you can use this again.")
        return true
    end

    local lastUsageTime = getPlayerStorageValue(cid, config.storage) or 0

    if lastUsageTime < os.time() then
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Your extra experience rate is double now . It will last for " .. config.time .. " hour.")

        setPlayerStorageValue(cid, config.storage, os.time() + config.time * 3600)
        doRemoveItem(item.uid, 1)
        exhaustion.set(cid, config.exhauststorage, config.exhausttime)
    else
        local remainingTime = lastUsageTime - os.time()
        local remainingHours = math.floor(remainingTime / 3600)
        local remainingMinutes = math.floor((remainingTime - (remainingHours * 3600)) / 60)
        local remainingSeconds = remainingTime % 60

        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You still have double experience time left: " .. remainingHours .. " hours, " .. remainingMinutes .. " minutes, and " .. remainingSeconds .. " seconds.")
    end

    return true
end
Post automatically merged:

data/events/player.lua add

Code:
if self:getStorageValue(20011) >= os.time() then
   exp = exp * 2.0
end
Post automatically merged:

<action itemid="id your scroll" script="namescript.lua" />
Hi.... Server othire no have (data/events)
 

Attachments

Back
Top