• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

Chest with Premium Points

Vrotz

Member
Joined
Apr 7, 2011
Messages
1,071
Reaction score
7
Location
Brazil
Hi,

I tried searching the internet but do not know if researched correctly and unfortunately not found.

So, today I need a chest or trunk that gives the player an item in exchange for premium points. But if he buys again the points he can click in the chest and get the same item again. Equal de shop system.


I have in mind i've seen this system in Otland but I couldn't find it.
I'm using the TFS 0.3.7 R2 by MartyX.

Im using that lib (048-ppoints.lua):
function getAccountPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return false
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end

function doAccountAddPoints(cid, count)
return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) + count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end

function doAccountRemovePoints(cid, count)
return db.executeQuery("UPDATE `accounts` SET `premium_points` = '".. getAccountPoints(cid) - count .."' WHERE `name` ='"..getPlayerAccount(cid).."'")
end

Thanks brah's.
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isPlayer(cid) == TRUE then
db.executeQuery('UPDATE accounts SET premium_points=premium_points-10 WHERE id=' .. getPlayerAccountId(cid))
doPlayerAddItem(cid,ITEM,1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"MSG")
end
return true
end

but still needs an edit i think because it doesnt check for points
i dont know what will happen if the player has less than the required premiumpoint
 
Last edited:
libs -

function getAccountPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return false
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end

and the code

function onUse(cid, item, fromPosition, itemEx, toPosition)
if isPlayer(cid) == TRUE and getAccountPoints(cid) >= 10 then
db.executeQuery('UPDATE accounts SET premium_points=premium_points-10 WHERE id=' .. getPlayerAccountId(cid))
doPlayerAddItem(cid,ITEM,1)
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE,"MSG")
end
return true
end

i think this is how you do it
 
Back
Top