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

Pull a lever to buy an item

gilbert123

~Caspin~
Joined
Mar 11, 2011
Messages
98
Reaction score
1
Hey- first off all before people yell at me for "Not Searching" I have... I don't know if i typed to wrong thing or what but I can NOT find this anywhere!
If anybody has a script where you can pull a lever and buy (for example) a spoon for 50 gold.
IF you wanna give me it, It would be greatly appreciated, thanks!
 
Download an 8.42/8.60 distro, open it, see if it has one of those lever scripts and use that script. There should be a few of distributions that have that script.
 
Maybe this if im correct?


function onUse(cid, item, frompos, item2, topos)
local cost = 2000
local charges = 50
if doPlayerRemoveMoney(cid, cost) == TRUE then
doPlayerAddItem(cid, 2268, charges)
doPlayerSendTextMessage(cid,22,"You have bought 50x Sudden Death runes.")
else
doPlayerSendTextMessage(cid,22,"You don/'t have 2k gold.")
end
end
 
Just made one :p

Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
   
	if doPlayerRemoveMoney(cid, 50) then
        	doPlayerAddItem(cid, 2565, 1)
        	doPlayerSendTextMessage(cid,25,"You bought a spoon for 50 gold")
	else
        	doPlayerSendCancel(cid, "You do not have enough money!")
	end
	return true
end
 
Last edited:
Lua:
function onUse(cid, item, frompos, item2, topos)
	local config = {
		item_id = 2565, -- here past item id which you are selling
		count_of_item = 1, -- here past count of item id which you are selling
		how_much_cost = 50 -- here past price, now it means 50 gold coins.
	}

	if doPlayerRemoveMoney(cid, config.how_much_cost) == false then
		doPlayerSendCancel(cid, "Sorry, you don't have enough money.")
		return true
	end
	if doPlayerRemoveMoney(cid, config.how_much_cost) then
		doPlayerAddItem(cid, config.item_id, config.count_of_item)
		doPlayerSendTextMessage(cid, 25, "You bought " .. config.count_of_item .. "x of " .. getItemNameById(config.item_id) .. " for " .. config.how_much_cost .. " gold coins.")
		return true
	end
	return true
end
 
Thanks! I will try both of yours and see which works better.
---> LIMOS thanks for making it specifically for the spoon :p I already repped you though so I can't again... but thank you :D
@ GarQet repped.
 
how can we change this to 1.3 and change the currency insted of gold or money a special token like a ot custom coin
Lua:
local config = {
    itemRequired = 1111,
    amountRequired = 1,
    
    itemGiven = 2222,
    amountGiven = 1,
    
    leverLeft = 1945,
    leverRight = 1946,
    leverActionId = 45001
}


local actions_leverShop = Action()

function actions_leverShop.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if player:getItemCount(config.itemRequired) < config.amountRequired then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You require " .. config.amountRequired .. " " .. ItemType(config.itemRequired):getName() .. " to buy this item.")
        return true
    end
    
    player:removeItem(config.itemRequired, config.amountRequired)
    player:addItem(config.itemGiven, config.amountGiven, true)
    
    item:transform(item:getId() == config.leverLeft and config.leverRight or config.leverLeft)
    return true
end

actions_leverShop:aid(config.leverActionId)
actions_leverShop:register()
 
Back
Top