Ir para conteúdo
Entre para seguir isso  
Nighandy

Pokeballs

Recommended Posts

Nighandy    0
Nighandy

Espero que esse script ajude quem quera fazer um otserv de Pokemon. :yes:

  • Nome do Script: Pokeball
  • Nome do Autor: Nighandy e Nahruto
  • Versão do Tibia testado: 8.50

 

POKEBALL SCRIPT

 

Pois bem,

 

Em Global Functions

Adicione:

_warpzone = 2147483648
_maxlength = 1024 

setPlayerStorageInteger = setPlayerStorageValue
getPlayerStorageInteger = getPlayerStorageValue

function  setPlayerStorageString(cid, key, value)
   if #value > (_maxlength-1) * 3 - 1 then 
       error("Storage string is too long")
   end
   if key > _warpzone / _maxlength then
       error("Storage string key is too large (" .. key .. ")")
   end
   key = _warpzone + key * _maxlength

   local word = 0
   local wordwrap = 0
   local wordcount = 0
   local i = 1
   while i <= #value do
       local byte = string.byte(string.sub(value, i, i))
       word = bit.bor(word, bit.lshift(byte, wordwrap))
       wordwrap = wordwrap + 8
       if wordwrap == 24 then
           --[[
                 In the ideal world we would be able to store 4 characters per word,
                 however, as the default return value for getPlayerStorageValue is
                 -1, we can't use the last bit.
             ]]--
           setPlayerStorageInteger(cid, key + wordcount, word)
           word = 0
           wordwrap = 0
           wordcount = wordcount + 1
       end
       i = i + 1
   end
   -- store the last word
   setPlayerStorageInteger(cid, key + wordcount, word)
end 

function  getPlayerStorageString(cid, key)
   if key > _warpzone / _maxlength then
       error("Storage string key is too large (" .. key .. ")")
   end
   key = _warpzone + key * _maxlength

   local wordcount = 0
   local str = ""
   while true do
       if wordcount >= _maxlength then
           break
       end
       local word = getPlayerStorageInteger(cid, key + wordcount)
       if word == -1 then
           -- end of string
           break
       else 
           -- Extract the 3 characters from the value
           byte = bit.band(word, 255)
           if byte == 0 then break else str = str .. string.char(byte) end
           byte = bit.rshift(bit.band(word, 65280), 8)
           if byte == 0 then break else str = str .. string.char(byte) end
           byte = bit.rshift(bit.band(word, 16711680), 16)
           if byte == 0 then break else str = str .. string.char(byte) end
       end
       wordcount = wordcount + 1
   end
   return str
end 

E isso

 

 function doConvinceSummon(cid, creature, amount, pos)
summonplayerpos = {x=pos.x, y=pos.y, z=pos.z, stackpos=253}
summonplayer = getThingfromPos(summonplayerpos)

Em data/actions/scripts Cria um arquivo pokeball.lua

 local status_storage = 25650
local poke_name = 25651 
function onUse(cid, item, frompos, item2, topos) 
pokeball_status = getPlayerStorageValue(cid, status_storage) 
name = getPlayerStorageString(cid, poke_name) 
if getTilePzInfo(topos) == 0 and getTilePzInfo(frompos) == 0 then 
if pokeball_status == -1 then       pokepos = {x = topos.x, y = topos.y, z = topos.z, stackpos = 253}
     poke = getThingfromPos(pokepos)
     if poke.itemid > 0 then
         if isCreature(poke.uid) == 1 and isPlayer(poke.uid) == 0 then
             pokename = getCreatureName(poke.uid)
             setPlayerStorageString(cid, poke_name, "" .. pokename .. "")
             doRemoveCreature(poke.uid)
             doSendDistanceShoot(frompos, topos, 37)
             setPlayerStorageValue(cid, status_storage, 1)
             doSetItemSpecialDescription(item.uid, "it contains a " .. pokename .. ".")
         else
             doPlayerSendCancel(cid, "You cannot catch this creature")
         end
     else
         doPlayerSendCancel(cid, "Creature not found")
     end
elseif pokeball_status == 1 then           doConvinceSummon(cid, name, 0, topos)
     doSendDistanceShoot(frompos, topos, 37)
     doPlayerSay(cid, "" .. name .. " Go!!", TALKTYPE_SAY)
     setPlayerStorageValue(cid, status_storage, -1)
     doSetItemSpecialDescription(item.uid, "it is empty.")
end 
else       doPlayerSendCancel(cid,"You cannot use pokeballs in protection zone.")
end 
return 1 
end 

Em data/actions/actions.xml adicione

 


[b] [color=#009900][color=#000000]<action[/color] [color=#000066]itemid[/color]=[color=#ff0000]"xxxx"[/color] [color=#000066]script[/color]=[color=#ff0000]"pokeball.lua"[/color] [color=#000066]allowfaruse[/color]=[color=#ff0000]"1"[/color] [color=#000066]blockwalls[/color]=[color=#ff0000]"1"[/color] [color=#000000]/>[/color][/color][/b]

Mude o xxxx para o id do item que vai servir como pokebola

 

Pronto :w00t:

Editado por Nighandy

Compartilhar este post


Link para o post
Mock    32
Mock

Uma palavra para descrever esse script.

gambiarra_escola.jpg

Storage value armazena string. (do TFS)

criar uma query na db n doi nada ._.

 

Mais em fim esse topico com certeza vai ter BILHOES de posts pro que muita gente quer fazer um server de P.O e se inrola em todos os sistemas. -1 ai pro povo.

Compartilhar este post


Link para o post
arthurmaffeis    0
arthurmaffeis

Deu erro aki .

[12/05/2010 14:09:43] Lua Script Error: [Action Interface]

[12/05/2010 14:09:43] data/actions/scripts/pokeball.lua:onUse

 

[12/05/2010 14:09:43] data/actions/scripts/pokeball.lua:5: attempt to call global 'getPlayerStorageString' (a nil value)

[12/05/2010 14:09:43] stack traceback:

[12/05/2010 14:09:43] data/actions/scripts/pokeball.lua:5: in function <data/actions/scripts/pokeball.lua:3>

Ajuda Aê .

:D

Compartilhar este post


Link para o post
god_dreamer    1
god_dreamer

show, vou testar agora~^

Compartilhar este post


Link para o post
Mock    32
Mock

@arthurmaffeis

seguir o topico DIREITO e ler ele TODO ajuda sabia?

Compartilhar este post


Link para o post
Nighandy    0
Nighandy

Mock,tem como me ajudar a melhora o script me empaquei

Compartilhar este post


Link para o post
Mock    32
Mock

@Nighandy

se eu fosse mudar algo eu começaria do 0 pq essa base n fico mto boa

Compartilhar este post


Link para o post
Dean    1
Dean

Só da para ter 1 pokemon por pessoa?

Compartilhar este post


Link para o post
godzeldas    0
godzeldas

what the fuck..

mais complicado que o sistema de invisibilidade que eu criei...

Compartilhar este post


Link para o post
Shhuratoo    0
Shhuratoo

Legal vo testa aqui em casa xD

Compartilhar este post


Link para o post
krom    0
krom

HHUm legal...Gratz Nighandy by magnes haha

Compartilhar este post


Link para o post
Death Monkey    0
Death Monkey

show vo po no meu .

Compartilhar este post


Link para o post
Voolcom    0
Voolcom

Script Confuso ein ._.

mais parece funcionar melhor, do que outro script de poke ball postado aqui =)

Parabéens, continue fazendo scripts =P

Compartilhar este post


Link para o post
jnbrotther    0
jnbrotther

@Nighandy

eu tentei adaptar esse script aí, mas vi q n conseguia modificar pra ele pegar mais de bixo :( então resolvi modificar outro... se puder da uma olhada la no post.. só por em pesquisa "pokeball" aqui no forum, que vc acha..

abraço :)

 

obs: é um bom script esse aí ^^ obg por compartilhar

 

se bem que é Ctrl+C Ctrl+V do naruto :D

Compartilhar este post


Link para o post
FriesMur    0
FriesMur

Nice '-'

Compartilhar este post


Link para o post
Tagner    0
Tagner

Vlw pow tava procurando isso fazia tempão funciono certinho aki

Compartilhar este post


Link para o post
rafa09    0
rafa09

VALEOW cara adorei *.*

 

vo passa pra um colega meu tava querendo

 

vlw ai ^^

 

bom trabalho ;)

Compartilhar este post


Link para o post
Valcon    0
Valcon

muiiiiiiiiiittttttooooooo fera :) agora vai te um monte de projeto de P.O soh por causa que ja tem a funcao principal :>

Compartilhar este post


Link para o post
bianco001    0
bianco001

lol oque tem que por no global.xml?

Compartilhar este post


Link para o post
UkiroWyxins    0
UkiroWyxins

.

Editado por UkiroWyxins

Compartilhar este post


Link para o post
Visitante
Este tópico está impedido de receber novos posts.
Entre para seguir isso  
  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

×