• 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 talkaction task points

Remember to specify TFS version!
This is for TFS 1.4+

data/scripts
Lua:
local config = {
    words = "!test",
    storage = 5151,
    itemId = 19654,
}

local talk = TalkAction(config.words)
function talk.onSay(player, words, param)
    local storage = player:getStorageValue(config.storage)
    local points = tonumber(param)

    if not points then
        player:sendCancelMessage("Usage: " .. config.words .. " <amount>")
        return false
    end

    if storage < points then
        player:sendCancelMessage("You don't have enough points! (You currently have " .. math.max(storage, 0) .. " points)")
        return false
    end

    if storage >= points then
        player:addItem(config.itemId, param)
        player:setStorageValue(config.storage, storage - points)
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You have exchanged " .. points .. " Task Point(s) for " .. points .. " Task Coin(s).")
    end
    return false
end

talk:separator(" ")
talk:register()
 
Last edited:
Back
Top