athenso
Average Coder
- Joined
- May 31, 2011
- Messages
- 155
- Solutions
- 3
- Reaction score
- 23
Resolved Script:
with OTX 3.7
Code:
function getPremiumPoints(cid)
local player = Player(cid)
local query = db.storeQuery("SELECT `premium_points` FROM `accounts` WHERE `id` =" ..player:getAccountId()..";")
if query ~= false then
local points = result.getNumber(query, 'premium_points')
print("Has points:" ..points)
result.free(query)
return points
else
print("Internal database load error.")
return 0
end
end
local function addPlayerPremiumPoints(cid, count)
db.query('UPDATE accounts SET premium_points = premium_points+'.. count ..' WHERE id = ' .. getAccountNumberByPlayerName(getCreatureName(cid)))
print("Points have been set. Now has: " ..getPremiumPoints(cid))
end
function onSay(cid, words, param, channel)
local player = Player(cid)
local cost = 10
if (getPremiumPoints(cid) >= cost) then
player:addItem(10135, 1)
addPlayerPremiumPoints(cid, -cost)
player:sendTextMessage(MESSAGE_INFO_DESCR, "You have " ..getPremiumPoints(cid).." remaining")
else
player:sendTextMessage(MESSAGE_INFO_DESCR, "You only have " .. getPremiumPoints(cid) .. " out of " ..cost.. " required points.")
end
end
with OTX 3.7
Last edited: