Postado Maio 6, 2020 5 anos @Bepovi Esse sistema é meio confuso, não sei se vai funcionar de um jeito bom. Mas enfim, arrumei a callback para uma melhor, onde você consegue puxar o id do player. Spoiler local rattatalvltest = { [0] = {pokemon = "rattata [1]"}, [1] = {pokemon = "rattata [1]"}, [2] = {pokemon = "rattata [1]"} } local rattatalvl5 = { [0] = {pokemon = 'rattata [2]'}, [1] = {pokemon = 'rattata [2]'}, [2] = {pokemon = 'rattata [2]'} } function onCombat(cid, target) if isPlayer(target) then if getCreatureName(cid) == "Rattata" then if getPlayerLevel(target) >= 10 and getPlayerLevel(target) <= 20 then local criature = doCreateMonster(Pokes1020[math.random(0,1)].pokemon, getCreaturePosition(cid)) doRemoveCreature(cid) elseif getPlayerLevel(target) >= 21 and getPlayerLevel(target) <= 40 then local criature = doCreateMonster(Pokes1020[math.random(0,1)].pokemon, getCreaturePosition(cid)) doRemoveCreature(cid) end end end return true end Arruma o nome das tabelas, desse jeito que está não vai funcionar. Outra coisa, troca a XML para isso: <event type="combat" name="Pokelvl" event="script" value="Pokelvl.lua"/> Editado Maio 6, 2020 5 anos por Storm (veja o histórico de edições)
Postado Maio 6, 2020 5 anos Autor @Storm Alterei conforme o script, arrumei as tabelas e o creaturescript.. Abri o servidor, quando o player acha o pokemon, ele não se transforma, nem quando ataca/mata. Não dá nenhum erro na distro. Testei com e sem o <event name="Pokelvl"/> no xml do pokemon. Testei com um char level 10. Ao alterar esse script para combat, acredito que o pokemon só vá se transformar quando for atacado/atacar, correto? Um pokemon passivo se manteria sem level até ser atacado. Talvez realmente seja a unica forma de identificar um player. No think, ele se transforma ao aparecer algum player na tela, visualmente falando seria melhor, mas acho que no think ele não consegue verificar o lvl do player que ativou o script.. local pokes1020 = { [0] = {pokemon = 'rattata [1] s'}, [1] = {pokemon = 'rattata [1] s'}, [2] = {pokemon = 'rattata [1] s'}, } local pokes2030 = { [0] = {pokemon = 'rattata [2] s'}, [1] = {pokemon = 'rattata [2] s'}, [2] = {pokemon = 'rattata [2] s'}, } function onCombat(cid, target) if isPlayer(target) then if getCreatureName(cid) == "Rattata" then if getPlayerLevel(target) >= 5 and getPlayerLevel(target) <= 20 then local criature = doCreateMonster(pokes1020[math.random(0,2)].pokemon, getCreaturePosition(cid)) doRemoveCreature(cid) elseif getPlayerLevel(target) >= 21 then local criature = doCreateMonster(pokes2030[math.random(0,2)].pokemon, getCreaturePosition(cid)) doRemoveCreature(cid) end end end return true end
Postado Maio 6, 2020 5 anos @Bepovi Tenta assim: Spoiler local pokes1020 = { [0] = {pokemon = 'rattata [1] s'}, [1] = {pokemon = 'rattata [1] s'}, [2] = {pokemon = 'rattata [1] s'}, } local pokes2030 = { [0] = {pokemon = 'rattata [2] s'}, [1] = {pokemon = 'rattata [2] s'}, [2] = {pokemon = 'rattata [2] s'}, } function onCombat(cid, target) if isPlayer(cid) and isMonster(target) then if getCreatureName(target) == "Rattata" then if getPlayerLevel(cid) >= 5 and getPlayerLevel(cid) <= 20 then local criature = doCreateMonster(pokes1020[math.random(0,2)].pokemon, getCreaturePosition(cid)) doRemoveCreature(target) elseif getPlayerLevel(cid) >= 21 then local criature = doCreateMonster(pokes2030[math.random(0,2)].pokemon, getCreaturePosition(cid)) doRemoveCreature(target) end end elseif isPlayer(target) and isMonster(cid) then if getCreatureName(cid) == "Rattata" then if getPlayerLevel(target) >= 5 and getPlayerLevel(target) <= 20 then local criature = doCreateMonster(pokes1020[math.random(0,2)].pokemon, getCreaturePosition(cid)) doRemoveCreature(cid) elseif getPlayerLevel(target) >= 21 then local criature = doCreateMonster(pokes2030[math.random(0,2)].pokemon, getCreaturePosition(cid)) doRemoveCreature(cid) end end end return true end
Postado Maio 6, 2020 5 anos Autor @Storm Coloquei isso e continua sem dar erros na distro, porém não muda nada.. creaturescript.xml <event type="combat" name="Pokelvl" event="script" value="Pokelvl.lua"/> rattata.xml <event name="Pokelvl"/> Testei também adicionando o registerCreatureEvent(cid, "pokelvl") no login.lua (que não era necessário no script onThink) também sem resultados.
Postado Maio 6, 2020 5 anos @Bepovi De qualquer forma, esse sistema é gambiarra pura. O certo seria ter na sua source a função onSpawn, aí sim poderiamos fazer algo bom. Faz assim, coloca esse script que vou te mandar e me manda o que vai printar na source, quando um jogador atacar um pokemon e vice e versa. Spoiler local pokes1020 = { [0] = {pokemon = 'rattata [1] s'}, [1] = {pokemon = 'rattata [1] s'}, [2] = {pokemon = 'rattata [1] s'}, } local pokes2030 = { [0] = {pokemon = 'rattata [2] s'}, [1] = {pokemon = 'rattata [2] s'}, [2] = {pokemon = 'rattata [2] s'}, } function onCombat(cid, target) print(1) if isPlayer(cid) and isMonster(target) then print(2) if getCreatureName(target) == "Rattata" then print(3) if getPlayerLevel(cid) >= 5 and getPlayerLevel(cid) <= 20 then print(4) local criature = doCreateMonster(pokes1020[math.random(0,2)].pokemon, getCreaturePosition(target)) doRemoveCreature(target) elseif getPlayerLevel(cid) >= 21 then local criature = doCreateMonster(pokes2030[math.random(0,2)].pokemon, getCreaturePosition(target)) doRemoveCreature(target) end end elseif isPlayer(target) and isMonster(cid) then print(5) if getCreatureName(cid) == "Rattata" then print(6) if getPlayerLevel(target) >= 5 and getPlayerLevel(target) <= 20 then print(7) local criature = doCreateMonster(pokes1020[math.random(0,2)].pokemon, getCreaturePosition(cid)) doRemoveCreature(cid) elseif getPlayerLevel(target) >= 21 then local criature = doCreateMonster(pokes2030[math.random(0,2)].pokemon, getCreaturePosition(cid)) doRemoveCreature(cid) end end end return true end Por onThink até da pra fazer, mas creio que vai pesar muito o servidor, já que na função onThink não é possível obter o id do player que está próximo ao pokemon.
Participe da conversa
Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.