local item = 1234 --- item id
local amount = 100 -- amount of the item
local removePoints = 50 -- amount to remove points
local str = 456 -- empty storage
local time = 60 -- exhaustion time
function onSay(cid, words, param, channel)
if exhaustion.check(cid, str) then
return doPlayerSendCancel(cid,'you are exhausted for '.. exhaustion.get(cid, str) ..' seconds')
end
if hasCondition(cid, CONDITION_INFIGHT) == TRUE then
return doPlayerSendCancel(cid, "You may not use this command while you are in combat.")
end
points = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = ".. getPlayerAccountId(cid) .." LIMIT 1;"):getDataInt("premium_points")
if points >= removePoints then
doPlayerAddItem(cid, item, amount)
db.executeQuery("UPDATE `accounts` SET `premium_points` = `premium_points` - ".. removePoints .." WHERE `id` = " .. getPlayerAccountId(cid) ..";")
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "you have bought ".. amount .." ".. getItemNameById(item) .." for ".. removePoints .." premium points")
else
doPlayerSendCancel(cid, "sorry you don't have enough premium points")
exhaustion.set(cid, str, time)
end
return true
end