RuneScape 2 Development > Server Tutorials

How to USE rs2dv.

Pages: <<< (35/48) >>>

x blitz x:

I need help i have added all the code to Command.java and Main.java and the command doesnt work. my code:
Command.java

--- Code: ---/*
 * Command.java
 *
 * Created on May 10th.
 *
 * Author: Hidendra < hid.en.dra@hotmail.com >
 *
 */

package net.varek.rs2d.packethandler;

import net.varek.rs2d.model.Player;
import net.varek.rs2d.net.Packet;
import net.varek.rs2d.model.Point;
import net.varek.rs2d.net.ActionSender;
import org.apache.mina.common.IoSession;


public class Command implements PacketHandler {

    public void handlePacket(Packet p, IoSession session) { // handle packet [103] ; commands
Player player = (Player)session.getAttachment();
String c = p.readRS2String();
ActionSender s = player.getActionSender();

if(c.equalsIgnoreCase("hello")) {
s.sendMessage("Hello world!");
}

    }

}

--- End code ---
Main.java

--- Code: ---/*
 * Main.java
 *
 * Created on 23-Dec-2007, 11:38:13
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */
package net.varek.rs2d.test;

import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import net.varek.rs2d.GameEngine;
import net.varek.rs2d.Server;
import net.varek.rs2d.model.World;
import net.varek.rs2d.packethandler.ActionButton;
import net.varek.rs2d.packethandler.PacketHandler;
import net.varek.rs2d.packethandler.PublicChat;
import net.varek.rs2d.packethandler.Walking;
import net.varek.rs2d.packethandler.Command;
import net.varek.rs2d.util.Logger;

/**
 *
 * @author alex
 */
public class Main {
private static final Map<Integer,String> packetNames = new HashMap<Integer,String>();

public static void main(String[] args) throws Exception {
World.loadWorld(new TestWorldLoader());
Server s = new Server();
Logger.log("Loaded world");
for(int i=0; i<handlers.length && i < handleIds.length; i++) {
PacketHandler h = handlers[i];
List<GameEngine.SingleBoundPacketHandler> overwritten = s.getGameEngine().registerPacketHandler(h, handleIds[i]);
if(overwritten != null)
Logger.err("Error! Overwritten packet handlers: "+overwritten.toString());
Logger.log("\tAdded packet handler: "+h+" (binds="+Arrays.toString(handleIds[i])+")");
}
s.start(43594);
Logger.log("Listening on port 43594");
    }

static {
int[] knownIds = new int[packetNames.size()];
Iterator<Integer> keys = packetNames.keySet().iterator();
for(int i=0; i<knownIds.length; i++) {
knownIds[i] = keys.next();
}

handleIds = new int[][] {
{ 0, 86, 210, 121, 3, 77, 202, 241 },
knownIds,
{ 164, 98, 248 },
{ 185 },
{ 4 },
{ 103 }
};
handlers = new PacketHandler[] {
new QuietPacketHandler(),
new DebuggingPacketHandler(packetNames),
new Walking(),
new ActionButton(),
new PublicChat(),
new Command()
};
}

private static final PacketHandler[] handlers;
private static final int[][] handleIds;
}

--- End code ---


jonaske:

Try readding it because i don't c any change
also try to print it out in ur console
maybe something wrong with sendmessage idk

Jonaske

bower007:

Nice tutorial! I don't use that but if some day I need I will come to see your post!

auroa:

ok, i'm having a shit load of problems with apache ant, and build.bat

Liamssword (Born2kill 92):

Sikkk bruvvv, thanks.

Pages: <<< (35/48) >>>

Go to full version