4 Replies - 440 Views - Last Post: 25 September 2013 - 11:45 AM Rate Topic: -----

#1 Xhalo7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 24-September 13

I tried everything but it just does not work.

Posted 24 September 2013 - 10:20 AM

Hello, i'm xhalo7. I have this problem for 6 months, and the problem is that, i've been making a BOTS (acclaim) private server, which in in java. that's why i'm here. Everything works perfecly, but the client does not recieve packets. No errors, but it isn't working. Also the serverside (a code error) doens't send packets aswell. However, it can login and start levels.

~Thanks
Xhalo7
Is This A Good Question/Topic? 0
  • +

Replies To: I tried everything but it just does not work.

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9383
  • View blog
  • Posts: 35,232
  • Joined: 12-June 08

Re: I tried everything but it just does not work.

Posted 24 September 2013 - 11:08 AM

That's a pretty general issue, abet even a confusing one. (as in how can it work perfectly but the client gets no data?).

You would have to show the code for what's going on. I mean you wrote this, right? It's not some sort of issue with you installing it?
Was This Post Helpful? 0
  • +
  • -

#3 Xhalo7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 24-September 13

Re: I tried everything but it just does not work.

Posted 25 September 2013 - 11:30 AM

/*
 * RelayServerConnection.java
 */
package ChannelServer;

import java.io.*;
import java.net.*;
import java.sql.*;

/**
 * RelayServerConnection reads policy requests from a client's socket and writes the server policy.
 */
public class ChannelServerConnection extends Thread
{

    protected Socket socket;
    protected BufferedReader socketIn;
    protected PrintWriter socketOut;
    protected ChannelServer server;
    protected Lobby lobby;
    protected String account;
    protected int bottype;
    protected String ip;
    protected String charname = "";
    protected MiscFunctions func = new MiscFunctions();
    protected boolean firstlog = true;
    protected BotClass bot;
    protected ItemClass item;
    protected Shop shop;
    protected SQLDatabase sql;

    /**
     * Creates a new instance of RelayServerConnection.
     */
    public ChannelServerConnection(Socket socket, ChannelServer server, Lobby _lobby, SQLDatabase _sql)
    {
        this.socket = socket;
        this.server = server;
        this.sql = _sql;
        item = new ItemClass(sql);
        this.ip = Main.getip(socket);
        this.lobby = _lobby;
        debug("" + socket.getLocalSocketAddress());
    }

    public void checkAccount()
    {
        try
        {
            ResultSet rs = Main.sql.doquery("SELECT username FROM bout_users WHERE current_ip='" + Main.getip(socket) + "' LIMIT 1");
            if (rs.next())
            {
                this.account = rs.getString("username");
            }
            if (this.account != null && isbanned(this.account) == 0)
            {
                //Main.sql.doupdate("UPDATE bout_users SET current_ip='' WHERE username='"+this.account+"'");
            }
            else
            {
                account = "a";
            }
        } catch (Exception e)
        {
            debug("Error :" + e);
        }
    }

    /**
     * Roots a debug message to the main application.
     */
    protected void debug(String msg)
    {
        Main.debug("ChannelServer (" + this.socket.getRemoteSocketAddress() + ")", msg);
    }

    public SocketAddress getRemoteAddress()
    {
        return this.socket.getRemoteSocketAddress();
    }

    protected int isbanned(String account)
    {
        try
        {

            ResultSet rs = Main.sql.doquery("SELECT banned FROM bout_users WHERE username='" + account + "' LIMIT 1");
            if (rs.next())
            {
                return rs.getInt("banned");
            }
        } catch (Exception e)
        {
        }
        return 0;
    }

    protected String removeheader(String packet)
    {
        return packet.substring(4);
    }

    protected String removenullbyte(String thestring)
    {
        byte[] stringbyte = thestring.getBytes();
        int a = 0;
        while (stringbyte[a] != 0x00)
        {
            a++;
        }
        return thestring.substring(0, a);
    }

    protected void prasecmd(int cmd, String packet)
    {
        try
        {
            Packet pack = new Packet();
            String[] packanwser = new String[2];
            switch (cmd)
            {
                case 0xF82A:
                    //debug("parse f8");
                    byte[] spacketb =
                    {
                        0x01, 0x00, 0x01, 0x00
                    };
                    socketOut.write(new String(ChannelServer.CLIENT_NUMBER_HEADER));
                    socketOut.flush();
                    //debug("send cnumberhead");
                    socketOut.write(new String(spacketb));
                    socketOut.flush();
                    //debug("send cnumberpacket");
                    break;

                case 0xF92A:
                    debug("parsing bots");
                    pack.addHeader((byte) 0x28, (byte) 0x27);
                    pack.addInt(1, 2, false);
                    send(pack);
                    pack.clean();
                    if (bot.checkbot())
                    {
                        bot.loadchar();
                        charname = bot.getName();
                        bottype = bot.getBot();
                        socketOut.write(new String(ChannelServer.CHARACTER_INFORMATION_HEADER));
                        socketOut.flush();
                        socketOut.write(bot.getpacketcinfo());
                        socketOut.flush();
                        byte[] bytearr =
                        {
                            (byte) 0x4E, (byte) 0x95, (byte) 0xDD, (byte) 0x29, (byte) 0xCE,
                            (byte) 0x3A, (byte) 0x55, (byte) 0xDB, (byte) 0x20, (byte) 0xB6, (byte) 0xAD,
                            (byte) 0x97, (byte) 0xA6, (byte) 0x5C, (byte) 0xC0, (byte) 0x1C
                        };
                        pack.addHeader((byte) 0x53, (byte) 0x2F);
                        pack.addByteArray(bytearr);
                        send(pack);
                        pack.clean();
                        pack.addHeader((byte) 0x27, (byte) 0x27);
                        pack.addInt(1, 2, false);
                        pack.addString(charname);
                        pack.addByte((byte) 0x00);
                        pack.addByte4((byte) 0xCC, (byte) 0xCC, (byte) 0x01, (byte) 0x01);
                        send(pack);
                        pack.clean();
                        pack.addHeader((byte) 0x4F, (byte) 0x2F);
                        pack.addInt(1, 2, false);
                        pack.addByte4((byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
                        send(pack);
                        pack.clean();

                    }
                    else
                    {
                        socketOut.write(new String(ChannelServer.CHARACTER_INFORMATION_HEADER));
                        socketOut.flush();
                        //debug("send cinfohead");
                        byte[] cinfopackbyte =
                        {
                            (byte) 0x00, (byte) 0x35
                        };
                        String cinfopack = new String(cinfopackbyte);
                        cinfopack += ChannelServer.longnullbyte;
                        socketOut.write(cinfopack);
                        socketOut.flush();
                    }
                    //debug("send cinfopack");
                    break;

                case 0xFA2A:
                {
                    //debug("parse fa");
                    //Packet pack = new Packet();
                    pack.setPacket(packet);
                    pack.removeHeader();
                    int client_num = pack.getInt(2);
                    int bottype = pack.getInt(2);
                    int unknown = pack.getInt(2);
                    String accountname = pack.getString(1, 23, false);
                    String charname = pack.getString(0, 15, false);
                    pack.clean();

                    if (this.account.equals("a"))
                    {
                        byte[] loginhack =
                        {
                            (byte) 0x00, (byte) 0x32
                        };
                        this.socket.getOutputStream().write(ChannelServer.BOT_CREATION_HEADER);
                        this.socket.getOutputStream().flush();
                        this.socket.getOutputStream().write(loginhack);
                        this.socket.getOutputStream().flush();
                        this.finalize();
                    }
                    else
                    {

                        if (!checkexist(charname, accountname))
                        {
                            if (charname.matches("[a-zA-Z0-9.~_!\\x2d]+"))
                            {
                                bot.createbot(accountname, charname, bottype);
                                socketOut.write(new String(ChannelServer.BOT_CREATION_HEADER));
                                socketOut.flush();
                                socketOut.write(new String(ChannelServer.CREATE_BOT_CREATED));
                                socketOut.flush();
                            }
                            else
                            {
                                socketOut.write(new String(ChannelServer.BOT_CREATION_HEADER));
                                socketOut.flush();
                                socketOut.write(new String(ChannelServer.CREATE_BOT_USERNAME_ERROR));
                                socketOut.flush();
                                this.finalize();
                            }
                        }
                        else
                        {
                            socketOut.write(new String(ChannelServer.BOT_CREATION_HEADER));
                            socketOut.flush();
                            socketOut.write(new String(ChannelServer.CREATE_BOT_USERNAME_TAKEN));
                            socketOut.flush();
                            this.finalize();
                        }
                    }
                    break;
                }

                case 0x742B:
                {
                    //Packet packs = new Packet();
                    if (firstlog)
                    {
                        lobby.adduser(this.charname, this.bottype, socketOut, socket);
                        firstlog = false;
                    }
                    //packs = lobby.getlobbypacket();
                    send(lobby.getlobbypacket());
                    // lobby.g
                    send(lobby.getroompacket(1, 0));
                    sendChatMsg("Welcome Secured's Test Server!", 4);
                    sendChatMsg("Have fun :)/>", 4);

                    this.socketOut.write(new String(ChannelServer.OK_HEADER));
                    this.socketOut.flush();
                    this.socketOut.write(new String(ChannelServer.OK_PACKET));
                    this.socketOut.flush();
                    break;
                }

                case 0x1A27:
                    pack.setPacket(packet);
                    pack.removeHeader();
                    String chatpack = pack.getPacket();
                    int a = func.compareChat(chatpack, this.charname, false, isGM());
                    if (a == -1)
                    {
                        lobby.kickPlayer(this.charname, "Player " + this.charname + " has been kick for wrong chatname(hacking)");
                    }
                    else
                    {
                        chatpack = chatpack.substring((a + this.charname.length() + 3));
                        chatpack = chatpack.substring(0, (chatpack.length() - 1));
                        debug(chatpack);
                        if (chatpack.startsWith("@"))
                        {
                            String command = chatpack.substring(1, chatpack.length());
                            parsechatcmd(command);
                        }
                        else
                        {
                            lobby.writeMessage(pack.getPacket(), this.charname, isGM());
                        }
                    }
                    pack.clean();
                    break;

                case 0x442B:
                    lobby.whisper(packet, this.charname);
                    break;

                case 0x222B:
                    sendBye(1);
                    this.finalize();
                    break;

                case 0xFB2A:
                    int anwser = bot.deleteBot(this.charname, this.account);
                    sendBye(anwser);
                    break;

                case 0x512B:
                    pack.addHeader((byte) 0x37, (byte) 0x2F);
                    pack.addPacketHead((byte) 0x01, (byte) 0x00);
                    pack.addInt(bot.getCoins(), 4, false);
                    send(pack);
                    send(bot.getInventPacket(0xEB));
                    break;

                case 0x022B:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 42, true);
                    int itemid = pack.getInt(4);
                    send(shop.buy(itemid));
                    //Main.sql.doupdate("UPDATE `bout_items` SET `buyable` = 1 WHERE id="+itemid);
                    break;
                }

                case 0x032B:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 42, true);
                    int slotnum = pack.getInt(2);
                    pack.getInt(2);
                    int itemid = pack.getInt(4);
                    send(shop.sell(itemid, slotnum));
                    break;
                }

                case 0x042B:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 42, true);
                    pack.getInt(2);
                    int itemid = pack.getInt(4);

                    send(shop.buycoin(itemid));
                    //Main.sql.doupdate("UPDATE `bout_items` SET `buyable` = 1 WHERE id="+itemid);
                    break;
                }

                case 0xFC2A:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 29, false);
                    int slot = pack.getInt(2);
                    pack.getInt(2);
                    send(bot.equip(slot, 1));
                    break;
                }

                case 0xFD2A:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 29, false);
                    int slot = pack.getInt(2);
                    pack.getInt(2);
                    send(bot.deequip(slot, 1));
                    break;
                }

                case 0x322B:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 6, false);
                    int slot = pack.getInt(2);
                    pack.clean();
                    send(bot.equip(slot, 2));
                    break;
                }

                case 0x332B:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 6, false);
                    int slot = pack.getInt(2);
                    pack.clean();
                    send(bot.deequip(slot, 2));
                    break;
                }

                case 0x342B:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 6, false);
                    int slot = pack.getInt(2);
                    pack.clean();
                    send(bot.equip(slot, 3));
                    break;
                }

                case 0x352B:
                {
                    pack.setPacket(packet);
                    pack.getString(0, 6, false);
                    int slot = pack.getInt(2);
                    pack.clean();
                    send(bot.deequip(slot, 3));
                    break;
                }


                case 0x412B:
                {
                    pack.setPacket(packet);
                    pack.removeHeader();
                    send(bot.getEquipByName(pack.getPacket()));
                    break;
                }

                case 0x0A2B:
                {
                    pack.setPacket(packet);
                    pack.removeHeader();
                    pack.getInt(2);
                    int page = pack.getInt(2);
                    int mode = pack.getInt(2);
                    send(lobby.getroompacket(mode, page));
                    pack.clean();
                    break;
                }

                case 0x092B:
                {
                    pack.setPacket(packet);
                    pack.removeHeader();
                    String cname = pack.getString(0, 27, false);
                    String cpass = pack.getString(0, 10, false);
                    pack.getInt(2);
                    int roommode = pack.getInt(1);
                    switch (roommode)
                    {
                        case 2:
                            roommode = 0;
                            break;

                        case 0:
                            roommode = 1;
                            break;

                        case 3:
                            roommode = 2;
                            break;
                    }
                    int num = lobby.addroom(roommode, cname, cpass, bot.getName(), bot.getLevel(), Main.getip(this.socket), this.socketOut, bot);
                    //lobby.setStatus(bot.getName(),0);
                    int[] room =
                    {
                        roommode, num
                    };
                    bot.setRoom(room);
                    break;
                }

                case 0x652B:
                {
                    int[] room = lobby.haveRoom(bot.getName());
                    if (room[0] == -1)
                    {
                        lobby.kickPlayer(this.charname, "Player " + this.charname + " has been kick for try to change map of not owning room(hacking)");
                    }
                    else
                    {
                        pack.setPacket(packet);
                        pack.removeHeader();
                        pack.getInt(2);
                        lobby.setRoomMap(room, pack.getInt(2));
                        pack.clean();
                    }
                    break;
                }

                case 0x062B:
                {
                    pack.setPacket(packet);
                    pack.removeHeader();
                    int roomnum = pack.getInt(1) - 89;
                    int roommode = pack.getInt(1);
                    switch (roommode)
                    {
                        case 2:
                            roommode = 0;
                            break;

                        case 0:
                            roommode = 1;
                            break;

                        case 3:
                            roommode = 2;
                            break;
                    }
                    String rname = pack.getString(0, 27, false);
                    String rpass = pack.getString(0, 10, false);
                    int[] room =
                    {
                        roommode, roomnum
                    };
                    Packet npacket = lobby.addRoomPlayer(room, rpass, ip, socketOut, bot);
                    if (npacket.getLen() == 1715)
                    {
                        bot.setRoom(room);
                        send(npacket);
                        //lobby.setStatus(bot.getName(),0);
                        ResultSet rs;
                        int port = 0;
                        while (port == 0)
                        {
                            rs = sql.doquery("SELECT `port` FROM `rooms` WHERE `ip`='" + ip + "'");
                            rs.next();
                            port = rs.getInt("port");
                        }

                        sql.doupdate("DELETE FROM `rooms` WHERE `ip` = '" + ip + "' and `port` = '" + port + "'");
                        lobby.isConnected(room, bot.getName(), port);
                    }
                    else
                    {
                        send(npacket);
                    }
                    break;
                }

                case 0x422B:
                {
                    int[] room = bot.getRoom();
                    if (room[0] == -1)
                    {
                        lobby.kickPlayer(this.charname, "Player " + this.charname + " has been kick for try to exit a room while he isn't in a room(hacking)");
                        break;
                    }
                    lobby.removeRoomPlayer(room, bot.getName());
                    break;
                }

                case 0x0B2B:
                {
                    int[] room = lobby.haveRoom(bot.getName());
                    if (room[0] == -1)
                    {
                        lobby.kickPlayer(this.charname, "Player " + this.charname + " has been kick for try to start not owning room(hacking)");
                    }
                    pack.setPacket(packet);
                    pack.removeHeader();
                    pack.getInt(2);
                    int map = pack.getInt(2);
                    int unknown = pack.getInt(2);
                    lobby.startRoom(room, map);
                    pack.clean();
                    break;
                }

                case 0x3E2B:
                {
                    if (bot.getRoom()[0] != -1)
                    {
                        lobby.readyToPlay(bot.getRoom(), bot.getName());
                    }
                    break;
                }

                case 0x392B:
                {
                    int slot = lobby.getSlot(bot.getRoom(), bot.getName());
                    if (slot == -1)
                    {
                        lobby.kickPlayer(this.charname, "Player " + this.charname + " has been kick for try to be ready and not being in a room(hacking)");
                    }
                    lobby.setRoomStatus(bot.getRoom(), slot);
                    break;
                }

                case 0x6F2B:
                {
                    pack.addHeader((byte)0x54, (byte)0x2F);
                    pack.addByte4((byte)0x01, (byte)0x00, (byte)0x00, (byte)0x00);
                    send(pack);
                }

                case 0x3A2B:
                {
                    int[] room = lobby.haveRoom(bot.getName());
                    if (room[0] == -1)
                    {
                        break;
                    }
                    pack.setPacket(packet);
                    pack.removeHeader();
                    int monsternum = pack.getInt(2);
                    int monstertyp = pack.getInt(2);
                    int who = pack.getInt(2);
                    lobby.roomMonsterDead(room, monstertyp, monsternum, who);
                }

                case 0x3C2B:
                {
                    if (bot.getRoom()[0] == -1)
                    {
                        break;
                    }
                    pack.setPacket(packet);
                    pack.removeHeader();
                    pack.getInt(2);
                    int typ = pack.getInt(1);
                    int num = pack.getInt(1);
                    lobby.useItem(bot.getRoom(), bot.getName(), typ, num);
                }



                default:
                    debug("ERROR IN PACKET!");
            }
        } catch (Exception e)
        {
            debug("Error aa" + e);
        }
    }

    protected void parsechatcmd(String cmd)
    {
        debug(cmd);
        String rcmd;
        Packet packet = new Packet();
        byte[] bytecmd = cmd.getBytes();
        int i = 0;
        while (bytecmd[i] != 0x20 && i < cmd.length() - 1)
        {
            i++;
        }

        if (i == cmd.length() - 1)
        {
            rcmd = cmd.substring(0, cmd.length());
        }
        else
        {
            rcmd = cmd.substring(0, i);
        }
        debug("rcmd : -" + rcmd + "-");

        if (rcmd.equals("kick") && isGM())
        {
            String chaname = cmd.substring(i + 1);
            if (lobby.kickPlayer(chaname, "Player " + chaname + " has been kicked by " + this.charname) == 0)
            {
                sendChatMsg("Player not found", 2);
            }
        }
        else
        {
            if (rcmd.equals("add") && isGM())
            {
                int anz = Integer.parseInt(cmd.substring(i + 1));
                lobby.createdummy(anz);
            }
            else
            {
                if (rcmd.equals("addroom") && isGM())
                {
                    int anz = Integer.parseInt(cmd.substring(i + 1));
                    lobby.createdummy(anz);
                }
                else
                {
                    if (rcmd.equals("coins"))
                    {
                        int anz = Integer.parseInt(cmd.substring(i + 1));
                        bot.setCoins((bot.getCoins() + anz));
                        sendChatMsg("Current coins : " + bot.getCoins(), 2);
                    }
                    else
                    {
                        if (rcmd.equals("gigas"))
                        {
                            int anz = Integer.parseInt(cmd.substring(i + 1));
                            bot.setGigas((bot.getGigas() + anz));
                            sendChatMsg("Current gigas : " + bot.getGigas(), 2);
                        }
                        else
                        {
                            if (rcmd.equals("delinvent"))
                            {
                                int part = Integer.parseInt(cmd.substring(i + 1));
                                if (part == 0)
                                {
                                    int[] items =
                                    {
                                        0, 0, 0, 0, 0, 0, 0, 0, 0, 0
                                    };
                                    bot.setInventAll(items);
                                    sendChatMsg("Invetory deleted", 2);
                                }
                                else
                                {
                                    String old = item.getItemName(bot.getInvent(part - 1));
                                    bot.setInvent(0, part - 1);
                                    sendChatMsg("Inventory-item " + old + " deleted.", 2);
                                }

                            }
                            else
                            {
                                if (rcmd.equals("item") && isGM())
                                {
                                    int id = 0;
                                    if (cmd.substring(i + 1).matches("\\d*"))
                                    {
                                        id = Integer.parseInt(cmd.substring(i + 1));
                                    }
                                    else
                                    {
                                        id = item.getItemId(cmd.substring(i + 1));
                                    }
                                    if (id != 0)
                                    {
                                        int slot = shop.slotAvaible();
                                        if (slot != -1)
                                        {
                                            bot.setInvent(id, slot);
                                            sendChatMsg("Item " + item.getItemName(id) + " added at slot " + slot, 2);
                                        }
                                        else
                                        {
                                            sendChatMsg("Your inventory is full!", 2);
                                        }
                                    }
                                    else
                                    {
                                        sendChatMsg("Item not found!", 2);
                                    }
                                }
                                else
                                {
                                    if (rcmd.equals("itemname"))
                                    {
                                        int id = Integer.parseInt(cmd.substring(i + 1));
                                        String name = item.getItemName(id);
                                        if (name != null)
                                        {
                                            sendChatMsg("Found :", 2);
                                            sendChatMsg("- " + name, 2);
                                        }
                                        else
                                        {
                                            sendChatMsg("Item not found!", 2);
                                        }
                                    }
                                    else
                                    {
                                        if (rcmd.equals("itemid"))
                                        {
                                            String name = cmd.substring(i + 1);
                                            String id[] = item.getItemIdLike(name);
                                            if (id != null)
                                            {
                                                int found = Integer.parseInt(id[5]);
                                                int display;
                                                if (found > 5)
                                                {
                                                    display = 5;
                                                }
                                                else
                                                {
                                                    display = found;
                                                }
                                                if (display == 1)
                                                {
                                                    sendChatMsg("Found " + found + " item, displaying " + display + " item.", 2);
                                                }
                                                else
                                                {
                                                    sendChatMsg("Found " + found + " items, displaying " + display + " items.", 2);
                                                }
                                                for (int i2 = 0; i2 < display; i2++)
                                                {
                                                    sendChatMsg("- " + id[i2], 2);
                                                }
                                            }
                                            else
                                            {
                                                sendChatMsg("No item found!", 2);
                                            }
                                        }
                                        else
                                        {
                                            if (rcmd.equals("help"))
                                            {
                                                sendChatMsg("@dummy <amount>          - need gm rights", 2);
                                                sendChatMsg("@kick <charactername     - need gm rights>", 2);
                                                sendChatMsg("@coins <amount>", 2);
                                                sendChatMsg("@gigas <amount>", 2);
                                                sendChatMsg("@delinvent <part/0 for all>", 2);
                                                sendChatMsg("@itemname <itemid>", 2);
                                                sendChatMsg("@itemid <itemname>", 2);
                                                sendChatMsg("@item <itemid/itemname>  - need gm rights", 2);
                                            }
                                            else
                                            {
                                                if (rcmd.equals("refresh"))
                                                {
                                                    send(lobby.getlobbypacket());
                                                    sendChatMsg("Userlist refreshed", 2);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    protected void send(Packet pack)
    {
        String[] packet = new String[2];
        packet[0] = pack.getHeader();
        packet[1] = pack.getPacket();
        this.socketOut.write(packet[0]);
        this.socketOut.flush();
        this.socketOut.write(packet[1]);
        this.socketOut.flush();
    }

    protected void sendBye(int whatpack)
    {
        Packet pack = new Packet();
        String[] packandhead = new String[2];
        switch (whatpack)
        {
            case 1:
                pack.addHeader((byte) 0x0A, (byte) 0x2F);
                pack.addInt(1, 2, false);
                packandhead[0] = pack.getHeader();
                packandhead[1] = pack.getPacket();
                this.socketOut.write(packandhead[0]);
                this.socketOut.flush();
                this.socketOut.write(packandhead[1]);
                this.socketOut.flush();
                break;

            case 2:
                pack.addHeader((byte) 0xE3, (byte) 0x2E);
                pack.addInt(1, 2, false);
                packandhead[0] = pack.getHeader();
                packandhead[1] = pack.getPacket();
                this.socketOut.write(packandhead[0]);
                this.socketOut.flush();
                this.socketOut.write(packandhead[1]);
                this.socketOut.flush();
                break;
        }
    }

    protected boolean isGM()
    {
        if (this.account.equals("auron") || this.account.equals("auron3") || this.account.equals("kevinwagner"))
        {
            return true;
        }
        return false;
    }

    protected void sendChatMsg(String msg, int color)
    {
        Packet pack = new Packet();

        pack.addHeader((byte) 0x1A, (byte) 0x27);

        pack.addByte4((byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
        pack.addInt(color, 2, false);
        pack.addString(msg);
        pack.addByte((byte) 0x00);

        String[] packandhead = new String[2];

        packandhead[0] = pack.getHeader();
        packandhead[1] = pack.getPacket();

        this.socketOut.write(packandhead[0]);
        this.socketOut.flush();
        this.socketOut.write(packandhead[1]);
        this.socketOut.flush();

    }

    protected boolean checkexist(String charname, String account)
    {
        try
        {

            ResultSet rs = Main.sql.doquery("SELECT username FROM bout_characters WHERE name='" + charname + "' LIMIT 1");
            if (rs.next())
            {
                String username = rs.getString("username");
                debug(username);
                return true;
            }
            rs = Main.sql.doquery("SELECT name FROM bout_characters WHERE username='" + account + "' LIMIT 1");
            if (rs.next())
            {
                String name = rs.getString("name");
                debug(name);
                return true;
            }
            rs = Main.sql.doquery("SELECT * FROM bout_users WHERE username='" + account + "' LIMIT 1");
            if (rs.next())
            {
                return false;
            }
            else
            {
                return true;
            }
        } catch (Exception e)
        {
        }
        return false;
    }

    protected String read()
    {
        StringBuffer buffer = new StringBuffer();
        int codePoint;

        try
        {
            //debug("start read");
            for (int i = 0; i < 4; i++)
            {
                codePoint = this.socketIn.read();
                if (codePoint == 0)
                {
                    String nulls = new String(ChannelServer.NULLBYTE);
                    buffer.append(nulls);
                }
                else
                {
                    if (Character.isValidCodePoint(codePoint))
                    {
                        buffer.appendCodePoint(codePoint);
                    }
                }
            }
            int plen = func.bytetoint(buffer.toString().substring(2), 2);

            if (plen > 1)
            {

                for (int i = 0; i < plen; i++)
                {
                    codePoint = this.socketIn.read();
                    if (codePoint == 0)
                    {
                        String nulls = new String(ChannelServer.NULLBYTE);
                        buffer.append(nulls);
                    }
                    else
                    {
                        if (Character.isValidCodePoint(codePoint))
                        {
                            buffer.appendCodePoint(codePoint);
                        }
                    }
                }
                //debug("end read");
            }
        } catch (Exception e)
        {
            debug("Error (read): " + e.getMessage());
            this.server.remove(this.getRemoteAddress());
            return null;
        }

        return buffer.toString();
    }

    /**
     * Create a reader and writer for the socket and call readPolicyRequest.
     */
    public void run()
    {
        try
        {
            this.socketIn = new BufferedReader(new InputStreamReader(this.socket.getInputStream(), "ISO8859-1"));
            this.socketOut = new PrintWriter(new OutputStreamWriter(this.socket.getOutputStream(), "ISO8859-1"));
            checkAccount();
            bot = new BotClass(this.account, this.ip, this.item, sql);
            shop = new Shop(bot, item);
            String packet;
            while ((packet = read()) != null)
            {
                //debug("main");
                prasecmd(func.getcmd(packet), packet);
            }
        } catch (Exception e)
        {
            debug("Exception (runhzhz): " + e.getMessage());
        }
        //debug("bye");
        this.finalize();
    }

    /**
     * Closes the reader, the writer and the socket.
     */
    protected void finalize()
    {
        try
        {
            if (!this.charname.equals(""))
            {
                int[] room = bot.getRoom();
                if (room[0] != -1)
                {
                    lobby.removeRoomPlayer(room, bot.getName());
                }
                lobby.removeuser(charname);
                debug("remove charname " + charname);
                this.charname = "";
            }
            this.server.remove(this.getRemoteAddress());
            this.socketIn.close();
            this.socketOut.close();
            this.socket.close();
        } catch (Exception e)
        {
            debug("Exception (finalize): " + e.getMessage());
        }
    }
}



Long way. I wrote this myself.
Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 9383
  • View blog
  • Posts: 35,232
  • Joined: 12-June 08

Re: I tried everything but it just does not work.

Posted 25 September 2013 - 11:38 AM

nice! What, if you could summarize, did you do?
Was This Post Helpful? 0
  • +
  • -

#5 Xhalo7  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 24-September 13

Re: I tried everything but it just does not work.

Posted 25 September 2013 - 11:45 AM

The server isn't sending the right packets in line 625
Here's another code, which is doing the same in line 688 (probably here is the packet error)
package ChannelServer;

import java.io.PrintWriter;
import java.sql.ResultSet;
/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author Secured
 */


public class Room
{

    private int[] roomnum = new int[2];
    private byte roomtyp = -1;
    private String roomname = new String();
    private String roompass = new String();
    private String roomowner = new String();
    private int roomlevel = -1;
    private byte roomstatus = 1;
    private int roommap = -1;
    private String roomip = new String();
    private String[] roomplayer = new String[8];
    private PrintWriter[] roomsocks = new PrintWriter[8];
    private byte[][] roomips = new byte[8][4];
    private BotClass[] bot = new BotClass[8];
    private int[] roomposi = new int[8];
    private int[] roomid = new int[8];
    private int[] roomport = new int[8];
    private boolean[] roomready = new boolean[8];
    private boolean[] roomreadytoplay = new boolean[8];
    private SQLDatabase sql;
    private boolean[] dead = new boolean[8];
    private int[] killcount = new int[8];
    private int[] monster;
    private Sector sector;
    private int lala = 0;
    private int[] items;
    private String owner;
    
    protected void debug(String msg) {
        Main.debug("["+owner+"]", msg);
    }
    
    public Room(int[] rnum, String rname, String rpass, int rlvl, String rowner, String rip, PrintWriter osock, BotClass _bot, SQLDatabase _sql)
    {
        try
        {
            this.sql = _sql;
            this.roomnum = rnum;
            this.roomname = rname;
            this.roompass = rpass;
            this.roomlevel = rlvl;
            this.roomowner = rowner;
            this.roomip = rip;
            this.roomplayer[0] = rowner;
            this.roomsocks[0] = osock;
            this.bot[0] = _bot;
            this.roomport[0] = 0;
            this.roomposi[0] = 0x70;
            this.roomid[0] = 0;
            this.roomready[0] = true;
            this.roomreadytoplay[0] = false;

            String[] ip = rip.split("\\.");
            for (int i = 0; i < 4; i++)
            {
                this.roomips[0][i] = (byte) Integer.parseInt(ip[i]);
            }

            switch (roomnum[0])
            {
                case 0:
                    this.roomtyp = 2;
                    this.sector = new Sector();
                    break;

                case 1:
                    this.roomtyp = 0;
                    break;

                case 2:
                    this.roomtyp = 3;
                    break;
            }

            sql.doupdate("INSERT INTO `rooms` (`ip`) VALUES ('" + this.roomip + "')");

            Packet pack = new Packet();
            pack.addHeader((byte) 0xEE, (byte) 0x2E);
            pack.addPacketHead((byte) 0x01, (byte) 0x00);
            pack.addByte((byte) (this.roomnum[1] + 89));
            switch (this.roomnum[0])
            {
                case 0:
                    pack.addByte((byte) 0x02);
                    break;

                case 1:
                    pack.addByte((byte) 0x00);
                    break;

                case 2:
                    pack.addByte((byte) 0x03);
                    break;

            }
            String[] aip = this.roomip.split("\\.");
            pack.addByte4((byte) Integer.parseInt(aip[0]),
                    (byte) Integer.parseInt(aip[1]),
                    (byte) Integer.parseInt(aip[2]),
                    (byte) Integer.parseInt(aip[3]));

            writeRoomPlayer(0, pack);
            pack.clean();

            ResultSet rs;
            while (this.roomport[0] == 0)
            {
                rs = sql.doquery("SELECT `port` FROM `rooms` WHERE `ip`='" + this.roomip + "'");
                if (rs.next())
                    this.roomport[0] = rs.getInt("port");
            }

            sql.doupdate("DELETE FROM `rooms` WHERE `ip` = '"+this.roomip+"' and `port` = '"+this.roomport[0]+"'");
            debug("[this.roomip]" + this.roomip);
            debug("[this.roomport]" + this.roomport);
            debug("[this.roompass]" + this.roompass);



            pack.addHeader((byte) 0x4A, (byte) 0x2F);
            pack.addByte4((byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00);
            writeRoomPlayer(0, pack);
            pack.clean();
            this.roommap = 0;

            pack.addHeader((byte) 0x39, (byte) 0x27);
            pack.addInt(7033, 2, true);
            for (int i = 0; i < 7; i++)
            {

                pack.addByte2((byte) 0x00, (byte) 0x00);
            }
            writeRoomPlayer(0, pack);

        } catch (Exception e)
        {
        }
    }

    public boolean isEmpty()
    {
        if (this.roomowner.equals(""))
        {
            return true;
        }
        else
        {
            return false;
        }
    }

    public boolean removePlayer(String player)
    {
        int slot = getSlot(player);
        int a = 0;
        boolean setowner = false;
        for (int i = 0; i < 8; ++i)
        {
            if (this.roomplayer[i] != null && this.roomplayer[i].equals(player))
            {
                if (this.roomowner.equals(player))
                {
                    setowner = true;
                }
                writeRoomPlayer(i, getQuitPacket(slot));
                this.roomplayer[i] = "";
                this.roomsocks[i] = null;
                this.roomready[i] = false;
                this.roomposi[i] = 0;
                this.bot[i] = null;
                this.roomport[i] = -1;
                this.roomid[i] = -1;

                for (int i2 = 0; i2 < 4; ++i2)
                {
                    this.roomips[i][i2] = 0;
                }
            }
            else
            {
                if (this.roomsocks[i] == null)
                {
                    ++a;
                }
            }
        }
        if (a >= 7)
        {
            return true;
        }
        else
        {
            if (!setowner)
            {
                writeRoomAll(getQuitPacket(slot));
                return false;
            }
            for (int i = 0; i < 8; ++i)
            {
                if (this.roomplayer[i] != null && !this.roomplayer[i].equals(""))
                {
                    this.roomowner = this.roomplayer[i];
                    this.roomposi[i] = 0x70;
                    writeRoomAll(getQuitPacket(slot));
                    return false;
                }
            }
        }
        return true;
    }

    public String getName()
    {
        return this.roomname;
    }

    public String getPass()
    {
        return this.roompass;
    }

    public int getLevel()
    {
        return this.roomlevel;
    }

    public int getStatus()
    {
        return this.roomstatus;
    }

    public String getOwner()
    {
        return this.roomowner;
    }

    public int getMap()
    {
        return this.roommap;
    }

    public void setMap(int map)
    {
        this.roommap = map;
        Packet packet = new Packet();
        packet.addHeader((byte) 0x4A, (byte) 0x2F);
        packet.addPacketHead((byte) 0x01, (byte) 0x00);
        packet.addInt(map, 2, false);
        writeRoomAll(packet);
    }

    protected void writeRoomAll(Packet pack)
    {
        for (int i = 0; i < 8; i++)
        {
            Packet packet = pack;
            if (this.roomsocks[i] != null)
            {
                this.roomsocks[i].write(packet.getHeader());
                this.roomsocks[i].flush();
                this.roomsocks[i].write(packet.getPacket());
                this.roomsocks[i].flush();
            }
        }
    }

    protected void writeRoomAllExcept(int num, Packet packet)
    {
        for (int i = 0; i < 8; i++)
        {
            if (this.roomsocks[i] != null && i != num)
            {
                this.roomsocks[i].write(packet.getHeader());
                this.roomsocks[i].flush();
                this.roomsocks[i].write(packet.getPacket());
                this.roomsocks[i].flush();
            }
        }
    }

    protected void writeRoomPlayer(int num, Packet packet)
    {
        this.roomsocks[num].write(packet.getHeader());
        this.roomsocks[num].flush();
        this.roomsocks[num].write(packet.getPacket());
        this.roomsocks[num].flush();
    }

    public void startRoom()
    {
        for (int i = 0; i < 8; i++)
        {
            if (this.roomsocks[i] != null && !this.roomready[i])
            {
                for (int i2=0; i2<8; i2++)
                    this.killcount[i2] = 0;
                Packet packet = new Packet();
                packet.addHeader((byte) 0xF3, (byte) 0x2E);
                packet.addPacketHead((byte) 0x00, (byte) 0x50);
                writeRoomPlayer(getSlot(this.roomowner), packet);
                return;
            }
        }

        this.roomstatus = 3;

        if (this.roomtyp == 2)
            this.monster = sector.getMapMonster(this.roommap);

        for (int i = 0; i < 8; i++)
        {
            if (this.roomsocks[i] != null)
            {
                Packet packet = new Packet();
                packet.addHeader((byte) 0xF3, (byte) 0x2E);
                packet.addPacketHead((byte) 0x01, (byte) 0x00);
                packet.addByte((byte) (roomnum[1] + 89));
                packet.addByte(this.roomtyp);
                packet.addInt(this.roommap, 2, false);
                packet.addByte2((byte) 0x03, (byte) 0x00);
                packet.addByte2((byte) (this.roomnum[1]), (byte) this.roomid[i]);
                packet.addByte2((byte) 0x00, (byte) 0x00);
                packet.addByte2((byte) 0x03, (byte) 0x00);
                writeRoomPlayer(i, packet);
            }
        }
    }

    public void readyToPlay(String name)
    {
        for (int i = 0; i<8; i++)
        {
            if (this.roomsocks[i] != null && this.roomplayer[i].equals(name))
            {
                roomreadytoplay[i] = true;
                checkStart();
                return;
            }
        }
    }

    private void checkStart()
    {
        for (int i = 0; i<8; i++)
            if (this.roomsocks[i] != null && !roomreadytoplay[i])
                return;

        Packet packet = new Packet();
        packet.addHeader((byte) 0x24, (byte) 0x2F);
        packet.addByte((byte) 0xCC);
        writeRoomAll(packet);
    }


    public Packet addPlayer(String player, String pass, String rip, PrintWriter socks, BotClass botc)
    {
        try {
        if (!this.roompass.equals(pass)) //wrong pass
        {
            Packet packet = new Packet();
            packet.addHeader((byte) 0x28, (byte) 0x2F);
            packet.addByte2((byte) 0x00, (byte) 0x3E);
            return packet;
        }
        if (this.roomstatus == 3) //already starten
        {
            Packet packet = new Packet();
            packet.addHeader((byte) 0x28, (byte) 0x2F);
            packet.addByte2((byte) 0x00, (byte) 0x3B);
            return packet;
        }
        for (int i = 0; i < 8; i++)
        {
            if (this.roomsocks[i] == null)
            {
                sql.doupdate("INSERT INTO `rooms` (`ip`) VALUES ('" + rip + "')");
                this.roomplayer[i] = player;
                this.bot[i] = botc;
                this.roomposi[i] = 0x50;

                this.roomport[i] = 0;
                this.roomid[i] = i;
                this.roomreadytoplay[i] = false;

                this.roomready[i] = false;

                String[] ip = rip.split("\\.");
                for (int i2 = 0; i2 < 4; i2++)
                {
                    this.roomips[i][i2] = (byte) Integer.parseInt(ip[i2]);
                }
                


                Packet packet = new Packet();
                packet.addHeader((byte) 0x29, (byte) 0x27);
                packet.addString(generateUserPack(i));
                this.writeRoomAll(packet);
                this.roomsocks[i] = socks;

                return getRoomPacket();
            }
        }
        Packet packet = new Packet();
        packet.addHeader((byte) 0x28, (byte) 0x2F);
        packet.addByte2((byte) 0x00, (byte) 0x50);
        return packet;
        } catch (Exception e){

        }
        return null;
    }

    public void isConnected(String name, int port)
    {
        for (int i = 0; i < 8; i++)
        {
            if (this.roomplayer[i].equals(name))
            {
                this.roomport[i] = port;
                this.writeRoomAll(this.getConnectedPacket());
                return;
            }
        }

    }

    private String generateUserPack(int num)
    {
        Packet packet = new Packet();
        packet.addInt(this.bot[num].getLevel(), 2, false);
        int[] equip = this.bot[num].getEquipAll();
        for (int i = 0; i < 19; i++)
        {
            packet.addInt(equip[i], 4, false);
        }
        packet.addByte2((byte) 0x02, (byte) 0x00);
        packet.addByte2((byte) (this.roomnum[1]), (byte) this.roomid[num]);

        for (int i = 0; i < 4; i++)
        {
            packet.addByte(this.roomips[num][i]);
        }

        for (int i = 0; i < 2; i++)
        {
            packet.addByte4((byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
        }
        packet.addByte2((byte) 0x00, (byte) 0x00);

        if (num == 0)
        //packet.addByte2((byte)27, (byte)(this.roomid[num]+161));
        {
            packet.addInt(this.roomport[num], 2, true);
        }
        else
        {
            packet.addByte2((byte) 0x00, (byte) 0x00);
        }

        for (int i = 0; i < 4; i++)
        {
            packet.addByte(this.roomips[num][i]);
        }

        for (int i = 0; i < 5; i++)
        {
            packet.addByte2((byte) 0x00, (byte) 0x00);
        }

        packet.addByte((byte) this.roomposi[num]);


        for (int i = 0; i < 5; i++)
        {
            packet.addByte4((byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
        }

        packet.addInt(bot[num].getAttMin()+bot[num].getAttMinB(), 2, false);
        packet.addInt(bot[num].getAttMax()+bot[num].getAttMaxB(), 2, false);
        packet.addInt(bot[num].getAttMinTrans()+bot[num].getAttMinTransB(), 2, false);
        packet.addInt(bot[num].getAttMaxTrans()+bot[num].getAttMaxTransB(), 2, false);
        packet.addInt(bot[num].getHp()+bot[num].getHpB(), 2, false);
        packet.addInt(0, 2, false);
        packet.addInt(bot[num].getTransGauge()+bot[num].getTransGaugeB(), 2, false);
        packet.addInt(bot[num].getCrit()+bot[num].getCritB(), 2, false);
        packet.addInt(bot[num].getEvade()+bot[num].getEvadeB(), 2, false);
        packet.addInt(bot[num].getSpecialTrans()+bot[num].getSpecialTransB(), 2, false);
        packet.addInt(bot[num].getSpeed()+bot[num].getSpeedB(), 2, false);
        packet.addInt(bot[num].getTransDef()+bot[num].getTransDefB(), 2, false);
        packet.addInt(bot[num].getTransBotAtt()+bot[num].getTransBotAttB(), 2, false);
        packet.addInt(bot[num].getTransSpeed()+bot[num].getTransSpeedB(), 2, false);
        packet.addInt(bot[num].getRangeAtt()+bot[num].getRangeAttB(), 2, false);
        packet.addInt(bot[num].getLuk()+bot[num].getLukB(), 2, false);
        packet.addInt(bot[num].getBot(), 2, false);

        packet.addByte((byte) num);
        packet.addByte4((byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);

        String name = this.roomplayer[num];

        byte[] nullbyteb =
        {
            0x00
        };
        String nullbyte = new String(nullbyteb);

        while (name.length() != 15)
        {
            name += nullbyte;
        }

        packet.addString(name);

        for (int i = 0; i < 21; i++)
        {
            packet.addByte((byte) 0x00);
        }

        return packet.getPacket();

    }

    private Packet getRoomPacket()
    {
        Packet packet = new Packet();
        packet.addHeader((byte) 0x28, (byte) 0x2F);
        packet.addPacketHead((byte) 0x01, (byte) 0x00);
        for (int i = 0; i < 8; i++)
        {
            if (this.roomsocks[i] != null)
            {
                packet.addString(this.generateUserPack(i));
            }
            else
            {
                for (int z = 0; z < 52; z++)
                {
                    packet.addByte4((byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
                }
            }
        }
        packet.addByte2((byte) (this.roomnum[1] + 89), this.roomtyp);
        String cname = this.roomname;

        byte[] nullbyteb =
        {
            0x00
        };
        String nullbyte = new String(nullbyteb);

        while (cname.length() != 38)
        {
            cname += nullbyte;
        }

        packet.addString(cname);
        packet.addByte2((byte) this.roomtyp, (byte) 0x08);
        packet.addByte2((byte) 0x01, (byte) 0x00);
        packet.addByte2((byte) 0x00, (byte) 0x00);
        packet.addByte((byte) 0x00); //key
        packet.addByte2((byte) 0x00, (byte) 0x00);

        //16 --- locked
        return packet;
    }

    public int getSlot(String user)
    {
        for (int i = 0; i < 8; i++)
        {
            if (this.roomplayer[i].equals(user))
            {
                return i;
            }
        }
        return -1;
    }


    private Packet getQuitPacket(int slot)
    {
        Packet pack = new Packet();
        pack.addHeader((byte) 0x2E, (byte) 0x27);
        pack.addByte4((byte) 0x01, (byte) 0x00, (byte) slot, (byte) 0x01);
        for (int i = 0; i < 8; i++)
        {
            if (this.roomsocks[i] != null)
            {
                pack.addByte((byte) this.roomposi[i]);
            }
            else
            {
                pack.addByte((byte) 0x00);
            }
        }
        return pack;
    }

    public Packet getConnectedPacket()
    {
        Packet packet = new Packet();
        packet.addHeader((byte) 0x39, (byte) 0x27);
        for (int i = 0; i < 8; i++)
        {
            if (this.roomsocks[i] != null)
            {
                packet.addInt(this.roomport[i], 2, true);
            }
            else
            {
                packet.addByte2((byte) 0x00, (byte) 0x00);
            }
        }
        return packet;
    }

    public int getOwnerPort()
    {
        for (int i = 0; i < 8; i++)
        {
            if (this.roomplayer[i] != null && this.roomplayer[i].equals(this.roomowner))
            {
                return this.roomport[i];
            }
        }
        return -1;
    }

    public void changeStatus(int slot)
    {
        if (!this.roomready[slot])
        {
            this.roomready[slot] = true;
        }
        else
        {
            this.roomready[slot] = false;
        }

        Packet packet = new Packet();
        packet.addHeader((byte) 0x20, (byte) 0x2F);
        packet.addInt(slot, 2, false);
        packet.addByte4((byte) 0x00, (byte) 0x00, (byte) 0x01, (byte) 0x00);
        if (this.roomready[slot])
        {
            packet.addByte4((byte) 0x01, (byte) 0x00, (byte) 0x00, (byte) 0x00);
        }
        else
        {
            packet.addByte4((byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00);
        }

        for (int i = 0; i < 8; i++)
        {
            if (this.roomsocks != null)
            {
                writeRoomPlayer(i, packet);
            }
        }

    }

    public void died(String name)
    {
        for (int i = 0; i<8; i++)
            if (this.roomsocks[i] != null && this.roomplayer[i].equals(name))
                this.dead[i] = true;
    }

    public void monsterKilled(int typ, int num, int killedby)
    {
        try {
        if (this.monster[num] == typ)
        {
            this.monster[num] = -1;
            this.killcount[killedby]++;
            Packet packet = new Packet();
            packet.addHeader((byte)0x18, (byte)0x00);
            packet.addPacketHead((byte)0x18, (byte)0x00);
            packet.addInt(num, 2, false);
            packet.addByte2((byte)0xFF3F, (byte)0x00);
            if (typ == 2)
            {
                packet.addByte4((byte) 0x08, (byte) 0x2F, (byte) 0x08, (byte)0x00);
            }
            else if (typ == 102)
            {
                packet.addByte4((byte) 0x08, (byte) 0x2F, (byte) 0x08, (byte) 0x06);
            } 
            else
                packet.addByte4((byte) 0x01, (byte) 0x00, (byte) 0x0C, (byte) 0x06);
            



            writeRoomAll(packet);
            
                for (int i = 0; i<sector.Mapmon; i++)
                    if (this.monster[i] != -1)
                    {
                        return;
                    }
            writeRoomMessage("All monster are killed");
            for (int i = 0; i<8; i++)
                if(this.roomsocks[i] != null)
                    writeRoomMessage(this.roomplayer[i]+" : "+this.killcount[i]);

            Thread.sleep(10000);
            for (int i=0; i<8; i++)
                if (this.roomsocks[i] != null)
                    removePlayer(this.roomplayer[i]);

        }
        } catch (Exception e){

        }
    }

    private void writeRoomMessage(String msg)
    {
        Packet packet = new Packet();
        packet.addHeader((byte)0x1A, (byte)0x27);
        packet.addByte4((byte)0x01, (byte)0x00, (byte)0x0F, (byte)0x00);
        packet.addByte2((byte)0x01, (byte)0x00);
        packet.addString("[Room] ");
        packet.addString(msg);
        packet.addByte((byte)0x00);
        writeRoomAll(packet);
    }

    public void useItem(String who, int typ, int num)
    {
        int slot = getSlot(who);
        Packet packet = new Packet();
        packet.addHeader((byte)0x23, (byte)0x2F);
        packet.addInt(slot, 2, false);
        packet.addByte((byte)typ);
        packet.addByte((byte)num);
        writeRoomAll(packet);
    }
}


Was This Post Helpful? 0
  • +
  • -

Page 1 of 1