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

Double XP Item 2 hours

bradette19

Member
Joined
May 25, 2011
Messages
97
Reaction score
6
Location
Canada
Hello, I want to add something to my script but I don't really know how.

A broadcast message to the player to told him is Double xp have expired.

Here my script

Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        player:say('You already have double exp!', TALKTYPE_MONSTER_SAY)
        return true
    end
    player:setStorageValue(1234, os.time() + 7200)
    Item(item.uid):remove(1)
    player:say('Your 2 hours of double XP has started!', TALKTYPE_MONSTER_SAY)
    return true
end
 
well, you'd have to add it to the script that adds the exp. Likely an onKill script. Alternatively, you could make an onThink creaturescript and if their time is up, immediately send them the message.
something like
Code:
function onThink(creature, interval)
local player = Player(creature)
if not player then
return true
end
if player:getStorageValue(1234) < os.time() then
player:sendTextMessage(MESSAGE_STATUS_WARNING, "Your double XP has ended!")
player:unregisterEvent("YOUR_EVENT_NAME")
end
return true
end
 
it'll be in a separate script.
in creaturescripts.xml
Code:
<event type="think" name="dblxp" script="dblxp.lua" />
in creaturescripts/scripts create dblxp.lua and put
Code:
function onThink(creature, interval)
    local player = Player(creature)
    if not player then
        return true
    end
    if player:getStorageValue(1234) < os.time() then
        player:sendTextMessage(MESSAGE_STATUS_WARNING, "Your double XP has ended!")
        player:unregisterEvent("dblxp")
    end
    return true
end
and in your script
Code:
function onUse(cid, item, fromPosition, itemEx, toPosition)
    local player = Player(cid)
    if player:getStorageValue(1234) >= os.time() then
        player:say('You already have double exp!', TALKTYPE_MONSTER_SAY)
        return true
    end
    player:setStorageValue(1234, os.time() + 7200)
    Item(item.uid):remove(1)
    player:say('Your 2 hours of double XP has started!', TALKTYPE_MONSTER_SAY)
    player:registerEvent("dblxp")
    return true
end
 
Back
Top