What's new

Party Cake

Status
Not open for further replies.

Edwand

Advanced User
Joined
Jul 16, 2010
Messages
260
Reaction score
28
Age
27
Witam, ot?? przedstawiam wam prosty skrypt na tworzenie Party Cake. Opiera si? on na bazie tworzenia chleba i ma prosty spos?b dzia?ania.
  • Tworzenie ciasta za pomoc? fiolki z mlekiem oraz korytkiem.
  • Po stworzeniu ciasta "bez dekoracji typu ?wieczka" wyskakuje You Make Cake!
Tak wi?c ka?dy widzi ?e to prosty skrypt.
Zaczynajmy!

Tworzymy plik od nazwie cake2.lua i wklejamy w niego to:
PHP:
function onUse(cid, item, frompos, item2, topos)
 
if item2.itemid == 1381 then
if item.type <= 1 then
doTransformItem(item.uid,2692)
else
doPlayerSendCancel(cid,"Only one by one.")
end
else 
return 0
end
return 1
end

Nast?pnie tworzymy plik o nazwie cake3.lua i wklejamy to:
PHP:
function onUse(cid, item, frompos, item2, topos)
if item2.type == 6 then
if item.type <= 6 then
if item2.itemid == 1775 or 
(item2.itemid >= 2005 and item2.itemid <= 2009) then
doTransformItem(item.uid,6277)
doChangeTypeItem(item2.uid,0)
else
return 0
end
else
doPlayerSendCancel(cid,"Only one by one.")
end
else 
return 0
end
return 1
end

I na ko?cu tworzymy plik o nazwie cake4.lua i wklejamy to:
PHP:
function onUse(cid, item, frompos, item2, topos)
if item2.itemid == 1786 or 
item2.itemid == 1788 or 
item2.itemid == 1790 or 
item2.itemid == 1792 then
doRemoveItem(item.uid,1)
doCreateItem(6278,1,topos)
doPlayerSendTextMessage(cid,22,"You Make Cake!")
else 
return 0
end
return 1
end

Dam wam tak?e skrypt kt?ry s?u?y do udekorowania ciasta za pomoc? no?a i jab?ka. Zosta? on napisany przez Oskara.

Tworzymy plik o nazwie knife.lua i wklejamy to:
PHP:
local config = { 
knife = 2566, 
cake = 6278, 
apple = 2674 
} 
function onUse(cid, item, fromPosition, itemEx, toPosition) 
if item.itemid == config.knife and itemEx.itemid == config.cake then 
if doPlayerRemoveItem(cid, config.apple, 1) then 
doTransformItem(itemEx.uid, itemEx.itemid + 2) 
end 
end 
return true 
end

Na koniec w actions.xml dodajemy te linijki:
PHP:
-- Make Cake
<action itemid="2694" script="cake2.lua" />
<action itemid="2692" script="cake3.lua" />
<action itemid="6277" script="cake4.lua" />
<action itemid="2566" script="knife.lua" />

Dlaczego doda?em skrypt? bynajmniej dlatego i? nie zauwa?y?em istnienia takiego w silnikach typu XML i pod wersje 8.00. Przynajmniej nie by?o go w moim silniku.
Skrypt testowany na silniku ArBee OT 8.00
Pozdrawiam!

#Edit
Chcia?bym wspomnie? ?e jestem zielony w LUA i zrobi?em ten skrypt na zasadzie pr?b i b??d?w. U mnie skrypt dzia?a i nie wywala mi b??d?w.

#Down
Aha.
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Party Cake

PHP:
local config = { 
				knife = 2566, 
				cake = 6278, 
				apple = 2674,
				flour = 2692,
				oven = {1786,1788,1790,1792},
				liquidContainers = {1775, 2005, 2006, 2007, 2008, 2009, 2011, 2012, 2013, 2014, 2015, 2023, 2031, 2032, 2033}
				}

function onUse(cid, item, fromPosition, itemEx, toPosition)
	if item.itemid == config.flour and isInArray(config.liquidContainers, itemEx.itemid) then
		if itemEx.type == 1 then
			doPlayerAddItem(cid, 2693, 1)
		elseif itemEx.type == 6 then
			doPlayerAddItem(cid, 6277, 1)
		end
		doChangeTypeItem(item.uid, item.type - 1)
		doChangeTypeItem(itemEx.uid, TYPE_EMPTY)
	elseif item.itemid == 2694 and itemEx.itemid == 1381 then
		doChangeTypeItem(item.uid, item.type - 1)
		doPlayerAddItem(cid, config.flour, 1)
	elseif isInArray({6277,2693}, item.itemid) and isInArray(config.oven, itemEx.itemid) then
		if item.itemid == 6277 then
			doCreateItem(6278, getThingPos(itemEx.uid))
		elseif item.itemid == 2693 then
			doCreateItem(2689, getThingPos(itemEx.uid))
		end
		doSendMagicEffect(getThingPos(itemEx.uid), CONST_ME_HITBYFIRE)
	elseif item.itemid == config.knife and itemEx.itemid == config.cake then
		if doPlayerRemoveItem(cid, config.apple, 1) then 
			doTransformItem(itemEx.uid, itemEx.itemid + 2) 
		end
	end
return true
end
PHP:
<action itemid="6277;2566" event="script" value="other/createbread.lua"/>
<action fromid="2692" toid="2694" event="script" value="other/createbread.lua"/>
 
Status
Not open for further replies.
Top