• 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!
  • New resources must be posted under Resources tab. A discussion thread will be created automatically, you can't open threads manually anymore.

MoveEvent Basic Cooking System

Silver Fred

New Member
Joined
Oct 19, 2010
Messages
31
Reaction score
0
Hey there everyone, this is my first script. Please evalute it.


Explanation:
You have to throw the meat on the campfire and it will be cooked.


Code:
<movevent type="AddItem" tileitem="1" itemid="[COLOR="gray"]1423[/COLOR]" event="script" value="cooking.lua"/>

campfire = Can change id.
cooked meat = Can change id for any other.
burned meat = Can change id for any other, but you have to change both.
food text = Write whatever you want.
burn text = /\


Code:
---ID LIST---
--2227 - Cooked Meat
--2666 - Raw Meat
--2241 - Fail
--------------------
local [B]raw meat[/B] = moveitem.itemid == [COLOR="#a0522d"]2666[/COLOR] 
local [B]cooked meat[/B] = moveitem.itemid == [COLOR="#4b0082"]2227[/COLOR] 
local [B]chance[/B] = math.random(1,10)
local [B]food[/B] = (cid,[COLOR="#4b0082"]2227[/COLOR],1)
local [B]burn[/B] = (cid,[COLOR="#2e8b57"]2241[/COLOR],1)
local [B]food text[/B] = (cid,22,"[COLOR="red"]You've cooked a Meat.[/COLOR]")
local [B]burn text[/B] = (cid,22,"[COLOR="#00bfff"]You've burned it.[/COLOR]")

function onAddItem(moveitem, tileitem, pos)
	if raw meat and item.type == 1 and chance == 1 then
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem(cid,2227,1)
		doSendTextMessage food text
	elseif chance == 2	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem food
		doSendTextMessage food text
	elseif chance == 3	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem food
		doSendTextMessage food text
	elseif chance == 4	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem food
		doSendTextMessage food text
	elseif chance == 5	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem food
		doSendTextMessage food text
	elseif chance == 6	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem food
		doSendTextMessage food text
	elseif chance == 7	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem food
		doSendTextMessage food text
	elseif chance == 8	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem food
		doSendTextMessage food text
	elseif chance == 9	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_GREEN)
		doPlayerAddItem food
		doSendTextMessage food text
	elseif chance == 10	
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_RED)
		doPlayerAddItem burn
		doSendTextMessage burn text
	elseif cooked meat and item.type == 1 then
		doRemoveItem(moveitem.itemid, 1)
		doSendMagicEffect(thing, CONST_ME_MAGIC_RED)
		doPlayerAddItem burn
		doSendTextMessage burn text
	end
end
 
You tested before publish?
Lua:
local chance = math.random(1,10)
local foodtext = "You've cooked a Meat."
local burntext = "You've burned it."
function onAddItem(moveitem, tileitem, pos)
	doRemoveItem(moveitem.uid, 1)
	doSendMagicEffect(pos, CONST_ME_MAGIC_GREEN)
	doPlayerAddItem(cid, chance <= 9 and 2227 or 2241, 1)
	doSendTextMessage(cid, 22, chance <= 9 and foodtext or burntext)
	return true
end
 
Last edited:
Wow you made it so shorter and easier to undestand >_> i'd like to know how to do it...
Can you explain me the return true function? And... when i use it :3
 
How about frying many things at the same time? I can't get it to work correctly. Also it would be nice to configure possible items 'to fry'.

Och and I had to remake the script to create item on the campfire (doCreateItem), not with (doPlayerAddItem). There seems to be a problem with declarating player correctly in both scripts...
 
How about frying many things at the same time? I can't get it to work correctly. Also it would be nice to configure possible items 'to fry'.

Och and I had to remake the script to create item on the campfire (doCreateItem), not with (doPlayerAddItem). There seems to be a problem with declarating player correctly in both scripts...

I just corrected it and reduced him script.
 
KylerXX... i made one little edit in your edit...
Cause topos is the campfire, and i have to move the raw meat to the campfire. e_ê?
local chance = math.random(1,10)
local foodtext = "You have cooked a Meat."
local burntext = "You have burned it."
function onAddItem(moveitem, tileitem, pos)
if moveitem.uid == 2666 then
doRemoveItem(moveitem.uid, 1)
doSendMagicEffect(pos, chance <= 9 and CONST_ME_MAGIC_GREEN or CONST_ME_MAGIC_RED)
doPlayerAddItem(cid, chance <= 9 and 2227 or 2241, 1)
doSendTextMessage(cid, 22, chance <= 9 and foodtext or burntext)
return true
end
 
Nice basic script!! keep it up and test yourself by making harder scripts, also practice makes better!
 
Back
Top Bottom