Ir para conteúdo

Spring Trap

Campones
  • Total de itens

    49
  • Registro em

  • Última visita

Posts postados por Spring Trap

  1. Acho bem chato esses dbo que a galera coloca pra download ou coloca online. Sao tudo a mesma base, a base do wodbo wars que veio do dbo hunter

    Por mais q tenha algumas coisas diferentes n deixa de ser algo diferente e inovador. acho q o dbo esta caindo por conta disso Muitos servidores repetidos

    De qlq forma parabens pelo trabalho e por disponibilizar aq na comunidade

  2. Em 17/11/2018 em 20:40, Yan Liima disse:

    Aperte WIN + R. e digite: AppData.

    O diretorio vai ficar assim: C:\Users\NOME DO SEU USUARIO\AppData

     

    Abre a pasta Roaming, procura pela pasta Tibia e deleta o AutoMap. O arquivo Tibia.cfg também contém informações/configurações do seu cliente.

     

    Se for OTclient talvez esteja nesse diretório: C:\Users\SEU USUARIO AQUI. terá uma pasta escrito Otclient.

    Funcionou, vlllww

  3. Galera em minhas sources eu coloquei o health e mana por porcentagem. Funciona de boa, porém eu gostaria que em frente dos numeros aparecesse %.

    Exemplo: 100%, 95% ... No caso no jogo só aparece o numero da vida&mana de 0 a 100, só faltou aparecer o % na frente.

     

    Healt:

     

    if (player->getPlayerInfo(PLAYERINFO_MAXHEALTH) > 0)
        {
            msg->put<uint16_t>(uint16_t(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH)));
            msg->put<uint16_t>(100);
        }
        else
        {
            msg->put<uint16_t>(0);
            msg->put<uint16_t>(0);  
        }

     

    Mana:

    if (player->getPlayerInfo(PLAYERINFO_MAXMANA) > 0)
        {
            msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA) * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA));
            msg->put<uint16_t>(100);
        }
        else
        {
            msg->put<uint16_t>(0);
            msg->put<uint16_t>(0);
        }

     

    REP ++

  4. Boa noite galera, seguinte eu uso o Modern acc. E nele uso um sistema de compra pelo pagseguro criado pelo tatu hunter. Eu gostaria que inves de exibir o login da conta exibisse o nome do personagem. Mas teria que exibir apenas um dos personagens que existe na conta, no caso o primeiro da lista do jogador.

     

    Aqui está o PHP que uso:

    <?php
    global $config;
    require("config.php");
    $ots = POT::getInstance();
    $ots->connect(POT::DB_MYSQL, connection());
    $SQL = $ots->getDBHandle();
    $ide = new IDE;
    $ide->requireLogin();
    if($ide->isLogged()){
        $accountName = $_SESSION['name'];
        //$SQL->query('SELECT * FROM accounts WHERE name="'.$accountName.'"')->fetch();
    ?>
     
    <form target="pagseguro" method="post" action="https://pagseguro.uol.com.br/checkout/checkout.jhtml">
    <input type="hidden" name="email_cobranca" value="<?php echo $config['pagseguro']['email']; ?>">
    <input type="hidden" name="tipo" value="CP">
    <input type="hidden" name="moeda" value="BRL">
     
    <input type="hidden" name="item_id_1" value="1">
    <input type="hidden" name="item_descr_1" value="<?php echo $config['pagseguro']['produtoNome']; ?>">
     
    <input type="hidden" name="item_valor_1" value="<?php echo $config['pagseguro']['produtoValor']; ?>">
    <input type="hidden" name="item_frete_1" value="0">
    <input type="hidden" name="item_peso_1" value="0">
    <input type="hidden" name="ref_transacao" value="<?php echo $accountName; ?>">
    <table border="0" cellpadding="4" cellspacing="1" width="100%" id="#estilo"><tbody>
        <tr>
            <th colspan="2">Escolha a quantidade de pontos que deseja comprar ex: 1 ponto=1,00 Real. Lembrando voçê Comprando os pontos voçê ajuda o Server crescer:</th>
        </tr>
        <tr>
            <td width="25%">Sua conta:</td>
            <td><strong><?php echo $accountName; ?></strong></td>
        </tr>
        <tr>
            <td width="25%">Pontos:</td>
            <td>
            <input name="item_quant_1" type="text" value="1" size="5" maxlength="5">
            </td>
            </tr>
        <tr>
            <td colspan="2">
                <input type="image" src="https://p.simg.uol.com.br/out/pagseguro/i/botoes/carrinhoproprio/btnFinalizar.jpg" name="submit" alt="Pague com PagSeguro - &eacute; r&aacute;pido, gr&aacute;tis e seguro!" />
            </td>
            </tr>
    </tbody></table></form><p style="text-align: right; font-size: 10px"><a href="http://otland.net/members/tatu+hunter/" target="_blank"></a></p><?php } ?>
     
    
    

    @Yan Liima sei que tu é profissional em modern acc se poder ajudar agradeço

  5. Boa tarde galera! Eu utilizo Modern ACC em meu servidor, e tem uma script de compra que eu gostaria que exibisse o nome do personagem que o cara tem na conta, não o id da conta.

     

    No caso quando compra-se ponto o sistema seleciona-se o nick do char , sempre selecionando o primeiro nick do personagem do cara.

     

    A função que estou usando que exibe o loguin da conta é essa : $accountName = $_SESSION['name']

    Alguém sabe qual a função de exibir o do character?

  6. Em 02/07/2016 at 21:17, Yan Liima disse:

    Em data/actions/scripts/ crie um arquivo .lua e cole isto dentro:

    function onUse(cid, item, frompos, item2, topos)-------------------Configurações-----------------ItemDaTroca = 2090 -- ID do item para por na pedraItemDaTroca2 = 2086 -- ID do item para por na pedra 2ItemID = 2087 -- ID do item a ser recebidopositem = {x=327,y=902,z=7,stackpos=1} -- Posição onde o item 1 terá que ficarpositem2 = {x=328,y=902,z=7,stackpos=1} -- Posição onde o item 2 terá que ficarpositemreceived = {x=329,y=904,z=7,stackpos=1} -- A posição onde o item irá parar ao fazer a troca---------Fim das Configurações importantes-------piece1 = getThingfromPos(positem)piece2 = getThingfromPos(positem2)if item.uid == 70050 and item.itemid == 1945 and piece1.itemid == ItemDaTroca and piece2.itemid == ItemDaTroca2 thendoRemoveItem(piece1.uid,1)doRemoveItem(piece2.uid,1)doTransformItem(item.uid,item.itemid+1)doCreateItem(ItemID,1,positemreceived)elseif item.uid == 70050 and item.itemid == 1946 thendoTransformItem(item.uid,item.itemid-1)elsedoPlayerSendTextMessage(cid,22,"Desculpe você não tem o item necessário para fazer a troca.")endreturn trueend

    Em actions.xml adicione isto:

    <action uniqueid="70050" script="NOME_DO_ARQUIVO.lua" />

    Na alavanca coloque o UniqueID: 70050

     

    Qualquer erro é só dizer.

     

    Aqui funcionou vlw :D

  7. 15 minutos atrás, Danihcv disse:

    @Spring Trap, ah saquei... Então nesse caso deixa o npc.lua como tava, então.. :v

    *ou seja, remove essa checagem:

    
    if s.z ~= c.z then
    	return nil
    end

     

    Ficando assim:

    
    function getNpcDistanceToCreature(id)
    	if id == 0 or id == nil then
    		selfIdle()
    		return nil
    	end
    
    	c = getCreaturePosition(id)
    	if c == nil then
    		return nil
    	end
    
    	s = getNpcPos()
    	return math.max(math.abs(s.x-c.x), math.abs(s.y-c.y))
    end

     

     

    Funcionou obrigado man serio mesmo esse erro tava enchendo meu saco

  8. @Danihcv então nao e so ele ta dando em todos  o erro de antes voltou. Quando vou pra outra posicao Z ele da o erro

     

    Spoiler

    local focus = 0
    local talk_start = 0
    local target = 0
    local following = false
    local attacking = false

    function onThingMove(creature, thing, oldpos, oldstackpos)

    end


    function onCreatureAppear(creature)

    end


    function onCreatureDisappear(cid, pos)
          if focus == cid then
              selfSay('Good bye then.')
              focus = 0
              talk_start = 0
          end
    end


    function onCreatureTurn(creature)

    end


    function msgcontains(txt, str)
          return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
    end


    function onCreatureSay(cid, type, msg)
          msg = string.lower(msg)

          
          if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 and getCreatureCondition(cid, CONDITION_INFIGHT) == false then
            selfSay('Hey Can you give me 1 Bandit King Hood?.')    
              focus = cid
              talk_start = os.clock()

          elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
              selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

        elseif focus == cid then
            talk_start = os.clock()

                if msgcontains(msg, 'yes') then
                if getPlayerStorageValue(cid,6004) == 1 then
                selfSay('Sorry You Cant Do this quest.')    
                elseif msgcontains(msg, 'yes') then
                if doPlayerRemoveItem(cid,5879,1) == 0 then
                selfSay('Sorry Dont have that items.')    
                else        
                if doPlayerAddItem(cid,5919,1) then
                setPlayerStorageValue(cid,6004,1)
                selfSay('Thanks take this')
                focus = 0
                talk_start = 0
          end
       end
    end
            
    elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
                selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
                focus = 0
                talk_start = 0
            end
        end
    end
    function onThink()
        doNpcSetCreatureFocus(focus)
          if (os.clock() - talk_start) > 45 then
              if focus > 0 then
                  selfSay('Next Please...')
              end
                  focus = 0
          end
         if focus ~= 0 then
             if getDistanceToCreature(focus) > 5 then
                 selfSay('Good bye then.')
                 focus = 0
             end
         end
    end
     

     

  9. 1 hora atrás, Danihcv disse:

    @Spring Trap, faltou eu botar um return nil.

    Eu reli a function original aí, e a minha function ficou menor pq eu tinha pensado que uma checagem ali era desnecessária, mas não é não.
    A function correta ficaria assim:

    
    function getNpcDistanceToCreature(id)
    	if id == 0 or id == nil then
    		selfIdle()
    		return nil
    	end
    
    	c = getCreaturePosition(id)
    	if c == nil then
    		return nil
    	end
    
    	s = getNpcPos()
    	if s.z ~= c.z then
    		return nil
    	end
    	return math.max(math.abs(s.x-c.x), math.abs(s.y-c.y))
    end

     

     

    ERRO

    [Error - NpcScript Interface] 
    data/npc/scripts/mayor2.lua:onThink
    Description: 
    data/npc/scripts/mayor2.lua:85: attempt to compare number with nil
    stack traceback:
    data/npc/scripts/mayor2.lua:85: in function <data/npc/scripts/mayor2.lua:76>

     

  10. 13 horas atrás, Danihcv disse:

    @Spring Trap, estranho... Tenta assim:

     

      Mostrar conteúdo oculto
    
    
    
    
    function selfIdle()
        following = false
        attacking = false
    
        selfAttackCreature(0)
        target = 0
    end
    
    function selfSayChannel(cid, message)
        return selfSay(message, cid, false)
    end
    
    function selfMoveToCreature(id)
        if(not id or id == 0) then
            return
        end
    
        local t = getCreaturePosition(id)
        if(not t.x or t.x == nil) then
            return
        end
    
        selfMoveTo(t.x, t.y, t.z)
        return
    end
    
    function getNpcDistanceToCreature(id)
    	if id == 0 or id == nil then
    		selfIdle()
    	end
    
    	c = getCreaturePosition(id)
    	if c == nil then
    		return nil
    	end
    	s = getNpcPos()
    	return math.max(math.abs(s.x-c.x), math.abs(s.y-c.y))
    end
    
    function doMessageCheck(message, keyword)
        if(type(keyword) == "table") then
            return table.isStrIn(keyword, message)
        end
    
        local a, b = message:lower():find(keyword:lower())
        if(a ~= nil and b ~= nil) then
            return true
        end
    
        return false
    end
    
    function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
        local amount = amount or 1
        local subType = subType or 1
        local ignoreCap = ignoreCap and true or false
    
        local item = 0
        if(isItemStackable(itemid)) then
            if(isItemRune(itemid)) then
                amount = amount * subType
            end
    
            local count = amount
            repeat
                item = doCreateItemEx(itemid, math.min(100, count))
                if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
                    return 0, 0
                end
    
                count = count - math.min(100, count)
            until count == 0
            return amount, 0
        end
    
        local a = 0
        if(inBackpacks) then
            local container = doCreateItemEx(backpack, 1)
            local b = 1
            for i = 1, amount do
                item = doAddContainerItem(container, itemid, subType)
                if(itemid == ITEM_PARCEL) then
                    doAddContainerItem(item, ITEM_LABEL)
                end
    
                if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then
                    if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
                        b = b - 1
                        break
                    end
    
                    a = i
                    if(amount > i) then
                        container = doCreateItemEx(backpack, 1)
                        b = b + 1
                    end
                end
            end
    
            return a, b
        end
    
        for i = 1, amount do
            item = doCreateItemEx(itemid, subType)
            if(itemid == ITEM_PARCEL) then
                doAddContainerItem(item, ITEM_LABEL)
            end
    
            if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
                break
            end
    
            a = i
        end
    
        return a, 0
    end
    
    function doRemoveItemIdFromPos(id, n, position)
        local thing = getThingFromPos({x = position.x, y = position.y, z = position.z, stackpos = 1})
        if(thing.itemid ~= id) then
            return false
        end
    
        doRemoveItem(thing.uid, n)
        return true
    end
    
    function getNpcName()
        return getCreatureName(getNpcId())
    end
    
    function getNpcPos()
        return getCreaturePosition(getNpcId())
    end
    
    function selfGetPosition()
        local t = getNpcPos()
        return t.x, t.y, t.z
    end
    
    msgcontains = doMessageCheck
    moveToPosition = selfMoveTo
    moveToCreature = selfMoveToCreature
    selfMoveToPosition = selfMoveTo
    selfGotoIdle = selfIdle
    isPlayerPremiumCallback = isPremium
    doPosRemoveItem = doRemoveItemIdFromPos
    doNpcBuyItem = doPlayerRemoveItem
    doNpcSetCreatureFocus = selfFocus
    getNpcCid = getNpcId
    getDistanceTo = getNpcDistanceTo
    getDistanceToCreature = getNpcDistanceToCreature

     

     

     

    Funcionou man pqp obrigado mesmo, de coracao man sempre salvando minha vida kk <3

    Agora ta de boa nao da mais erro e o npc funciona normal

     

    So que mais pra frente daria bug nao ne?

    ja que o original e esse:

    function getNpcDistanceToCreature(id)
    	if(not id or id == 0) then
    		selfIdle()
    		return nil
    	end
    
    	local c = getCreaturePosition(id)
    	if(not c.x or c.x == 0) then
    		return nil
    	end
    
    	local s = getCreaturePosition(getNpcId())
    	if(not s.x or s.x == 0 or s.z ~= c.z) then
    		return nil
    	end
    
    	return math.max(math.abs(s.x - c.x), math.abs(s.y - c.y))
    end

    E tu fez uma function bem menor

  11. 7 minutos atrás, Danihcv disse:

    O erro tava no código que teu amigo mandou (bem que eu tinha achado uma coisa estranha nele).

     

    Vê se o npc.lua assim funciona:

      Ocultar conteúdo
    function selfIdle()    following = false    attacking = false    selfAttackCreature(0)    target = 0endfunction selfSayChannel(cid, message)    return selfSay(message, cid, false)endfunction selfMoveToCreature(id)    if(not id or id == 0) then        return    end    local t = getCreaturePosition(id)    if(not t.x or t.x == nil) then        return    end    selfMoveTo(t.x, t.y, t.z)    returnendfunction getNpcDistanceToCreature(id)	if id == 0 or id == nil then		selfIdle()	end	c = getCreaturePosition(id)	if c == nil then		return nil	end	s = selfGetPosition()	return math.max(math.abs(s.x-c.x), math.abs(s.y-c.y))endfunction doMessageCheck(message, keyword)    if(type(keyword) == "table") then        return table.isStrIn(keyword, message)    end    local a, b = message:lower():find(keyword:lower())    if(a ~= nil and b ~= nil) then        return true    end    return falseendfunction doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)    local amount = amount or 1    local subType = subType or 1    local ignoreCap = ignoreCap and true or false    local item = 0    if(isItemStackable(itemid)) then        if(isItemRune(itemid)) then            amount = amount * subType        end        local count = amount        repeat            item = doCreateItemEx(itemid, math.min(100, count))            if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then                return 0, 0            end            count = count - math.min(100, count)        until count == 0        return amount, 0    end    local a = 0    if(inBackpacks) then        local container = doCreateItemEx(backpack, 1)        local b = 1        for i = 1, amount do            item = doAddContainerItem(container, itemid, subType)            if(itemid == ITEM_PARCEL) then                doAddContainerItem(item, ITEM_LABEL)            end            if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then                if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then                    b = b - 1                    break                end                a = i                if(amount > i) then                    container = doCreateItemEx(backpack, 1)                    b = b + 1                end            end        end        return a, b    end    for i = 1, amount do        item = doCreateItemEx(itemid, subType)        if(itemid == ITEM_PARCEL) then            doAddContainerItem(item, ITEM_LABEL)        end        if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then            break        end        a = i    end    return a, 0endfunction doRemoveItemIdFromPos(id, n, position)    local thing = getThingFromPos({x = position.x, y = position.y, z = position.z, stackpos = 1})    if(thing.itemid ~= id) then        return false    end    doRemoveItem(thing.uid, n)    return trueendfunction getNpcName()    return getCreatureName(getNpcId())endfunction getNpcPos()    return getCreaturePosition(getNpcId())endfunction selfGetPosition()    local t = getNpcPos()    return t.x, t.y, t.zendmsgcontains = doMessageCheckmoveToPosition = selfMoveTomoveToCreature = selfMoveToCreatureselfMoveToPosition = selfMoveToselfGotoIdle = selfIdleisPlayerPremiumCallback = isPremiumdoPosRemoveItem = doRemoveItemIdFromPosdoNpcBuyItem = doPlayerRemoveItemdoNpcSetCreatureFocus = selfFocusgetNpcCid = getNpcIdgetDistanceTo = getNpcDistanceTogetDistanceToCreature = getNpcDistanceToCreature

     

     

     

    Agora deu esse:

    [Error - NpcScript Interface] data/npc/scripts/mayor2.lua:onCreatureSayDescription: data/npc/lib/npc.lua:40: attempt to index global 's' (a number value)stack traceback:data/npc/lib/npc.lua:40: in function 'getNpcDistanceToCreature'data/npc/scripts/mayor2.lua:40: in function <data/npc/scripts/mayor2.lua:36>

    Ta foda man :( 

  12. 39 minutos atrás, Danihcv disse:

    @Spring Trap, fiz a adaptação. Vê se resolve:

      Ocultar conteúdo
     function selfIdle()    following = false    attacking = false    selfAttackCreature(0)    target = 0endfunction selfSayChannel(cid, message)    return selfSay(message, cid, false)endfunction selfMoveToCreature(id)    if(not id or id == 0) then        return    end    local t = getCreaturePosition(id)    if(not t.x or t.x == nil) then        return    end    selfMoveTo(t.x, t.y, t.z)    returnendfunction getNpcDistanceToCreature(id)	if id == 0 or id == nil then		selfIdle()	end	cx, cy, cz = getCreaturePosition(id)	if cx == nil then		return nil	endsx, sy, sz = selfGetPosition()	return math.max(math.abs(sx-cx), math.abs(sy-cy))endfunction doMessageCheck(message, keyword)    if(type(keyword) == "table") then        return table.isStrIn(keyword, message)    end    local a, b = message:lower():find(keyword:lower())    if(a ~= nil and b ~= nil) then        return true    end    return falseendfunction doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)    local amount = amount or 1    local subType = subType or 1    local ignoreCap = ignoreCap and true or false    local item = 0    if(isItemStackable(itemid)) then        if(isItemRune(itemid)) then            amount = amount * subType        end        local count = amount        repeat            item = doCreateItemEx(itemid, math.min(100, count))            if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then                return 0, 0            end            count = count - math.min(100, count)        until count == 0        return amount, 0    end    local a = 0    if(inBackpacks) then        local container = doCreateItemEx(backpack, 1)        local b = 1        for i = 1, amount do            item = doAddContainerItem(container, itemid, subType)            if(itemid == ITEM_PARCEL) then                doAddContainerItem(item, ITEM_LABEL)            end            if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then                if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then                    b = b - 1                    break                end                a = i                if(amount > i) then                    container = doCreateItemEx(backpack, 1)                    b = b + 1                end            end        end        return a, b    end    for i = 1, amount do        item = doCreateItemEx(itemid, subType)        if(itemid == ITEM_PARCEL) then            doAddContainerItem(item, ITEM_LABEL)        end        if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then            break        end        a = i    end    return a, 0endfunction doRemoveItemIdFromPos(id, n, position)    local thing = getThingFromPos({x = position.x, y = position.y, z = position.z, stackpos = 1})    if(thing.itemid ~= id) then        return false    end    doRemoveItem(thing.uid, n)    return trueendfunction getNpcName()    return getCreatureName(getNpcId())endfunction getNpcPos()    return getCreaturePosition(getNpcId())endfunction selfGetPosition()    local t = getNpcPos()    return t.x, t.y, t.zendmsgcontains = doMessageCheckmoveToPosition = selfMoveTomoveToCreature = selfMoveToCreatureselfMoveToPosition = selfMoveToselfGotoIdle = selfIdleisPlayerPremiumCallback = isPremiumdoPosRemoveItem = doRemoveItemIdFromPosdoNpcBuyItem = doPlayerRemoveItemdoNpcSetCreatureFocus = selfFocusgetNpcCid = getNpcIdgetDistanceTo = getNpcDistanceTogetDistanceToCreature = getNpcDistanceToCreature

     

     

     

    Deu erro ;/:

    agora quando falo HI ele nao diz nada

     

    ERRO:

    Error - NpcScript Interface] data/npc/scripts/mayor2.lua:onCreatureSayDescription: stack traceback:data/npc/lib/npc.lua:40: in function 'getDistanceToCreature'data/npc/scripts/mayor2.lua:40: in function <data/npc/scripts/mayor2.lua:36>

    Tentei trocar a função la do mayor2 de getDistanceToCreature para getNpcDistanceToCreature e deu isso

    [Error - NpcScript Interface] data/npc/scripts/mayor2.lua:onCreatureSayDescription: data/npc/lib/npc.lua:40: attempt to perform arithmetic on global 'cx' (a table value)stack traceback:data/npc/lib/npc.lua:40: in function 'getNpcDistanceToCreature'data/npc/scripts/mayor2.lua:40: in function <data/npc/scripts/mayor2.lua:36>

    a linha 40 do mayor2 é essa

    if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 and getCreatureCondition(cid, CONDITION_INFIGHT) == false then

    Troquei por

    if msgcontains(msg, 'hi') then

    E o npc voltou falar comigo so que deu varios erros na distro:

    [Error - NpcScript Interface] data/npc/scripts/mayor2.lua:onThinkDescription: data/npc/lib/npc.lua:40: attempt to perform arithmetic on global 'cx' (a table value)stack traceback:data/npc/lib/npc.lua:40: in function 'getNpcDistanceToCreature'data/npc/scripts/mayor2.lua:85: in function <data/npc/scripts/mayor2.lua:76>

     

  13. Gente eu descobri qual é o motivo do erro, na verdade todos os npcs igual a este estão dando erro, até o que eu disse q nao estava

    Ele funciona normal se tu falar com o npc e tals e ir embora sem falar bye. O problema é que se você falar HI e ir em bora para outra posição Z ele vai fica dando erro na distro

    até o jogador estiver na posição Z que o npc esta ai o npc irá dar good bye automaticamente

     

    Achei que o outro npc nao estava dando erro porque ele fica na posição Z: 7 e nao tem escadas por perto para subir o solo e descer, já o mayor tinha por isso dava erro

     

    Meu npc.lua

    Spoiler

    function selfIdle()
        following = false
        attacking = false

        selfAttackCreature(0)
        target = 0
    end

    function selfSayChannel(cid, message)
        return selfSay(message, cid, false)
    end

    function selfMoveToCreature(id)
        if(not id or id == 0) then
            return
        end

        local t = getCreaturePosition(id)
        if(not t.x or t.x == nil) then
            return
        end

        selfMoveTo(t.x, t.y, t.z)
        return
    end

    function getNpcDistanceToCreature(id)
        if(not id or id == 0) then
            selfIdle()
            return nil
        end

        local c = getCreaturePosition(id)
        if(not c.x or c.x == 0) then
            return nil
        end

        local s = getCreaturePosition(getNpcId())
        if(not s.x or s.x == 0 or s.z ~= c.z) then
            return nil
        end

        return math.max(math.abs(s.x - c.x), math.abs(s.y - c.y))
    end

    function doMessageCheck(message, keyword)
        if(type(keyword) == "table") then
            return table.isStrIn(keyword, message)
        end

        local a, b = message:lower():find(keyword:lower())
        if(a ~= nil and b ~= nil) then
            return true
        end

        return false
    end

    function doNpcSellItem(cid, itemid, amount, subType, ignoreCap, inBackpacks, backpack)
        local amount = amount or 1
        local subType = subType or 1
        local ignoreCap = ignoreCap and true or false

        local item = 0
        if(isItemStackable(itemid)) then
            if(isItemRune(itemid)) then
                amount = amount * subType
            end

            local count = amount
            repeat
                item = doCreateItemEx(itemid, math.min(100, count))
                if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
                    return 0, 0
                end

                count = count - math.min(100, count)
            until count == 0
            return amount, 0
        end

        local a = 0
        if(inBackpacks) then
            local container = doCreateItemEx(backpack, 1)
            local b = 1
            for i = 1, amount do
                item = doAddContainerItem(container, itemid, subType)
                if(itemid == ITEM_PARCEL) then
                    doAddContainerItem(item, ITEM_LABEL)
                end

                if(isInArray({(getContainerCapById(backpack) * b), amount}, i)) then
                    if(doPlayerAddItemEx(cid, container, ignoreCap) ~= RETURNVALUE_NOERROR) then
                        b = b - 1
                        break
                    end

                    a = i
                    if(amount > i) then
                        container = doCreateItemEx(backpack, 1)
                        b = b + 1
                    end
                end
            end

            return a, b
        end

        for i = 1, amount do
            item = doCreateItemEx(itemid, subType)
            if(itemid == ITEM_PARCEL) then
                doAddContainerItem(item, ITEM_LABEL)
            end

            if(doPlayerAddItemEx(cid, item, ignoreCap) ~= RETURNVALUE_NOERROR) then
                break
            end

            a = i
        end

        return a, 0
    end

    function doRemoveItemIdFromPos(id, n, position)
        local thing = getThingFromPos({x = position.x, y = position.y, z = position.z, stackpos = 1})
        if(thing.itemid ~= id) then
            return false
        end

        doRemoveItem(thing.uid, n)
        return true
    end

    function getNpcName()
        return getCreatureName(getNpcId())
    end

    function getNpcPos()
        return getCreaturePosition(getNpcId())
    end

    function selfGetPosition()
        local t = getNpcPos()
        return t.x, t.y, t.z
    end

    msgcontains = doMessageCheck
    moveToPosition = selfMoveTo
    moveToCreature = selfMoveToCreature
    selfMoveToPosition = selfMoveTo
    selfGotoIdle = selfIdle
    isPlayerPremiumCallback = isPremium
    doPosRemoveItem = doRemoveItemIdFromPos
    doNpcBuyItem = doPlayerRemoveItem
    doNpcSetCreatureFocus = selfFocus
    getNpcCid = getNpcId
    getDistanceTo = getNpcDistanceTo
    getDistanceToCreature = getNpcDistanceToCreature
     

     

    Um amigo meu disse pra mim tentar adaptar essa função:

    function getDistanceToCreature(id)	if id == 0 or id == nil then		selfGotoIdle()	end	cx, cy, cz = getCreaturePosition(id)	if cx == nil then		return nil	end	sx, sy, sz = selfGetPosition()	return math.max(math.abs(sx-cx), math.abs(sy-cy))	end

    Alguém pode ajudaaarr por favor nao sei o que fazer :/ 

     

    @Danihcv pode ajudar?

  14. 40 minutos atrás, Mendiguinho91 disse:
    local focus = 0local talk_start = 0local target = 0local following = falselocal attacking = falsefunction onThingMove(creature, thing, oldpos, oldstackpos)endfunction onCreatureAppear(creature)endfunction onCreatureDisappear(cid, pos)      if focus == cid then          selfSay('Good bye then.')          focus = 0          talk_start = 0      endendfunction onCreatureTurn(creature)endfunction msgcontains(txt, str)      return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))endfunction onCreatureSay(cid, type, msg)      msg = string.lower(msg)    if msgcontains(msg, 'hi') then	selfSay('Hey Can you give me 1 Bandit King Hood?.')              focus = cid          talk_start = os.clock()      elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then          selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')    elseif focus == cid then        talk_start = os.clock()	if msgcontains(msg, 'yes') then        if getPlayerStorageValue(cid,6004) >= 1 then        selfSay('Sorry You Cant Do this quest.') return true            elseif not doPlayerRemoveItem(cid, 5879, 1) then        selfSay('Sorry Dont have that items.') return true    	end         doPlayerAddItem(cid,5919,1)         setPlayerStorageValue(cid,6004,1)         selfSay('Thanks take this')         focus = 0         talk_start = 0end     elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then            selfSay('Good bye, ' .. getCreatureName(cid) .. '!')            focus = 0            talk_start = 0        endendfunction onThink()    doNpcSetCreatureFocus(focus)      if (os.clock() - talk_start) > 45 then          if focus > 0 then              selfSay('Next Please...')          end              focus = 0      end     if focus ~= 0 then         if getDistanceToCreature(focus) > 5 then             selfSay('Good bye then.')             focus = 0         end     endend

     

     

    Continua com o mesmo erro so que em outra linha

    [Error - NpcScript Interface] data/npc/scripts/mayor2.lua:onThinkDescription: ata/npc/scripts/mayor2.lua:64: attempt to compare number with nilstack traceback:data/npc/scripts/mayor2.lua:64: in function <data/npc/scripts/mayor2.lua:55>

    E nao tem como dar bye mais

     

    O erro sempre causava quando o personagem nao dava BYE e ia pra bem longe. creio que seja erro de distance

  15. 12 horas atrás, Danihcv disse:

    @Spring Trap, como que tá os arquivos .xml desses npcs?

     

    Todos estão do mesmo jeito so muda o nome e a looktype

    <npc name="Mayor" script="data/npc/scripts/mayor2.lua" walkinterval="2000" floorchange="0" access="5" level="1" maglevel="1">
        <health now="150" max="150"/>
        <look type="314" head="132" body="79" legs="97" feet="132" corpse="2212"/>
    </npc>

     

  16. Galera sera q alguem pode me ajudar? estou tendo problemas com alguns npcs do meu servidor. Eles funciona normal mais quando eu falo HI e vou pra bem longe sem falar bye eles ainda fica como se tivesse falando comigo, quando eu volto eles ainda estao esperando respostas de mim. 

     

    E na distro fica varias vezes repetindo o mesmo erro

     

    ERRO:

    Spoiler

    [Error - NpcScript Interface] 
    data/npc/scripts/mayor2.lua:onThink
    Description: 
    data/npc/scripts/mayor2.lua:92: attempt to compare number with nil
    stack traceback:
    data/npc/scripts/mayor2.lua:92: in function <data/npc/scripts/mayor2.lua:83>

     

    Script mayor2:

    Spoiler

    local focus = 0
    local talk_start = 0
    local target = 0
    local following = false
    local attacking = false

    function onThingMove(creature, thing, oldpos, oldstackpos)

    end


    function onCreatureAppear(creature)

    end


    function onCreatureDisappear(cid, pos)
          if focus == cid then
              selfSay('Good bye then.')
              focus = 0
              talk_start = 0
          end
    end


    function onCreatureTurn(creature)

    end


    function msgcontains(txt, str)
          return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
    end


    function onCreatureSay(cid, type, msg)
          msg = string.lower(msg)

      
        if msgcontains(msg, 'hi') then

    selfSay('Hey Can you give me 1 Bandit King Hood?.')    
              focus = cid
              talk_start = os.clock()

          elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
              selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')

        elseif focus == cid then
            talk_start = os.clock()

                            if msgcontains(msg, 'yes') then
                if getPlayerStorageValue(cid,6004) == 1 then
                
            selfSay('Sorry You Cant Do this quest.')    
                elseif msgcontains(msg, 'yes') then
                           if doPlayerRemoveItem(cid,5879,1) == 0 then
                           selfSay('Sorry Dont have that items.')    

    else        
                    if doPlayerAddItem(cid,5919,1) then
                    
                        setPlayerStorageValue(cid,6004,1)
                                        selfSay('Thanks take this')
                        focus = 0
                        talk_start = 0

                
    end
    end
    end
            
    elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
                selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
                focus = 0
                talk_start = 0
            end
        end

    end
    function onThink()
        doNpcSetCreatureFocus(focus)
          if (os.clock() - talk_start) > 45 then
              if focus > 0 then
                  selfSay('Next Please...')
              end
                  focus = 0
          end
         if focus ~= 0 then
             if getDistanceToCreature(focus) > 5 then
                 selfSay('Good bye then.')
                 focus = 0
             end
         end
    end
     

     

    Tem varios npc igual a esse que da esse erro na distro tem um parecido mais nao da, e esta a mesma coisa

     

    Esse nao da erro:

    Spoiler

    local focus = 0
    local talk_start = 0
    local target = 0
    local following = false
    local attacking = false

    function onThingMove(creature, thing, oldpos, oldstackpos)

    end


    function onCreatureAppear(creature)

    end


    function onCreatureDisappear(cid, pos)
          if focus == cid then
              selfSay('Hey!.')
              focus = 0
              talk_start = 0
          end
    end


    function onCreatureTurn(creature)

    end


    function msgcontains(txt, str)
          return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
    end


    function onCreatureSay(cid, type, msg)
          msg = string.lower(msg)

          if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 and getCreatureCondition(cid, CONDITION_INFIGHT) == false then
            
                selfSay('I see you want to fight with me, But not in the town???')
                focus = cid
                talk_start = os.clock()
            

          elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
              selfSay('Sorry, ' .. getCreatureName(cid) .. '! ????????.')

          elseif focus == cid then
            talk_start = os.clock()

                if msgcontains(msg, 'yes') then
                    if getPlayerStorageValue(cid,8000) == 16 then
                        doTeleportThing(cid, { x=46, y=553, z=7})
                        selfSay('Yes!')
                        focus = 0
                        talk_start = 0
                    else
                        selfSay('Sorry You Cant Do this saga.')
                    end

            elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
                selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
                focus = 0
                talk_start = 0
            end
        end
    end

    function onThink()
        doNpcSetCreatureFocus(focus)
          if (os.clock() - talk_start) > 45 then
              if focus > 0 then
                  selfSay('Next Please...')
              end
                  focus = 0
          end
         if focus ~= 0 then
             if getDistanceToCreature(focus) > 5 then
                 selfSay('Good bye then.')
                 focus = 0
             end
         end
    end
     

     

    Rep + pra quem ajudar

    @Danihcv @dalvorsn @Yan Liima

  17. Eu tava querendo esse servidor a um bom tempo, hoje nem tanto kk mais mesmo assim valeu man REP +

     

    2 horas atrás, Bruno Nasc disse:

    opa fion, Administradores peço que removam o conteúdo, nenhum dos editores ou verdadeiros donos permitiu isso ! quanto ao jovem ai, Boa sorte nessa sua jornada 

    Mais ele n era da equipe ou so ajudou vc? ué

    Isso se tu for o bruno mesmo pq tem cada baba ovo nesse servidor kkkkkkk

  18. Galera queria ajuda com um Npc, tipo ele funciona normal eu digo Hi ele diz: Hello Teste. say travel. eu digo travel ele diz: Eu posso levá-lo para? city 1 eu digo city 1 e ele me leva normal.

    Porem gostaria que o npc verificasse se ele tem X storage se ele nao tiver ele nao e teleportado e ele manda uma mensagem pro player: Voce nao tem tal storage.

     

    Script:

    Spoiler

    local keywordHandler = KeywordHandler:new()
    local npcHandler = NpcHandler:new(keywordHandler)
    NpcSystem.parseParameters(npcHandler)

    -- OTServ event handling functions start
    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
    -- OTServ event handling functions end

    local travelNode = keywordHandler:addKeyword({'travel'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Eu posso levá-lo para? {city 1}'})
    travelNode:addChildKeyword({'city 1'}, StdModule.travel, {npcHandler = npcHandler, premium = false, level = 1, cost = 0, destination = {x=463, y=446, z=5} })
        
    -- Makes sure the npc reacts when you say hi, bye etc.
    npcHandler:addModule(FocusModule:new())

     

    Ah e se for possivel gostaria de saber se tem como arrumar o BUG de um jogador dizer que vai pra tal cidade e o outro diz ao mesmo tempo, ai quando o outro jogador diz yes vai pra cidade errada que foi a cidade que o outro jogador disse ...

  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...