Olá galera, hoje vou postar mais um script para pokemon dash advanced. Bem legal e acho que também é um dos mais procurados... Vamos a ele.
Nome: Duel System por Action
O que faz? Faz com que dois players duelem com limites de pokemons, escolhido no inicio das configurações da batalha.
Primeiro vamos à actions/scripts e criaremos um arquivo chamado duelSystem.lua e dentro vamos colar o código abaixo:
function onUse(cid, item, fromPos, item2, toPos) if isPlayer(item2.uid) then doPlayerSetVocation(cid, 51) openChannelDialog(cid) doPlayerSendTextMessage(item2.uid, 27, ""..getCreatureName(cid)..", are is invited you fot duel. You accept?") setPlayerStorageValue(item2.uid, 5489, 1) end return true end
Agora vamos a tag, em actions.XML cole a seguinte tag:
<action itemid="id do item que vai o player vai usar para o duel" event="script" value="duelSystem.lua"/>
Pronto. Vamos a pasta xml/channels.xml e crie as seguintes janelas:
<channel id="id decorrente da sua channel" name="1 Pokemon"> <vocation id="51"/> </channel> <channel id=" id decorrente da sua channel " name="2 Pokemons"> <vocation id="51"/> </channel> <channel id=" id decorrente da sua channel " name="3 Pokemons"> <vocation id="51"/> </channel> <channel id=" id decorrente da sua channel " name="4 Pokemons"> <vocation id="51"/> </channel> <channel id=" id decorrente da sua channel " name="5 Pokemons"> <vocation id="51"/> </channel> <channel id=" id decorrente da sua channel " name="6 Pokemons"> <vocation id="51"/> </channel>
Depois disso, não mude mais nada. Vamos agora em vocations.xml e vamos colar a seguinte tag dentro:
<vocation id="51" name="Duel" description="pokemon trainer" needpremium="0" gaincap="0" gainhp="55" gainmana="0" gainhpticks="0" gainhpamount="0" gainmanaticks="0" gainmanaamount="0" manamultiplier="1.1" attackspeed="-1" soulmax="251" gainsoulticks="-1" fromvoc="1" lessloss="0"> <formula meleeDamage="1.0" distDamage="1.0" wandDamage="1.0" magDamage="1.0" magHealingDamage="1.0" defense="1.0" magDefense="1.0" armor="1.0"/> <skill fist="2" club="2" sword="2" axe="2" distance="2" shielding="2" fishing="2" experience="1.1"/> </vocation> Obs: Não mude nada nela...
Feito isso, vamos a pasta creaturescripts/scripts e vamos criar um arquivo chamado duelSystemChannel.lua e colaremos o código a seguir dentro:
local config = { channelId1 = 13, -- Aqui você coloca-ra o id da sua primeira channel. A qual está escrito "1 Pokemon". channelId2 = 14, -- Aqui você coloca-rá o id da sua 2° channel. A qual está escrito "2 Pokemons". channelId3 = 15, -- Aqui você coloca-rá o id da sua 3° channel. A qual está escrito "3 Pokemons". channelId4 = 16, -- Aqui você coloca-rá o id da sua 4° channel. A qual está escrito "4 Pokemons". channelId5 = 17, -- Aqui você coloca-rá o id da sua 5° channel. A qual está escrito "5 Pokemons". channelId6 = 18, -- Aqui você coloca-rá o id da sua 6° channel. A qual está escrito "6 Pokemons". } function onJoinChannel(cid, channelId, users, isTv) if getPlayerVocation(cid) == 51 then else return true end if channelId == config.channelId1 then setPlayerStorageValue(cid, 12541, 0) setPlayerStorageValue(cid, 12542, 1) setGlobalStorageValue(12542, 1) doSendAnimatedText(getThingPos(cid), "1 Poke", 28) doPlayerSetVocation(cid, 1) return false elseif channelId == config.channelId2 then setPlayerStorageValue(cid, 12541, 0) setPlayerStorageValue(cid, 12542, 1) setGlobalStorageValue(12542, 2) doSendAnimatedText(getThingPos(cid), "2 Pokes", 28) doPlayerSetVocation(cid, 1) return false elseif channelId == config.channelId3 then setPlayerStorageValue(cid, 12541, 0) setPlayerStorageValue(cid, 12542, 1) setGlobalStorageValue(12542, 3) doSendAnimatedText(getThingPos(cid), "3 Pokes", 28) doPlayerSetVocation(cid, 1) return false elseif channelId == config.channelId4 then setPlayerStorageValue(cid, 12541, 0) setPlayerStorageValue(cid, 12542, 1) setGlobalStorageValue(12542, 4) doSendAnimatedText(getThingPos(cid), "4 Pokes", 28) doPlayerSetVocation(cid, 1) return false elseif channelId == config.channelId5 then setPlayerStorageValue(cid, 12541, 0) setPlayerStorageValue(cid, 12542, 1) setGlobalStorageValue(12542, 5) doSendAnimatedText(getThingPos(cid), "5 Pokes", 28) doPlayerSetVocation(cid, 1) return false elseif channelId == config.channelId6 then setPlayerStorageValue(cid, 12541, 0) setPlayerStorageValue(cid, 12542, 1) setGlobalStorageValue(12542, 6) doSendAnimatedText(getThingPos(cid), "6 Pokes", 28) doPlayerSetVocation(cid, 1) return false end return true end
Agora vamos colocar duas tags, uma em login.lua e a outra em creaturescripts.xml:
CreatureScript.xml:
<event type="joinchannel" name="DuelSystemChannel" event="script" value="duelSystemChannel.lua"/>
Login.lua
registerCreatureEvent(cid, "DuelSystemChannel")
Feito isso, vamos a talkactions/scripts e criaremos um arquivo chamado acceptDuel.lua e dentro cole o código abaixo:
function onSay(cid, words, param, channel) if getPlayerStorageValue(cid, 5489) >= 1 then setPlayerStorageValue(cid, 12541, 0) setPlayerStorageValue(cid, 6598755, 1) doSendAnimatedText(getThingPos(cid), "BATTLE", math.random(20, 60)) for _, sid in ipairs(getPlayersOnline()) do if getPlayerStorageValue(sid, 12542) >= 1 then setPlayerStorageValue(sid, 6598754, 1) doSendAnimatedText(getThingPos(sid), "BATTLE", math.random(20, 60)) end end setGlobalStorageValue(1203, 1) else return false end end
Agora vamos á talkactions.XML e colaremos as tag a seguir:
<talkaction words="yes" event="script" value="duel.lua"/> <talkaction words="sim" event="script" value="duel.lua"/>
Agora vamos em lib/ e criaremos um arquivo chamado duelLibSystem.lua e colaremos o seguinte código dentro:
function checkPokeballsInDuel(cid) if getGlobalStorageValue(1203) >= 1 and getPlayerStorageValue(cid, 12541) >= getGlobalStorageValue(12542) then doSendAnimatedText(getThingPos(cid), "LOOSES", 118) setPlayerStorageValue(cid, 12541, 0) setPlayerStorageValue(cid, 6598755, 0) setPlayerStorageValue(cid, 6598754, 0) setGlobalStorageValue(1203, 0) for _, sid in ipairs(getPlayersOnline())do if getPlayerStorageValue(sid, 12541) < 7 and getPlayerStorageValue(sid, 6598754) >= 1 or getPlayerStorageValue(sid, 12541) < 7 and getPlayerStorageValue(sid, 6598755) >= 1 then doSendAnimatedText(getThingPos(sid), "WINS", 118) setPlayerStorageValue(sid, 12541, 0) setPlayerStorageValue(sid, 6598755, 0) setPlayerStorageValue(sid, 6598754, 0) end end end if getGlobalStorageValue(1203) >= 1 and getPlayerStorageValue(cid, 12541) <= getGlobalStorageValue(12542) then setPlayerStorageValue(cid, 12541, getPlayerStorageValue(cid, 12541) +1) doSendAnimatedText(getThingPos(cid), "POKEIN", 28) end end function doBackPokeballsInDuel(cid) if getGlobalStorageValue(1203) >= 1 and getPlayerStorageValue(cid, 12541) >= 0 then doSendAnimatedText(getThingPos(cid), "POKEOUT", 118) end end
Vamos para actions/scripts/goback.lua e vamos procurar por está linha:
if item.itemid == usando then
Abaixo disso cole isso:
doBackPokeballsInDuel(cid)
Aindan no mesmo script procure por:
elseif item.itemid == pokeballs[btype].on then
E abaixo dele cole isso:
checkPokeballsInDuel(cid)
Vamos agora em creaturescripts/scripts/goback.lua e antes do utimo apague tudo e cole isto dentro:
function onLogout(cid) if getPlayerStorageValue(cid, 1460) >= 1 then doPlayerSendCancel(cid, "Sorry, you are in tournament.") return TRUE end local thisitem = getPlayerSlotItem(cid, 8) local pokeballl = getPlayerSlotItem(cid, 8) if thisitem.uid <= 0 then return true end local ballName = getItemAttribute(thisitem.uid, "poke") -------------------------------------------------------- btype = getPokeballType(thisitem.itemid) --------------------------------------------------------------- if #getCreatureSummons(cid) > 1 and getPlayerStorageValue(cid, 637501) >= 1 then BackTeam(cid, getCreatureSummons(cid), effect) --edited team scyther end ------------------------------------------------------------------- local summon = getCreatureSummons(cid)[1] if #getCreatureSummons(cid) == 1 and thisitem.uid > 1 then doItemSetAttribute(thisitem.uid, "hp", getPlayerStorageValue(cid, 212120) / getPlayerStorageValue(cid, 212121)) doTransformItem(thisitem.uid, pokeballs[btype].on) doSendMagicEffect(getThingPos(summon), pokeballs[btype].effect) doRemoveCreature(summon) end if getCreatureOutfit(cid).lookType == 814 then doPlayerStopWatching(cid) end if getPlayerStorageValue(cid, 17000) >= 1 then markFlyingPos(cid, getThingPos(cid)) end if getPlayerStorageValue(cid, 22545) == 1 then --Edited golden arena setGlobalStorageValue(22550, getGlobalStorageValue(22550)-1) setPlayerStorageValue(cid, 22545, -1) end return TRUE end local 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 ballName = getItemAttribute(thisball.uid, "poke") if getPlayerStorageValue(cid, 212124) >= 1 then return true end btype = getPokeballType(thisball.itemid) doSendMagicEffect(getThingPos(cid), pokeballs[btype].effect) doTransformItem(thisball.uid, pokeballs[btype].off) doItemSetAttribute(thisball.uid, "morta", "yes") doPlayerSendTextMessage(owner, 22, "Your pokemon fainted.") local say = deathtexts[math.random(#deathtexts)] say = string.gsub(say, "POKENAME", getCreatureName(cid)) if getPlayerStorageValue(cid, 33) <= 0 then doCreatureSay(owner, say, TALKTYPE_SAY) end doItemSetAttribute(thisball.uid, "hp", 0) doItemSetAttribute(thisball.uid, "happy", getPlayerStorageValue(cid, 1008) - happyLostOnDeath) doItemSetAttribute(thisball.uid, "hunger", getPlayerStorageValue(cid, 1009)) doRemoveCreature(cid) if getGlobalStorageValue(1203) >= 1 and getPlayerStorageValue(owner, 12541) <= getGlobalStorageValue(12542) then doSendAnimatedText(getThingPos(owner), "POKEOUT", 118) end return false end
Obs: O script falta duas funções para funcionar perfeitamente. A primeira é para não deixar o player usar o item em cima dele mesmo. A segunda e para não deixar o player deslogar enquanto está no duel. Tentei e tentei mas não consegui... Caso alguém possa ajudar fico muito grato.
Como funciona?
Você da use em cima do player que quer batalhar, escolhe quantos pokemons querem usar. O outro player fala (“yes” ou “sim”) e começam a duelar. Eu deixei uma função para deixar um player attackar o outro se ele estiver sem pokemon. Porem não perdera nada se morrer.
É isso galera espero que gostem. Lembrando vou atualizar este sistema para melhora-lo. Só deixei ele para teste. Caso gostem termino ele.