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

lib 034-exhaust problem

wikutag

SoulBound 8.6 100% custom
Joined
Dec 27, 2012
Messages
305
Reaction score
0
Location
United states Kentucky
0.3.6 tfs

My 034-exhaust lib
Code:
exhaustion =
{
    check = function (cid, storage)
        if(getPlayerStorageValue(cid, storage) >= os.time(t)) then
            return TRUE
        end
 
        return FALSE
    end,
 
    get = function (cid, storage)
        local exhaust = getPlayerStorageValue(cid, storage)
        if(exhaust > 0) then
            local left = exhaust - os.time(t)
            if(left >= 0) then
                return left
            end
        end
 
        return FALSE
    end,
 
    set = function (cid, storage, time)
        setPlayerStorageValue(cid, storage, os.time(t) + time)
    end,
 
    make = function (cid, storage, time)
        local exhaust = exhaustion.get(cid, storage)
        if(not exhaust) then
            exhaustion.set(cid, storage, time)
            return TRUE
        end
 
        return FALSE
    end
}

error
Code:
[17/10/2014 20:40:03] [Error - TalkAction Interface]
[17/10/2014 20:40:03] buffer:onSay
[17/10/2014 20:40:03] Description:
[17/10/2014 20:40:03] data/lib/034-exhaustion.lua:4: field 'day' missing in date table
[17/10/2014 20:40:03] stack traceback:
[17/10/2014 20:40:03]     [C]: in function 'time'
[17/10/2014 20:40:03]     data/lib/034-exhaustion.lua:4: in function 'check'
[17/10/2014 20:40:03]     [string "loadBuffer"]:13: in function <[string "loadBuffer"]:8>".
 
Its a player broadcasting talkaction
Code:
--- Config ---
local levelReq = 100 -- minimum level requirement
local minChars = 3 -- minimum characters in message
local basePrice = 50 -- Base price, will be multiplied by the player's level.
local group_id = 2 -- players with this group_id or higher won't be able to use this command
local exhaustionInSeconds = 60
local a = math.floor(exhaustionInSeconds/60)
local storage = 73210
 
 
function onSay(cid, words, param)
    local letterPrice = basePrice + getPlayerLevel(cid) * 2
    local broadcastPrice = letterPrice * param:len()
    if(getPlayerLevel(cid) < levelReq) then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Sorry, you need to be atleast level " .. levelReq .. " to use this command.")
    elseif(exhaustion.check(cid, storage) == TRUE) then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you need to wait before broadcasting another message.")
    elseif(param:len() < minChars) then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you need to enter atleast " .. minChars .. " characters. Each character will cost you " .. letterPrice .. " gold coins.")
    elseif(getPlayerGroupId(cid) >= group_id) then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, staff members do not need to broadcast messages with this command.")
    elseif(doPlayerRemoveMoney(cid, broadcastPrice) == FALSE) then
        return doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you have not enough money. This message would have costed you " .. broadcastPrice .. " gold coins.")
    else
        doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, "Broadcast successfully sent. Your message contained " .. param:len() .. " characters and costed you " .. broadcastPrice .. " gold coins. You may broadcast again in " .. a .. " minute.")
        broadcastMessage(getCreatureName(cid) .. " [" .. getPlayerLevel(cid) .. "]: " .. param, MESSAGE_STATUS_WARNING)
        exhaustion.set(cid, storage, exhaustionInSeconds)
    end
end
 
Back
Top