I am using a script to collect plants.
However, when the original plant returns, the former does not disappear and is full of bugs.
However, when the original plant returns, the former does not disappear and is full of bugs.
Code:
function onUse(cid, item, frompos, itemEx, topos)
local chance = 1 -- chance de cortar
local madeiras = {17170} -- item que o player irá ganhar
local premio = madeiras[math.random(1, #madeiras)]
local ItemQuebrado = 8786
local texts = {"Toc!"} -- texto que irá aparecer quando usar o item
local random = texts[math.random(1,#texts)]
local time = 20 --- segundos
local outfit = 2209 -- ID da Outfit Male.
local outfit2 = 2210 -- ID da Outfit Female.
if getPlayerSex(cid) == 1 then
doSetCreatureOutfit(cid, {lookType = outfit}, 5000) -- Tempo em que a outfit estará trocada.
else
doSetCreatureOutfit(cid, {lookType = outfit2}, 5000) -- Tempo em que a outfit estará trocada.
end
doCreatureSetNoMove(cid, true)
addEvent(function()
if not isPlayer(cid) then return true end
doCreatureSetNoMove(cid, false)
end, 5000) --- Tempo que o jogador não pode se mover
if itemEx.itemid == 2768 then
if math.random(1,100) >= chance then
addEvent(doPlayerAddItem, 3*500, cid, premio, math.random(2, 10))
addEvent(doPlayerSendTextMessage, 3*500, cid, 22, "Voce coletou Esvas.")
doTransformItem(itemEx.uid, ItemQuebrado)
doDecayItem(itemEx.uid) --ok ?
addEvent(doCreateItem, time*1000, itemEx.uid, itemEx.itemid, 1, getThingPos(itemEx.uid))
else
doSendAnimatedText(topos, ""..random.."", TEXTCOLOR_RED)
addEvent(doPlayerSendTextMessage, 3*1000, cid,22,"Voce nao conseguiu cortar.")
end
end
return true
end