L2JMobius

C6 ExShowScreenMessage - messages in different places on the screen

Reanimation · 1 · 825

Online Reanimation

  • Knight
  • ***
    • Posts: 62
With this modification of the class, you will be able to have different ads on the screen, without having to fill out the chat themselves.

just add in your lines new ExShowScreenMessage this next: , ExShowScreenMessage.SMPOS.BOTTOM_RIGHT, false

leaving for example like this:
player.sendPacket(new ExShowScreenMessage("Welcome " + player.getName() + ", you are fighting for the " + Config.FACTION_EVIL_TEAM_NAME + " faction.", 10000 , ExShowScreenMessage.SMPOS.BOTTOM_RIGHT, false));

ExShowScreenMessage.java
Code: [Select]
package org.l2jmobius.gameserver.network.serverpackets;

import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;

/**
 * @author Kerberos
 */
public class ExShowScreenMessage implements IClientOutgoingPacket
{
public static enum SMPOS
{
DUMMY,
TOP_LEFT,
TOP_CENTER,
TOP_RIGHT,
MIDDLE_LEFT,
MIDDLE_CENTER,
MIDDLE_RIGHT,
BOTTOM_CENTER,
BOTTOM_RIGHT,
}

private final int _type;
private final int _sysMessageId;
// private final int _unk1;
private final boolean _hide;
private final int _unk2;
private final int _unk3;
// private final int _unk4;
private final boolean _fade;
private final int _size;
private final int _position;
private final boolean _effect;
private final String _text;
private final int _time;

public ExShowScreenMessage(String text, int time)
{
_type = 1;
_sysMessageId = -1;
// _unk1 = 0;
_hide = false;
_unk2 = 0;
_unk3 = 0;
// _unk4 = 0;
_fade = false;
_position = 0x02;
_text = text;
_time = time;
_size = 0;
_effect = false;
}

// public ExShowScreenMessage(int type, int messageId, int position, int unk1, int size, int unk2, int unk3, boolean showEffect, int time, int unk4, String text)
public ExShowScreenMessage(String text, int time, SMPOS pos, boolean effect)
{
this(text, time, pos.ordinal(), effect);
}

public ExShowScreenMessage(String text, int time, int pos, boolean effect)
{
_type = 1;
_sysMessageId = -1;
_hide = false;
_unk2 = 0;
_unk3 = 0;
_fade = false;
_position = pos;
_text = text;
_time = time;
_size = 0;
_effect = effect;
}

public ExShowScreenMessage(int type, int messageId, int position, boolean hide, int size, int unk2, int unk3, boolean showEffect, int time, boolean fade, String text)
{
_type = type;
_sysMessageId = messageId;
// _unk1 = unk1;
_hide = hide;
_unk2 = unk2;
_unk3 = unk3;
// _unk4 = unk4;
_fade = fade;
_position = position;
_text = text;
_time = time;
_size = size;
_effect = showEffect;
}

@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_SHOW_SCREEN_MESSAGE.writeId(packet);
packet.writeD(_type); // 0 - system messages, 1 - your defined text
packet.writeD(_sysMessageId); // system message id (_type must be 0 otherwise no effect)
packet.writeD(_position); // message position
// packet.writeD(_unk1); // ?
packet.writeD(_hide ? 1 : 0); // hide
packet.writeD(_size); // font size 0 - normal, 1 - small
packet.writeD(_unk2); // ?
packet.writeD(_unk3); // ?
packet.writeD(_effect ? 1 : 0); // upper effect (0 - disabled, 1 enabled) - _position must be 2 (center) otherwise no effect
packet.writeD(_time); // time
// packet.writeD(_unk4); // ?
packet.writeD(_fade ? 1 : 0); // fade effect (0 - disabled, 1 enabled)
packet.writeS(_text); // your text (_type must be 1, otherwise no effect)
return true;
}
}