Ir para conteúdo
  • Cadastre-se

(Resolvido)[Pedido] Sistema de Arena.


Ir para solução Resolvido por zipter98,

Posts Recomendados

Mato e nao aparece a outra WAVE

do Distro:

Hidden Content

    Give reaction to this post to see the hidden content.

 

 

Creaturescripts:

function onKill(cid, target)
print("test6")
    if isPlayer(cid) and getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) > -1 then
        print("test3")
        local new_wave = getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) + 1
        if newWave() then
            print("test4")
            local reward = ARENA.WAVES[getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto)].prize
            local str = "You won:"
            if reward.cash then
                doPlayerAddMoney(cid, reward.cash)
                str = str.."\n"..reward.cash.."$"
            end
            if reward.items then
                for i = 1, #reward.items do
                    local item = reward.items[i][1]
                    local count = reward.items[i][2]
                    if not isItemStackable(item) and count > 1 then
                        for i = 1, count do
                            doPlayerAddItem(cid, item, 1)
                        end
                    else
                        doPlayerAddItem(cid, item, count)
                    end
                    str = str.."\nItem - "..count.."x "..getItemNameById(item)
                end
            end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, str)
            if ARENA.WAVES[new_wave] then
                setPlayerStorageValue(cid, ARENA.STORAGES.wave_sto, new_wave)
                doWave(cid, new_wave)
            else
                local tp = doCreateTeleport(ARENA.TELEPORT.tpId, ARENA.TELEPORT.tpToPos, ARENA.TELEPORT.tpPos)
                doItemSetAttribute(tp, "aid", ARENA.TELEPORT.aid)
            end
        end
    end
    return true
end
function onLogout(cid)
  if isPlayer(cid) then
        if getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) > -1 then
            doPlayerSendCancel(cid, "You can't logout now.") 
            return false
        end
    end
    return true
end
function onPrepareDeath(cid)
    if getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) > -1  then
        setPlayerStorageValue(cid, ARENA.STORAGES.wave_sto, -1)
        doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
        setGlobalStorageValue(1000, -1)
        clearArena()
    end
    return true
end

e a LIB:

ARENA = {
    WAVES = {
        [1] = {
            monsters = {
                {"Demon", {x = 617, y = 2086, z = 6}},     --{nome_do_monstro, {posição_que_vai_nascer}},
                {"Demon", {x = 617, y = 2089, z = 6}},
                {"Demon", {x = 627, y = 2086, z = 6}},
				{"Demon", {x = 627, y = 2089, z = 6}},
            },
            prize = {
                cash = 500000,                              --Coloque false se não for receber cash nessa wave.
                items = false,                              --Coloque false se não for receber item(s) nessa wave.
            },
        },
        [2] = {
            monsters = {
                {"Hellfire Figher", {x = 617, y = 2086, z = 6}},     --{nome_do_monstro, {posição_que_vai_nascer}},
                {"Hellfire Figher", {x = 617, y = 2089, z = 6}},
                {"Hellfire Figher", {x = 627, y = 2086, z = 6}},
				{"Hellfire Figher", {x = 627, y = 2089, z = 6}},
            },
            prize = {
                cash = 1000000,                           
                items = false,                               
            },
        },
        [3] = {
            monsters = {
                {"Orshabaal", {x = 617, y = 2086, z = 6}},     --{nome_do_monstro, {posição_que_vai_nascer}},
                {"Orshabaal", {x = 617, y = 2089, z = 6}},
                {"Orshabaal", {x = 627, y = 2086, z = 6}},
				{"Orshabaal", {x = 627, y = 2089, z = 6}},
            },
            prize = {
                cash = 1000000,                             
                items = {
                    {2160, 1},                        --{ID do item, quantidade},                  
                    {2160, 1},
                },
            },
        },
    },
    NPC = {
        price = 2000,                                --Preço para entrar na arena.
        position = {x = 622, y = 2088, z = 6},            --Para onde o jogador será teleportado ao falar com o NPC.
    },
    TELEPORT = {
      tpId = 1387,                                 --ID do teleporte.
        tpPos = {x = 622, y = 2084, z = 6},               --Onde o teleporte será criado, ao matar o último boss.
        tpToPos = {x = 622, y = 2081, z = 5},             --Para onde o teleporte levará.
        aid = 1307,
    },
    STORAGES = {
        storage = 90190,
        wave_sto = 90191,
    },
    toPos = {x = 630, y = 2092, z = 6},               --Coordenadas da posição superior esquerda da arena.
    fromPos = {x = 614, y = 2082, z = 6},             --Coordenadas da posição inferior direita da arena.
    delay = 15,                                  --Segundos para o boss aparecer.
    level = 100,                                 --Level mínimo.
}
function doWave(cid, wave)
    if not isPlayer(cid) then
        return true
    elseif not ARENA.WAVES[wave] then
        return true
    elseif getPlayerStorageValue(cid, ARENA.STORAGES.storage) > -1 then
        return true
    end
    local monster = ARENA.WAVES[wave]
    local m = monster.monsters
    doPlayerSendTextMessage(cid, 27, "Em "..ARENA.delay.." segundos, começa seu desafio. [Wave: "..wave.."]")
    addEvent(function()
        for i = 1, #m do
            doCreateMonster(m[i][1], m[i][2])
        end
    end, ARENA.delay * 1000)
end
function clearArena()
    for x = ARENA.fromPos.x, ARENA.toPos.x do
        for y = ARENA.fromPos.y, ARENA.toPos.y do
            for z = ARENA.fromPos.z, ARENA.toPos.z do
                local area = {x = x, y = y, z = z}
                local creature = getTopCreature(area).uid
                if isCreature(creature) then   
                    doRemoveCreature(creature)
                end
            end
        end
    end
end
function newWave()
    for x = ARENA.fromPos.x, ARENA.toPos.x do
        for y = ARENA.fromPos.y, ARENA.toPos.y do
            for z = ARENA.fromPos.z, ARENA.toPos.z do
                local area = {x = x, y = y, z = z}
                local creature = getTopCreature(area).uid
                if isCreature(creature) then
                    print("test1")
                    if not isPlayer(creature) and not isSummon(creature) then
                        print("test5")
                        return false
                    end
                end
            end
        end
    end
    print("test2")
    return true
end
Editado por glacialot (veja o histórico de edições)

FPCMCUA.jpg

Link para o post
Compartilhar em outros sites
  • Respostas 99
  • Created
  • Última resposta

Top Posters In This Topic

Top Posters In This Topic

Popular Posts

OK. Eu fiz bem rapidamente o sistema aqui, talvez haja algum(s) erro(s). data/lib, crie um arquivo com extensão .lua e coloque o seguinte conteúdo: ARENA = {     WAVES = {         [1] = {"monster_name", {x = x, y = y, z = z}},     --{nome_do_monstro, {posição_que_vai_nascer}},         [2] = {"monster_name", {x = x, y = y, z = z}},         [3] = {"monster_name", {x = x, y = y, z = z}},         [4] = {"monster_name", {x = x, y = y, z = z}},         [5] = {"monster_name", {x = x, y = y, z = z}},

Ah, isso explica. Você configurou errado. toPos nunca terá valores menores que fromPos.  Provavelmente você inverteu fromPos e toPos. E também deve ser por isso que algumas funções que usei anteriormente não funcionaram com você.   @glacialot Pronto, terminei o que você pediu. Deixei 3 waves configuradas como exemplo. Para adicionar mais waves, siga o modelo das já existentes. Substitua sua lib por essa: ARENA = {     WAVES = {         [1] = {             monsters = {                 {"m

OK. Refiz a parte que checa se a wave foi ou não completa. Tanto a maneira antiga quanto a nova funcionaram aqui. Espero que o mesmo aconteça no seu servidor. Troque sua lib por essa: ARENA = {     WAVES = {         [1] = {             monsters = {                 {"Demon", {x = 617, y = 2086, z = 6}},     --{nome_do_monstro, {posição_que_vai_nascer}},                 {"Demon", {x = 617, y = 2089, z = 6}},                 {"Demon", {x = 627, y = 2086, z = 6}}, {"Demon", {x = 6

OK. Refiz a parte que checa se a wave foi ou não completa. Tanto a maneira antiga quanto a nova funcionaram aqui. Espero que o mesmo aconteça no seu servidor.

Troque sua lib por essa:

ARENA = {
    WAVES = {
        [1] = {
            monsters = {
                {"Demon", {x = 617, y = 2086, z = 6}},     --{nome_do_monstro, {posição_que_vai_nascer}},
                {"Demon", {x = 617, y = 2089, z = 6}},
                {"Demon", {x = 627, y = 2086, z = 6}},
                {"Demon", {x = 627, y = 2089, z = 6}},
            },
            prize = {
                cash = 500000,                              --Coloque false se não for receber cash nessa wave.
                items = false,                              --Coloque false se não for receber item(s) nessa wave.
            },
        },
        [2] = {
            monsters = {
                {"Hellfire Figher", {x = 617, y = 2086, z = 6}},     --{nome_do_monstro, {posição_que_vai_nascer}},
                {"Hellfire Figher", {x = 617, y = 2089, z = 6}},
                {"Hellfire Figher", {x = 627, y = 2086, z = 6}},
                {"Hellfire Figher", {x = 627, y = 2089, z = 6}},
            },
            prize = {
                cash = 1000000,                           
                items = false,                               
            },
        },
        [3] = {
            monsters = {
                {"Orshabaal", {x = 617, y = 2086, z = 6}},     --{nome_do_monstro, {posição_que_vai_nascer}},
                {"Orshabaal", {x = 617, y = 2089, z = 6}},
                {"Orshabaal", {x = 627, y = 2086, z = 6}},
                {"Orshabaal", {x = 627, y = 2089, z = 6}},
            },
            prize = {
                cash = 1000000,                             
                items = {
                    {2160, 1},                        --{ID do item, quantidade},                  
                    {2160, 1},
                },
            },
        },
    },
    NPC = {
        price = 2000,                                --Preço para entrar na arena.
        position = {x = 622, y = 2088, z = 6},            --Para onde o jogador será teleportado ao falar com o NPC.
    },
    TELEPORT = {
      tpId = 1387,                                 --ID do teleporte.
        tpPos = {x = 622, y = 2084, z = 6},               --Onde o teleporte será criado, ao matar o último boss.
        tpToPos = {x = 622, y = 2081, z = 5},             --Para onde o teleporte levará.
        aid = 1307,
    },
    STORAGES = {
        storage = 90190,
        wave_sto = 90191,
        kill = 90194,
    },
    toPos = {x = 630, y = 2092, z = 6},               --Coordenadas da posição superior esquerda da arena.
    fromPos = {x = 614, y = 2082, z = 6},             --Coordenadas da posição inferior direita da arena.
    delay = 15,                                  --Segundos para o boss aparecer.
    level = 100,                                 --Level mínimo.
}
function doWave(cid, wave)
    if not isPlayer(cid) then
        return true
    elseif not ARENA.WAVES[wave] then
        return true
    elseif getPlayerStorageValue(cid, ARENA.STORAGES.storage) > -1 then
        return true
    end
    local monster = ARENA.WAVES[wave]
    local m = monster.monsters
    doPlayerSendTextMessage(cid, 27, "Em "..ARENA.delay.." segundos, começa seu desafio. [Wave: "..wave.."]")
    addEvent(function()
        for i = 1, #m do
            doCreateMonster(m[i][1], m[i][2])
        end
    end, ARENA.delay * 1000)
end
function clearArena()
    for x = ARENA.fromPos.x, ARENA.toPos.x do
        for y = ARENA.fromPos.y, ARENA.toPos.y do
            for z = ARENA.fromPos.z, ARENA.toPos.z do
                local area = {x = x, y = y, z = z}
                local creature = getTopCreature(area).uid
                if isCreature(creature) then   
                    doRemoveCreature(creature)
                end
            end
        end
    end
end
function getKilledMonsters(cid)
    return getPlayerStorageValue(cid, ARENA.STORAGES.kill) > 0 and getPlayerStorageValue(cid, ARENA.STORAGES.kill) or 0
end
Troque seu creaturescript por esse:
function onKill(cid, target)
    if isPlayer(cid) and getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) > -1 then
        setPlayerStorageValue(cid, ARENA.STORAGES.kill, getKilledMonsters(cid) + 1)
        local wave = getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto)
        local new_wave = wave + 1
        if getKilledMonsters(cid) >= #ARENA.WAVES[wave].monsters then
            local reward = ARENA.WAVES[getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto)].prize
            local str = "You won:"
            if reward.cash then
                doPlayerAddMoney(cid, reward.cash)
                str = str.."\n"..reward.cash.."$"
            end
            if reward.items then
                for i = 1, #reward.items do
                    local item = reward.items[i][1]
                    local count = reward.items[i][2]
                    if not isItemStackable(item) and count > 1 then
                        for i = 1, count do
                            doPlayerAddItem(cid, item, 1)
                        end
                    else
                        doPlayerAddItem(cid, item, count)
                    end
                    str = str.."\nItem - "..count.."x "..getItemNameById(item)
                end
            end
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE, str)
            setPlayerStorageValue(cid, ARENA.STORAGES.kill, 0)
            if ARENA.WAVES[new_wave] then
                setPlayerStorageValue(cid, ARENA.STORAGES.wave_sto, new_wave)
                doWave(cid, new_wave)
            else
                local tp = doCreateTeleport(ARENA.TELEPORT.tpId, ARENA.TELEPORT.tpToPos, ARENA.TELEPORT.tpPos)
                doItemSetAttribute(tp, "aid", ARENA.TELEPORT.aid)
            end
        end
    end
    return true
end
function onLogout(cid)
    if isPlayer(cid) then
        if getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) > -1 then
            doPlayerSendCancel(cid, "You can't logout now.") 
            return false
        end
    end
    return true
end
function onPrepareDeath(cid)
    if getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) > -1  then
        setPlayerStorageValue(cid, ARENA.STORAGES.wave_sto, -1)
        setGlobalStorageValue(1000, -1)
        clearArena()
    end
    return true
end
Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Cara tu não vai acreditar mas agora ele da erro no script do NPC

jMHmS6.png

 

Script:

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid) npcHandler:onCreatureAppear(cid) end
function onCreatureDisappear(cid) npcHandler:onCreatureDisappear(cid) end
function onCreatureSay(cid, type, msg) npcHandler:onCreatureSay(cid, type, msg) end
function onThink() npcHandler:onThink() end
function creatureSayCallback(cid, type, msg)
    if(not npcHandler:isFocused(cid)) then
        return false
    end
    local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
    if msgcontains(msg:lower(), "arena") or msgcontains(msg:lower(), "enter") then
        if getPlayerLevel(cid) < ARENA.level then
            selfSay("You do not have enough level ["..ARENA.level.."].", cid)
            talkState[talkUser] = 0
            return true
        elseif getGlobalStorageValue(1000) > -1 then
            selfSay("Someone is at the arena right now, please wait.", cid)
            talkState[talkUser] = 0
            return true
        elseif getPlayerStorageValue(cid, ARENA.STORAGES.storage) > -1 then
            selfSay("You already completed the arena.", cid)
            talkState[talkUser] = 0
            return true
        else
            selfSay("You really want enter in the arena? It will cost you {"..ARENA.NPC.price.."}.", cid)
            talkState[talkUser] = 1
            return true
        end
    elseif msgcontains(msg:lower(), "yes") and talkState[talkUser] == 1 then
        if doPlayerRemoveMoney(cid, ARENA.NPC.price) then
            selfSay("Good luck! ^.^", cid)
            doTeleportThing(cid, ARENA.NPC.position)
            setPlayerStorageValue(cid, ARENA.STORAGES.wave_sto, 1)
			setPlayerStorageValue(cid, 90183, 1)
            setGlobalStorageValue(1000, 1)
            doWave(cid, 1)
            talkState[talkUser] = 0
            return true
        else
            selfSay("You do not have enough money.", cid)
            talkState[talkUser] = 0
            return true
        end
    elseif msgcontains(msg:lower(), "no") and talkState[talkUser] == 1 then
        selfSay("Ok, then...", cid)
        talkState[talkUser] = 0
        return true
    end       
    return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())    
Editado por glacialot (veja o histórico de edições)

FPCMCUA.jpg

Link para o post
Compartilhar em outros sites

Solucionado pelo Skype. O erro estava sendo causado porque o glacialot havia copiado o nome da tabela errado (RENA, e não ARENA).

O sistema está funcionando perfeitamente.

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Link para o post
Compartilhar em outros sites

Show de bola, o problema estava quando substitui esse ultimo post dele copiei apenas RENA e nao ARENA como ele mesmo informou...

 

Quero agradecer imensamente a ajuda do @ziper98 pelo esforço e dedicação aplicada nesse script, ficou 100% mesmo, tudo funcionando conforme o pedido, que você continue ajudando aqui no Forum, faz um ótimo trabalho amigo, precisamos de mais pessoas como você por aqui!

 

Parabéns!

FPCMCUA.jpg

Link para o post
Compartilhar em outros sites

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.

Visitante
Responder

×   Você colou conteúdo com formatação.   Remover formatação

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

×   Seu conteúdo anterior foi restaurado.   Limpar o editor

×   Não é possível colar imagens diretamente. Carregar ou inserir imagens do URL.

  • Quem Está Navegando   0 membros estão online

    Nenhum usuário registrado visualizando esta página.

  • Estatísticas dos Fóruns

    96846
    Tópicos
    519599
    Posts



×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo