Advertisement
Guest User

Untitled

a guest
Jul 1st, 2015
191
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 2.69 KB | None | 0 0
  1. -- Criado por GabrielTxu
  2. -- Go/Back
  3. function onUse(cid, item, frompos, item2, topos)
  4. if #getCreatureSummons(cid) >= 1 and getPlayerStorageValue(getCreatureSummons(cid)[1], 33) >= 1 then
  5. return true
  6. end
  7.  
  8. local ballName = getItemAttribute(item.uid, "poke")
  9. local btype = getPokeballType(item.itemid)
  10. local usando = pokeballs[btype].use
  11.  
  12. local effect = pokeballs[btype].effect
  13.     if not effect then
  14.         effect = 21
  15.     end
  16.    
  17.    
  18.     if item.itemid == usando then
  19.     if getPlayerStorageValue(cid, 990) == 1 then
  20.         doPlayerSendTextMessage(cid, 27, "You can't return your pokemon during gym battles.")
  21.     return true
  22.     end
  23.     end
  24.    
  25.     if #getCreatureSummons(cid) <= 0 then
  26.         if isInArray(pokeballs[btype].all, item.itemid) then
  27.             doTransformItem(item.uid, pokeballs[btype].off)
  28.             doItemSetAttribute(item.uid, "hp", 0)
  29.             doPlayerSendTextMessage(cid, 27, "This pokemon is fainted.")
  30.             return true
  31.         end
  32.     end
  33.    
  34.     local cd = getCD(item.uid, "blink", 30)
  35.     if cd > 0 then
  36.        setCD(item.uid, "blink", 0)
  37.     end
  38.    
  39.     local z = getCreatureSummons(cid)[1]
  40.    
  41.     if getCreatureCondition(z, CONDITION_INVISIBLE) then
  42.        return true
  43.     end
  44.     doReturnPokemon(cid, z, item, effect)
  45.    
  46.     elseif item.itemid == pokeballs[btype].on then
  47.  
  48.     if item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_FEET).uid then
  49.         doPlayerSendTextMessage(cid, 27, "You must put your pokeball in the correct place!")
  50.     return true
  51.     end
  52.    
  53.     local thishp = getItemAttribute(item.uid, "hp")
  54.  
  55.     if thishp <= 0 then
  56.         if isInArray(pokeballs[btype].all, item.itemid) then
  57.             doTransformItem(item.uid, pokeballs[btype].off)
  58.             doItemSetAttribute(item.uid, "hp", 0)
  59.             doPlayerSendTextMessage(cid, 27, "This pokemon is fainted.")
  60.             return true
  61.         end
  62.     end
  63.  
  64.     local pokemon = getItemAttribute(item.uid, "poke")
  65.  
  66.     if not pokes[pokemon] then
  67.     return true
  68.     end
  69.    
  70.     doSummonMonster(cid, pokemon)
  71.  
  72.     local pk = getCreatureSummons(cid)[1]
  73.     if not isCreature(pk) then return true end
  74.    
  75.     doTeleportThing(pk, getPosByDir(getThingPos(cid), math.random(0, 7)), false)
  76.  
  77.     doCreatureSetLookDir(pk, 2)
  78.  
  79.     adjustStatus(pk, item.uid, true, true, true)
  80.     doAddPokemonInOwnList(cid, pokemon)
  81.  
  82.     doTransformItem(item.uid, item.itemid+1)
  83.  
  84.     local pokename = getPokeName(pk)
  85.     -------------------------------------------------
  86.     local mgo = gobackmsgs[math.random(1, #gobackmsgs)].go:gsub("doka", pokename)
  87.     doCreatureSay(cid, mgo, TALKTYPE_SAY)
  88.    
  89.     doSendMagicEffect(getCreaturePosition(pk), effect)
  90.     --------------------------------------------------
  91.     if useOTClient then
  92.        doPlayerSendCancel(cid, '12//,show') --alterado v1.7
  93.     end
  94.     --------------------------------------------------
  95.     if useKpdoDlls then
  96.         doUpdateMoves(cid)
  97.     end
  98. return true
  99. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement