Ir para conteúdo

Posts Recomendados

  • 3 weeks later...
Postado
  Em 04/10/2021 em 20:30, najatheus disse:

Sistema funciona da seguinte maneira, ao clicar na alavanca, vai gerar um numero de 1 a quantidade de mesa ou piso que for configurado na tabela, esse numero sera a posição do item até o ponto que o player vai receber o item, assim si o player tirar o menor numero possivel ele podera ter a sorte de receber os stacks do items, vou estar deixando um video aqui em baixo mostrando o sistema

Expand  

 

tem como add um itens pro player poder girar a roleta? por ex: o player presisa de determinado item e lvl pra poder girar e se ele nao tiver aparecera uma mensagem e se ele tive ele consegue girar e os itens que presisa some do inventario dele

Postado (editado)
  Em 29/10/2021 em 12:37, rafersiq disse:

 

tem como add um itens pro player poder girar a roleta? por ex: o player presisa de determinado item e lvl pra poder girar e se ele nao tiver aparecera uma mensagem e se ele tive ele consegue girar e os itens que presisa some do inventario dele

Expand  
local configuration_table = {
    storage_pos_item = 0; -- não mexa
    level_requeriment = { -- requimento para poder girar alavanca
        min = 1;
        max = 100;
    };
    count = 0; -- não mexa
    player_to_use_item_id = 3000; -- id do item que o player precisa ter para girar a roleta
    count_gire_item = 0; -- não mexa
    bag_id = 1991; -- id da bag que o player vai receber junto com o item
    count_remove = 0; -- não mexa
    floor_id_or_table = 10449; -- id da mesa ou piso que vão ficar os item por cima
    items = {3000, 2012, 13042, 13045, 13047, 13051, 13044, 13041}; -- items da roleta que vai ser usado na roleta
    effect_item = 8; -- efeito de quando estiver gerando o item
    effect_addItem = 1;  -- efeito de qnd o player receber o item
    effect_addItem_remove = 32; -- efeito de qnd o item for pro slot do player
    effect_removeItem = 36; -- efeito de qnd for remover os item da mesa ou piso
    time_create_item = 400; -- tempo para criar um a um item na mesa ou piso
    time_calcule_pos_item = 500; -- tempo para mover o item para a proxima posição
    time_count_calcule_pos_item = 3200; -- tempo para começar a mover o item ( obs o calculo min tem que ser a quantidade de mesa que vai ter x o tempo time_create_item)
    position = { -- configuração dos movimentos e posição
        create_item = { -- posição para criar os items
            [1] = {x = 981, y = 945, z = 7};
            [2] = {x = 981, y = 946, z = 7};
            [3] = {x = 982, y = 945, z = 7};
            [4] = {x = 982, y = 946, z = 7};
            [5] = {x = 983, y = 945, z = 7};
            [6] = {x = 983, y = 946, z = 7};
            [7] = {x = 984, y = 945, z = 7};
            [8] = {x = 984, y = 946, z = 7};
        };
        roleta = { -- giros da roleta
            [1] = {            
                [1] = {x = 0, y = 1, z = 0};
                [2] = {x = 1, y = -1, z = 0};
                [3] = {x = 0, y = 1, z = 0};
                [4] = {x = 1, y = -1, z = 0};
                [5] = {x = 0, y = 1, z = 0};
                [6] = {x = 1, y = -1, z = 0};
                [7] = {x = 0, y = 1, z = 0};
                [8] = {x = 3, y = 0, z = 0};
            };
            [2] = {
                [1] = {x = 0, y = 0, z = 0};
                [2] = {x = 1, y = -1, z = 0};
                [3] = {x = 0, y = 1, z = 0};
                [4] = {x = 1, y = -1, z = 0};
                [5] = {x = 0, y = 1, z = 0};
                [6] = {x = 1, y = -1, z = 0};
                [7] = {x = 0, y = 1, z = 0};
                [8] = {x = 3, y = 0, z = 0};
            };
            [3] = {
                [1] = {x = 0, y = 0, z = 0};
                [2] = {x = 0, y = 0, z = 0};
                [3] = {x = 0, y = 1, z = 0};
                [4] = {x = 1, y = -1, z = 0};
                [5] = {x = 0, y = 1, z = 0};
                [6] = {x = 1, y = -1, z = 0};
                [7] = {x = 0, y = 1, z = 0};
                [8] = {x = 3, y = 0, z = 0};
            };
            [4] = {
                [1] = {x = 0, y = 0, z = 0};
                [2] = {x = 0, y = 0, z = 0};
                [3] = {x = 0, y = 0, z = 0};
                [4] = {x = 1, y = -1, z = 0};
                [5] = {x = 0, y = 1, z = 0};
                [6] = {x = 1, y = -1, z = 0};
                [7] = {x = 0, y = 1, z = 0};
                [8] = {x = 3, y = 0, z = 0};
            };
            [5] = {
                [1] = {x = 0, y = 0, z = 0};
                [2] = {x = 0, y = 0, z = 0};
                [3] = {x = 0, y = 0, z = 0};
                [4] = {x = 0, y = 0, z = 0};
                [5] = {x = 0, y = 1, z = 0};
                [6] = {x = 1, y = -1, z = 0};
                [7] = {x = 0, y = 1, z = 0};
                [8] = {x = 3, y = 0, z = 0};
            };
            [6] = {
                [1] = {x = 0, y = 0, z = 0};
                [2] = {x = 0, y = 0, z = 0};
                [3] = {x = 0, y = 0, z = 0};
                [4] = {x = 0, y = 0, z = 0};
                [5] = {x = 0, y = 0, z = 0};
                [6] = {x = 1, y = -1, z = 0};
                [7] = {x = 0, y = 1, z = 0};
                [8] = {x = 3, y = 0, z = 0};
            };
            [7] = {
                [1] = {x = 0, y = 0, z = 0};
                [2] = {x = 0, y = 0, z = 0};
                [3] = {x = 0, y = 0, z = 0};
                [4] = {x = 0, y = 0, z = 0};
                [5] = {x = 0, y = 0, z = 0};
                [6] = {x = 0, y = 0, z = 0};
                [7] = {x = 0, y = 1, z = 0};
                [8] = {x = 3, y = 0, z = 0};
            };
            [8] = {
                [1] = {x = 0, y = 0, z = 0};
                [2] = {x = 0, y = 0, z = 0};
                [3] = {x = 0, y = 0, z = 0};
                [4] = {x = 0, y = 0, z = 0};
                [5] = {x = 0, y = 0, z = 0};
                [6] = {x = 0, y = 0, z = 0};
                [7] = {x = 0, y = 0, z = 0};
                [8] = {x = 3, y = 0, z = 0};
            };
        }
    }
}

local function createItemPos()
    if(configuration_table.count >= #configuration_table.position.create_item)then
        configuration_table.count = 0
        return
    end

    configuration_table.count = configuration_table.count + 1

    local item = Game.createItem(configuration_table.items[math.random(1, #configuration_table.items)], 1, configuration_table.position.create_item[configuration_table.count])
    local pos_item = item:getPosition()
    pos_item:sendMagicEffect(configuration_table.effect_item)
    item:setAttribute(ITEM_ATTRIBUTE_DESCRIPTION, "Item do evento da roleta")
    addEvent(createItemPos, configuration_table.time_create_item)
end

local function removeItemPos()
    if(configuration_table.count_remove >= #configuration_table.position.create_item)then
        configuration_table.count_remove = 0
        return
    end

    configuration_table.count_remove = configuration_table.count_remove + 1

    local tile = Tile(configuration_table.position.create_item[configuration_table.count_remove])
    if not tile then
        return
    end

   local item = tile:getTopVisibleThing()
   if not item then
       return
   end

   if(item:getId() == configuration_table.floor_id_or_table)then
        return removeItemPos()
   end

   item:getPosition():sendMagicEffect(configuration_table.effect_removeItem)
   item:remove()
   removeItemPos()
end

local function addItemPlayer(player_uid)
    local player = Player(player_uid)
    if not player then
        return
    end

    local tile = Tile(configuration_table.storage_pos_item)
    if not tile then
        return
    end

    local item = tile:getTopVisibleThing()
    if not item then
        return
    end

    local player_pos = player:getPosition()
    local item_pos = item:getPosition()

    local bag = player:addItem(configuration_table.bag_id, 1, true, 1, 3)
    bag:addItem(item:getId(), item:getCount(), true, 1, 3)
    player_pos:sendMagicEffect(configuration_table.effect_addItem)
    item_pos:sendMagicEffect(configuration_table.effect_addItem_remove)
    item:remove(item:getCount())
end

local function calculePosItem(value, player_uid)
    if(configuration_table.count_gire_item >= #configuration_table.position.create_item)then
        removeItemPos()
        addItemPlayer(player_uid)
        configuration_table.count_gire_item = 0
        return nil
    end

    configuration_table.count_gire_item = configuration_table.count_gire_item + 1

    local tile = Tile(configuration_table.position.create_item[configuration_table.count_gire_item])
    if not tile then
        return nil
    end

   local item = tile:getTopVisibleThing()
   if not item then
       return nil
   end

   if(item:getId() == configuration_table.floor_id_or_table)then
       return nil
   end

   local pos = item:getPosition()
   local item_pos_x = pos.x
   local item_pos_y = pos.y
   local item_pos_z = pos.z

   local pos_ = configuration_table.position.roleta[value]

   local position = Position(item_pos_x + pos_[configuration_table.count_gire_item].x, item_pos_y + pos_[configuration_table.count_gire_item].y, item_pos_z)
   if not position then
        return nil
   end

    configuration_table.storage_pos_item = position

   item:moveTo(position)
   addEvent(calculePosItem, configuration_table.time_calcule_pos_item, value, player_uid)
end

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if(player:getLevel() > configuration_table.level_requeriment.max)then
        return(not(player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " your level(" .. player:getLevel() .. ") needs to be bigger(" .. configuration_table.level_requeriment.max .. ")")))
    end

    if(player:getLevel() < configuration_table.level_requeriment.min)then
        return(not(player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " your level(" .. player:getLevel() .. ") needs to be smaller(" .. configuration_table.level_requeriment.min .. ")")))
    end

    local item_ = player:getItemById(configuration_table.player_to_use_item_id, true, -1)

    if not item_ then
        return not player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " você não tem o item")
    end

    if(configuration_table.count_gire_item >= 1) or (configuration_table.count >= 1) or (configuration_table.count_remove >= 1)then
        return(not(player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " wait the roulette is in action, wait for it to finish")))
    end

    local random = math.random(1, #configuration_table.position.roleta)

    item_:remove(1)

    configuration_table.storage_pos_item = 0

    createItemPos()
    addEvent(calculePosItem, configuration_table.time_count_calcule_pos_item, random, player.uid)
    Game.sendAnimatedText("Spin number will be: " .. random, player:getPosition(), math.random(1, 255))
    player:sendTextMessage(MESSAGE_INFO_DESCR, player:getName() .. " item of the day is on the rocks there")
  return true
end


Espero ter ajudado

Editado por najatheus (veja o histórico de edições)
  • 1 month later...
Postado

Para colocar itens muito raros ou VIP, seria bom se você tivesse uma chance em cada item que aparecer.

por exemplo:

 

red apple: 50% chance
crystal coin: 20%
red gem: 20%
green gem: 7%
vip legs: 3%

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

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

  Apenas 75 emojis são permitidos.

×   Seu link foi automaticamente incorporado.   Mostrar como link

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

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

×
×
  • Criar Novo...

Informação Importante

Confirmação de Termo