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

Help With this FAST PLEASE

Sigoles

Discord: @sigoles
Joined
Nov 20, 2015
Messages
1,209
Solutions
2
Reaction score
154
Hello, this command is for check exp:

Code:
local price_aols = 5000

function onSay(player, words, param)
    local bonusTime = math.ceil((player:getStorageValue(1234) - os.time())/60)

    if player:getStorageValue(1234) >= bonusTime and player:getMoney() >= price_aols then
        player:removeMoney(price_aols)
        player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have " .. bonusTime .. " minutes of Double Exp on your Character.")
    else
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need 5k for check exp.")
    end
  
end


But when character dont have the bonus exp this happens:
10:20 You have -24207320 minutes of Double Exp on your Character.

Someone can help with this ?
 
Last edited by a moderator:
This was solved in a post in premium support, the code was fixed by @imkingran.
Code:
local price_aols = 5000

function onSay(player, words, param)
    local bonusStor = player:getStorageValue(1234)
    local bonusTime = math.ceil((bonusStor - os.time())/60)
 
    -- check if player has bonus time. (compare to os.time() not to 0)
    if bonusStor < os.time() then
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "Your bonus time has run out.")
        return false
    end

    -- check if player has the money
    if player:getMoney() < price_aols then
        player:getPosition():sendMagicEffect(CONST_ME_POFF)
        player:sendTextMessage(MESSAGE_STATUS_CONSOLE_ORANGE, "You need 5k for check exp.")
        return false
    end
 
    player:removeMoney(price_aols)
    player:getPosition():sendMagicEffect(CONST_ME_MAGIC_RED)
    player:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have " .. bonusTime .. " minutes of Double Exp on your Character.")
    return false
end
 
You could always do something like
Code:
local bonusTime = math.ceil((player:getStorageValue(1234) - os.time())/60) >= 0 and math.ceil((player:getStorageValue(1234) - os.time())/60) or 0
 
Back
Top