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

Action Mango Tree

tetra20

DD
Joined
Jan 17, 2009
Messages
1,315
Solutions
4
Reaction score
323
Location
Egypt
i am new to scripting :D
add this in actions

Code:
function onUse(cid, item, toPosition, itemEx, fromPosition)
	local place = getPlayerPosition(cid)
	local  chance = math.random(1,3)
	local  nofood = 4
	local pos = getThingPos(item.uid)
if item.itemid == 5157 then
	if nofood <= math.random(1,7) then
	doPlayerAddItem(cid, 5097,chance)
	doSendMagicEffect(place, 14)
	doPlayerSendTextMessage(cid, 4, "you got "..chance.." mango")
	else
	if  doPlayerSendTextMessage(cid, 4, "Tree Died") then
	doRemoveItem(item.uid)
	addEvent(doCreateItem, 60 * 1000, 5157, 1, pos)
	end
	end
	end
	end
Code:
<action itemid="5157" script="test2.lua"/>

it is easy.. but might be useful
it give 1~3 mango . the tree might die.
~~ It Respawn after 60 sec
 
Last edited:
Lua:
local chance = 40 -- this states for % of harvesting mangoes
local mangoesAmmount = {1, 3} -- first number is min ammount, second number is max ammount
local treeDeathPercent = 40 -- this states for % of tree dying
	
function onUse(cid, item, toPosition, itemEx, fromPosition)
	if(math.random(100) <= chance) then
		ammount = math.random(mangoesAmmount[1], mangoesAmmount[2])
		doPlayerAddItem(cid, 5097, ammount)
		doSendMagicEffect(fromPosition, CONST_ME_MAGIC_GREEN)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You harvested " .. ammount .. " " .. (ammount > 1 and "mangoes" or "mango") .. " from the tree.")
		if(math.random(100) <= treeDeathPercent) then
			doRemoveItem(item.uid)
			addEvent(doCreateItem, 60 * 1000, 5157, toPosition)
		else
			doTransformItem(item.uid, item.itemid - 1)
		end
	else
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You didn't harvest any mangoes from this tree.")
	end
	return true
end

Made this script more sexy and actually working. :D

Btw. in your script
Lua:
if  doPlayerSendTextMessage(cid, 4, "Tree Died") then
is always true so the tree will die every time.
 
Last edited:
Ty TeckMan for the comment .. i will try it again

Sry for misunderstanding It Work or No??

- - - Updated - - -

TeckMan your Script Works Great but when i used it . it don't tell me the amount i got

Using TFS 0.3.6 V8.2
 
Dont like... Tree disappears.

- - - Updated - - -

Lua:
function onUse(cid, item, frompos, item2, topos)
if item.itemid == 5157 then
doTransformItem(item.uid,5156)
doPlayerAddItem(cid,5097,3)
doDecayItem(item.uid)
end
return 1 
end
 
Last edited:
Nice One Azz . but don't you think it should be random it would be better like RPG

- - - Updated - - -

Here a Better One Azz
Lua:
function onUse(cid, item, toPosition, itemEx, fromPosition)
	local place = getPlayerPosition(cid)
	local  chance = math.random(1,3)
	local  changeplant = 4
	local pos = getThingPos(item.uid)
if item.itemid == 5157 then
	if changeplant <= math.random(1,7) then
	doPlayerAddItem(cid, 5097,chance)
	doSendMagicEffect(place, 14)
	doPlayerSendTextMessage(cid, 4, "you got "..chance.." mango")
	else
	if  doPlayerSendTextMessage(cid, 4, "You Can't Harvest Mango Anymore Please Wait.") then
	doTransformItem(item.uid,5156)
	addEvent(doCreateItem, 60 * 1000, 5157, 1, pos)
	end
	end
	end
	end
 
Last edited:
Nice One Azz . but don't you think it should be random it would be better like RPG

- - - Updated - - -

Here a Better One Azz
Lua:
function onUse(cid, item, toPosition, itemEx, fromPosition)
	local place = getPlayerPosition(cid)
	local  chance = math.random(1,3)
	local  changeplant = 4
	local pos = getThingPos(item.uid)
if item.itemid == 5157 then
	if changeplant <= math.random(1,7) then
	doPlayerAddItem(cid, 5097,chance)
	doSendMagicEffect(place, 14)
	doPlayerSendTextMessage(cid, 4, "you got "..chance.." mango")
	else
	if  doPlayerSendTextMessage(cid, 4, "You Can't Harvest Mango Anymore Please Wait.") then
	doTransformItem(item.uid,5156)
	addEvent(doCreateItem, 60 * 1000, 5157, 1, pos)
	end
	end
	end
	end

Yes, more RPG:

Lua:
function onUse(cid, item, toPosition, itemEx, fromPosition)
	local place = getPlayerPosition(cid)
	local  chance = math.random(1,3)
	local  changeplant = 4
	local pos = getThingPos(item.uid)
if item.itemid == 5157 then
	if changeplant <= math.random(1,7) then
	doPlayerAddItem(cid, 5097,chance)
	doSendMagicEffect(place, 14)
	doPlayerSendTextMessage(cid, 4, "you got "..chance.." mango")
	else
	if  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You didn't harvest any mangoes from this tree.") then
	doTransformItem(item.uid,5156)
	addEvent(doCreateItem, 60 * 1000, 5157, 1, pos)
	end
	end
	end
	end
 
Nice One Azz . but don't you think it should be random it would be better like RPG

- - - Updated - - -

Here a Better One Azz
Lua:
function onUse(cid, item, toPosition, itemEx, fromPosition)
	local place = getPlayerPosition(cid)
	local  chance = math.random(1,3)
	local  changeplant = 4
	local pos = getThingPos(item.uid)
if item.itemid == 5157 then
	if changeplant <= math.random(1,7) then
	doPlayerAddItem(cid, 5097,chance)
	doSendMagicEffect(place, 14)
	doPlayerSendTextMessage(cid, 4, "you got "..chance.." mango")
	else
	if  doPlayerSendTextMessage(cid, 4, "You Can't Harvest Mango Anymore Please Wait.") then
	doTransformItem(item.uid,5156)
	addEvent(doCreateItem, 60 * 1000, 5157, 1, pos)
	end
	end
	end
	end

"you got "..chance.." mango" this sentence is incorrect as mango has its plural form - mangoes. Also getPlayerPosition(cid) = fromPosition and getThingPos(item.uid) = toPosition so why declare them twice? Also tab your codes to be readable.
 
kk TeckMan Ty for the advice can you give me a example of "if mango is plural"?
 
kk TeckMan Ty for the advice can you give me a example of "if mango is plural"?

Lua:
local mangoesAmmount = {1, 3} -- first number is min ammount, second number is max         
ammount = math.random(mangoesAmmount[1], mangoesAmmount[2])
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You harvested " .. ammount .. " " .. (ammount > 1 and "mangoes" or "mango") .. " from the tree.")
 
Back
Top