kite28
Member
- Joined
- May 15, 2012
- Messages
- 69
- Reaction score
- 5
I have a problem my character must approach this item to give the creature. I would like her to be able to give a long way how to do it?
Code:
function onUse(cid, item, frompos, item2, topos)
if not isCreature(item2.uid) or not isSummon(item2.uid) then
doPlayerSendCancel(cid, "You can only give this candy to trainers' pokemons.")
return true
end
if getCreatureHealth(item2.uid) == 0 then return true end
local pb = getPlayerSlotItem(getCreatureMaster(item2.uid), 8)
local levelon = getItemAttribute(pb.uid, "level")
if levelon >= 60 and not isGod(cid) then
doPlayerSendCancel(cid, "Your pokemon cant use more rare candy.")
return true
end
doPlayerSendTextMessage(cid, 27, "You gave a rare candy to "..getPokeName(item2.uid)..".")
doCreatureSay(cid, getPokeName(item2.uid)..", take this candy!", TALKTYPE_SAY)
doRemoveItem(item.uid, 1)
local level = getItemAttribute(pb.uid, "level")
local exp = getItemAttribute(pb.uid, "exp")
if getHappiness(item2.uid) < 50 then
doSendMagicEffect(getThingPos(item2.uid), 168)
return true
end
doCreatureSay(item2.uid, "Yum.", TALKTYPE_ORANGE_1)
doPlayerSendTextMessage(getCreatureMaster(item2.uid), 27, "Your "..getPokeName(item2.uid).." has eaten a rare candy!")
local poke = getCreatureSummons(cid)[1]
levelUp(pb.uid, getItemAttribute(pb.uid, "level"), cid, poke)
return true
end
function levelUp(pb, currentlevel, cid, poke)
local poke = getCreatureSummons(cid)[1]
doItemSetAttribute(pb, "exp", 0)
doItemSetAttribute(pb, "level", currentlevel+1)
doSendFlareEffect(getThingPos(poke))
doSendAnimatedText(getThingPos(poke), "Level up!!!["..(currentlevel+1).."]", 215)
local level = getItemAttribute(pb, "level")
local xpperlevel=50
SetExpNeed(currentlevel+1, pb, xpperlevel)
if isMega(poke) then
doTransformMega(poke, true)
else
adjustStatus(poke, pb, true, true, true)
end
end