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

Shop System

socio

New Member
Joined
Dec 29, 2011
Messages
76
Reaction score
1
Can anyone make a script that you have some chests and when you click if you have x gold coins you get a item?

Exemple:
I have a chest with a mana rune and when i click i buy for 50gp the rune!
 
Lua:
local SHOP = {
	[ACTION_ID] = {
		reward = ITEM_ID,
		cost = 100,
		count = 1,
	}
}
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local t = SHOP[item.actionid]
	if t then
		if(doPlayerRemoveMoney(cid, t.cost)) then
			local id = doCreateItemEx(t.reward, t.count or 1)
			if(doPlayerAddItemEx(cid, id) ~= RETURNVALUE_NOERROR) then
				return doPlayerSendCancel(cid, "You cannot carry this item."), false
			end
 
			doSendMagicEffect(getThingPosition(cid), CONST_ME_MAGIC_BLUE)
			doPlayerSendTextMessage(cid, MESSAGE_EVENT_ADVANCE, "You have purchased " .. getItemName(t.reward) .. ".")
		else
			doPlayerSendCancel(cid, "You do not have enough money.")
		end
	end
 
	return true
end
 
Last edited:
Lua:
local item = 2157
local price = 10
local count = 10
local exh = 10
local exhstorage = 35252

function onSay(cid, words, param, channel)
if (exhaustion.get (cid, exhstorage)) then
	doPlayerSendCancel (cid, "You are exhausted!")
return true
else
	exhaustion.set(cid, exhstorage, exh)
end
        local query = db.getResult("SELECT `premium_points` FROM `accounts` WHERE `id` = " .. getPlayerAccountId(cid) .. ";")
        local pkt = query:getDataInt("premium_points")
        if pkt >= price then
            local update = db.executeQuery("UPDATE `accounts` SET `premium_points`= "..(pkt - price).." WHERE `id`= " .. getPlayerAccountId(cid) .. "; ")     
		doPlayerSendTextMessage(cid, 22, "You have bought item for 10 premium points!")
		doPlayerAddItem(cid,item, count)
        else
            doPlayerSendCancel(cid, "You need 10 premium points to buy this item!")
        end
    return true
 
end
 
Back
Top