Hello, i was working with an lever system that allows you to buy donates ingame with lever. Look my thread here
Read this old thread for information about this script and how to config it.
It is the same system, but now you can choose "true" or "false" if you want it to cost premium points or an item.
V.2.0 Update:
Here is the code:
Open actions/lib/actions.lib and put this at bottom
Read this old thread for information about this script and how to config it.
It is the same system, but now you can choose "true" or "false" if you want it to cost premium points or an item.
V.2.0 Update:
Code:
* Added function to buy with items, read the config in script.
Here is the code:
Lua:
local t = {
[1938] = {100,"arcane staff",2453},
[1939] = {100,"magic plate armor",2472},
}
local config = {
cost = 2160, --- Id of the item cost if you use "true"
useitem = false, --- If it on false, then it cost premium points, if it on true then it use the "item cost"
amount = 10 --- How many it will cost, in this case 10cc
}
function onUse(cid,item,fromPosition,itemEx,toPosition)
local v = t[item.uid]
local points = 0
local qry = db.getResult(string.format("SELECT premium_points FROM accounts WHERE id = %d", getPlayerAccountId(cid)))
if qry:getID() ~= -1 then
points = qry:getDataInt("premium_points")
qry:free()
end
if config.useitem == true then
if doPlayerRemoveItem(cid,config.cost,config.amount) then
doPlayerAddItem(cid,v[3])
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have buy a " .. v[2] .. " for "..config.amount.." "..getItemNameById(config.cost).."!")
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need at least "..config.amount.." "..getItemNameById(config.cost).." to buy "..getItemNameById(v[3]).."!")
end
else
if points >= v[1] then
doPlayerAddItem(cid,v[3])
db.executeQuery('UPDATE accounts SET premium_points=premium_points-'..v[1]..' WHERE id=' .. getPlayerAccountId(cid))
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You have buy a " .. v[2] .. " for "..v[1].." points! Your current balance is "..getPremiumPoints(cid).." points!")
else
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need at least "..v[1].." points to buy a "..v[2].."! Your current balance is "..getPremiumPoints(cid).." points! ")
end
end
if getPlayerFreeCap(cid) < (getItemWeightById(v[3])) then
doPlayerSendTextMessage(cid,MESSAGE_INFO_DESCR, "You need " .. getItemWeightById(v[3]) .. ".00 oz in order to get the item")
end
return true
end
Open actions/lib/actions.lib and put this at bottom
Lua:
function getPremiumPoints(cid)
local res = db.getResult('select `premium_points` from accounts where name = \''..getPlayerAccount(cid)..'\'')
if(res:getID() == -1) then
return 0
end
local ret = res:getDataInt("premium_points")
res:free()
return tonumber(ret)
end
Last edited: