Ir para conteúdo

Featured Replies

Postado

Sou leigo nisso brother ;|.. onde colocaria essa Tag sua?

 

No caso seria no NPC. 

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 isThereSomeone(ARENA.fromPos, ARENA.toPos) 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 getGlobalStorageValue(1000) == -1 then
if doPlayerRemoveMoney(cid, ARENA.NPC.price * 100) then
selfSay("Good luck! ^.^", cid)
setGlobalStorageValue(1000, 1)
doTeleportThing(cid, ARENA.NPC.position)
setPlayerStorageValue(cid, ARENA.STORAGES.wave_sto, 1)
doWave(cid, 1)
talkState[talkUser] = 0
return true
else
selfSay("You do not have enough money.", cid)
talkState[talkUser] = 0
return true
end
else
selfSay("Ocupado!", 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())  

Já tem uma função que verifica caso haja um jogador na arena. 

 

 

Por Global Storage é mais fácil.  ;D

Não esqueça de colocar em algum lugar pra remover a Global Storage que se ganha ao entrar na arena.

cms1-pr%C3%AAmio.png

  • Respostas 99
  • Visualizações 3.7k
  • Created
  • Última resposta

Top Posters In This Topic

Most 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_n

  • 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 anteriorm

  • 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 = {    

Postado

Pronto, alterei o NPC com level mínimo para entrar na arena. Estranho não estar funcionando a função que fiz, mas enfim. Faça como o Frenesy disse: checagem por global storage. 

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

Postado
  • Autor

@Frenesy

Usei o seu "Npc" e ele impediu que outro players entrasse, porém, depois, sempre o "npc" fala que ta ocupado >.< ( mesmo não tando).. Você me disse para colocar remove storage, onde seria isso? :|.

 

@zipter98

Usei o seu Novo "Npc", porém, quando falo "Arena" , da esse erro na distro.

 

 

2qd7ckg.png

Eu te Ajudei? Então solta aquele REP+ !!

Meus Tutoriais [Tutorial] Bug "Temple position is wrong" (MySql)

Outros:    [Meu Show OFF | Mapa próprio 8.6] 

Postado

Usei o seu "Npc" e ele impediu que outro players entrasse, porém, depois, sempre o "npc" fala que ta ocupado >.< ( mesmo não tando).. Você me disse para colocar remove storage, onde seria isso? :|.

 

É como eu te disse, precisa remover a Global Storage na hora que o player sai da arena pra poder entrar outros player.

Se você não remover, o NPC sempre dirá que está ocupado

cms1-pr%C3%AAmio.png

Postado

Esqueci de avisar, mas eu também alterei a lib. Sem essa alteração, vai dar erro no NPC mesmo.

Abaixo de:

delay = 15,                                  --Segundos para o boss aparecer.
adicione:
level = 100,                                 --Level mínimo.

Sobre a remoção da storage global:

altere seu creaturescript para este:

function onKill(cid, target)
    if isPlayer(target) and getPlayerStorageValue(target, ARENA.STORAGES.wave_sto) > -1 then
        setPlayerStorageValue(target, ARENA.STORAGES.wave_sto, -1)
        setGlobalStorageValue(1000, -1)
    elseif isPlayer(cid) and getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) > -1 then
        local new_wave = getPlayerStorageValue(cid, ARENA.STORAGES.wave_sto) + 1
        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
    return true
end
function onLogout(cid)
    if isInArea(getThingPos(cid), ARENA.fromPos, ARENA.toPos) then
        doPlayerSendCancel(cid, "You can't logout now.") 
        return false
    end
    return true
end
e seu movement para este:
function onStepIn(cid, item, position, fromPosition)
    if not isPlayer(cid) then
        return true
    end
    setPlayerStorageValue(cid, ARENA.STORAGES.storage, 1)
    setPlayerStorageValue(cid, ARENA.STORAGES.wave_sto, -1)
    setGlobalStorageValue(1000, -1)
    addEvent(function()
        if getTileItemById(position, ARENA.TELEPORT.tpId).uid > 0 then
            doRemoveItem(getTileItemById(position, ARENA.TELEPORT.tpId).uid, 1)
        end
    end, 50)
    return true
end

E o novo NPC:

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 isThereSomeone(ARENA.fromPos, ARENA.toPos) or 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 * 100) then
            selfSay("Good luck! ^.^", cid)
            doTeleportThing(cid, ARENA.NPC.position)
            setPlayerStorageValue(cid, ARENA.STORAGES.wave_sto, 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 zipter98 (veja o histórico de edições)

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

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

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.7k

Informação Importante

Confirmação de Termo