[SHARE] Announce dropped item from mob (need specify id of item) (good for epic itens announce works only from mob drops)

Rafito

Heir
[SHARE] Announce dropped item from mob (need specify id of item) (good for epic itens announce works only from mob drops)



1710711195006.png}
 
Last edited:
EN: I updated, I tested and tested even more and I managed to solve it, now I just need to create an array of item ids (I don't know yet because I don't know Java, but if I manage to do it I'll update the post)
If you liked it, leave a feedback.

PT-BR:
Script para mostrar o drop no chat shout com um item id específico, logo irei atualizar com possibilidade de colocar uma lista de itens ou um config na qual seja mais fácil de configurar somente os ids ou possibilidade de ser em outros chats ou no próprio PM.
 
Updated:
  • Code
  • External jar
  • List with ids
(Good for epic items)
1710255352909.png


Today i will create a protection to not spam chat if not dropped from mob, if anyone can help, i will thank
 
If anyone can adapt an option to validate whether it was dropped from a mob to help with the evolution of the mod, I would be grateful.
 
funcionou aqui. obrigado.
BR:
Obrigado por testar, estou esperando implementações pra melhoria dele, pra realmente verificar se foi dropado de um mob, pra evitar spam no chat, por enquanto vai deixando somente os itens assim pra evitar q joguem e catem e fique spamando no chat:

<set name="tradeable" value="false"/>

EN
Thanks for testing, I'm waiting for implementations to improve it, to really check if it was dropped from a mob, to avoid spam in the chat, for now just leave items like this to prevent them from being thrown and picked up and spammed in the chat:

<set name="tradeable" value="false"/>
 
Can anyone tell me how I can add a method that checks the relationship between the monster/npc and the item in which it was dropped? If you can help, how do I instantiate it.

Example, currently in the script it only checks the id.

In the future, it will check if the item was dropped from a monster/mob.
 
Last edited:
EN:
Updated code!

It is no longer spamming the chat if the player throws the item on the ground and picks it up again, now it checks if the item has already been dropped before (itemInstance.getLastDropTime() == 0), if it is 0 the item is new (it was created from a monster or something)


BR:
Código atualizado!

Não é mais spam no chat se o jogador jogar o item no chão e pegá-lo novamente, agora ele verifica se o item já foi dropado antes (itemInstance.getLastDropTime() == 0), se for 0 o item é novo (foi criado a partir de um monstro ou algo assim)
 
[COMPARTILHAR] Anunciar item descartado da máfia (precisa especificar id do item) (bom para itens épicos, anunciar funciona apenas a partir de quedas da máfia)

PT: O código é atualizado e só requer IDS para anunciar, verificar se o item já foi descartado antes para poder anunciá-lo para evitar spam no bate-papo se alguém continuar jogando e coletá-lo de volta (itemInstance.getLastDropTime() == 0), agora você pode retornar os itens para dropable = true para que os jogadores possam soltá-los quando tiverem karma, (Quando outros jogadores coletarem as gotas PK, elas não serão mais anunciadas).

BR: O código está atualizado e somente necessita de IDS para anunciar, verifica se o item já foi dropado antes pra poder anunciar pra evitar spam no chat caso alguém fique jogando e catando de volta (itemInstance.getLastDropTime() == 0), agora você pode retornar os itens para dropable = true para poder os jogadores deixarem dropar quando estiver com karma, (quando outros jogadores catarem os drops de pk não vai anunciar mais).


Java:
pacote Anunciar;

importar l2.gameserver.Announcements;
importar l2.gameserver.listener.actor.player.OnItemPickupListener;
importar l2.gameserver.model.Player;
importar l2.gameserver.model.actor.listener.PlayerListenerList;
importar l2.gameserver.model.items.ItemInstance;
importar l2.gameserver.network.l2.components.ChatType;
importar l2.gameserver.scripts.Functions;
importar l2.gameserver.scripts.ScriptFile;

importar java.io.BufferedReader;
importar java.io.File;
importar java.io.FileReader;
importar java.io.IOException;
importar java.time.LocalTime;
importar java.time.format.DateTimeFormatter;
importar java.util.ArrayList;
importar java.util.List;

public class Announce estende Functions implementa ScriptFile, OnItemPickupListener {

    private static final List<Integer> itemIds = new ArrayList<>();

    @Override
    public void onLoad() {
 PlayerListenerList.addGlobal(este);
        loadItemIds();
 System.out.println("Script de anunciar drops ativossss
    }

    @Override
    public void onReload() {}

    @Override
    public void onShutdown() {
 PlayerListenerList.removeGlobal(este);
    }

    @Override
 public void onItemPickup(Player player, itemInstance itemInstance) {
        if (itemIds.contains(itemInstance.getItemId()) && itemInstance.getLastDropTime() == 0) {
            String currentTime = LocalTime.now().format(DateTimeFormatter.ofPattern("HH:mm:ss"));
            String playerName = player.getName();
            String itemName = itemInstance.getName();
            String message = String.format("[%s] >Atenção< : O jogador %s obteve o item [%s]", currentTime, playerName, itemName);

 System.out.println(mensagem);
 Announcements.getInstance().announceToAll(mensagem, ChatType.SHOUT);
        }
    }

    private void loadItemIds() {
 try (leitor BufferedReader = new BufferedReader(new FileReader(new File("config/itemids.properties")))) {
 Linha de corda;
 enquanto ((linha = reader.readLine()) != null) {
                int itemId = Integer.parseInt(line.trim());
                itemIds.add(itemId);
                System.out.println("Ids dos itens carregados corretamente - Sistema de Anunciar Drops");
            }
        } catch (IOException e) {
            System.err.println("Erro ao carregar IDs de itens do arquivo config/itemids.properties: " + e.getMessage());
        }
    }

}
[/CÓDIGO]

[config/itemids.properties]

[CODE=java]236[/CÓDIGO]


[ATTACH=completo]3700[/ATTACH]}
[/QUOTE]
funciou aqui, como faço pra adicionar duas menssagens?
 
Last edited:
@Junenhol2

String message = String.format("PT: [%s] >Atenção< : O jogador %s obteve o item [%s]", currentTime, playerName, itemName);
String message1 = String.format("EN: [%s] >Attention< : The player %s has obtained [%s]", currentTime, playerName, itemName);

System.out.println(message);
System.out.println(message1);

Announcements.getInstance().announceToAll(message, ChatType.SHOUT);
Announcements.getInstance().announceToAll(message1, ChatType.SHOUT);
 
@Rafito si quiero que en el chat global/trade y cosas asi, aparezca como:

[Trade] - Rafito: eu galera
[Global] - Rafito: wts> lucera scripts

es parte del systemmsg.dat?
 
Back
Top