Você tem as sources do seu servidor? Porque, se os itens forem removidos da bag, não terá como removê-los depois. Por isso, será necessário implantar um creatureevent que evite isso.
- Fórum
- OTServ
- Suporte
- Resolvidos
- [Resolvido] Pokémon Adiciona item em x Bag
[Resolvido] Pokémon Adiciona item em x Bag
Por Amantezinho, 09 de out. de 2015 em Resolvidos
Editado Outubro 9 por zipter98
info
Grupo: Campones
Registrado: 02/10/15
Posts: 92
Reputação: +18

Você tem as sources do seu servidor? Porque, se os itens forem removidos da bag, não terá como removê-los depois. Por isso, será necessário implantar um creatureevent que evite isso.
Tenho sim.
Poderia postar seu código de go/back (data/actions/scripts)? Se houver também um script em data/creaturescripts/scripts que seja responsável por executar alguma coisa quando o summon morre, poste-o também (o callback provavelmente é onDeath).
Editado Outubro 10 por zipter98
info
Grupo: Herói
Registrado: 25/10/11
Posts: 2.2k
Reputação: +862
Gênero: Masculino
Char no Tibia: Sociopata

Em data/creaturescript, tem o goback tambem. Responsável por executar a death do summon kk
Editado Outubro 10 por Overllord
info
Grupo: Campones
Registrado: 02/10/15
Posts: 92
Reputação: +18

Poderia postar seu código de go/back (data/actions/scripts)? Se houver também um script em data/creaturescripts/scripts que seja responsável por executar alguma coisa quando o summon morre, poste-o também (o callback provavelmente é onDeath).
Data/actions/scripts/Goback
local backMSG = {"Come back, doka!", "Thanks for helping, doka!", "That's enough, come back!", "You were great, doka!", "Excellent work, doka!", "Well done, doka!"}
local goMSG = {"Go, doka!", "Let's do it, doka!", "I choose you, doka!", "I need your help, doka!", "Let's fight, doka!", "It's battle time, doka!"}function onUse(cid, item, frompos, item2, topos)if #getCreatureSummons(cid) >= 1 and getPlayerStorageValue(getCreatureSummons(cid)[1], 33) >= 1 thenreturn trueend--------msgunicaback = backMSG[math.random(#backMSG)]msgunicago = goMSG[math.random(#goMSG)]btype = getPokeballType(item.itemid)usando = pokeballs[btype].useonline = pokeballs[btype].onmorto = pokeballs[btype].offif isIconeSystem(cid) theneffect = getItemAttribute(item.uid, "effect")elseeffect = getItemAttribute(item.uid, "effect")end--------if item.itemid == usando thenif #getCreatureSummons(cid) >= 1 thenlocal z = getCreatureSummons(cid)[1]local pokename = getCreatureName(z)local mbk = msgunicaback:gsub("doka", pokename)if getItemAttribute(item.uid, "poke"):find(getCreatureName(z)) thendoTransformItem(item.uid, item.itemid-1)doCreatureSay(cid, mbk, TALKTYPE_SAY)local summom = getCreatureSummons(cid)local maxh = pokes[getCreatureName(summom[1])].vidalocal pct2 = ((getCreatureHealth(summom[1])) / (getCreatureMaxHealth(summom[1])))local vids = ((getCreatureHealth(summom[1])) - 2)doCreatureAddHealth(summom[1], -vids)setCreatureMaxHealth(summom[1], maxh)doCreatureAddHealth(summom[1], ((maxh) * (pct2)))if math.random(1,100) <= 35 thensetPokemonFeed(cid, getPokemonFeed(cid)-15) -- Food systemenddoItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")) .. " HP = ["..getCreatureHealth(z).."/"..getCreatureMaxHealth(z).."]")setPlayerStorageValue(cid, 61204, 0)setPlayerStorageValue(cid, 2, 0)doSendMagicEffect(getCreaturePosition(z), effect)doRemoveCreature(z)if getPlayerStorageValue(cid, 991) >= 1 then --- GinasiosdoSendAnimatedText(getThingPos(cid), "POKEOUT", 181)setPlayerStorageValue(cid, 991, getPlayerStorageValue(cid, 991) -1)endreturn trueendendelseif item.itemid == morto thenreturn doPlayerSendCancel(cid, "This pokemon is fainted.")elseif item.itemid == online thenif isZumbie(cid) or isHuman(cid) thenreturn doPlayerSendCancel(cid, "Sorry, is not possible.")endif item.uid ~= getPlayerSlotItem(cid, CONST_SLOT_FEET).uid thendoPlayerSendCancel(cid, "You must put your pokeball in the correct place!")return TRUEendif not canSummon(cid) thenreturn doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTENOUGHROOM)endif getPlayerStorageValue(cid, 63215) >= 1 thenreturn doPlayerSendCancel(cid, "You can't use pokeball while surfing.")endif getPlayerStorageValue(cid, 62314) >= 1 thenreturn doPlayerSendCancel(cid, "You can't use pokeball while flying.")endif #getCreatureSummons(cid) >= 1 thenreturn doPlayerSendCancel(cid, "You have already summoned a pokemon.")endfor i,x in pairs(pokes) doif i == getItemAttribute(item.uid, "poke"):sub(9, findLetter(getItemAttribute(item.uid, "poke"), "'")-1) thenif getPlayerLevel(cid) < x.level+getPokemonBoostt(item.uid) thendoPlayerSendCancel(cid, "You need level "..x.level+getPokemonBoostt(item.uid).." or higher to use this pokemon.")return trueendlocal removed = doCreateItem(1285, 1, getThingPos(cid))doSummonMonster(cid, i)local pk = getCreatureSummons(cid)[1]doTeleportThing(pk, getClosestFreeTile(pk, getThingPos(cid)), false)doRemoveItem(removed, 1)doCreatureSetLookDir(pk, 2)local maxh = pokes[getCreatureName(pk)].vidalocal levellife = ((getPlayerLevel(cid)) *2+ getPokemonBoost(getPlayerSlotItem(cid,8).uid))local health = tonumber(getItemAttribute(item.uid, "poke"):match("%[(.-)/"))doConvinceCreature(cid, pk)doCreatureAddHealth(pk, health-maxh)local pct = ((getCreatureHealth(pk)) / (getCreatureMaxHealth(pk)))local vidis = (getCreatureHealth(pk))setCreatureMaxHealth(pk, ((maxh) + (levellife)))doCreatureAddHealth(pk, 2)doCreatureAddHealth(pk, -vidis)doCreatureAddHealth(pk, ((getCreatureMaxHealth(pk)) * (pct)) - 2)doTransformItem(item.uid, item.itemid+1)local pokename = getCreatureName(getCreatureSummons(cid)[1])local mgo = msgunicago:gsub("doka", pokename)doCreatureSay(cid, mgo, TALKTYPE_SAY)if math.random(1,100) <= 35 thensetPokemonFeed(cid, getPokemonFeed(cid)-5) -- Food systemenddoSendFeedEffect(cid)if getItemAttribute(item.uid, "nome") ~= "Ditto" thenfor i = 1, 12 doif not getMoveNamee(cid, i) thenaddEvent(doGoBackSetCooldown, 200, cid)endendelsefor a = 1, 12 dosetPokemonCooldown(cid, a, "Don't have this move.")endend----- Burn, venom e ice system ------getBurn(cid)getVenom(cid)getIce(cid)----- Burn, venom e ice system ------doItemSetAttribute(item.uid, "poke", getItemAttribute(item.uid, "poke"):sub(1, findLetter(getItemAttribute(item.uid, "poke"), ".")))doItemSetAttribute(item.uid, "pokes", ""..pokename.."")doSendMagicEffect(getCreaturePosition(pk), effect)setPlayerStorageValue(cid, 61204, 1)registerCreatureEvent(pk, "DiePoke")registerCreatureEvent(pk, "Exp")--ShinyBallSystem\/isShinyBallOrBoosted(cid, item)if getPlayerStorageValue(cid, 991) >= 1 then --- GinasiosdoSendAnimatedText(getThingPos(cid), "POKEIN", TEXTCOLOR_LIGHTBLUE)endbreakendendendreturn TRUEend
Creaturescripts/scripts/goback
function onLogout(cid)
---------doLeaveSuddenAttack(cid)if isZumbie(cid) or isHuman(cid) thendoPlayerSendCancel(cid, "Sorry, you cant logout in event.")return falseendif getPlayerStorageValue(cid, 888) >= 1 thendoPlayerSendCancel(cid, "You cant logout during control mind.")return falseend---------if #getCreatureSummons(cid) == 1 thendoTransformItem(getPlayerSlotItem(cid, 8).uid, getPlayerSlotItem(cid, 8).itemid-1)stopEvent(doSendFeedEffect, cid)if getPlayerStorageValue(cid, 61204) >= 1 and getPlayerStorageValue(cid, 63215) <= 0 and getPlayerStorageValue(cid, 62314) <= 0 thenlocal summom = getCreatureSummons(cid)local maxh = (pokes[getCreatureName(summom[1])].vida)local pct2 = ((getCreatureHealth(summom[1])) / (getCreatureMaxHealth(summom[1])))local vids = ((getCreatureHealth(summom[1])) - 2)doCreatureAddHealth(summom[1], -vids)setCreatureMaxHealth(summom[1], maxh)doCreatureAddHealth(summom[1], ((maxh) * (pct2)))local health = getCreatureHealth(summom[1])local maxhealth = getCreatureMaxHealth(summom[1])setPlayerStorageValue(cid, 61205, health)setPlayerStorageValue(cid, 61206, maxhealth)setPlayerStorageValue(cid, 61204, 0)setPlayerStorageValue(cid, 61207, 1)doItemSetAttribute(getPlayerSlotItem(cid, 8).uid, "poke", getItemAttribute(getPlayerSlotItem(cid, 8).uid, "poke") .. " HP = ["..getPlayerStorageValue(cid, 61205).."/"..getPlayerStorageValue(cid, 61206).."]")if getPlayerGroupId(cid) == 8 thensetPlayerStorageValue(cid, 1, 0)setPlayerGroupId(cid, 1)endendendreturn TRUEendlocal deathtexts = {"Oh no! POKENAME, come back!", "Come back, POKENAME!", "That's enough, POKENAME!", "You did well, POKENAME!", "You need to rest, POKENAME!", "Nice job, POKENAME!", "POKENAME, you are too hurt!"}function onDeath(cid, deathList)local owner = getCreatureMaster(cid)local thisball = getPlayerSlotItem(owner, 8)local btype = getPokeballType(thisball.itemid)doSendMagicEffect(getThingPos(cid), getItemAttribute(thisball.uid, "effect"))doTransformItem(thisball.uid, pokeballs[btype].off)doItemSetAttribute(thisball.uid, "morta", "yes")local say = deathtexts[math.random(#deathtexts)]say = string.gsub(say, "POKENAME", getCreatureName(cid))doCreatureSay(owner, say, TALKTYPE_SAY)doItemSetAttribute(thisball.uid, "poke", getItemAttribute(thisball.uid, "poke"):sub(1, findLetter(getItemAttribute(thisball.uid, "poke"), ".")) .. " HP = [0/"..getCreatureMaxHealth(cid).."]")setPlayerStorageValue(owner, 61207, 0)setPlayerStorageValue(owner, 61204, 0)if getPlayerGroupId(owner) == 8 thensetPlayerGroupId(owner, 1)endsetPokemonFeedd(thisball.uid, math.floor(getPokemonFeed(cid)-math.random(25, 30)))doRemoveCreature(cid)if getPlayerStorageValue(owner, 991) >= 1 thensetPlayerStorageValue(owner, 991, getPlayerStorageValue(owner, 991) -1)doSendAnimatedText(getThingPos(owner), "POKEOUT", 181)endreturn FALSEend
Se precisar tem esse playerdeath.lua também, slá hahahahaha
function onDeath(cid)
local health,maxhealth = getSummonLifes(cid)if #getCreatureSummons(cid) >= 1 thensetPlayerStorageValue(cid, 61205, health)setPlayerStorageValue(cid, 61206, maxhealth)setPlayerStorageValue(cid, 61204, 0)setPlayerStorageValue(cid, 61207, 1)endif getPlayerStorageValue(cid, 63215) >= 1 thensetPlayerStorageValue(cid, 61205, getPlayerStorageValue(cid, 61210))setPlayerStorageValue(cid, 61206, getPlayerStorageValue(cid, 61209))setPlayerStorageValue(cid, 61204, 0)setPlayerStorageValue(cid, 63215, 0)setPlayerStorageValue(cid, 61207, 1)endif getPlayerStorageValue(cid, 62314) >= 1 thensetPlayerStorageValue(cid, 61205, getPlayerStorageValue(cid, 61262))setPlayerStorageValue(cid, 61206, getPlayerStorageValue(cid, 61263))setPlayerStorageValue(cid, 61204, 0)setPlayerStorageValue(cid, 62314, 0)setPlayerStorageValue(cid, 61207, 1)endsetPlayerGroupId(cid, 1)doRemoveCreature(cid)doCreateItem(2160, 100,getThingPos(cid))return TRUEend
Agradeço a ajuda desde já ![]()
Editado Outubro 11 por Iluargrott2
O nível para obter os itens será o mesmo para todos?
info
Grupo: Campones
Registrado: 02/10/15
Posts: 92
Reputação: +18

O nível para obter os itens será o mesmo para todos?
Exemplo :
Player Level 19 tá usando um charmander.
O charmander vai adicionar os itens 1, (para level 1), 2 (para level 5), 3 (para o level 18), mas não adicionará o item 4 pois o player não tem o nível para tal item.
(é tipo um move sistem por action
)
Os itens são cumulativos?
info
Grupo: Herói
Registrado: 25/10/11
Posts: 2.2k
Reputação: +862
Gênero: Masculino
Char no Tibia: Sociopata

Zipter, não são kk kk conheço esse sistema..
Primeiramente, instale esse creatureevent nas suas sources. Depois, crie um arquivo em data/creatureevents/scripts com extensão .lua e coloque o seguinte conteúdo:
local poke_items = {}
for _, poke in pairs(poke_item_table) do
for level, itemid in pairs(poke) do
table.insert(poke_items, itemid)
end
end
function onMoveItem(cid, item)
return not isInArray(poke_items, item.itemid)
end<event type="move" name="blockPokeItem" event="script" value="nome_do_arquivo.lua"/>
Em qualquer arquivo da lib, coloque a seguinte tabela:
poke_item_table = {
["Charmander"] = {
--[level] = itemid,
[1] = xxx,
[5] = yyy,
[8] = zzz,
--etc
},
}
doSummonMonster(cid, i)
coloque:
local poke_item = poke_item_table[i]
if poke_item then
for level, itemid in pairs(poke_item) do
if getPlayerLevel(cid) > level then
doPlayerAddItem(cid, itemid, 1)
end
end
end
doRemoveCreature(z)
local poke_item = poke_item_table[pokename]
if poke_item then
for level, itemid in pairs(poke_item) do
if getPlayerItemCount(cid, itemid) > 0 then
doPlayerRemoveItem(cid, itemid, 1)
end
end
endif #getCreatureSummons(cid) == 1 then
local poke_item = poke_item_table[getCreatureName(getCreatureSummons(cid)[1])]
if poke_item then
for level, itemid in pairs(poke_item) do
if getPlayerItemCount(cid, itemid) > 0 then
doPlayerRemoveItem(cid, itemid, 1)
end
end
endfunction onDeath(cid, deathList)
local poke_item = poke_item_table[getCreatureName(cid)]
if poke_item then
for level, itemid in pairs(poke_item) do
if getPlayerItemCount(cid, itemid) > 0 then
doPlayerRemoveItem(cid, itemid, 1)
end
end
end
Editado Outubro 14 por zipter98
info
Grupo: Campones
Registrado: 02/10/15
Posts: 92
Reputação: +18

Zipter98, para adicionar o creatureevent é em .cpp ou .h?
Basta seguir o tutorial. Lá indica os arquivos que devem ser modificados.
info
Grupo: Campones
Registrado: 02/10/15
Posts: 92
Reputação: +18

Tentando compilar as sources para testar xD





info
Grupo: Campones
Registrado: 02/10/15
Posts: 92
Reputação: +18
E aí XTibiaos, queria uma ajuda rápida, e creio que seja "fácil" para quem entende de scripts. HAHAHAHAHA
Segue abaixo:
Ao sumonar x Pokémon será adicionado y item em z bag. Ao ele ser chamdo devolta/estar morto, os itens serão removidos.
Se possível um script bem fácil de manusear, por exemplo, uma tabela com os nomes de pokemons para adicionar item tal tal tal na bag Z.
Agradeço desde já.