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()