• 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!

Action [LEVER] Donate shop ingame *HOT* V.2.0

Cornex

Web Developer
Staff member
Global Moderator
Joined
Jun 15, 2008
Messages
3,444
Solutions
5
Reaction score
1,166
Location
Sweden
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:

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:
Updated with functions in actions lib in stead of in the script.
 
[1938] = {100,"arcane staff",2453},
the 100, is it how many points it costs if it set to false and given points in local right?
 
Last edited:
You should add so it checks if he have enough space, because it drops on the ground :)
 
You should add so it checks if he have enough space, because it drops on the ground :)

Oo, never think about that. Will update it later, if someone make the code feel free to post it here :)
 
how can a same lever give you two different items?
and also for example a lever which gives 100 iron ores
 
Back
Top