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

Click to buy?

Majeski20

New Member
Joined
Apr 21, 2008
Messages
602
Reaction score
4
Location
Sweden
Hello! :w00t: I'm searching for a script that you can just right-click on a item to buy it. Not with lever. Just click on it :).
I would be very happy if somone helped me!

Thanks in advance. :)
 
Use the lever script, put the actionid on the item, remove funcions "doTransformItem(blablablba)" from script and you are done
 
Use the lever script, put the actionid on the item, remove funcions "doTransformItem(blablablba)" from script and you are done

Im not sure what to delete, here is my lever script.

Code:
--[[
	Potion Script v1.0
	by Shawak
]]--
 
local config = {
	[8502] = {potion = 7620, cost = 50},
 
	[8503] = {potion = 7589, cost = 80},
	[8504] = {potion = 7590, cost = 100},
	[8505] = {potion = 8472, cost = 200},
	[8506] = {potion = 8473, cost = 500},
	[8507] = {potion = 7591, cost = 100},
	[8508] = {potion = 7588, cost = 80},
	[8509] = {potion = 7618, cost = 50},
} -- config end --
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local potion = config[item.uid]
	if isInArray({1945, 1946}, item.itemid) ~= TRUE then
		return TRUE
	end
	if doPlayerBuyItem(cid,potion.potion, 1, potion.cost, 1) == TRUE then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought 100 "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_RED)
				
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for 1 "..getItemNameById(potion.potion)..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
	return TRUE
end
 
LUA:
--[[
	Potion Script v1.0
	by Shawak
]]--
 
local config = {
	[8502] = {potion = 7620, cost = 50},
 
	[8503] = {potion = 7589, cost = 80},
	[8504] = {potion = 7590, cost = 100},
	[8505] = {potion = 8472, cost = 200},
	[8506] = {potion = 8473, cost = 500},
	[8507] = {potion = 7591, cost = 100},
	[8508] = {potion = 7588, cost = 80},
	[8509] = {potion = 7618, cost = 50},
} -- config end --
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local potion = config[item.uid]

	if doPlayerBuyItem(cid,potion.potion, 1, potion.cost, 1) == TRUE then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought 100 "..getItemNameById(potion.potion).." for "..potion.cost.." gold coins.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_RED)
				
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..potion.cost.." gold coins for 1 "..getItemNameById(potion.potion)..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
	return TRUE
end
 
Last edited:
didnt work :o

no wonder when the call ids and costs wasn't correct...
should be config.potion instead of potion.potion...

LUA:
--[[
	Potion Script v1.0
	by Shawak, corrected by RealSoft
]]--
 
local config = {
	[8502] = {potion = 7620, cost = 50},
 
	[8503] = {potion = 7589, cost = 80},
	[8504] = {potion = 7590, cost = 100},
	[8505] = {potion = 8472, cost = 200},
	[8506] = {potion = 8473, cost = 500},
	[8507] = {potion = 7591, cost = 100},
	[8508] = {potion = 7588, cost = 80},
	[8509] = {potion = 7618, cost = 50},
} -- config end --
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
	local potion = config[item.uid]
 
	if doPlayerBuyItem(cid,potion.potion, 1, potion.cost, 1) == TRUE then
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You bought 100 "..getItemNameById(config.potion).." for "..config.cost.." gold coins.")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_FIREWORK_RED)
 
	else
		doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "You need "..config.cost.." gold coins for 1 "..getItemNameById(config.potion)..".")
doSendMagicEffect(getPlayerPosition(cid), CONST_ME_POFF)
	end
	return TRUE
end
 
LUA:
local t = {
	[ITEM] = {pot, price, count, effect}
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	local i = t[item.itemid]
	if i then
		if getPlayerMoney(cid) >= i[2] then
			local id = doCreateItemEx(i, i[1])
			if doPlayerAddItemEx(cid, id, true) ~= RETURNVALUE_NOERROR then
				return false
			end
			
			doPlayerRemoveMoney(cid, i[2])
			doSendMagicEffect(getThingPos(cid), i[4])
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have purchased " .. i[3] .. "x " .. getItemInfo(i[1]).name .. ".")
		else
			return doPlayerSendCancel(cid, "Sorry, you do not have enough money.")
		end
	end
	
	return true
end

Edit: I forgot to mention that I didn't test this.
 
Last edited:
Back
Top