Ir para conteúdo

klbkevinklb

Campones
  • Total de itens

    44
  • Registro em

  • Última visita

  • Dias Ganhos

    3

Posts postados por klbkevinklb

  1. Em 05/11/2023 em 19:40, wenderotpoke disse:

    Cara não sei se e possivel mas queria um sistema de regen fora o base que o proprio game ja tem né no vactions quando ta de barriga cheia. queria que o food tivesse um regen dele mesmo tipo por exemplo a Pizza dar 10 de vida /s e o hotdog dar 7.5. a ideia é usar esses numeros do proprio feed de cada item como regen base

     

      Ocultar conteúdo

    local FOODS =
    {
        [2362] = {80, "Crunch."},
        [2666] = {150, "Munch."},
        [2667] = {120, "Munch."},
        [2668] = {100, "Mmmm."},
        [2669] = {170, "Munch."},
        [2670] = {40, "Gulp."},
        [2671] = {300, "Chomp."},
        [2672] = {600, "Chomp."},
        [2673] = {50, "Yum."},
        [2674] = {60, "Yum."},
        [2675] = {130, "Yum."},
        [2676] = {80, "Yum."},
        [2677] = {10, "Yum."},
        [2678] = {180, "Slurp."},
        [2679] = {10, "Yum."},
        [2680] = {20, "Yum."},
        [2681] = {90, "Yum."},
        [2682] = {200, "Yum."},
        [2683] = {170, "Munch."},
        [2684] = {80, "Crunch."},
        [2685] = {60, "Munch."},
        [2686] = {90, "Crunch."},
        [2687] = {20, "Crunch."},
        [2688] = {90, "Munch."},
        [2689] = {100, "Crunch."},
        [2690] = {30, "Crunch."},
        [2691] = {80, "Crunch."},
        [2792] = {60, "Munch."},
        [2793] = {90, "Munch."},
        [2695] = {60, "Gulp."},
        [2696] = {90, "Smack."},
        [2787] = {90, "Munch."},
        [2788] = {40, "Munch."},
        [2789] = {220, "Munch."},
        [2790] = {300, "Munch."},
        [2791] = {300, "Munch."},
        [2792] = {60, "Munch."},
        [2794] = {30, "Munch."},
        [2795] = {360, "Munch."},
        [2796] = {50, "Munch."},
        [2793] = {90, "Munch."},
        [5097] = {40, "Yum."},
        [6125] = {80, "Gulp."},
        [6278] = {100, "Mmmm."},
        [6279] = {150, "Mmmm."},
        [6393] = {120, "Mmmm."},
        [6394] = {150, "Mmmm."},
        [6501] = {200, "Mmmm."},
        [6541] = {60, "Gulp."},
        [6542] = {60, "Gulp."},
        [6543] = {60, "Gulp."},
        [6544] = {60, "Gulp."},
        [6545] = {60, "Gulp."},
        --[6569] = {100, "Mmmm."}, Retirado para script de rare candy
        [6574] = {40, "Mmmm."},
        [7158] = {150, "Munch."},
        [7159] = {130, "Munch."},
        [7372] = {70, "Yum."},
        [7373] = {70, "Yum."},
        [7374] = {70, "Yum."},
        [7375] = {70, "Yum."},
        [7376] = {70, "Yum."},
        [7377] = {70, "Yum."},
        [7909] = {40, "Crunch."},
        [8838] = {70, "Gulp."},
        [8839] = {50, "Yum."},
        [8840] = {20, "Yum."},
        [8841] = {30, "Urgh."},
        [8842] = {30, "Munch."},
        [8843] = {30, "Crunch."},
        [8844] = {30, "Gulp."},
        [8845] = {20, "Munch."},
        [8847] = {110, "Yum."},
        [12211] = {180, "Mmmm."},
        [12213] = {130, "Munch."},
        [12214] = {80, "Crunch."},
        [12215] = {100, "Munch."},
        [12216] = {60, "Gulp."},
        [12217] = {50, "Yum."},
        [12218] = {150, "Crunch."},
        [12219] = {70, "Mmmm."},
        [12220] = {70, "Mmmm."},
        [12221] = {70, "Mmmm."},
        [12222] = {240, "Crunch."},
    }

    local pos = getThingPos(cid)
    function onUse(cid, item, fromPosition, itemEx, toPosition)
        local food = FOODS[item.itemid]
        if(not food) then
            return false
        end

        local thing = getCreatureSummons(cid)[1] or cid

            if isPlayer(thing) then

                if((getPlayerFood(cid) + food[1]) >= 1000) then
                    doPlayerSendCancel(cid, "You are full.")
                return true
                end

                doPlayerFeed(cid, food[1] * 4)
                doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1)
                doRemoveItem(item.uid, 1)

            elseif isSummon(thing) then

                local feed = food[1]

                if getPlayerStorageValue(thing, 1009) - feed < 0 then
                    doSendMagicEffect(getThingPos(thing), 169)
                    doSendMagicEffect(pos, 169)
                    local newh = getPlayerStorageValue(thing, 1008) - math.ceil(feed / 😎
                    if newh <= 1 then newh = 1 end
                    setPlayerStorageValue(thing, 1008, newh)
                return true
                end

                setPlayerStorageValue(thing, 1009, getPlayerStorageValue(thing, 1009) - feed)
                setPlayerStorageValue(thing, 1008, getPlayerStorageValue(thing, 1008) + 1)
                doCreatureSay(thing, food[2], TALKTYPE_ORANGE_1)
                doRemoveItem(item.uid, 1)
            end
                    
    return true
    end

     

    local FOODS =
    {
        [2362] = {80, "Crunch.", 10},  -- Pizza
        [2666] = {150, "Munch.", 5},   -- Hamburger
        [2667] = {120, "Munch.", 7},   -- Cheeseburger
        [2668] = {100, "Mmmm.", 8},    -- Hot Dog
        [2669] = {170, "Munch.", 6},   -- Sandwich
        [2670] = {40, "Gulp.", 15},    -- Milkshake
        [2671] = {300, "Chomp.", 3},   -- Ice Cream
        [2672] = {600, "Chomp.", 2},   -- Cake
        [2673] = {50, "Yum.", 12},     -- Cookie
        [2674] = {60, "Yum.", 10},     -- Donut
        [2675] = {130, "Yum.", 7},     -- Chocolate Bar
        [2676] = {80, "Yum.", 9},      -- Candy
        [2677] = {10, "Yum.", 20},     -- Lollipop
        [2678] = {180, "Slurp.", 6},   -- Soda
        [2679] = {10, "Yum.", 18},     -- Chips
        [2680] = {20, "Yum.", 15},     -- Popcorn
        [2681] = {90, "Yum.", 8},      -- Pretzel
        [2682] = {200, "Yum.", 5},     -- Pie
        [2683] = {170, "Munch.", 5},   -- Pancake
        [2684] = {80, "Crunch.", 10},  -- Waffle
        [2685] = {60, "Munch.", 8},    -- French Fries
        [2686] = {90, "Crunch.", 10},  -- Onion Rings
        [2687] = {20, "Crunch.", 12},  -- Nachos
        [2688] = {90, "Munch.", 7},    -- Chicken Nuggets
        [2689] = {100, "Crunch.", 8},  -- Fish Sticks
        [2690] = {30, "Crunch.", 12},  -- Potato Chips
        [2691] = {80, "Crunch.", 9},   -- Tortilla Chips
        [2792] = {60, "Munch.", 8},    -- Brownie
        [2793] = {90, "Munch.", 6},    -- Cupcake
        [2695] = {60, "Gulp.", 8},     -- Smoothie
        [2696] = {90, "Smack.", 6},    -- Fruit Salad
        [2787] = {90, "Munch.", 7},    -- Salad
        [2788] = {40, "Munch.", 10},   -- Soup
        [2789] = {220, "Munch.", 4},   -- Ramen
        [2790] = {300, "Munch.", 3},   -- Sushi
        [2791] = {300, "Munch.", 3},   -- Burrito
        [2794] = {30, "Munch.", 10},   -- Tacos
        [2795] = {360, "Munch.", 2},   -- Pasta
        [2796] = {50, "Munch.", 8},    -- Mac & Cheese
        [5097] = {40, "Yum.", 10},     -- Bread
        [6125] = {80, "Gulp.", 7},     -- Milk
        [6278] = {100, "Mmmm.", 8},    -- Orange Juice
        [6279] = {150, "Mmmm.", 6},    -- Apple Juice
        [6393] = {120, "Mmmm.", 7},    -- Grape Juice
        [6394] = {150, "Mmmm.", 6},    -- Fruit Punch
        [6501] = {200, "Mmmm.", 5},    -- Energy Drink
        [6541] = {60, "Gulp.", 8},     -- Water
        [6542] = {60, "Gulp.", 8},     -- Coconut Water
        [6543] = {60, "Gulp.", 8},     -- Sports Drink
        [6544] = {60, "Gulp.", 8},     -- Tea
        [6545] = {60, "Gulp.", 8},     -- Coffee
        [6574] = {40, "Mmmm.", 10},    -- Milkshake (Strawberry)
        [7158] = {150, "Munch.", 6},   -- Milkshake (Vanilla)
        [7159] = {130, "Munch.", 6},   -- Milkshake (Chocolate)
        [7372] = {70, "Yum.", 9},      -- Milkshake (Banana)
        [7373] = {70, "Yum.", 9},      -- Milkshake (Mint Chocolate Chip)
        [7374] = {70, "Yum.", 9},      -- Milkshake (Caramel)
        [7375] = {70, "Yum.", 9},      -- Milkshake (Cookies & Cream)
        [7376] = {70, "Yum.", 9},      -- Milkshake (Peanut Butter)
        [7377] = {70, "Yum.", 9},      -- Milkshake (Strawberry Banana)
        [7909] = {40, "Crunch.", 10},  -- Milkshake (Blueberry)
        [8838] = {70, "Gulp.", 7},     -- Milkshake (Raspberry)
        [8839] = {50, "Yum.", 9},      -- Milkshake (Blackberry)
        [8840] = {20, "Yum.", 15},     -- Milkshake (Peach)
        [8841] = {30, "Urgh.", 20},    -- Milkshake (Mango)
        [8842] = {30, "Munch.", 10},   -- Milkshake (Pineapple)
        [8843] = {30, "Crunch.", 10},  -- Milkshake (Watermelon)
        [8844] = {30, "Gulp.", 12},    -- Milkshake (Cantaloupe)
        [8845] = {20, "Munch.", 10},   -- Milkshake (Kiwi)
      	[8847] = {110, "Yum.", 8},      -- Milkshake (Coconut)
        [12211] = {180, "Mmmm.", 6},   -- Milkshake (Mango-Peach)
        [12213] = {130, "Munch.", 7},   -- Milkshake (Berry Blast)
        [12214] = {80, "Crunch.", 9},   -- Milkshake (Tropical Twist)
        [12215] = {100, "Munch.", 7},   -- Milkshake (Pineapple-Banana)
        [12216] = {60, "Gulp.", 9},     -- Milkshake (Cherry)
        [12217] = {50, "Yum.", 10},     -- Milkshake (Orange)
        [12218] = {150, "Crunch.", 6},  -- Milkshake (Grape)
        [12219] = {70, "Mmmm.", 7},     -- Milkshake (Strawberry)
        [12220] = {70, "Mmmm.", 7},     -- Milkshake (Blueberry)
        [12221] = {70, "Mmmm.", 7},     -- Milkshake (Raspberry)
        [12222] = {240, "Crunch.", 5},  -- Milkshake (Mixed Berry) -- o 5 é a quantia de regen
    }
    
    function onUse(cid, item, fromPosition, itemEx, toPosition)
        local food = FOODS[item.itemid]
        if not food then
            return false
        end
    
        local thing = getCreatureSummons(cid)[1] or cid
    
        if isPlayer(thing) then
            if getPlayerFood(cid) + food[1] >= 1000 then
                doPlayerSendCancel(cid, "You are full.")
                return true
            end
            doPlayerFeed(cid, food[1] * 4)
            doCreatureSay(cid, food[2], TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid, 1)
    
        elseif isSummon(thing) then
            local feed = food[1]
            local regeneration = food[3] or 0  -- Regeneração padrão
    
            if getPlayerStorageValue(thing, 1009) - feed < 0 then
                doSendMagicEffect(getThingPos(thing), 169)
                doSendMagicEffect(pos, 169)
                local newh = getPlayerStorageValue(thing, 1008) - math.ceil(feed / 😎
                if newh <= 1 then newh = 1 end
                setPlayerStorageValue(thing, 1008, newh)
                return true
            end
    
            setPlayerStorageValue(thing, 1009, getPlayerStorageValue(thing, 1009) - feed)
            setPlayerStorageValue(thing, 1008, getPlayerStorageValue(thing, 1008) + regeneration) -- Incremento baseado na regeneração específica da comida
            doCreatureSay(thing, food[2], TALKTYPE_ORANGE_1)
            doRemoveItem(item.uid, 1)
        end
    
        return true
    end
    

     

  2. 21 horas atrás, Sacani disse:

    Sim, você está na área errada. Aqui é para pedir ajuda, ou seja, suporte.

    De qualquer forma, tomei a liberdade de organizar o script:

      Ocultar conteúdo
    local cfg = {
        msg = "Voce nao pode passar aqui de fly ou ride.",
    }
    
    function onStepIn(cid, item, position, fromPosition)
        if getPlayerStorageValue(cid, 17000) == 1 or getPlayerStorageValue(cid, 17001) == 1 then
            doTeleportThing(cid, fromPosition, true)
            doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, cfg.msg)
        end
    
        return true
    end

     

     

    Okay, muito obrigado...deus o abençoe.

  3. function onStepIn(cid, item, position, fromPosition)
    
    if getPlayerStorageValue(cid, 17000) == 1 or getPlayerStorageValue(cid, 17001) == 1 then
    doTeleportThing(cid, fromPosition, true)
    doSendMagicEffect(getThingPos(cid), CONST_ME_MAGIC_RED)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Voce nao pode passar aqui de fly ou ride.")
    
    end
    return TRUE
    end

     

    Bom galera, esse script nada mais é que um piso que cancela de voce poder entrar em algum local de fly ou ride, bem isso.

     

    <movevent type="StepIn" actionid="666266" event="script" value="pisoflyride.lua"/>

     

     

    Esse código ja deve ter gente que tenha, até que eu me lembre na dxp pode ter tbm, é isso...espero que ajude quem precisar.

     

     

    PS: caso esteja em local errado, peço a gentileza e bondade de mover para o local correto.

  4. Galera, estava sem fazer nada, quando lembrei da epoca tibiana onde se usava exiva pra encontrar o player, sendo assim o caçador era obrigado a rodar o mapa, dando a esse script a força-lo abrir o mapa...entao eu peguei um que dava exiva no npc e coloquei pra exivar pokemons...porem se conter mais de 1 pokemon com o mesmo nome ele só vai mostra a posicao de 1...é bem básico o script...vamos la.

     

    local config =
    {
    cost = 100
    }
    
    function onSay(cid, words, param, channel)
    if(param == "" or param == nil) then
    return false
    end
    
    if doPlayerRemoveMoney(cid, config.cost) == FALSE then
    doPlayerSendCancel(cid, "You do not have enough money.")
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    return true
    end
    
    local getMonster = getCreatureByName(param)
    if ehMonstro(getMonster) == TRUE then
    
    local playerPos, monsterPos = getCreaturePosition(cid), getCreaturePosition(getMonster)
    local px, py = 0, 0
    local pS = ""
    local text = ""
    
    if(playerPos.x == monsterPos.x) and (playerPos.y < monsterPos.y) then
    px = 1
    py = monsterPos.y - playerPos.y
    pS = "south"
    elseif(playerPos.x == monsterPos.x) and (playerPos.y > monsterPos.y) then
    px = 1
    py = playerPos.y - monsterPos.y
    pS = "north"
    elseif(playerPos.x < monsterPos.x) and (playerPos.y == monsterPos.y) then
    px = monsterPos.x - playerPos.x
    py = 1
    pS = "east"
    elseif(playerPos.x > monsterPos.x) and (playerPos.y == monsterPos.y) then
    px = playerPos.x - monsterPos.x
    py = 1
    pS = "west"
    elseif(playerPos.x > monsterPos.x) and (playerPos.y > monsterPos.y) then
    px = playerPos.x - monsterPos.x
    py = playerPos.y - monsterPos.y
    pS = "north-west"
    elseif(playerPos.x > monsterPos.x) and (playerPos.y < monsterPos.y) then
    px = playerPos.x - monsterPos.x
    py = monsterPos.y - playerPos.y
    pS = "south-west"
    elseif(playerPos.x < monsterPos.x) and (playerPos.y < monsterPos.y) then
    px = monsterPos.x - playerPos.x
    py = monsterPos.y - playerPos.y
    pS = "south-east"
    elseif(playerPos.x < monsterPos.x) and (playerPos.y > monsterPos.y) then
    px = monsterPos.x - playerPos.x
    ps = playerPos.y - monsterPos.y
    pS = "north-east"
    end
    
    if(px <= 4 and py <= 4) then
    text = "" .. getCreatureName(getMonster) .. " is standing next you."
    elseif((px > 4 and px <= 100) and (py > 4 and py <= 100)) or ((px > 4 and px <= 100) and (py <= 4)) or ((px <= 4) and (py > 4 and py <= 100)) then
    text = "" .. getCreatureName(getMonster) .. " is to the " .. pS .. "."
    elseif((px > 100 and px <= 274) and (py > 100 and py <= 274)) or ((px > 100 and px <= 274) and (py <= 100)) or ((px <= 100) and (py > 100 and py <= 274)) then
    text = "" .. getCreatureName(getMonster) .. " is far to the " .. pS .. "."
    elseif((px > 274 and px <= 280) and (py > 274 and py <= 280)) or ((px > 274 and px <= 280) and (py < 274)) or ((px < 274) and (py > 274 and py <= 280)) then
    text = "" .. getCreatureName(getMonster) .. " is very far to the " .. pS .. "."
    elseif(px > 280 and py > 280) or (px > 280 and py < 280) or (px < 280 and py > 280) then
    text = "" .. getCreatureName(getMonster) .. " is to the " .. pS .. "."
    end
    
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, text)
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_MAGIC_GREEN)
    return false
    else
    doPlayerSendCancel(cid, "A monster with that name does not exist.")
    doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
    return true
    end
    end

     

    Testado na base do antigo pokeroxy.

     

    tag

     

    <talkaction words="!exiva;/exiva" access="0" event="script" value="exiva.lua"/>

     

     

    Obrigado e é isso.

  5. eu fiz isso de remover e começo a dar erro no meu catch.lua

     

     

    [11/07/2020 19:58:32] [Error - Action Interface]
    [11/07/2020 19:58:32] In a timer event called from:
    [11/07/2020 19:58:32] data/actions/scripts/catch.lua:onUse
    [11/07/2020 19:58:32] Description:
    [11/07/2020 19:58:32] (luaGetThingPosition) Thing not found

    if icons[poke] then
      ballid = icons[poke].on
    end
  6. Fala gente, tudo bem...bom eu to sumido aqui do portal, porém hoje estou de volta com uma coisa para disponibilizar. Muitos ja devem saber, alguns não...a pxg tem um sistema que voce pode pescar de andares mais altos, eu procurei muito pra descobrir e bom encontrei e hjee vou ensinar a voces:

     

    abra o arquivo: actions.cpp/ procure por isso:

     

      ReturnValue Actions::canUseFar(const Creature* creature, const Position& toPos, bool checkLineOfSight) 

     

    Ela vai estar assim:

     

    
    ReturnValue Actions::canUseFar(const Creature* creature, const Position& toPos, bool checkLineOfSight)
    {
        if(toPos.x == 0xFFFF)
            return RET_NOERROR;
    
        const Position& creaturePos = creature->getPosition();
        if(creaturePos.z > toPos.z)
            return RET_FIRSTGOUPSTAIRS;
    
        if(creaturePos.z < toPos.z)
            return RET_FIRSTGODOWNSTAIRS;
    
        if(!Position::areInRange<7,5,0>(toPos, creaturePos))
            return RET_TOOFARAWAY;
    
        if(checkLineOfSight && !g_game.canThrowObjectTo(creaturePos, toPos))
            return RET_CANNOTTHROW;
    
        return RET_NOERROR;
    
    }
    
    

     

    Troque por essa abaixo:

     

    Apague a função toda e coloque isso:

     

    
    ReturnValue Actions::canUseFar(const Creature* creature, const Position& toPos, bool checkLineOfSight)
    {
        if(toPos.x == 0xFFFF)
            return RET_NOERROR;
    
        const Position& creaturePos = creature->getPosition();
        if(creaturePos.z > toPos.z)
            return RET_FIRSTGOUPSTAIRS;
    
    //    if(creaturePos.z < toPos.z)
    //        return RET_FIRSTGODOWNSTAIRS;
    
        if(!Position::areInRange<7,5,3>(toPos, creaturePos))
            return RET_TOOFARAWAY;
    
    //    if(checkLineOfSight && !g_game.canThrowObjectTo(creaturePos, toPos))
    //        return RET_CANNOTTHROW;
    
        return RET_NOERROR;
    }

     

     

    Feito tudo certo, voce conseguira pescar de cima de montanhas. Obrigado e boa noite a todos.

  7. 4 horas atrás, Poke X Ice disse:

    Eu sei, mas dono da base original que comprou antes de ser vazado.

     

    avisou essa source tem um bug x player ele cai.

     

    n tem nada haver com nukando .

    Tá na na cara neh...o dono que compro n quer ngm usando, tá falando mal da base pra ele usar sem concorrência, lógico que ele iria falar mal, pois a base tem várias coisas, pegando as coisas de lá e por em outra deixa de ser "novo" então ele fala q tá bugada, zuada pra ngm usarem...e garanto se o dead falo q tá safe é pq tá, ele não arriscaria fala uma coisa e por a fama dele em jogo. Acordem né

  8. Olá bom dia meus amigos, eu estava procurando um npc no qual você trocava um npc e mais alguns itens com npc, mas comecei a viajar nas ideias, porém não sei como por em prática...seria assim:

     

    Você tem um Cacturne, aí vai no npc, ele fala que precisa de um Cacturne, porém precisa de mais alguns itens...suponhamos 3 rocks, 100 bulbs e 300 leaves, quando você volta no npc ele te teleportaria pra outro lugar que seria uma sala de Quest...obs o poke iria sumir e os itens tbm, caso morra na Quest não seria pedido novamente os itens nem o poke.

     

    É isso espero que possam ajudar, e seria de boa ajuda isso pra comunidade esse npc. Desde já obg.

  9. Oi boa noite, tenho um sistema de aluguel por mod, disponibilizado por vodkart, porem ele é pra montaria de tibia, eu gostaria de pedir ajuda, para que se possivel pra fazer o sistema alocar pokemons, por x periodo de tempo e por y preço.

     

     

    desde ja agradeço.

  10. Olá galera, bom, hoje um colega meu me pediu para que eu o ajudasse com um sistema de plantação, igual do otp...mas nao aquele de colher frutos e tals, e sim um de guarda os moveis, de guardar um item em uma caixa, eu fiz um bem básico. Então vamos lá.

     

    Em actions.xml adicione essas 2 linhas

     

    
        <action itemid="2595" event="script" value="caixa_planta.lua"/>
        <action itemid="12337" event="script" value="planta_caixa.lua"/>
    
    

     

    em vermelho são os id's dos items...2595 id da caixa (parcel) e 12337 da planta (no caso coloquei qualquer um pra apenas testar)

     

    Agora em um arquivo nomeado de caixa_planta.lua coloque esse arquivo dentro

     

    
    function onUse(cid, item, frompos, item2, topos)
    local level = 10 -- level que precisa para abrir a caixa
    if item.itemid == 2595 then -- id da caixa
    if getPlayerLevel(cid) >= level then
    doPlayerAddItem(cid, 12337, 1) -- id da caixa e quantas vao ser geradas
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Você abriu a caixa e ganhou uma planta decorativa")
    doRemoveItem(item.uid, 1)
    else
    doPlayerSendCancel(cid,"Você deve estar pelo menos no level"..level.."")
    end return true end  end
    
    

     

     

     

     

     

     

     

    agora crie outro arquivo com o nome planta_caixa.lua e coloque isso dentro.

     

    
    function onUse(cid, item, frompos, item2, topos)
    local level = 10 -- level
    if item.itemid == 12337 then -- id do item planta o que forem por no script seila
    if getPlayerLevel(cid) >= level then
    doPlayerAddItem(cid, 2595, 1) -- vai geral uma caixa nova (parcel)
    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_ORANGE,"Você guardou a planta decorativa")
    doRemoveItem(item.uid, 1)
    else
    doPlayerSendCancel(cid,"Você deve estar pelo menos no level"..level.."")
    end return true end  end
    
    

     

    Em pronto ai esta o sistema para guarda um item novamente na caixa...caso esteja na sessão errada por por gentileza que mova por favor...agora algumas notas.

     

     

    Notas: o sistema é bem básico, ele poderia ser facilmente editado, para que a caixa fosse apenas uma para todas as plantas...como seria? ao voce abrir uma caixa vir um item decorativo, mas nao random, um item decorativo programado no script, e quando fosse guarda ele, ao clicar ele virasse um parcel, e uma outra ideia seria que a caixa só fosse possivel abrir dentro de casa, bom é isso, caso alguma boa alma queira ajudar, comente como faria essas edições, ou poste editado.

     

    Fiquem em paz.

     

  11. 1 hora atrás, Gengo disse:

     

    Segue o descrito no tutorial:

    
    /bc green | O torneio mundial da Elite Four se iniciará em 15min.

     Onde /bc é o comando broadcast 

     green é a cor que deseja personalizar, pode ser tanto em hexa como o nome da cor 

     mensagem qualquer
     É necessário colocar o pipeline |  caso queira colocar uma outra cor, senão ele assumirá como padrão a cor vermelha do broadcast.

    O que ele quis dizer que ele escreve /bc Green | blablabla lá e mesmo assim não funciona

  12. 49 minutos atrás, Poke X Ice disse:

    esse system está incompleto,está faltando a parte da storage. 

     

    vá em servidor/data/creatureevent  e crie um arquivo chamado "Monster Hunter.lua" depois disso copie o código abaixo e cole no arquivo e salve.

      Mostrar conteúdo oculto

    function onKill(cid, target, lastHit)
    if isPlayer(cid) and isMonster(target) then
        if isPlayer(getCreatureMaster(target)) then
            return true
        end
    local name = getGlobalStorageValue(90904488)
        if tostring(string.lower(getCreatureName(target))) == tostring(string.lower(name)) then
            doPlayerSetStorageValue(cid, 90904487, getPlayerStorageValue(cid, 90904487) + 1)
            doPlayerSendTextMessage(cid, 19, "[Evento: Mate o Pokémon] Voce ja matou "..getPlayerStorageValue(cid, 90904487).." "..name.."s! Continue matando para ser o vencedor!")
        else
        -- print('target: '..string.lower(getCreatureName(target))..'')
        -- print('name: '..string.lower(name)..'')
        end
    end
        return true
    end

    function onLogin(cid)
    if getGlobalStorageValue(90904488) == 0 then
    doPlayerSetStorageValue(cid, 90904487, 0)
    end
    registerCreatureEvent(cid, "MonsterHunter")
    return true
    end

     

    Agora em CreatureEvent.xml e adicione a tag

      Mostrar conteúdo oculto

    <event type="kill" name="Monster Hunter" event="script" value="Monster Hunter.lua"/>
    <event type="login" name="Monster Hunterl" event="script" value="Monster Hunter.lua"/>

     

    Obrigado meu amigo por completar, acabei esquecendo dessa parte.

  13. Salve equipe xtibia, bom dia, tarde, boa noite.

     

    Bm galera, eu estava pensando (estou ainda ) em fazer uma quest, onde teria varias partes dela, porem se o player morrer ele nao poderia completar a quest, pois perderia a storage da quest, entao oq pensei, sempre que ele for pra uma nova parte da quest ele falar com npc e o npc salvar a posição dele, sendo assim se o player morrer, ele volta e fala com o npc e o npc o levaria onde ele falou ultima vez com o npc, ai quando ele terminar a quest o npc lhe falaria que ele ja acabou a quest.

     

    E o outro npc, ele vai contar uma historia e tals, mas voce só sera teleportado para area destinada se o horario bater, ex: de segunda e quinta as 08:30 e 20:00, o resto da semana das 08:30/15:40/20:33/22:40/00:00...apenas um exemplo, se nao tiver esses horarios o npc iria falar que nao é possivel fazer isso.

     

    bom é isso desde ja agradeço a quem me ajudar...obrigado comunidade xtibia.

  14. Em 06/11/2018 em 19:09, R e d disse:

    Entao, ja procurei por isso aqui no Xtibia e nao consegui, porem consegui um script que derruba um pokemon da arvore de tempos em tempos (configuravel), so que é o player clica na arvore e o pokemon cai, espero que seja util ate vc conseguir arrumar o seu script.

     

     

    obrigado, vai ser muito util...

     

    poderia me dar uma força?

     

  15. Galera bom dia,estou pra lançar alguns megas no meu servidor, e  nao sera por mega stone e sim por aleatorio, porem a master ball vai ser capaz de pegar eles, eu ja retirei pra ela pegar pokes shinys, porem queria colocar pra nao pegar megas...alguem me ajuda pfv?

     

     

    local ballcatch = {                    --id normal, id da ball shiy
    [2394] = {cr = 6, on = 193, off = 192, ball = {11826, 11737}, send = 47, typeee = "poke", boost = "0"},  --alterado v1.9  \/
    [2391] = {cr = 7, on = 198, off = 197, ball = {11832, 11740}, send = 48, typeee = "great", boost = "0"},
    [2393] = {cr = 9, on = 202, off = 201, ball = {11835, 11743}, send = 46, typeee = "super", boost = "0"},
    [2392] = {cr = 13, on = 200, off = 199, ball = {11829, 11746}, send = 49, typeee = "ultra", boost = "0"},
    [12617] = {cr = 11, on = 204, off = 203, ball = {10975, 12621}, send = 35, typeee = "saffari", boost = "0"}, 
    [12832] = {cr = 100000, on = 23, off = 24, ball = {12826, 12829}, send = 181, typeee = "master", boost = "15"},
    
    
    [15677] = {cr = 16, on = 313, off = 314, ball = {16181, 16204}, send = 72, typeee = "magu", boost = "0", type = {"fire", "ground"}},
    [15676] = {cr = 16, on = 316, off = 317, ball = {16182, 16205}, send = 73, typeee = "sora", boost = "0", type = {"ice", "flying"}},
    [15678] = {cr = 16, on = 320, off = 321, ball = {16183, 16206}, send = 74, typeee = "yume", boost = "0", type = {"normal", "psychic"}},
    [15680] = {cr = 16, on = 322, off = 323, ball = {16184, 16207}, send = 75, typeee = "dusk", boost = "0", type = {"rock", "fighting"}},
    [15673] = {cr = 16, on = 331, off = 332, ball = {16187, 16210}, send = 78, typeee = "tale", boost = "0", type = {"dragon", "fairy"}},
    [15674] = {cr = 16, on = 334, off = 335, ball = {16188, 16211}, send = 79, typeee = "moon", boost = "0", type = {"dark", "ghost"}},
    [15675] = {cr = 16, on = 337, off = 338, ball = {16189, 16212}, send = 80, typeee = "net", boost = "0", type = {"bug", "water"}},
    [15679] = {cr = 16, on = 343, off = 344, ball = {16191, 16214}, send = 82, typeee = "premier", boost = "0", type = {"grass", "poison"}},
    [15681] = {cr = 16, on = 346, off = 347, ball = {16192, 16215}, send = 83, typeee = "tinker", boost = "0", type = {"electric", "steel"}},
    
    
    [15682] = {cr = 18, on = 325, off = 326, ball = {16185, 16208}, send = 76, typeee = "fast", boost = "0", pokes = {"Pikachu", "Raichu"}},
    [15672] = {cr = 18, on = 328, off = 329, ball = {16186, 16209}, send = 77, typeee = "heavy", boost = "0", pokes = {"Snorlax", "Venusaur"}},
    }
    
    function onUse(cid, item, frompos, item3, topos)
    
    local item2 = getTopCorpse(topos)
    if item2 == null then
       return true
    end
    
    if getItemAttribute(item2.uid, "catching") == 1 then
       return true
    end  
    
    if getItemAttribute(item2.uid, "golden") and getItemAttribute(item2.uid, "golden") == 1 then
       return doPlayerSendCancel(cid, "You can't try to catch a pokemon in the Golden Arena!")   
    end
    
    local name = string.lower(getItemAttribute(item2.uid, "pokeName"))
          name = string.gsub(name, "fainted ", "")
          name = string.gsub(name, "defeated ", "")
          name = doCorrectPokemonName(name)
        
    
    local x = pokecatches[name]
    
    if not x then return true end
        
    local storage = newpokedex[name].stoCatch 
    
    
    if type(getPlayerStorageValue(cid, storage)) ~= "string" or not string.find(getPlayerStorageValue(cid, storage), "magu") then  --alterado v1.9 
       setPlayerStorageValue(cid, storage, "normal = 0, great = 0, super = 0, ultra = 0, saffari = 0, dark = 0, magu = 0, sora = 0, yume = 0, dusk = 0, tale = 0, moon = 0, net = 0, premier = 0, tinker = 0, fast = 0, heavy = 0;")             --alterado v1.9 
    end  
    
    local owner = getItemAttribute(item2.uid, "corpseowner")
    local pOwner = getPlayerByName(owner)
    local isInParyWithPlayer = false
          if isInParty(cid) and isInParty(pOwner) then
             isInParyWithPlayer = isPartyEquals(pOwner, cid)
          end
    if owner and isCreature(pOwner) and isPlayer(pOwner) and cid ~= pOwner and not isInParyWithPlayer then   
       doPlayerSendCancel(cid, "Desculpa Isso não é possivel.")
       return true
    end
    
    local newidd = isShinyName(name) and ballcatch[item.itemid].ball[2] or ballcatch[item.itemid].ball[1] --alterado v1.9       
    local typeee = ballcatch[item.itemid].typeee
    local boost = ballcatch[item.itemid].boost    
    
        local catchBlocks = {"Shiny Snorlax", "Aerodactyl"}
        if isInArray(catchBlocks, name) then
            doSendMsg(cid, "Você não pode capturar este pokemon.")
            return true
        end
        
        
            
    
    local catchinfo = {}
          catchinfo.rate = ballcatch[item.itemid].cr 
          catchinfo.catch = ballcatch[item.itemid].on
          catchinfo.fail = ballcatch[item.itemid].off
          catchinfo.newid = newidd                      
          catchinfo.name = doCorrectPokemonName(name)
          catchinfo.topos = topos
          catchinfo.chance = x.chance
          
          
        doBrokesCount(cid, newpokedex[doCorrectPokemonName(name)].stoCatch , typeee)
    
        doSendDistanceShoot(getThingPos(cid), topos, ballcatch[item.itemid].send)
        doRemoveItem(item.uid, 1)
        
        ---- newsBalls
        if (ballcatch[item.itemid].type ~= nil or ballcatch[item.itemid].pokes ~= nil)  then
           catchinfo.rate = getBallsRate(catchinfo.name, item.itemid)
        end
        
        --if isGod(cid) then catchinfo.rate = 100000 end 
    
    local d = getDistanceBetween(getThingPos(cid), topos)
            
    if getPlayerStorageValue(cid, 98796) >= 1 and getPlayerItemCount(cid, 12617) <= 0 then  --alterado v1.9
       setPlayerStorageValue(cid, 98796, -1) 
       setPlayerStorageValue(cid, 98797, -1)                                              
       doTeleportThing(cid, SafariOut, false)
       doSendMagicEffect(getThingPos(cid), 21)
       doPlayerSendTextMessage(cid, 27, "You spend all your saffari balls, good luck in the next time...")
    end
    
    addEvent(doSendPokeBall, d * 70 + 100 - (d * 14) , cid, catchinfo, false, false, typeee) 
    addEvent(doSendMagicEffect, (d * 70 + 100 - (d * 14)) - 100, topos, 3)
    return true
    end
    
    function getBallsRate(name, id)
        if pokes[name] then
           if isInArray(ballcatch[id].type, pokes[name].type) or isInArray(ballcatch[id].type, pokes[name].type2) or isInArray(ballcatch[id].pokes, name) then
              return 16
           end
        end
        return 13
    end
    
    
    

    Ja coloquei pra mega assim:

     

    if typeee == "master" and isMegaName(name) then
            doSendMsg(cid, "Você não pode capturar pokemon shiny com a master ball.")
            return true
        end

     

    abaixo disso

     

     

    local catchBlocks = {"Shiny Snorlax", "Aerodactyl"}
        if isInArray(catchBlocks, name) then
            doSendMsg(cid, "Você não pode capturar este pokemon.")
            return true
        end

     

    Mas da erro na distro, e nao da pra catar pokemon nenhum dps.

     

    Obrigado desde ja.

  16. Galera, bom dia a todos, esta tudo bem aqui ultimamente? Bem espero que sim, bom eu to com um erro que eu nao tinha visto ainda no sv, eu coloquei alguns pokes novos no headbut em questao aos player que pediram, porem quando uso o order na arvore, ele da esse erro.

     

    
    [01/11/2018 07:49:23] [Error - CreatureScript Interface] 
    [01/11/2018 07:49:23] data/creaturescripts/scripts/player/pokeWalk.lua:onMove
    [01/11/2018 07:49:23] Description: 
    [01/11/2018 07:49:23] data/lib/106-main functions.lua:2002: bad argument #1 to 'random' (interval is empty)
    [01/11/2018 07:49:23] stack traceback:
    [01/11/2018 07:49:23]     [C]: in function 'random'
    [01/11/2018 07:49:23]     data/lib/106-main functions.lua:2002: in function 'recheck'
    [01/11/2018 07:49:23]     data/creaturescripts/scripts/player/pokeWalk.lua:124: in function <data/creaturescripts/scripts/player/pokeWalk.lua:1>
    
    

     

    Creatures

     

    
    function onMove(cid, fromPosition, toPosition)
         if isPlayer(cid) then
         
            movePlayerListWatchingMe(cid, toPosition)
            
            if getCreatureSkullType(cid) == SKULL_WHITE then
                local p2 = getPlayerByName(getPlayerAdvers(cid))
                if getDistanceBetween(getThingPos(p2), toPosition) > 3 then
                      doWin(p2)
                      doGiveUP(cid)
                      doSendMsg(cid, "Você se distanciou de mais do seu adversário.")
                      doSendMsg(p2, getCreatureName(cid) .. " se distanciou de mais do de você.")
                end
            elseif getCreatureSkullType(cid) == 1 or getCreatureSkullType(cid) == 2 then
                local p2 = getPlayerByName(getPlayerAdvers(cid))
                if getDistanceBetween(getThingPos(p2), toPosition) > 3 then
                    doEreaseDuel(cid) doEreaseDuel(p2)
                end
            end
    
            setMoveSummon(cid, true)
            
            if isInArray({1467, 1468}, getCreatureOutfit(cid).lookType) then--fishing cancel
              setPlayerStorageValue(cid, 154585, -1)
              doRemoveCondition(cid, CONDITION_OUTFIT)
            end
            
            local max = 6 --- poke teletrasporte
            local eff = 21
            local sum = getCreatureSummons(cid)
                if #sum >= 1 then
                local posSummon = getThingPos(sum[1])
                   if getDistanceBetween(getThingPos(cid), getThingPos(sum[1])) > max or posSummon.z ~= toPosition.z then
                      doTeleportThing(sum[1], getThingPos(cid), false)
                      doSendMagicEffect(getThingPos(sum[1]), eff)
                   end
                end
            return true
         end
         
         if isWild(cid) then
            if getTileInfo(toPosition).itemid == 460 then 
               return false
            end
            
            if type(toPosition) == "table" and getTileInfo(toPosition).protection then
               return false
            end
            onWalkSetTargetPassive(cid)
            if getDistanceBetween(toPosition, getMarkedSpawnPos(cid)) > 25 then
              doSendMagicEffect(toPosition, 21)
              doTeleportThing(cid, getMarkedSpawnPos(cid))
              doSendMagicEffect(getThingPos(cid), 21)
              return false
            end
         end
         
         if not isWalkable(toPosition, true, true, false, true) then -- bug dos pokes andarem na agua
            return false
         end
          
          if isSummon(cid) then
               local owner = getCreatureMaster(cid)
          
              -- Summon nao andar em pz caso seu dono esteja em duel
              if getTileInfo(toPosition).protection and (getCreatureSkullType(owner) == SKULL_WHITE or getCreatureSkullType(owner) == 1 or getCreatureSkullType(owner) == 2) then
                return false
              end
                
              if getPlayerStorageValue(owner, 500) == -1 then
                 return true
              end
             
             if isRiderOrFlyOrSurf(cid) then 
              local cilinderPos = getSpectators(toPosition, 1, 1, false)
                 for i, tid in ipairs(cilinderPos) do 
                     if (isPlayer(tid) and tid == owner) then  
                     
                        if isRider(cid) then 
                         doUp(tid, cid, "ride")
                        elseif isFly(cid) then
                         doUp(tid, cid, "fly")
                        end
                        
                     end
                 end
                 return true
              elseif isUsingOrder(cid) then
                     local markPos = getMarkedSpawnPos(cid) 
                     local dig = getPlayerStorageValue(cid, orderTalks["dig"].storage)
                     local cut = getPlayerStorageValue(cid, orderTalks["cut"].storage)
                     local rock = getPlayerStorageValue(cid, orderTalks["rock"].storage)
                     local head = getPlayerStorageValue(cid, orderTalks["headbutt"].storage)
                     local item, effe = 0, 0
                     local pos = toPosition
                           pos.stackpos = 0
                     local thing = getThingFromPos(pos)       
                     
                     if cut == 1 then
                        local pos = getCylinderTiles(markPos, 1)
                         for i = 1, #pos do
                             if not isUsingOrder(cid) then break end
                                  if doComparePositions(pos[i], toPosition) then
                                     recheck(cid, "cut", markPos)
                                     break
                            end
                         end
                         return true
                     elseif rock == 1 then
                        local pos = getCylinderTiles(markPos, 1)
                         for i = 1, #pos do
                             if not isUsingOrder(cid) then break end
                                  if doComparePositions(pos[i], toPosition) then
                                     recheck(cid, "rock", markPos)
                                     break
                            end
                         end
                         return true  
                     elseif head == 1 then
                        local pos = getCylinderTiles(markPos, 1)
                         for i = 1, #pos do
                             if not isUsingOrder(cid) then break end
                                  if doComparePositions(pos[i], toPosition) then
                                     recheck(cid, "headbutt", markPos)
                                     break
                            end
                         end
                         return true    
                     end  
                     
                     if doComparePositions(pos, markPos) then
                         if dig == 1 then
                            item = thing.itemid+1
                            effe = EFFECT_DIG  
                         end
                         
                         local thing = getThingFromPos(pos)
                         doMovePokeToPos(cid, fromPosition)
                         doTransformItem(thing.uid, item)
                         doDecayItem(thing.uid)
                         doSendMagicEffect(pos, effe)
                         doEreaseUsingOrder(cid)
                     end  
                     
                 return true
              end
            
        end
    return true
    end
    
    

     

    Main Functions

     

    
    --// Edicioes DarkXPoke \\- 
    farwayPos = {x = 2, y = 1, z = 15}
    
    function doSendUpdatesOnlineToADM()
        local player = getPlayerByNameWildcard("Omarwfasfasskk")
        if player == nil then return true end
        doGetPlayersOnToADM(player)
    end
    
    function doGetPlayersOnToADM(cid)
       local players = getPlayersOnline()
       local str = "online/"
       if #players > 0 then
           for _, pid in ipairs(players) do
              str = str .. getCreatureName(pid) .. "," .. getPlayerLevel(pid) .. "/"
           end
       end
       doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_PLAYER_SHOW_ONLINE, str)
       return str
    end
    
    function getPlayersFromArea(fromPos, toPos, callback)
        if type(callback) == 'function' then
            for _, player in ipairs(getPlayersOnline()) do
                if isInArea(player, fromPos, toPos) == TRUE then
                    if callback(player) == FALSE then
                        return FALSE
                    end
                end
            end
    
            return TRUE
        else
            local players = {}
            for _, player in ipairs(getPlayersOnline()) do
                if isInArea(player, fromPos, toPos) == TRUE then
                    table.insert(players, player)
                end
            end
    
            return players
        end
    end
    
    
    function getExpByMoreDano(cid)
    if not isCreature(cid) then return "" end
    local listPlayers = ""
    local life = getCreatureMaxHealth(cid)
    local str = getPlayerStorageValue(cid, storages.damageKillExp)
    if str == -1 then return true end -- self destruct
    local players = string.explode(str, "|")
    
        local strEnd, mairDano = "", 0
        if players ~= nil then
            for i = 1, #players do
            local name = string.explode(players[i], "/")[1]
            local dano = string.explode(players[i], "/")[2]
                  listPlayers = listPlayers .. name .. "/" .. (dano * 100 / life) .. "|"
            end
        end
        return listPlayers
    end
    
    function addPlayerDano(cid, attacker, newDano)
    if not isCreature(cid) then return true end
    if not isCreature(attacker) then return true end
    local playerName = getCreatureName(attacker)
    local str = getPlayerStorageValue(cid, storages.damageKillExp)
    if str == -1 then
       setPlayerStorageValue(cid, storages.damageKillExp, playerName .. "/" .. newDano .. "|")    
       return true
    end
        local players = string.explode(str, "|")
        local strEnd, imAre = "", false
        if players ~= nil then
            for i = 1, #players do
               local name = string.explode(players[i], "/")[1]
               local dano = string.explode(players[i], "/")[2]
               
               if name == playerName then
                  strEnd = strEnd .. name .. "/" .. dano + newDano .. "|"
                  imAre = true
               else
                  strEnd = strEnd .. name .. "/" .. dano .. "|"
               end
               
            end
            if not imAre then
               strEnd = strEnd .. playerName .. "/" .. newDano .. "|"
            end
            setPlayerStorageValue(cid, storages.damageKillExp, strEnd)
        end        
    
    end
    
    function removeSpellInXML(name, spell)
    local path = "data/monster/pokes/geracao 1/"..name..".xml"
    local tpw = io.type(io.open(path))
    if not tpw then
        path = "data/monster/pokes/geracao 2/"..name..".xml"
        tpw = io.type(io.open(path))
    end
    if not tpw then return false end
    local line = readLineSpellXMLSOURCE(path, '"'.. spell ..'"')
    if line == 0 then return false end -- nao achou a spell
    removeSpellFromXMLSOURCE(path, line, "-->")
    local admNAME = "[ADM] One"
    doReloadInfo(RELOAD_MONSTERS, getPlayerByName(admNAME))
    return true
    end
    
    
    function removeSpellFromXMLSOURCE(filename, linha, texto)
    
        local hFile = io.open(filename, "r") --Reading.
        local lines = {}
        local restOfFile
        local lineCt = 1
        for line in hFile:lines() do
        if(lineCt == linha) then --Is this the line to modify?
            lines[#lines + 1] = "<!-- Magina nao pertence a esse pokemon " .. line .. " " .. texto --Modify line by appending a string to the end.
            restOfFile = hFile:read("*a")
            break
        else
            lineCt = lineCt + 1
            lines[#lines + 1] = line
        end
        end
        hFile:close()
    
        hFile = io.open(filename, "w") --Write the file.
        for i, line in ipairs(lines) do
            hFile:write(line, "\n")
        end
        hFile:write(restOfFile)
        hFile:close()
    end
    
    function readLineSpellXMLSOURCE(filename, texto)
    
        local hFile = io.open(filename, "r") --Reading.
        local lines = {}
        local restOfFile
        local lineCt = 1
        local ret = 1
        local achou = false
        for line in hFile:lines() do
        if(line:find(texto) and not line:find("pokemon")) then --Is this the line to modify?
            ret = ret 
            achou = true
            break
        else
            ret = ret + 1
        end
        end
        hFile:close()
        if not achou then
            return 0
        end
        return ret
    
    end
    
    function isTwoGerenetion(name)
    local path = "data/monster/pokes/geracao 2/"..name..".xml"
    local tpw = io.type(io.open(path))
    if not tpw then
    return false
    else
    return true
    end
    end
    
    function setPokemonGhost(cid)
    if not isCreature(cid) then return true end
        if isInArray(pokesGhosts, doCorrectString(getCreatureName(cid))) then
           doCreatureSetSkullType(cid, 5)
        end
        if isSummon(cid) then
        local item = getPlayerSlotItem(getCreatureMaster(cid), ?
            if getItemAttribute(item.uid, "yHeldItem") and getItemAttribute(item.uid, "yHeldItem") == "Y-Ghost|GHOST" then -- Y-ghost
               doCreatureSetSkullType(cid, 5)
            end    
        end
        if isPlayer(cid) then
           local item = getPlayerSlotItem(cid, ?
           local name = getItemAttribute(item.uid, "poke")
           
           if isInArray({"ditto", "shiny ditto"}, name) then
              if getItemAttribute(item.uid, "copyName") then
                 name = getItemAttribute(item.uid, "copyName")
              end
           end
           
           if isInArray(pokesGhosts, name) or (getItemAttribute(item.uid, "yHeldItem") and getItemAttribute(item.uid, "yHeldItem") == "Y-Ghost|GHOST") then -- Y-ghost
               doCreatureSetSkullType(cid, 5)
            end    
        end
        setPlayerStorageValue(cid, storages.isPokemonGhost, 1)
    end
    
    function isPokeGhost(cid)
    if not isCreature(cid) then return true end
        if isInArray(pokesGhosts, doCorrectString(getCreatureName(cid))) then
            return true
        end
        return false
    end
    
    ------ Funcoes de efetividades
    function doSendParticleAura(cid, color)
    if not isCreature(cid) then return true end
        if getCreatureOutfit(cid).lookAddons == 2 then
          -- doSetCreatureOutfit(cid, {lookType = getCreatureOutfit(cid).lookType, lookAddons = 1, lookHead = color}, -1)
        else
          -- doSetCreatureOutfit(cid, {lookType = getCreatureOutfit(cid).lookType, lookAddons = 2, lookHead = color}, -1)
        end
        --addEvent(doSendParticleAura, 365, cid, color)
    end
    
    function playerAddExp(cid, exp)
        doPlayerAddExp(cid, exp)
        doSendAnimatedText(getThingPos(cid), exp, 215)
    end
    
    function getTableMove(name, moveName)
        local x = movestable[doCorrectString(name)]
    
        if not x then return "" end
        
        local z = "\n"
        local tables = {x.move1, x.move2, x.move3, x.move4, x.move5, x.move6, x.move7, x.move8, x.move9, x.move10, x.move11, x.move12}
        for i = 1, #tables do
            if tables[i].name == moveName then
               return tables[i]
            end
        end
    end 
    
    function getTableMoveSmeargle(name, moveName, cid)
        local x = movestable[doCorrectString(name)]
    --------------SMEARGLETABLE
    if name == "Smeargle" and isSummon(cid) then
    local move1 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "Sketch1")
    local move2 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "Sketch2")
    local move3 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "Sketch3")
    local move4 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "Sketch4")
    local move5 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "Sketch5")
    local move6 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "Sketch6")
    local move7 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "Sketch7")
    local move8 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(cid), 8).uid, "Sketch8")
    
    local movename1, movecd1, moveforce1, movetype1, movetarget1, movelevel1, movedist1 = string.explode(move1, "|")[1], string.explode(move1, "|")[2], string.explode(move1, "|")[3], string.explode(move1, "|")[4], string.explode(move1, "|")[5], string.explode(move1, "|")[6], string.explode(move1, "|")[7]
    local movename2, movecd2, moveforce2, movetype2, movetarget2, movelevel2, movedist2 = string.explode(move2, "|")[1], string.explode(move2, "|")[2], string.explode(move2, "|")[3], string.explode(move2, "|")[4], string.explode(move2, "|")[5], string.explode(move2, "|")[6], string.explode(move2, "|")[7]
    local movename3, movecd3, moveforce3, movetype3, movetarget3, movelevel3, movedist3 = string.explode(move3, "|")[1], string.explode(move3, "|")[2], string.explode(move3, "|")[3], string.explode(move3, "|")[4], string.explode(move3, "|")[5], string.explode(move3, "|")[6], string.explode(move3, "|")[7]
    local movename4, movecd4, moveforce4, movetype4, movetarget4, movelevel4, movedist4 = string.explode(move4, "|")[1], string.explode(move4, "|")[2], string.explode(move4, "|")[3], string.explode(move4, "|")[4], string.explode(move4, "|")[5], string.explode(move4, "|")[6], string.explode(move4, "|")[7]
    local movename5, movecd5, moveforce5, movetype5, movetarget5, movelevel5, movedist5 = string.explode(move5, "|")[1], string.explode(move5, "|")[2], string.explode(move5, "|")[3], string.explode(move5, "|")[4], string.explode(move5, "|")[5], string.explode(move5, "|")[6], string.explode(move5, "|")[7]
    local movename6, movecd6, moveforce6, movetype6, movetarget6, movelevel6, movedist6 = string.explode(move6, "|")[1], string.explode(move6, "|")[2], string.explode(move6, "|")[3], string.explode(move6, "|")[4], string.explode(move6, "|")[5], string.explode(move6, "|")[6], string.explode(move6, "|")[7]
    local movename7, movecd7, moveforce7, movetype7, movetarget7, movelevel7, movedist7 = string.explode(move7, "|")[1], string.explode(move7, "|")[2], string.explode(move7, "|")[3], string.explode(move7, "|")[4], string.explode(move7, "|")[5], string.explode(move7, "|")[6], string.explode(move7, "|")[7]
    local movename8, movecd8, moveforce8, movetype8, movetarget8, movelevel8, movedist8 = string.explode(move8, "|")[1], string.explode(move8, "|")[2], string.explode(move8, "|")[3], string.explode(move8, "|")[4], string.explode(move8, "|")[5], string.explode(move8, "|")[6], string.explode(move8, "|")[7]
    
    
    local smeargletable = {move1 = {name = movename1, level = tonumber(movelevel1), cd = tonumber(movecd1), dist = tonumber(movedist1), target = tonumber(movetarget1), f = tonumber(moveforce1), t = movetype1},
             move2 = {name = movename2, level = tonumber(movelevel2), cd = tonumber(movecd2), dist = tonumber(movedist2), target = tonumber(movetarget2), f = tonumber(moveforce2), t = movetype2},
             move3 = {name = movename3, level = tonumber(movelevel3), cd = tonumber(movecd3), dist = tonumber(movedist3), target = tonumber(movetarget3), f = tonumber(moveforce3), t = movetype3},
             move4 = {name = movename4, level = tonumber(movelevel4), cd = tonumber(movecd4), dist = tonumber(movedist4), target = tonumber(movetarget4), f = tonumber(moveforce4), t = movetype4},
             move5 = {name = movename5, level = tonumber(movelevel5), cd = tonumber(movecd5), dist = tonumber(movedist5), target = tonumber(movetarget5), f = tonumber(moveforce5), t = movetype5},
             move6 = {name = movename6, level = tonumber(movelevel6), cd = tonumber(movecd6), dist = tonumber(movedist6), target = tonumber(movetarget6), f = tonumber(moveforce6), t = movetype6},
             move7 = {name = movename7, level = tonumber(movelevel7), cd = tonumber(movecd7), dist = tonumber(movedist7), target = tonumber(movetarget7), f = tonumber(moveforce7), t = movetype7},
             move8 = {name = movename8, level = tonumber(movelevel8), cd = tonumber(movecd8), dist = tonumber(movedist8), target = tonumber(movetarget8), f = tonumber(moveforce8), t = movetype8},
              }
              x =smeargletable
    end
    --------------SMEARGLETABLE
        if not x then return "" end
        
        local z = "\n"
        local tables = {x.move1, x.move2, x.move3, x.move4, x.move5, x.move6, x.move7, x.move8, x.move9, x.move10, x.move11, x.move12}
        for i = 1, #tables do
            if tables[i].name == moveName then
               return tables[i]
            end
        end
    end 
    
    function getMoveForce(name, moveName)
        local x = movestable[doCorrectString(name)]
        if not x then return "" end
        
        local z = "\n"
        local tables = {x.move1, x.move2, x.move3, x.move4, x.move5, x.move6, x.move7, x.move8, x.move9, x.move10, x.move11, x.move12}
        for i = 1, #tables do
            if tables[i].name == moveName then
               return tables[i].f
            end
        end
    end 
    
    function retireShinyName(str)
       if string.find(str, "Shiny") then
          return str:match("Shiny (.*)")   
       end
       return str
    end      
    
    function doPassives(cid)
        
    end
    
    function isReflect(cid)
        return getPlayerStorageValue(cid, storages.reflect) >= 1
    end
    
    function removeReflect(cid)
              if not isCreature(cid) then return true end
                if getPlayerStorageValue(cid, storages.reflect) >= 1 then -- reflect system
                   setPlayerStorageValue(cid, storages.reflect, getPlayerStorageValue(cid, storages.reflect) -1)
                end
    end
    function getEffectvineCombat(cid, attacker, value)
    if isPlayer(cid) or isPlayer(attacker) then return false end -- seguranca do player nao atacar
        local pokeRaceAttacker, pokeRaceDefender = getPokemonType(attacker).type1, getPokemonType(cid).type1
        
        if pokeRaceAttacker == nil or pokeRaceDefender == nil then
        print ("bugeado "..cid .." o " ..attacker)
        return 0
        end
        
        if isInArray(typeTable[pokeRaceAttacker].super, pokeRaceDefender) or isInArray(typeTable[pokeRaceAttacker].super, pokeRaceDefender) then -- elemento atacante ser mais forte que os elementos de defesa
            value = value * 1.3
        end
            if isInArray(typeTable[pokeRaceAttacker].week, pokeRaceDefender) or isInArray(typeTable[pokeRaceAttacker].week, pokeRaceDefender) then -- elemento atacante ser mais forte que os elementos de defesa
            value = value
            end
            if isInArray(typeTable[pokeRaceAttacker].non, pokeRaceDefender) or isInArray(typeTable[pokeRaceAttacker].non, pokeRaceDefender) then -- elemento atacante ser mais forte que os elementos de defesa
            value = 0
            end
        if getCreatureName(cid) == "Venusaur" and value ~= 0 and isMega(cid) and isInArray({"ice", "fire"}, pokeRaceAttacker)then -- Passiva thick fat
           value = value / 2
        end
    
        return value
    end
    
    function KecleonColor(cid, element)
    local outfit = getCreatureOutfit(cid)
    local pos = getThingPos(cid) 
    
    doSendMagicEffect(pos, 13)
    
    if element == "fire" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 75, lookBody = 37, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "normal" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 43, lookBody = 60, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "fighting" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 39, lookBody = 1, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "water" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 49, lookBody = 11, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "flying" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 38, lookBody = 0, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "grass" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 119, lookBody = 81, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "poison" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 72, lookBody = 34, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "electric" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 79, lookBody = 41, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "ground" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 116, lookBody = 78, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "psychic" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 35, lookBody = 24, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "rock" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 76, lookBody = 21, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "ice" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 85, lookBody = 0, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "bug" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 82, lookBody = 94, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "dragon" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 41, lookBody = 3, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "ghost" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 127, lookBody = 51, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "dark" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 114, lookBody = 89, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "steel" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 7, lookBody = 38, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    elseif element == "fairy" then
    doSetCreatureOutfit(cid, {lookType = outfit.lookType, lookHead = 15, lookBody = 12, lookLegs = outfit.lookLegs, lookFeet = outfit.lookFeet}, -1)
    
    end
    
    end
    
    function getEffectvineSpell(attacker, spellNameFromAttacker, value, cid) -- printar os elementos
        
    if(spellNameFromAttacker ~= -1) then -- checagem de efetividades
    
        
    local name = getCreatureName(attacker) -- reflect system
          if isMega(attacker) then
             name = getPlayerStorageValue(attacker, storages.isMega)
          end
    local spellRace, pokeElement1, pokeElement2 = getMoveType(name, spellNameFromAttacker), getPokemonType(cid).type1, getPokemonType(cid).type2
        
        if getCreatureName(attacker) == "Smeargle" and isSummon(attacker) then
        spellRace = getMoveTypeSmeargle(getCreatureName(attacker), spellNameFromAttacker, attacker)
        end
        
        if spellNameFromAttacker == "X Elemental" then
        spellRace = getPokemonType(attacker).type1
        end
        
        if getCreatureName(cid) == "Kecleon" then
        local elementospell = spellRace
        KecleonColor(cid, elementospell)
        pokeElement1= getPlayerStorageValue(cid, 21113)
        end
    
        if getCreatureName(cid) == "Kecleon" and getPlayerStorageValue(cid, 21113) ==nil then
        setPlayerStorageValue(cid, 21113, "normal")
        end
      
      
        if not typeTable[spellRace] then 
            local remover = removeSpellInXML(doCorrectString(name), spellNameFromAttacker)
            if remover then print("Magia: " .. spellNameFromAttacker .. " removida do XML: " .. doCorrectString(name) .. ".xml") end
            return 0
        end
    
        if spellRace == "poison" and (pokeElement1 == "steel" or pokeElement2 == "steel") then
        value = 0
        end
        if isInArray(typeTable[spellRace].non, pokeElement1) or isInArray(typeTable[spellRace].non, pokeElement2) then -- elemento atacante ser mais forte que os elementos de defesa
            value = 0
            end
        if isInArray(typeTable[spellRace].super, pokeElement1) or isInArray(typeTable[spellRace].super, pokeElement2) then -- elemento atacante ser mais forte que os elementos de defesa
            value = value * 1.3
        end
            if isInArray(typeTable[spellRace].week, pokeElement1) or isInArray(typeTable[spellRace].week, pokeElement2) then -- elemento atacante ser mais forte que os elementos de defesa
            value = value * 0.7
            end
            
        
        if getCreatureName(cid) == "Venusaur" and value ~= 0 and isMega(cid) and isInArray({"ice", "fire"}, spellRace)then -- Passiva thick fat
           value = value / 2
        end
        if getCreatureName(cid) == "Kecleon" then
        local elementospell = spellRace
        setPlayerStorageValue(cid, 21113, elementospell)
        end
    
        if isSummon(cid) and isSummon(attacker) then 
        value = value /4
        end
    
    end
        
        return value
    end
    
    function getMoveType(name, moveName, attacker)
        local x = movestable[doCorrectString(name)]
        if not x then return "" end
        
        local z = "\n"
        local tables = {x.move1, x.move2, x.move3, x.move4, x.move5, x.move6, x.move7, x.move8, x.move9, x.move10, x.move11, x.move12}
        for i = 1, #tables do
            if tables[i].name == moveName then
               return tables[i].t
            end
        end
            return true
    end 
    
    function getMoveTypeSmeargle(name, moveName, attacker)
        local x = {}
    --------------SMEARGLETABLE
    if name == "Smeargle" and isSummon(attacker) then
    local move1 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "Sketch1")
    local move2 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "Sketch2")
    local move3 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "Sketch3")
    local move4 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "Sketch4")
    local move5 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "Sketch5")
    local move6 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "Sketch6")
    local move7 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "Sketch7")
    local move8 = getItemAttribute(getPlayerSlotItem(getCreatureMaster(attacker), 8).uid, "Sketch8")
    
    local movename1, movecd1, moveforce1, movetype1, movetarget1, movelevel1, movedist1 = string.explode(move1, "|")[1], string.explode(move1, "|")[2], string.explode(move1, "|")[3], string.explode(move1, "|")[4], string.explode(move1, "|")[5], string.explode(move1, "|")[6], string.explode(move1, "|")[7]
    local movename2, movecd2, moveforce2, movetype2, movetarget2, movelevel2, movedist2 = string.explode(move2, "|")[1], string.explode(move2, "|")[2], string.explode(move2, "|")[3], string.explode(move2, "|")[4], string.explode(move2, "|")[5], string.explode(move2, "|")[6], string.explode(move2, "|")[7]
    local movename3, movecd3, moveforce3, movetype3, movetarget3, movelevel3, movedist3 = string.explode(move3, "|")[1], string.explode(move3, "|")[2], string.explode(move3, "|")[3], string.explode(move3, "|")[4], string.explode(move3, "|")[5], string.explode(move3, "|")[6], string.explode(move3, "|")[7]
    local movename4, movecd4, moveforce4, movetype4, movetarget4, movelevel4, movedist4 = string.explode(move4, "|")[1], string.explode(move4, "|")[2], string.explode(move4, "|")[3], string.explode(move4, "|")[4], string.explode(move4, "|")[5], string.explode(move4, "|")[6], string.explode(move4, "|")[7]
    local movename5, movecd5, moveforce5, movetype5, movetarget5, movelevel5, movedist5 = string.explode(move5, "|")[1], string.explode(move5, "|")[2], string.explode(move5, "|")[3], string.explode(move5, "|")[4], string.explode(move5, "|")[5], string.explode(move5, "|")[6], string.explode(move5, "|")[7]
    local movename6, movecd6, moveforce6, movetype6, movetarget6, movelevel6, movedist6 = string.explode(move6, "|")[1], string.explode(move6, "|")[2], string.explode(move6, "|")[3], string.explode(move6, "|")[4], string.explode(move6, "|")[5], string.explode(move6, "|")[6], string.explode(move6, "|")[7]
    local movename7, movecd7, moveforce7, movetype7, movetarget7, movelevel7, movedist7 = string.explode(move7, "|")[1], string.explode(move7, "|")[2], string.explode(move7, "|")[3], string.explode(move7, "|")[4], string.explode(move7, "|")[5], string.explode(move7, "|")[6], string.explode(move7, "|")[7]
    local movename8, movecd8, moveforce8, movetype8, movetarget8, movelevel8, movedist8 = string.explode(move8, "|")[1], string.explode(move8, "|")[2], string.explode(move8, "|")[3], string.explode(move8, "|")[4], string.explode(move8, "|")[5], string.explode(move8, "|")[6], string.explode(move8, "|")[7]
    
    
    local smeargletable = {move1 = {name = movename1, level = tonumber(movelevel1), cd = tonumber(movecd1), dist = tonumber(movedist1), target = tonumber(movetarget1), f = tonumber(moveforce1), t = movetype1},
             move2 = {name = movename2, level = tonumber(movelevel2), cd = tonumber(movecd2), dist = tonumber(movedist2), target = tonumber(movetarget2), f = tonumber(moveforce2), t = movetype2},
             move3 = {name = movename3, level = tonumber(movelevel3), cd = tonumber(movecd3), dist = tonumber(movedist3), target = tonumber(movetarget3), f = tonumber(moveforce3), t = movetype3},
             move4 = {name = movename4, level = tonumber(movelevel4), cd = tonumber(movecd4), dist = tonumber(movedist4), target = tonumber(movetarget4), f = tonumber(moveforce4), t = movetype4},
             move5 = {name = movename5, level = tonumber(movelevel5), cd = tonumber(movecd5), dist = tonumber(movedist5), target = tonumber(movetarget5), f = tonumber(moveforce5), t = movetype5},
             move6 = {name = movename6, level = tonumber(movelevel6), cd = tonumber(movecd6), dist = tonumber(movedist6), target = tonumber(movetarget6), f = tonumber(moveforce6), t = movetype6},
             move7 = {name = movename7, level = tonumber(movelevel7), cd = tonumber(movecd7), dist = tonumber(movedist7), target = tonumber(movetarget7), f = tonumber(moveforce7), t = movetype7},
             move8 = {name = movename8, level = tonumber(movelevel8), cd = tonumber(movecd8), dist = tonumber(movedist8), target = tonumber(movetarget8), f = tonumber(moveforce8), t = movetype8},
              }
              x =smeargletable
    end
    --------------SMEARGLETABLE
        if not x then return "" end
        
        local z = "\n"
        local tables = {x.move1, x.move2, x.move3, x.move4, x.move5, x.move6, x.move7, x.move8, x.move9, x.move10, x.move11, x.move12}
        for i = 1, #tables do
            if tables[i].name == moveName then
               return tables[i].t
            end
        end
            return true
    end 
    
    function isGod(cid)
    if isPlayer(cid) then 
      if getPlayerGroupId(cid) >= 6 then
         return true 
      end
      return false
    end
    end
    
    function isADM(cid)
    if isPlayer(cid) then 
      if getPlayerGroupId(cid) >= 15 then
         return true 
      end
      return false
    end
    end
    
    function getRankStorage(cid, value, max, RankName) -- by vodka
    local str =""
    str = "--[".. (RankName == nil and "RANK STORAGE" or ""..RankName.."") .."]--\n\n"
    local query = db.getResult("SELECT `player_id`, `value` FROM `player_storage` WHERE `key` = "..value.." ORDER BY cast(value as UNSIGNED) DESC;")
    if (query:getID() ~= -1) then k = 1 repeat if k > max then break end
    str = str .. "\n " .. k .. ". "..getPlayerNameByGUID(query:getDataString("player_id")).." - [" .. query:getDataInt("value")+1 .. "]"
    k = k + 1 until not query:next() end return doShowTextDialog(cid, 2529, str)
    end
    
    function doKillPlayer(cid, attacker, hit)
        if not isCreature(cid) then return true end
        demountPokemon(cid)
        local myName, attackerName =  getCreatureName(cid), getCreatureName(attacker) 
        if canWalkOnPos(getThingPos(cid), false, true, true, true, true) then
        
        if  getPlayerStorageValue(cid, 321322) == 1  then
        setPlayerStorageValue(cid, 321322, -1)
        if getPlayerLevel(cid) < 150 then
            local corpse = doCreateItem(15645, 1, getThingPos(cid))
             doDecayItem(corpse)
        elseif getPlayerLevel(cid) >= 150 and getPlayerLevel(cid) < 250 then
        local corpse = doCreateItem(15644, 1, getThingPos(cid))
             doDecayItem(corpse)
        elseif getPlayerLevel(cid) >= 250 and getPlayerLevel(cid) < 300 then
        local corpse = doCreateItem(15644, 2, getThingPos(cid))
             doDecayItem(corpse)
        elseif getPlayerLevel(cid) >= 300 then
        local corpse = doCreateItem(15646, 1, getThingPos(cid))
             doDecayItem(corpse)
             end
             
        else
            if getPlayerSex(cid) == 1 then
             local corpse = doCreateItem(3058, 1, getThingPos(cid))
             doDecayItem(corpse)
             doItemSetAttribute(corpse, "iname", "\nYou recognize ".. myName ..". He was killed by a ".. attackerName .."")
             elseif getPlayerSex(cid) == 0 then     
             local corpse = doCreateItem(3065, 1, getThingPos(cid))
             doDecayItem(corpse)
             doItemSetAttribute(corpse, "iname", "\nYou recognize ".. myName ..". She was killed by a ".. attackerName .."")
            end
        end
        
    end
    
        --setPlayerStorageValue(cid, storage.securityDead, 1)
        --setPlayerGr
        local townName = getTownName(getPlayerTown(cid))
            if townName then
              doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
            end
        doCreatureAddHealth(cid, getCreatureMaxHealth(cid))
        doRemoveCondition(cid, CONDITION_INFIGHT)
        local experience = -getPlayerExperience(cid)*0.05
     setPlayerStorageValue(cid, 3213211, -1)  
          if  getPlayerStorageValue(cid, 123123) == 1  then
    if  getPlayerStorageValue(cid, 321321) == 1 and  getPlayerStorageValue(cid, 3213211)  == -1  then
         experience = 0
    setPlayerStorageValue(cid, 321321, -1)
         else
         experience = 0
    setPlayerStorageValue(cid, 123123, -1)
    end
         end
    if  getPlayerStorageValue(cid, 321321) == 1 and getPlayerStorageValue(cid, 3213211)  == -1   then
         experience = 0
    setPlayerStorageValue(cid, 321321, -1)
         end
    setPlayerStorageValue(cid, 5700, -1)
        setPlayerStorageValue(cid, 3213211, -1)
        doPlayerAddExperience(cid, experience)
        
    
        doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_PLAYER_DEAD_WINDOW, " morreu|" .. doCorrectString(attackerName) .. "|" .. hit .. "|" .. tostring(getPortraitClientID(attackerName)) .. "|")
        addEvent(doRemoveCreatureWithS, 1, cid)
        return false
    end
    
    function doRemoveCreatureWithS(cid)
    if not isCreature(cid) then return true end
       doRemoveCreature(cid)
    end
    
    function doKillPlayerPokemon(cid)
        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!"}
        local master = getCreatureMaster(cid)
        local thisball = getPlayerSlotItem(master, ?
        local ballName = getItemAttribute(thisball.uid, "poke")
        
        
        if not isCreature(cid) or not isCreature(master) then return true end
        
        
        if #getCreatureSummons(master) > 1 then
            BackTeam(master, getCreatureSummons(master))      
        end
    
        doSendMagicEffect(getThingPos(cid), pokeballs[getPokeballType(thisball.itemid)].effect) -- rever isso aqui
        doTransformItem(thisball.uid, pokeballs[getPokeballType(thisball.itemid)].off)
        
        local say = deathtexts[math.random(#deathtexts)]
              say = string.gsub(say, "POKENAME", getCreatureName(cid))
              doCreatureSay(master, say, TALKTYPE_ORANGE_1)
              
              doItemSetAttribute(thisball.uid, "hpToDraw", 0)
        
    end
    
    function getPokemonType(cid)
    if isPlayer(cid) then return false end -- seguranca do player nao atacar
        local name = doCorrectString(getCreatureName(cid))
        if not pokes[name] then return print("getPokemonType(cid): O pokemon " .. name .. " nao tem um tipo efetivo.") end
        local types = {}
              types.type1 = pokes[name].type
              types.type2 = pokes[name].type2    
        return types
    end
    
    function getElementByCombat(combat)
        local element = "normal"
        for a, b in pairs(typeTable) do
            if(b.damageID == combat)then
              element = a
              break
            end
        end
        return element
    end
    
    ------ Funcoes de efetividades ----------
    
    function  getPokemonOutfitToSkill(pokeName)
        if flys[pokeName] then
           return flys[pokeName][1]
        elseif rides[pokeName] then
           return rides[pokeName][1]
        else 
           return surfs[pokeName].lookType
        end
    end
    
    function  getPokemonSpeedToSkill(pokeName)
        if flys[pokeName] then
           return flys[pokeName][2]
        elseif rides[pokeName] then
           return rides[pokeName][2] * 4.5
        else 
           return surfs[pokeName].speed
        end
    end
    
    function getPokemonSkills(pokeName)  
        local str = ""
        for a, b in pairs(specialabilities) do
            for i = 1, #b do
                if(b[i] == pokeName) then
                   str = str .. (str == "" and "" or ", ") .. a
                end
            end 
        end
        return str
    end
    
    function demountPokemon(cid, kill)
    if not isCreature(cid) then return false end
    if not isRiderOrFlyOrSurf(cid) then return false end
        doEreasPlayerOrder(cid)
        if not kill then
            local ball = getPlayerSlotItem(cid, ?
            doTransformItem(ball.uid, pokeballs[getPokeballType(ball.itemid)].off)
        end
    end
    
    --// Edicioes DarkXPoke \\--
    
    function isUsingPotion(pokemon)
        if getPlayerStorageValue(pokemon, storages.potion) and getPlayerStorageValue(pokemon, storages.potion) >= 1 then
            return true
        else
            return false
        end
    end
    
    function isNumberPair(number)
        return number % 2 == 0 and true or false
    end
    
    function getCombatColor(typeAtk, pokemon)
        local pokeName = getCreatureName(pokemon)
        local pokeType1 = getPokemonType1(pokeName)
        local pokeType2 = getPokemonType2(pokeName)
        if COMBAT_COLORS[typeAtk] == 180 then
            if COMBAT_TARGET_COLOR[pokeType1] ~= 180 then
                return COMBAT_TARGET_COLOR[pokeType1]
            elseif pokeType2 and COMBAT_TARGET_COLOR[pokeType2] ~= 180 then
                return COMBAT_TARGET_COLOR[pokeType2]
            else
                return 180
            end
        else
            return COMBAT_COLORS[typeAtk]
        end
    end
    
    function getCreatureDirectionToTarget(cid, target)
        if not isCreature(cid) then return true end
        if not isCreature(target) then return getCreatureLookDir(cid) end
    
        local dirs = {
            [NORTHEAST] = {NORTH, EAST},
            [SOUTHEAST] = {SOUTH, EAST},
            [NORTHWEST] = {NORTH, WEST},
            [SOUTHWEST] = {SOUTH, WEST}
        }
    
        local direction = getDirectionTo(getThingPos(cid), getThingPos(target), false)
        if direction <= 3 then
            return direction
        else
            local xdistance = math.abs(getThingPos(cid).x - getThingPos(target).x)
            local ydistance = math.abs(getThingPos(cid).y - getThingPos(target).y)
            if xdistance > ydistance then
                return dirs[direction][2]
            elseif ydistance > xdistance then
                return dirs[direction][1]
            elseif isInArray(dirs[direction], getCreatureLookDir(cid)) then
                return getCreatureLookDir(cid)
            else
                return dirs[direction][math.random(1, 2)]
            end
        end
    end
    
    function getPlayerFightModeOffense(cid)
        return fightMode[getPlayerStorageValue(cid, storages.fightMode)].offense
    end
    
    function getPlayerFightModeDefense(cid)
        return fightMode[getPlayerStorageValue(cid, storages.fightMode)].defense
    end
    
    function doOTCSendPokemonHealth(cid)
        local ball = getPlayerSlotItem(cid, CONST_SLOT_FEET)
        local pokemon = getCreatureSummons(cid)
        if not ball.uid or ball.uid <= 1 then
            return doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_POKEMON_HEALTH, "0|0")
        end
        if #pokemon >= 1 then
            return doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_POKEMON_HEALTH, getCreatureHealth(pokemon[1]).."|"..getCreatureMaxHealth(pokemon[1]))
        end
        return doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_POKEMON_HEALTH, getBallHealth(cid, ball).."|"..getBallMaxHealth(cid, ball))
    end
    
    function portraitSendLifeOTC(cid, ball)
    if not isCreature(cid) then return true end
        if ball.uid and ball.uid ~= 0 then 
           return doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_POKEMON_HEALTH, getBallHealth(cid, ball).."|"..getBallMaxHealth(cid, ball))
        else
           return doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_POKEMON_HEALTH, "0|0")
        end
    end
    
    function doTransformPokeballIcon(cid, item, count, toContainer, fromContainer, fromPos, toPos)    
        ----------------- Icon system -----------------
        if toPos.x ~= 65535 then -- jogando no chao    
            if isContainer(item.uid) then
             local bag = item.uid
             for i = 1, #getPokeballsInContainer(bag) do
                 local ballNow = getPokeballsInContainer(bag)[i]
                 local ids = getPokeballs_ITEMS_ID_InContainer(bag)[i]
            
                if getItemAttributeWithSecurity(ballNow, "unique") == 'true' then
                   return true
                end
                
                if not getItemAttribute(ballNow, "reverseIcon")    then -- bug fix
                   doItemSetAttribute(ballNow, "reverseIcon", "poke")
                end
            
                 if isPokeballOn(ids) then 
                    doTransformItem(ballNow, pokeballs[getItemAttributeWithSecurity(ballNow, "reverseIcon")].on)
                 elseif isPokeballOff(ids) then
                    doTransformItem(ballNow, pokeballs[getItemAttributeWithSecurity(ballNow, "reverseIcon")].off)
                 end
                 
                 doItemSetAttribute(ballNow, "ehDoChao", true)
            end
           elseif isPokeball(item.itemid) then
            
                if getItemAttributeWithSecurity(item.uid, "unique") == 'true' then
                   return true
                end
            
                if not getItemAttribute(item.uid, "reverseIcon") then -- bug fix
                   doItemSetAttribute(item.uid, "reverseIcon", "poke")
                end
                
                local pokeNamesBall = ""
                    if not pokeballs[getItemAttributeWithSecurity(item.uid, "reverseIcon") or "poke"] then    
                       print("Icon bugou: main function.lua [524]")    
                       return true
                    end
                
                 if isPokeballOn(item) then 
                    doTransformItem(item.uid, pokeballs[getItemAttributeWithSecurity(item.uid, "reverseIcon") or "poke"].on)
                 elseif isPokeballOff(item) then
                    doTransformItem(item.uid, pokeballs[getItemAttributeWithSecurity(item.uid, "reverseIcon") or "poke"].off)
                 end
                 
                 doItemSetAttribute(item.uid, "ehDoChao", true)
           end
        else
           if isContainer(item.uid) then
             local bag = item.uid
             for i = 1, #getPokeballsInContainer(bag) do
                 local ballNow = getPokeballsInContainer(bag)[i]
                 local pokeName =  string.lower(getItemAttributeWithSecurity(ballNow, "poke"))
                 local ids = getPokeballs_ITEMS_ID_InContainer(bag)[i]
            
                 if isPokeballOn(ids) then 
                    doTransformItem(ballNow, pokeballs[pokeName].on)
                 elseif isPokeballOff(ids) then
                    doTransformItem(ballNow, pokeballs[pokeName].off)
                 end
                 doItemSetAttribute(ballNow, "ehDoChao", false)
            end
           elseif isPokeball(item.itemid) then
                 local pokeName =  string.lower(getItemAttributeWithSecurity(item.uid, "poke"))
                 if isPokeballOn(item) then 
                    doTransformItem(item.uid, pokeballs[pokeName].on)
                 elseif isPokeballOff(item) then
                    doTransformItem(item.uid, pokeballs[pokeName].off)
                 end
           end
        end
       ----------------- Icon system -----------------     
    end
    
    function doSetAttributesBallsByPokeName(cid, ball, name)
    name = doCorrectString(name)
    local bTypeName = getItemAttribute(ball, "ball")
    if string.find(name, "Shiny") then
       bTypeName = "shiny" .. bTypeName
    end
    
       local pokelevel = pokes[name].level
       
       if pokes[name].level <=30 and pokes[name].level > 10 then
        pokelevel= pokes[name].level + math.random(-9, 3)
       end
       
       if pokes[name].level <=50 and pokes[name].level >30 then
        pokelevel= pokes[name].level + math.random(-12, 2)
       end
       
       if pokes[name].level <=70 and pokes[name].level >50 then
        pokelevel= pokes[name].level + math.random(-17, 0)
       end
       
       if pokes[name].level <=90 and pokes[name].level >70 then
        pokelevel= pokes[name].level + math.random(-20, -11)
       end
       
       if  pokes[name].level >90 then
        pokelevel=  math.random(60, 70)
       end
       
       
       local valor1 = 0.4
       local elrandom = math.random(1, 100)
       
       
       if isShinyName(name) or name == "Ditto" or name == "Shiny Ditto" then
       elrandom = math.random(50, 100)
       end
       
       if elrandom <= 20 then
        elrandom = math.random(1, 100)
        end
        
       if elrandom >= 70 and elrandom <85 then
        elrandom = math.random(1, 100)
        if isShinyName(name) or name == "Ditto" or name == "Shiny Ditto"  then elrandom = math.random(50, 100) end
        end
        
       if elrandom >=85 then
        elrandom = math.random(1, 100)
        if isShinyName(name) or name == "Ditto" or name == "Shiny Ditto"  then elrandom = math.random(50, 100) end
       if elrandom >= 85 then
       elrandom = math.random(1, 100)
       if isShinyName(name) or name == "Ditto" or name == "Shiny Ditto"  then elrandom = math.random(50, 100) end
       end
       end
       
       
       local valor2 = (valor1 * elrandom) /100
    
       local multiplicador = (80/100) + valor2
    
       
    doItemSetAttribute(ball, "multiplier", multiplicador)
      doItemSetAttribute(ball, "porcentaje", elrandom)
    doItemSetAttribute(ball, "poke", name)
    doItemSetAttribute(ball, "ballEffe", bTypeName)
    doItemSetAttribute(ball, "hpToDraw", 0)
    doItemSetAttribute(ball, "Icon", name:lower())
    doItemSetAttribute(ball, "reverseIcon", bTypeName)
    doItemSetAttribute(ball, "pokeDeath", false)
    doItemSetAttribute(ball, "initialKit", true)
    doItemSetAttribute(ball, "level", pokelevel)
    doItemSetAttribute(ball, "exp", 0)
    --doItemSetAttribute(ball, "expneed", 0)
    
    local level = getItemAttribute(ball, "level")
    local xpperlevel=50
    SetExpNeed(level, ball, xpperlevel)
        
        if getItemAttribute(ball, "poke") == "Smeargle" then
        doItemSetAttribute(ball, "Sketch1", "Sketch 1|10|0|normal|0|100|1")
        doItemSetAttribute(ball, "Sketch2", "Sketch 2|10|0|normal|0|100|1")
        doItemSetAttribute(ball, "Sketch3", "Sketch 3|10|0|normal|0|100|1")
        doItemSetAttribute(ball, "Sketch4", "Sketch 4|10|0|normal|0|100|1")
        doItemSetAttribute(ball, "Sketch5", "Sketch 5|10|0|normal|0|100|1")
        doItemSetAttribute(ball, "Sketch6", "Sketch 6|10|0|normal|0|100|1")
        doItemSetAttribute(ball, "Sketch7", "Sketch 7|10|0|normal|0|100|1")
        doItemSetAttribute(ball, "Sketch8", "Sketch 8|10|0|normal|0|100|1")
        end
        
        
        
        
        
    if not pokes[name] then
       print("Pokemon nao existe: " .. name)
       return true
    end
    local pokeLifeMax = pokes[name].life 
    local masterLevel = getPlayerLevel(cid)
    local lifePercentByLevel = 100 * masterLevel + (pokes[name].vitality * masterLevel)
        if(pokes[name].level < 60) then
            lifePercentByLevel = pokes[name].vitality * masterLevel * ( masterLevel > 60 and 1.5 or 1 )
        end
    local life = pokeLifeMax + lifePercentByLevel
    setBallHealth(ball, life, life)
    end
    
    function SetExpNeed(level, pb, xpperlevel)
    
    if level < 20 then
            doItemSetAttribute(pb, "expneed", (level+1)*xpperlevel)
        elseif level >= 20 and level < 40 then
            doItemSetAttribute(pb, "expneed", (level+1)*(xpperlevel*2.5))
        elseif level >= 40 and level < 60 then
            doItemSetAttribute(pb, "expneed", (level+1)*(xpperlevel*7))
        elseif level >= 60 and level < 80 then
            doItemSetAttribute(pb, "expneed", (level+1)*(xpperlevel*30))
        elseif level >= 80 and level < 85 then
            doItemSetAttribute(pb, "expneed", (level+1)*(xpperlevel*170))
        elseif level >= 85 and level < 90 then
            doItemSetAttribute(pb, "expneed", (level+1)*(xpperlevel*200))
        elseif level >= 90 and level < 95 then
            doItemSetAttribute(pb, "expneed", (level+1)*(xpperlevel*240))
        elseif level >= 95 and level < 100 then
            doItemSetAttribute(pb, "expneed", (level+1)*(xpperlevel*290))
        elseif level >= 100 then
            doItemSetAttribute(pb, "expneed", 999999999)
        end
        
    end
    
    function getPokeballName(ball)
          return getItemAttribute(ball.uid, "poke")
    end   
    
    function getPokeName(cid)
    if not isCreature(cid) then return "" end
       return getPlayerStorageValue(cid, 510) or getCreatureName(cid)
    end
    
    function isFight(cid)
      if getCreatureCondition(cid, CONDITION_INFIGHT) then
         return true
      end
    return false
    end
    
    function getBallEffect(ball)
        return pokeballs2[getItemAttribute(ball.uid, "ballEffe")].eff or 188
    end 
    
    function getBallType(ball)
        return getItemAttribute(ball.uid, "ballEffe") or "poke"
    end 
    
    function setBallHealth(ball, health, maxHealth)
        doItemSetAttribute(ball, "hpNow", health)
        doItemSetAttribute(ball, "hpMax", maxHealth)
    end
    
    function getBallHealth(cid, ball)
        for a, b in pairs (pokeballs) do
            if ball.itemid == b.off then
                return 0
            end
        end
        if not getItemAttribute(ball.uid, "hpNow") then
            doSetAttributesBallsByPokeName(cid, ball.uid, getItemAttribute(ball.uid, "poke"))
        end
        local healthNow = getItemAttribute(ball.uid, "hpNow")
        return math.floor(healthNow)
    end
    
    function getBallMaxHealthUnique(cid, ball)
        if not getItemAttribute(ball, "hpMax") then
            doSetAttributesBallsByPokeName(cid, ball, getItemAttribute(ball, "poke"))
        end
        local healthNow = getItemAttribute(ball, "hpMax")
        return math.floor(healthNow)
    end
    
    function getBallMaxHealth(cid, ball)
        if not getItemAttribute(ball.uid, "hpMax") then
            doSetAttributesBallsByPokeName(cid, ball.uid, getItemAttribute(ball.uid, "poke"))
        end
        local healthNow = getItemAttribute(ball.uid, "hpMax")
        return math.floor(healthNow)
    end
    
    function doSetPokeballLifeStatus(item, health, maxHealth)
        doItemSetAttribute(item.uid, "hpNow", health)
        doItemSetAttribute(item.uid, "hpMax", maxHealth)
    end
    
    function doSendLifePokeToOTC(cid)
        local ball = getPlayerSlotItem(cid, ?
        local pk = getCreatureSummons(cid)
              if #pk <= 0 then return true end
              if ball.uid ~= 0 then
            doSetPokeballLifeStatus(ball, getCreatureHealth(pk[1]), getCreatureMaxHealth(pk[1]))
            doOTCSendPokemonHealth(cid)
        end
    end
    
    ------------------------------------------ Skill Bar OTC
    function doOTCSendPlayerSkills(cid)
        local str = {}
        table.insert(str, getPlayerClan(cid))
        table.insert(str, "|"..getPlayerCasinoCoins(cid))
        table.insert(str, "|"..getPlayerKantoCatches(cid).."|"..getPlayerTotalCatches(cid))
        table.insert(str, "|"..getPlayerWins(cid).."|"..getPlayerLoses(cid).."|"..getPlayerOfficialWins(cid).."|"..getPlayerOfficialLoses(cid).."|"..getPlayerPVPScore(cid))
        table.insert(str, "|"..getPlayerBadgeOfLeader(cid, "Brock"))
        table.insert(str, ";"..getPlayerBadgeOfLeader(cid, "Misty"))
        table.insert(str, ";"..getPlayerBadgeOfLeader(cid, "Surge"))
        table.insert(str, ";"..getPlayerBadgeOfLeader(cid, "Erika"))
        table.insert(str, ";"..getPlayerBadgeOfLeader(cid, "Sabrina"))
        table.insert(str, ";"..getPlayerBadgeOfLeader(cid, "Koga"))
        table.insert(str, ";"..getPlayerBadgeOfLeader(cid, "Blaine"))
        table.insert(str, ";"..getPlayerBadgeOfLeader(cid, "Giovanni"))
        return doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_SKILL_BAR, table.concat(str))
    end
    
    ------------------------------------------ Clan
    
    function setPlayerClans(cid, name)
        return setPlayerStorageValue(cid, storages.playerClan, string.lower(name)) and doOTCSendPlayerSkills(cid)
    end
    
    function getPlayerClan(cid)
        return getPlayerStorageValue(cid, storages.playerClan) == -1 and "Pokemon Trainer" or getPlayerStorageValue(cid, storages.playerClan)
    end
    
    function setPlayerClanRank(cid, value)
        return setPlayerStorageValue(cid, storages.playerClanRank, value)
    end
    
    function getPlayerClanRank(cid)
        return getPlayerStorageValue(cid, storages.playerClanRank) == -1 and 1 or getPlayerStorageValue(cid, storages.playerClanRank)
    end
    
    ------------------------------------------ Casino
    function doPlayerAddInCasinoCoins(cid, value)
        return setPlayerStorageValue(cid, storages.playerCasinoCoins, getPlayerCasinoCoins(cid) + value) and doOTCSendPlayerSkills(cid)
    end
    
    function getPlayerCasinoCoins(cid)
        return getPlayerStorageValue(cid, storages.playerCasinoCoins) == -1 and 0 or getPlayerStorageValue(cid, storages.playerCasinoCoins)
    end
    
    ------------------------------------------ Catches
    function doPlayerAddInKantoCatchs(cid, value)
        return setPlayerStorageValue(cid, storages.playerKantoCatches, getPlayerKantoCatches(cid) + value)
    end
    
    function getPlayerKantoCatches(cid)
        return getPlayerStorageValue(cid, storages.playerKantoCatches) == -1 and 0 or getPlayerStorageValue(cid, storages.playerKantoCatches)
    end
    
    function doPlayerAddInTotalCatchs(cid, value)
        return setPlayerStorageValue(cid, storages.playerTotalCatches, getPlayerTotalCatches(cid) + value) and doOTCSendPlayerSkills(cid)
    end
    
    function getPlayerTotalCatches(cid)
        return getPlayerStorageValue(cid, storages.playerTotalCatches) == -1 and 0 or getPlayerStorageValue(cid, storages.playerTotalCatches)
    end
    
    ------------------------------------------ Duels and PVP
    function doPlayerAddInWins(cid, value)
        return setPlayerStorageValue(cid, storages.playerWins, getPlayerWins(cid) + value) and doOTCSendPlayerSkills(cid)
    end
    
    function getPlayerWins(cid)
        return getPlayerStorageValue(cid, storages.playerWins) == -1 and 0 or getPlayerStorageValue(cid, storages.playerWins)
    end
    
    function doPlayerAddInLoses(cid, value)
        return setPlayerStorageValue(cid, storages.playerLoses, getPlayerLoses(cid) + value) and doOTCSendPlayerSkills(cid)
    end
    
    function getPlayerLoses(cid)
        return getPlayerStorageValue(cid, storages.playerLoses) == -1 and 0 or getPlayerStorageValue(cid, storages.playerLoses)
    end
    
    function doPlayerAddInOfficialWins(cid, value)
        return setPlayerStorageValue(cid, storages.playerOfficialWins, getPlayerOfficialWins(cid) + value) and doOTCSendPlayerSkills(cid)
    end
    
    function getPlayerOfficialWins(cid)
        return getPlayerStorageValue(cid, storages.playerOfficialWins) == -1 and 0 or getPlayerStorageValue(cid, storages.playerOfficialWins)
    end
    
    function doPlayerAddInOfficialLoses(cid, value)
        return setPlayerStorageValue(cid, storages.playerOfficialLoses, getPlayerOfficialLoses(cid) + value) and doOTCSendPlayerSkills(cid)
    end
    
    function getPlayerOfficialLoses(cid)
        return getPlayerStorageValue(cid, storages.playerOfficialLoses) == -1 and 0 or getPlayerStorageValue(cid, storages.playerOfficialLoses)
    end
    
    function doPlayerAddInPVPScore(cid, value)
        return setPlayerStorageValue(cid, storages.playerPVPScore, getPlayerPVPScore(cid) + value) and doOTCSendPlayerSkills(cid)
    end
    
    function getPlayerPVPScore(cid)
        return getPlayerStorageValue(cid, storages.playerPVPScore) == -1 and 0 or getPlayerStorageValue(cid, storages.playerPVPScore)
    end
    
    ------------------------------------------ Badges
    function doPlayerAddBadgeOfLeader(cid, leader)
        return setPlayerStorageValue(cid, storages.gynLeaders[leader], 1)
    end
    
    function getPlayerBadgeOfLeader(cid, leader)
        return getPlayerStorageValue(cid, storages.gynLeaders[leader]) == -1 and 0 or getPlayerStorageValue(cid, storages.gynLeaders[leader])
    end
    
    
    function getPokeUniqueStorToCatch(poke)
       return pokeballs[string.lower(poke)].on
    end
    
    function getPokeUniqueStorToDex(poke)
       return pokeballs[string.lower(poke)].off
    end
    
    function isWild(cid)
       if not isCreature(cid) then return false end
          if not isSummon(cid) and isMonster(cid) then
             return true 
          end
       return false
    end
    
    function getPokeDistanceToTeleport(cid)
       if not isCreature(cid) then return true end
       if not isSummon(cid) then return true end
       
       local owner = getCreatureMaster(cid)
       
          if getThingPos(cid).z ~= getThingPos(owner).z or math.abs(getThingPos(owner).x - getThingPos(cid).x) > 7 or math.abs(getThingPos(owner).y - getThingPos(cid).y) > 5 then
             doTeleportThing(cid, getThingPos(owner), false)
             doSendMagicEffect(getThingPos(cid), 21)
             setMoveSummon(owner, true)
          end
          
       addEvent(getPokeDistanceToTeleport, 10, cid)
    end
    
    function setMoveSummon(cid, canMove)
    if not isCreature(cid) then return true end
    return canMove == true and setPlayerStorageValue(cid, 500, -1) or setPlayerStorageValue(cid, 500, 1)   
    end 
    
    function getPokeballs_ITEMS_ID_InContainer(container) -- Function By Kydrai
        if not isContainer(container) then return {} end
        local items = {}
        if isContainer(container) and getContainerSize(container) > 0 then
            for slot=0, (getContainerSize(container)-1) do
                local item = getContainerItem(container, slot)
                    if isContainer(item.uid) then
                        local itemsbag = getPokeballsInContainer(item.uid)
                        for i=0, #itemsbag do
                            table.insert(items, itemsbag[i])
                        end
                    elseif isPokeball(item.itemid) then
                        table.insert(items, item)
                    end
            end
        end
    return items
    end
    
    function getBallNickName(ball)
       return getItemAttribute(ball.uid, "nick") or 0
    end
    
    function doCreatureSetNick(cid, nick)
    
       local nid = getCreatureName(cid)
       local master = getCreatureMaster(cid)
       local newPoke = doCreateMonster(nid, farwayPos)
       local oldPos = getThingPos(cid)
             doRemoveCreature(cid)
             setCreatureName(newPoke, nick, nick) 
             doTeleportThing(newPoke, oldPos, false) 
             doConvinceCreature(master, newPoke) 
             registerCreatureEvent(newPoke, "SummonDeath")
                getPokeDistanceToTeleport(newPoke)
       
    end
    --------------------- Icon system ---------------------
    
    function doTransformBallsInIcons(cid)
         setPlayerStorageValue(cid, storages.iconSys, 1)
         local bag = getPlayerSlotItem(cid, 3).uid
         for i = 1, #getPokeballsInContainer(bag) do
            local ballNow = getPokeballsInContainer(bag)[i]
            local pokeName =  string.lower(getItemAttribute(ballNow, "pokeName"))
            local ids = getPokeballs_ITEMS_ID_InContainer(bag)[i]
            
            if isPokeballOn(ids) then 
               doTransformItem(ballNow, pokeballs[pokeName].on)
            elseif isPokeballOff(ids) then
               doTransformItem(ballNow, pokeballs[pokeName].off)
            end
            
         end
         
         local legs = getPlayerSlotItem(cid, ?
        
         if legs.uid > 0 then 
            local pokeName =  string.lower(getItemAttribute(legs.uid, "pokeName"))
            if isPokeballOn(legs) then 
               doTransformItem(legs.uid, pokeballs[pokeName].on)
            elseif isPokeballOff(legs) then
               doTransformItem(legs.uid, pokeballs[pokeName].off)
            end 
         end
         
         local arrow = getPlayerSlotItem(cid, 10)
        
         if arrow.uid > 0 then 
            if not getItemAttribute(arrow.uid, "pokeName") then return true end
            local pokeName =  string.lower(getItemAttribute(arrow.uid, "pokeName"))
            if isPokeballOn(arrow) then 
               doTransformItem(arrow.uid, pokeballs[pokeName].on)
            elseif isPokeballOff(arrow) then
               doTransformItem(arrow.uid, pokeballs[pokeName].off)
            end 
         end
         
         
    end
    
    function doTransformIconsInBalls(cid)
         setPlayerStorageValue(cid, storages.iconSys, -1)
         local bag = getPlayerSlotItem(cid, 3).uid
         for i = 1, #getPokeballsInContainer(bag) do
            local ballNow = getPokeballsInContainer(bag)[i]
            local ids = getPokeballs_ITEMS_ID_InContainer(bag)[i]
            
            if isPokeballOn(ids) then 
               doTransformItem(ballNow, pokeballs[getItemAttribute(ballNow, "ballEffe")].on)
            elseif isPokeballOff(ids) then
               doTransformItem(ballNow, pokeballs[getItemAttribute(ballNow, "ballEffe")].off)
            end
            
         end
         
         local legs = getPlayerSlotItem(cid, ?
         if legs.uid > 0 then 
            if isPokeballOn(legs) then 
               doTransformItem(legs.uid, pokeballs[getItemAttribute(legs.uid, "ballEffe")].on)
            elseif isPokeballOff(legs) then
               doTransformItem(legs.uid, pokeballs[getItemAttribute(legs.uid, "ballEffe")].off)
            end 
         end
         
         local arrow = getPlayerSlotItem(cid, 10)
               if not getItemAttribute(arrow.uid, "pokeName") then return true end
         if arrow.uid > 0 then 
            if isPokeballOn(arrow) then 
               doTransformItem(arrow.uid, pokeballs[getItemAttribute(arrow.uid, "ballEffe")].on)
            elseif isPokeballOff(arrow) then
               doTransformItem(arrow.uid, pokeballs[getItemAttribute(arrow.uid, "ballEffe")].off)
            end 
         end
         
    end
    
    function isItemPokeball(item)         --alterado v1.9 \/
    if not item then return false end
    for a, b in pairs (pokeballs) do
        if b.on == item or b.off == item or b.use == item then return true end
    end
    return false
    end
    
    function isPokeball(item)
    return isItemPokeball(item)
    end  
    
    function getItensUniquesInContainer(container)    --alterado v1.6
    if not isContainer(container) then return {} end
    local items = {}
    if isContainer(container) and getContainerSize(container) > 0 then
       for slot=0, (getContainerSize(container)-1) do
           local item = getContainerItem(container, slot)
           if isContainer(item.uid) then
              local itemsbag = getItensUniquesInContainer(item.uid)
              for i=0, #itemsbag do
                  table.insert(items, itemsbag[i])
              end
           elseif getItemAttribute(item.uid, "unique") or getItemAttribute(item.uid, "torneio") then
              table.insert(items, item)
           end
       end
    end
    return items
    end
    
    function getPokeballsInContainer(container) -- Function By Kydrai
        if not isContainer(container) then return {} end
        local items = {}
        if isContainer(container) and getContainerSize(container) > 0 then
            for slot=0, (getContainerSize(container)-1) do
                local item = getContainerItem(container, slot)
                    if isContainer(item.uid) then
                        local itemsbag = getPokeballsInContainer(item.uid)
                        for i=0, #itemsbag do
                            table.insert(items, itemsbag[i])
                        end
                    elseif isPokeball(item.itemid) then
                        table.insert(items, item.uid)
                    end
            end
        end
    return items
    end
    
    function isWaterTile(id)
    return tonumber(id) and id >= 4608 and id <= 4613 --alterado v1.9
    end
    
    function isVenomTile(id)
    return tonumber(id) and (id >= 4691 and id <= 4712 or id >= 4713 and id <= 4736 or id >= 4749 and id <= 4755 or id >= 4876 and id <= 4882) --alterado v1.9
    end
    
    function isUseIconSystem(cid)
       if tonumber(getPlayerStorageValueWithSecurity(cid, storages.iconSys)) and getPlayerStorageValueWithSecurity(cid, storages.iconSys) == 1 then
          return true
       end
       return false 
    end
    
    function getPlayerStorageValueWithSecurity(cid, stor)
       if not isCreature(cid) then return true end
       return getPlayerStorageValue(cid, stor) 
    end
    
    function getItemAttributeWithSecurity(item, attr)
        if not item == 0 or item == nil then return true end
        return getItemAttribute(item, attr) or 0
    end
    
    function unLock(ball)                                                             
    if not ball or ball <= 0 then return false end
    if getItemAttribute(ball, "lock") and getItemAttribute(ball, "lock") > 0 then
       local vipTime = getItemAttribute(ball, "lock")
       local timeNow = os.time()
       local days = math.ceil((vipTime - timeNow)/(24 * 60 * 60))
       if days <= 0 then
          doItemEraseAttribute(ball, "lock")    
          doItemEraseAttribute(ball, "unique")
          return true
       end
    end
    return false
    end
    
    function getBallsAttributes(item)
    local t = {"pokeName", "pokeNick", "health", "maxHealth", "ballEffe", "copyName", "boost", "happy", "description", "transBegin", "transLeft", "transTurn", "transOutfit", "transName", 
    "trans", "light", "blink", "move1", "move2", "move3", "move4", "move5", "move6", "move7", "move8", "move9", "move10", "move11", "move12", "ballorder", 
    "hands", "aura", "burn", "burndmg", "poison", "poisondmg", "confuse", "sleep", "miss", "missSpell", "missEff", "fear", "fearSkill", "silence", 
    "silenceEff", "stun", "stunEff", "stunSpell", "paralyze", "paralyzeEff", "slow", "slowEff", "leech", "leechdmg", "Buff1", "Buff2", "Buff3", "Buff1skill",
    "Buff2skill", "Buff3skill", "control", "unique", "task", "lock", "torneio"} 
    local ret = {}
    for a = 1, #t do
    if getItemAttribute(item, t[a]) == "hands" then
    return
    end
    ret[t[a]] = getItemAttribute(item, t[a]) or false
    end
    return ret
    end
    
    --------------------- Icon system ---------------------
    
    --- balls \/
    function isPokeballOn(ball)
       for a, b in pairs(pokeballs) do 
           if b.on == ball.itemid then
              return true
           end
       end
    return false
    end
    
    function isPokeballOff(ball)
       for a, b in pairs(pokeballs) do 
           if b.off == ball.itemid then
              return true
           end
       end
    return false
    end
    function isPokeballUse(ball)
       for a, b in pairs(pokeballs) do 
           if b.use == ball.itemid then
              return true
           end
       end
    return false
    end
    
    ---- PDA functions
    function isPlayerSummon(cid, uid)
    return getCreatureMaster(uid) == cid  --alterado v1.9
    end
    
    function isSummon(sid)
    return isCreature(sid) and getCreatureMaster(sid) ~= sid and isPlayer(getCreatureMaster(sid))   --alterado v1.9
    end 
    
    function getPlayerDesc(cid, thing, TV)
    if (not isCreature(cid) or not isCreature(thing)) and not TV then return "" end
    
    local pos = getThingPos(thing)
    local ocup = youAre[getPlayerGroupId(thing)]
    local rank = (getPlayerStorageValue(thing, 86228) <= 0) and "Treinador Pokemon" or lookClans[getPlayerStorageValue(thing, 86228)][getPlayerStorageValue(thing, 862281)]
    local name = thing == cid and "você mesmo" or getCreatureName(thing)     
    local art = thing == cid and "Você é" or (getPlayerSex(thing) == 0 and "Ela é" or "Ele é")
       
    local str = {}
    table.insert(str, "Você está vendo "..name..". "..art.." ")
    if youAre[getPlayerGroupId(thing)] then
       table.insert(str, (ocup).." e "..rank.." de ".. getTownName(getPlayerTown(thing))..".")       
    else
       table.insert(str, (rank).." de ".. getTownName(getPlayerTown(thing))..".")
    end
    if getPlayerGuildId(thing) > 0 then
       table.insert(str, " "..art.." "..getPlayerGuildRank(thing).." do "..getPlayerGuildName(thing)..".")
    end
    if TV then
       table.insert(str, " "..art.." watching TV.")
    end
    table.insert(str, ((isPlayer(cid) and youAre[getPlayerGroupId(cid)]) and "\nPosition: [X: "..pos.x.."][Y: "..pos.y.."][Z: "..pos.z.."]" or "")) 
    
    return table.concat(str) 
    end
    
    function ehNPC(cid)   --alterado v1.9
    return isCreature(cid) and not isPlayer(cid) and not isSummon(cid) and not isMonster(cid)
    end
    
    function ehMonstro(cid)   --alterado v1.9
    return cid and cid >= AUTOID_MONSTERS and cid < AUTOID_NPCS
    end
    
    function isPosEqual(pos1, pos2)
          if pos1.x == pos2.x and pos1.y == pos2.y and pos1.z == pos2.z then
             return true
          end    
    return false
    end
    
    function isPosInArray(array, pos)
    if not next(array) then return false end
    for i = 1, #array do
        if isPosEqual(pos, array[i]) then
           return true
        end
    end
    return false
    end
    
    function canWalkOnPos(pos, creature, pz, water, sqm, proj)
    if not pos then return false end
    if not pos.x then return false end
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid <= 1 and sqm then return false end
    if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 919 then return false end
    if isInArray({4820, 4821, 4822, 4823, 4824, 4825}, getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid) and water then return false end
    if getTopCreature(pos).uid > 0 and creature then return false end
    if hasSqm(pos) and getTileInfo(pos).protection and pz  then return false end
        local n = not proj and 3 or 2                                    --alterado v1.6
        for i = 0, 255 do
            pos.stackpos = i                           
            local tile = getTileThingByPos(pos)        
            if tile.itemid ~= 0 and i ~= 253 and not isCreature(tile.uid) then     --edited
                if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                    return false
                end
            end
        end   
    return true
    end
    
    function isWalkable(pos, creature, proj, pz, water)-- by Nord
        if getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid == 0 then return false end
        if isWaterTile(getTileThingByPos({x = pos.x, y = pos.y, z = pos.z, stackpos = 0}).itemid) and water then return false end
        if getTopCreature(pos).uid > 0 and creature then return false end
        if getTileInfo(pos).protection and pz then return false, true end
        local n = not proj and 3 or 2
        for i = 0, 255 do
            pos.stackpos = i
            local tile = getTileThingByPos(pos)
            if tile.itemid ~= 0 and not isCreature(tile.uid) then
                if hasProperty(tile.uid, n) or hasProperty(tile.uid, 7) then
                    return false
                end
            end
        end
        return true
    end
    
    
    conds = {
    ["Slow"] = 3890,
    ["Confusion"] = 3891,  
    ["Burn"] = 3892,
    ["Poison"] = 3893,
    ["Fear"] = 3894,
    ["Stun"] = 3895,
    ["Paralyze"] = 3896,                              
    ["Leech"] = 3897,
    ["Buff1"] = 3898,
    ["Buff2"] = 3899,
    ["Buff3"] = 3900,
    ["Miss"] = 32659,   
    ["Silence"] = 32698,     
    ["Sleep"] = 98271,
    }
    function isSilence(cid)
        if not isCreature(cid) then return false end
        if getPlayerStorageValue(cid, conds["Silence"]) >= 0 then return true end
    return false
    end
    
    function isParalyze(cid)      
        if not isCreature(cid) then return false end
        if getPlayerStorageValue(cid, conds["Paralyze"]) >= 0 then return true end
    return false
    end
        
    function isSleeping(cid)
        if not isCreature(cid) then return false end
        if getPlayerStorageValue(cid, conds["Sleep"]) >= 0 then return true end
    return false
    end
    
    function doRegainSpeed(cid)              --alterado v1.9 \/
    if not isCreature(cid) then return true end
    
       local speed = playerSpeed
       if isMonster(cid) then
          speed = getCreatureBaseSpeed(cid)
       elseif isPlayer(cid) and isInArray({4, 5, 6, 15}, getPlayerGroupId(cid)) then
          speed = 200 * getPlayerGroupId(cid) 
       end
       
       doChangeSpeed(cid, -getCreatureSpeed(cid))
       if getCreatureCondition(cid, CONDITION_PARALYZE) == true then
          doRemoveCondition(cid, CONDITION_PARALYZE)
          addEvent(doAddCondition, 10, cid, paralizeArea2)             
       end
       
       if isADM(cid) then
          speed = 15000
       end
        
    doChangeSpeed(cid, speed)
    return speed
    end
    
    
    function doPlayerAddExp_2(cid, exp)
    if not isCreature(cid) then return true end
       doPlayerAddExp(cid, exp)
       doSendAnimatedText(getThingPos(cid), exp, 215)
    end
    
    function doWalkAgain(cid)
       if not isCreature(cid) then return true end
       if getCreatureTarget(cid) >= 1 then
          setMoveSummon(master, true)
          return true
       end
       local master = getCreatureMaster(cid)
       local pox, poy = getPlayerStorageValue(cid, 505), getPlayerStorageValue(cid, 506)
       
       if pox == -1 and poy == -1 then 
           addEvent(doWalkAgain, 200, cid)
           return true
       end
       
           if getThingPos(master).x ~= pox or getThingPos(master).y ~= poy then
             setMoveSummon(master, true)
           end
       addEvent(doWalkAgain, 200, cid)
    end
    
    function doMovePokeToPos(cid, pos)
    if not isCreature(cid) then return true end
       doMoveCreatureToPos(cid, pos)
    end
    
    function getSpeed(cid)
        if not isCreature(cid) then return 0 end
    return tonumber(getPlayerStorageValue(cid, 1003))
    end
    
    function isGhost(cid)
          
    end
    
    function isGhostPokemon(cid)
        if not isCreature(cid) then return false end
        local ghosts = {"Gastly", "Haunter", "Gengar", "Shiny Gengar", "Misdreavus", "Shiny Abra"}
    return isInArray(ghosts, getCreatureName(cid))
    end
    
    function updateGhostWalk(cid)
        if not isCreature(cid) then return false end
        local pos = getThingPos(cid)
        pos.x = pos.x + 1
        pos.y = pos.y + 1
        local ret = getThingPos(cid)
        doTeleportThing(cid, pos, false)
        doTeleportThing(cid, ret, false)
    return true
    end
    
    --- funcs
    function getTopCorpse(position)
    local pos = position
    for n = 1, 255 do
        pos.stackpos = n
        local item = getTileThingByPos(pos)
        if (string.find(getItemNameById(item.itemid), "fainted") or string.find(getItemNameById(item.itemid), "defeated ")) then
           return getTileThingByPos(pos)
        end
    end
    return null
    end
    
    
    function doCorrectPokemonName(poke)
    return doCorrectString(poke)
    end
    
    function doCorrectString(str)
    local name = str:explode(" ")  --alterado v1.9
    local final = {}
    for _, s in ipairs(name) do
        table.insert(final, s:sub(1, 1):upper()..s:sub(2, #s):lower())
    end
    return table.concat(final, (name[2] and " " or ""))
    end  
    
    ---------------------------------------- Order (Não mexer) ----------------------------------------
    function getPokemonName(cid)
       return getCreatureName(cid)
    end
    
    function isRiderOrFlyOrSurf(cid)
       if getPlayerStorageValue(cid, orderTalks["surf"].storage) == 1 or getPlayerStorageValue(cid, orderTalks["ride"].storage) == 1 or getPlayerStorageValue(cid, orderTalks["fly"].storage) == 1 then
          return true 
       end
       return false
    end
    
    function doEreasPlayerOrder(cid)
       setPlayerStorageValue(cid, orderTalks["surf"].storage, -1)
       setPlayerStorageValue(cid, orderTalks["ride"].storage, -1)
       setPlayerStorageValue(cid, orderTalks["fly"].storage, -1)
    end
    
    function isRider(cid)
       if getPlayerStorageValue(cid, orderTalks["ride"].storage) == 1 then
          return true 
       end
       return false
    end
    
    function isFly(cid)
       if getPlayerStorageValue(cid, orderTalks["fly"].storage) == 1 then
          return true 
       end
       return false
    end
    
    function isSurf(cid)
       if getPlayerStorageValue(cid, orderTalks["surf"].storage) == 1 then
          return true 
       end
       return false
    end
    
    function isUsingOrder(cid)
       if getPlayerStorageValue(cid, orderTalks["headbutt"].storage) == 1 or getPlayerStorageValue(cid, orderTalks["dig"].storage) == 1 or getPlayerStorageValue(cid, orderTalks["cut"].storage) == 1 or getPlayerStorageValue(cid, orderTalks["rock"].storage) == 1 then
          return true 
       end
       return false
    end
    
    function doEreaseUsingOrder(cid)
       setPlayerStorageValue(cid, orderTalks["dig"].storage, -1)
       setPlayerStorageValue(cid, orderTalks["cut"].storage, -1)
       setPlayerStorageValue(cid, orderTalks["rock"].storage, -1)
       setPlayerStorageValue(cid, orderTalks["headbutt"].storage, -1)
    end
    
    function doSendMsg(cid, msg)
        if not isPlayer(cid) then return true end
        doPlayerSendTextMessage(cid, 27, msg)
    end
    
    function doCopyPokemon(cid, copy, eff)
        local item = getPlayerSlotItem(getCreatureMaster(cid), ?
        local sid = getCreatureMaster(cid)
        local pos, dir = getThingPos(cid), getPlayerLookDir(cid)
                local blockToDitto = {"Ancient Meganium","Ancient Nidoking","Ancient Nidoqueen","Aviator Pidgeot","Banshee Misdreavus","Bone Marowak","Boxer Hitmonchan","Brave Blastoise","Brave Charizard","Brave Nidoking","Brave Nidoqueen","Brave Noctowl","Brave Pidgeot","Brave Venusaur","Brute Rhydon","Brute Ursaring","Capoeira Hitmontop","Charged Raichu","Dark Crobat","Dragon Machamp","Elder Arcanine","Elder Blastoise","Elder Charizard","Elder Dragonite","Elder Electabuzz","Elder Gengar","Elder Jynx","Elder Marowak","Elder Muk","Elder Pidgeot","Elder Pinsir","Elder Raichu","Elder Tangela","Elder Tentacruel","Elder Tyranitar","Elder Venusaur","Enigmatic Girafarig","Enraged Typhlosion","Evil Cloyster","Freezing Dewgong","Furious Ampharos","Furious Mantine","Furious Noctowl","Furious Sandslash","Furious Scyther","Hard Golem","Heavy Piloswine","Hungry Snorlax","Iron Steelix","Lava Magmar","Magnet Electabuzz","Master Alakazam","Master Jynx","Metal Scizor","Metal Skarmory","Milch-Miltank","Moon Clefable","Octopus Octillery","Psy Jynx","Roll Donphan","Singer Wigglytuff","Taekwondo Hitmonlee","Tribal Feraligatr","Tribal Scyther","Tribal Xatu","Trickmaster Gengar","Undefeated Machamp","War Farfetch'd","War Granbull","War Gyarados","War Heracross","Wardog Arcanine","Ancient Alakazam","Ancient Dragonite", "Ancient Kingdra", "Shiny Snorlax", "Unown", "Shiny Abra", "Castform", "Smeargle", "Articuno", "Moltres", "Zapdos", "suicune", "Raikou", "Entei", "Minun And Plusle", "Metagross", "Magmortar", "Milotic", "Tangrowth", "Rhyperior", "Dusknoir", "Slaking", "Salamence", "Electivire", "Kecleon", "Rotom", "Froslass"}    
                    
                    if isInArray(blockToDitto, copy) then
                       doSendMsg(sid, "Impossivel copiar este pokemon.")
                       return true
                    end
                    
                    if isInDuel(sid) then
                       doSendMsg(sid, "Você não pode transformar seu ditto estando duelo.")
                       return true
                    end
        
                    local nick = retireShinyName(getItemAttribute(item.uid, "poke"))
                          if getItemAttribute(item.uid, "poke") == "Ditto" and isShinyName(copy) then
                             doSendMsg(sid, "So um Shiny Ditto pode se transformar em pokemons do tipo Shiny.")
                             return true 
                          end
                    
                          if getItemAttribute(item.uid, "nick") then 
                             nick = getItemAttribute(item.uid, "nick") 
                          end
                          
                          if getItemAttribute(item.uid, "copyName") == copy then
                             doSendMsg(sid, "Seu ditto já é uma copia do " .. copy)
                             return true
                          end
                          
                          
                          
                          if not pokes[copy] then
                          if copy == "Ancient Electabuzz" then
                          copy = "Shiny Electabuzz"
                          else
                             doSendMsg(cid, "Isso não é um pokemon.")
                             print(">>>>>DittoBUG: " .. copy)
                             return true
                                                      end
                          end
                          
                    doPlayerSay(sid, nick..", copia a "..retireShinyName(copy)..".")
                    local levelin = getItemAttribute(getPlayerSlotItem(sid, 8).uid, "level")
                    local boostin = getItemAttribute(getPlayerSlotItem(sid, 8).uid, "boost") or 0
                    local heath_toDrawPercent = getCreatureMaxHealth(cid) - getCreatureHealth(cid)
                    doRemoveCreature(cid)
                    local poke = doCreateMonsterNick(sid, copy, nick.." [L"..levelin.."] [B+"..boostin.."]", pos, true)
                          doTeleportThing(poke, pos)
                 
                setPlayerStorageValue(poke, 510, copy)
                doCreatureSetLookDir(poke, dir)
                doItemSetAttribute(item.uid, "copyName", copy)
                doSendPlayerExtendedOpcode(sid, opcodes.OPCODE_BATTLE_POKEMON, tostring(poke))
                doUpdateMoves(sid)
                 getPokeDistanceToTeleport(poke)
                 adjustStatus(poke, item.uid, true, heath_toDrawPercent, true)
                 setPokemonGhost(poke)
                 if eff then
                   doSendMagicEffect(pos, 184) 
                 end
                 
                -- doOTCSendPokemonHealth(sid)
    end
    
    function round(num, idp)
      return tonumber(string.format("%." .. (idp or 0) .. "f", num))
    end
    
    function doGoPokemonInOrder(cid, item, goMsg)
        if getPlayerSlotItem(cid, 8).uid ~= item.uid then
           return true
        end
        
        item = getPlayerSlotItem(cid, ?
        if item.uid == 0 then return true end
        
                 local name = getItemAttribute(item.uid, "poke")
                 local nick = name 
                      if isInArray({"Ditto", "shiny ditto"}, name:lower()) then
                         name = getItemAttribute(item.uid, "copyName")
                      end
                
                 local effe = pokeballs[getPokeballType(item.itemid)].effect
           
             
                if getItemAttribute(item.uid, "nick") then
                     nick = getItemAttribute(item.uid, "nick")
                end
                
                local boostin = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "boost") or 0
                local levelin = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "level")
                
                pokeSourceCode = doCreateMonsterNick(cid, name, retireShinyName(nick).." [L"..levelin.."][B:"..boostin.."]", getThingPos(cid), true)
                if not pokeSourceCode then
                   doSendMsg(cid, "Erro. Comunique esse codigo ao GM. [31121994]")
                   return true
                end
                
                 local poke = getCreatureSummons(cid)[1] 
                 doTeleportThing(poke, farWayPos)
                 doTeleportThing(poke, getThingPos(cid))
                 
                 
                 doSendPlayerExtendedOpcode(cid, opcodes.OPCODE_BATTLE_POKEMON, tostring(poke))
                 setPlayerStorageValue(poke, 510, name)
                 doCreatureSetLookDir(poke, getPlayerLookDir(cid))
                 getPokeDistanceToTeleport(poke)
                 setMoveSummon(cid, true)
                 doUpdateMoves(cid)
                 doUpdateCooldowns(cid)
    
                 doItemEraseAttribute(item.uid, "healthChanged")
                 adjustStatus(poke, item.uid, true, true, true)
                 setPokemonGhost(poke)
                 if getCreatureSkullType(cid) == 5 then
                    doCreatureSetSkullType(cid, 0)
                 end
                 --setCreatureMaxHealth(poke, getBallMaxHealth(cid, item))
                 --doCreatureAddHealth(poke, -(getCreatureHealth(poke)-1))
                 --doCreatureAddHealth(poke, (getBallHealth(cid, item)-1))
                 --doItemSetAttribute(item.uid, "healthChanged", getCreatureName(cid))
                 --doOTCSendPokemonHealth(cid)
    end
    
    function doUp(cid, summon, move)
                         local pokeName = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "poke")
                         local ditto = getItemAttribute(getPlayerSlotItem(cid, 8).uid, "copyName")
                              if ditto and ditto ~= "" then
                                 pokeName = ditto
                              end
                         local outfit = getPokemonOutfitToSkill(pokeName)
                         local speed = getPokemonSpeedToSkill(pokeName)
                         addEvent(doRemoveCreature, 10, summon)
                         doSetCreatureOutfit(cid, {lookType = outfit + 351}, -1)
                         
                         doChangeSpeed(cid, -getCreatureSpeed(cid))
                         doChangeSpeed(cid, speed)
    
                         if #getCreatureSummons(cid) > 1 and getPlayerStorageValue(cid, 212124) <= 0 then     --alterado v1.6
                           if getPlayerStorageValue(cid, 637501) == -2 or getPlayerStorageValue(cid, 637501) >= 1 then  
                              BackTeam(cid)       
                           end
                         end
                        
                        if move == "ride" then 
                         setPlayerStorageValue(cid, orderTalks["ride"].storage, 1)
                        elseif move == "fly" then
                         setPlayerStorageValue(cid, orderTalks["fly"].storage, 1)
                        end
                        setPokemonGhost(cid)
                        
                        doPlayerSendCancel(cid, '12//,hide') --alterado v1.7
        
    end
    
    
    function getCylinderTiles(pos, cilinderSize) -- By SmiX
    local position = pos
    local c = cilinderSize
    local pos = {}
    for i=-c, c do
            for j=-c, c do
                    local posEffect = {x=position.x+i,y=position.y+j,z=position.z}
                      table.insert(pos, posEffect)
            end
    end
       return pos
    end
    
    function recheck(sid, skill, pos)
        if not isCreature(sid) or not isCreature(getCreatureMaster(sid)) then return end
        if not isUsingOrder(sid) then return true end
        local cid = getCreatureMaster(sid)
    
        if skill == "cut" then
    
            local item = getTileItemById(pos, 2767)
            if not item or item.uid <= 0 then return true end
            
            doCreatureSay(sid, "CUT!", TALKTYPE_MONSTER)
            doSendMagicEffect(getThingPos(item.uid), EFFECT_CUT)
            doTransformItem(item.uid, 6216)
            local function growRock()
                doTransformItem(getTileItemById(pos, 6216).uid, 2767)
                end
            addEvent(growRock, tempoPraVoltarAoNormal * 1000)
      
        elseif skill == "rock" then
    
            local item = getTileItemById(pos, 1285)
            if not item or item.uid <= 0 then return true end
            
            doCreatureSay(sid, "ROCK SMASH!", TALKTYPE_MONSTER)
            doSendMagicEffect(getThingPos(item.uid), EFFECT_DIG)
            doTransformItem(item.uid, 3610)
                local function growRock()
                doTransformItem(getTileItemById(pos, 3610).uid, 1285)
                end
            addEvent(growRock, tempoPraVoltarAoNormal * 1000)
            
     elseif skill == "headbutt" then  --alterado v1.6
    
        local item = getTileItemById(pos, 2707)    --id do item   arvore normal
            if not item or item.uid <= 0 then return true end
                
        local master = getCreatureMaster(sid)
        local array = {}                           
        local lvl = {25, 40, 60, 80, 150, 1000} --lvls
    
        for i = 1, #lvl do
            if getPlayerLevel(master) <= lvl[i] then
               array = headbutt[lvl[i]]
               break
            end
        end 
        local rand = array[math.random(#array)]
        for j = 1, rand[2] do        
            local poke = doCreateMonster(rand[1] , getClosestFreeTile(sid, pos))
            --doCreatureSay(sid, rand[1], TALKTYPE_MONSTER)
        end
        doCreatureSay(sid, "HEADBUTT!", TALKTYPE_MONSTER)
        doSendMagicEffect(getThingPos(item.uid), EFFECT_DIG)
        doTransformItem(item.uid, 2702)  --id do item   arvore quebrada
        local function growHead()
              doTransformItem(getTileItemById(pos, 2702).uid, 2707) --id do item  arvore quebrada, arvore normal
        end
        addEvent(growHead, choose(5, 8, 10, 15) * 60 * 1000)   --o tempo pra arvore voltar ao normal varia de 5~30min
    end 
       doEreaseUsingOrder(sid)   
    end
    
    function choose(...) -- by mock
        local arg = {...}
        return arg[math.random(1,#arg)]
    end
    
    
    function getFreeTile(pos)
       if canWalkOnPos(pos, true, false, false, false, false) then
          return pos
       end
       local tmp
       for dir = 0, 7 do
          tmp = getPosByDir(pos, dir)
          if canWalkOnPos(tmp, true, false, false, false, false) then
             return tmp
          end 
       end
       return farWayPos
    end
    
    ------------------------ marcar a pos do spawn do poke e retornar ela
    function doMarkedSpawnPos(cid)
    local pos = getThingPos(cid)
        setPlayerStorageValue(cid, storages.markedPosPoke, "x = "..pos.x..", y = "..pos.y..", z = "..pos.z..";")
    end
    
    function doMarkedPos(cid, pos)
        setPlayerStorageValue(cid, storages.markedPosPoke, "x = "..pos.x..", y = "..pos.y..", z = "..pos.z..";")
    end
    
    function isInPartyAndSharedExperience(cid)
        if isInParty(cid) and isPartyEnabledExp(cid) then
           return true
        end
        return false
    end
    
    function getMarkedSpawnPos(cid)
     local l = {}
     local pos = getPlayerStorageValue(cid, storages.markedPosPoke)
     local strPos = "x = (.-), y = (.-), z = (.-);"
       for a, b, c in pos:gmatch(strPos) do
          l = {x = tonumber(a), y = tonumber(b), z = tonumber(c)}
       end
       return l
    end
    
    function doComparePositions(position, positionEx)
    return position.x == positionEx.x and position.y == positionEx.y and position.z == positionEx.z
    end
    ------------------------ marcar a pos do spawn do poke e retornar ela
    
    function doPlayerAddPoke(cid, pokeName, ball, unique)
        local ballid = pokeballs[ball]
        local send = false
    
        if not ballid then
            return print("doPlayerAddPoke: Não foi encontrada a pokebola: "..ball)
        end
    
        if isUseIconSystem(cid) then
            id = pokeballs[string.lower(pokeName)].on
        else
            id = ballid.on
        end
    
        if (getPlayerFreeCap(cid) <= 1 and not isInArray({5, 6}, getPlayerGroupId(cid))) or not hasSpaceInContainer(getPlayerSlotItem(cid, 3).uid) then
            item = doCreateItemEx(id)
            send = true
        else
            item = addItemInFreeBag(getPlayerSlotItem(cid, 3).uid, id, 1)
        end
    
        doItemSetAttribute(item, "health", getPokemonHealth(pokeName))
        doItemSetAttribute(item, "maxHealth", getPokemonHealth(pokeName))
        doItemSetAttribute(item, "pokeName", doCorrectString(pokeName))
        doItemSetAttribute(item, "ballEffe", ball)
    
        if send then
            doPlayerSendMailByName(getCreatureName(cid), item, 1)
            doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Você já está segurando seis pokebolas, o seu novo pokemon foi enviado para o CP.")
        end
    end
    
    function hasSpaceInContainer(container)                --alterado v1.6
    if not isContainer(container) then return false end
    if getContainerSize(container) < getContainerCap(container) then return true end
    
    for slot = 0, (getContainerSize(container)-1) do
        local item = getContainerItem(container, slot)
        if isContainer(item.uid) then
           if hasSpaceInContainer(item.uid) then
              return true
           end
        end
    end
    return false
    end
    
    function doSendEffect(cid, effe)
    if not isCreature(cid) then return true end
       doSendMagicEffect(getThingPos(cid), effe)  
    end
    
    function doSendEffectAndText(cid, effe, text, color)
    if not isCreature(cid) then return true end
    if not color then color = 215 end
       doSendEffect(cid, effe)
       if text and text ~= "" then
          doSendAnimatedText(getThingPos(cid), text, color) 
       end
    end
    
    function setCreatureVisibility(cid, vis)
        if not isCreature(cid) then return true end
        if vis then
            doAddCondition(cid, invisiblecondition)
        else
            doRemoveCondition(cid, CONDITION_INVISIBLE)
        end
    end
    
    function setCreatureHick(cid, secs, i)
    if not isCreature(cid) then return true end
        i = i +1
        local pos2 = getThingPos(cid)
              pos2.x = pos2.x + math.random(1, 4)
              pos2.y = pos2.y + math.random(1, 4)
        if(i < secs) then
          local pos = getPosByDir(pos2, math.random(0, 7))
          local master = getCreatureMaster(cid)
            if(isPlayer(master)) then
               setMoveSummon(master, false)
            end
          doAddCondition(cid, bebo)
          doMovePokeToPos(cid, pos)
          pos = getThingPos(cid)
          pos.y = pos.y -1
          doSendMagicEffect(pos, 31)
          addEvent(setCreatureHick, 1000, cid, secs, i)
        else
           doRemoveCondition(cid, CONDITION_DRUNK)
        end
    end
    
    function doRemoveConditionWithSecurity(cid, cond)
    if not isCreature(cid) then return true end
             doRemoveCondition(cid, cond)
    end
    
    function doCanAttackOther(cid, target)
    
    setPlayerStorageValue(cid, storages.teamRed, 1)
    setPlayerStorageValue(target, storages.teamBlue, 1)
    
    end
    
    function isInDuel(cid)
    if not isCreature(cid) then return false end
       if getPlayerStorageValue(cid, storages.isInDuel) == 1 then
          return true 
        end
       return false
    end
    
    -------------- pokedex
    function getPokemonVitalityD(name)
        if not pokes[name] then return false end
        return pokes[name].vitality
    end
    
    function getPokemonAttackD(name)
        if not pokes[name] then return false end
        return pokes[name].offense
    end
    
    function getPokemonDefenseD(name)
        if not pokes[name] then return false end
        return pokes[name].defense
    end
    
    function getPokemonSpAttackD(name)
        if not pokes[name] then return false end
        return pokes[name].specialattack
    end
    
    function getPokemonLevelD(name)
        if not pokes[name] then return false end
        if pokes[name].level <= 1 then
            return 5
        end
        return pokes[name].level
    end
    
    function getPokemonPortraitD(name)
        if not pokes[name] then return false end
        return pokes[name].portrait
    end
    
    function getPokemonType1D(name)
        if not pokes[name] then return "normal" end
        return pokes[name].type
    end
    
    function getPokemonType2D(name)
        if not pokes[name] or not pokes[name].type2 then return false end
        return pokes[name].type2
    end
    
    function getPokemonHealthD(name)                
        if not pokes[name] then return false end
        return getMonsterInfo(name).healthMax
    end
    
    function getPokemonExperienceD(name)
        if not pokes[name] then return false end
        return getMonsterInfo(name).experience
    end
    
    function getPokemonCatchedStorage(name)
        if not pokes[name] then return false end
        return getMonsterInfo(name).lookCorpse
    end
    
    function getPokemonCorpse(name)
        if not pokes[name] then return false end
        return getMonsterInfo(name).lookCorpse
    end
    
    

     

     

    Por favor, poderiam me ajudar?

     

  • Quem Está Navegando   0 membros estão online

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