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

[solved thx to cykotitan]

Exmortis

Member
Joined
Jun 27, 2008
Messages
189
Reaction score
5
To avoid posting hundreds of threads per day, im requesting two different scripts in this thread.
Mostly this is for Cykotitan and his expertise in lua scripting. :w00t::D

First one: When you rightclick an oven must be a oven with UID since i dont want it for all ovens, it generates you either between 1-15 fish, meat or ham. You can only do this every five minutes. (exhaust for the oven)
IDs:

Oven:
Oven North - 1790
Oven East - 1792
Oven South - 1786
Oven West - 1788

Food:
Ham: 2671
Fish: 2667
Meat: 2666

Second one: rightclicking a bookshelf gives you random papersort, which one of them is a minor experience scroll. You can only do this every fifteen minutes. (exhaust for the bookcase)
IDs:

Bookshelves:
Bookshelf East: 1722
Bookshelf South: 1720

Scrolls/books:
1949-1955

If anything is unclear, just let me know! :thumbup:
 
Last edited:
1 :
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(math.random(1, 3) == 1) then
		doSendAnimatedText(fromPosition, "Fishes!")
		doPlayerAddItem(cid, 2667 ,math.random(1,15))
	elseif(math.random(1, 3) == 2) then
        doSendAnimatedText(fromPosition, "Ham!")
		doPlayerAddItem(cid, 2671, 1)
	elseif(math.random(1, 3) == 3) then
        doSendAnimatedText(fromPosition, "Meat!")
        doPlayerAddItem(cid,2666, 1)
	end
	return true
end

Try this for exhausted:

Lua:
local exhaustion = 3247
local seconds = 60
 
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if exhaustion.check(cid, exhaustion) then
        doPlayerSendCancel(cid, 'You can\'t use this yet['..exhaustion.get(cid, exhaustion)..'].')
        doSendMagicEffect(fromPosition, CONST_ME_POFF)
        return true
    else
        exhaustion.set(cid, exhaustion, seconds)
    end
if(math.random(1, 3) == 1) then
		doSendAnimatedText(fromPosition, "Fishes!")
		doPlayerAddItem(cid, 2667 ,math.random(1,15))
	elseif(math.random(1, 3) == 2) then
        doSendAnimatedText(fromPosition, "Ham!")
		doPlayerAddItem(cid, 2671, 1)
	elseif(math.random(1, 3) == 3) then
        doSendAnimatedText(fromPosition, "Meat!")
        doPlayerAddItem(cid,2666, 1)
	end
	return true
end
end

Got exhausted idea from a post from CyberM
 
Last edited:
Yup, sorry, my mistake
Lua:
function onUse(cid, item, fromPosition, itemEx, toPosition)
	if(math.random(1, 3) == 1) then
		doSendAnimatedText(fromPosition, "Fishes!", math.random(1,15))
		doPlayerAddItem(cid, 2667 ,math.random(1,15))
	elseif(math.random(1, 3) == 2) then
        doSendAnimatedText(fromPosition, "Ham!", math.random(1,15))
		doPlayerAddItem(cid, 2671, 1)
	elseif(math.random(1, 3) == 3) then
        doSendAnimatedText(fromPosition, "Meat!", math.random(1,15))
        doPlayerAddItem(cid,2666, 1)
	end
	return true
end

You have to use the oven sometimes 1 or 2 or 3 times before it gives the food.
But it's working, just tested it in TFS 0.3.6 :) (not with exhaustion though :S)
 
Lua:
local ovenKey = 9400
local ovenUIDs = {1000, 1001}
local bookshelfKey = 9401

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if isInArray(ovenUIDs, item.uid) == TRUE then
		if os.time() - getPlayerStorageValue(cid, ovenKey) >= 300 then
			setPlayerStorageValue(cid, ovenKey, os.time())
			local t = {2666, 2667, 2671}
			local id, count = t[math.random(#t)], math.random(15)
			doPlayerAddItem(cid, id, count)
			doCreatureSay(cid, 'You have found ' .. (count == 1 and getItemDescriptions(id).article or count) .. ' ' .. getItemName(id) .. '.', TALKTYPE_ORANGE_1)
		else
			doCreatureSay(cid, 'It is empty.', TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
		end
		return TRUE
	elseif isInArray({1722, 1720}, item.itemid) == TRUE then
		if os.time() - getPlayerStorageValue(cid, bookshelfKey) >= 900 then
			setPlayerStorageValue(cid, bookshelfKey, os.time())
			local id = math.random(1949, 1955)
			doPlayerAddItem(cid, id, 1)
			doCreatureSay(cid, 'You have found ' .. getItemDescriptions(id).article .. ' ' .. getItemName(id) .. '.', TALKTYPE_ORANGE_1)
		else
			doCreatureSay(cid, 'It is empty.', TALKTYPE_ORANGE_1, false, cid, getThingPos(cid))
		end
		return TRUE
	end
end
In actions.xml, both to same script.
Register oven(s) by uniqueids, and bookshelves by their itemids.
 
Back
Top