Thread: [PI] CMD Printing Unhandeled IDs

Results 1 to 9 of 9
  1. #1 [PI] CMD Printing Unhandeled IDs 
    Registered Member
    Join Date
    Oct 2010
    Posts
    68
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    What should I add so my CMD will print out object ids when pressed.

    Server.java

    Code:
    package server;
    
    import java.io.IOException;
    import java.net.InetSocketAddress;
    import java.text.DecimalFormat;
    
    import org.apache.mina.common.IoAcceptor;
    import org.apache.mina.transport.socket.nio.SocketAcceptor;
    import org.apache.mina.transport.socket.nio.SocketAcceptorConfig;
    
    import server.event.EventManager;
    import server.model.npcs.NPCHandler;
    import server.model.npcs.NPCDrops;
    import server.model.players.PlayerHandler;
    import server.model.players.Player;
    import server.model.players.Client;
    import server.model.players.PlayerSave;
    import server.model.minigames.*;
    import server.net.ConnectionHandler;
    import server.net.ConnectionThrottleFilter;
    import server.util.ShutDownHook;
    import server.util.SimpleTimer;
    import server.util.log.Logger;
    import server.world.*;
    import server.world.ItemHandler;
    import server.world.ObjectHandler;
    import server.world.ObjectManager;
    import server.world.ShopHandler;
    import server.world.map.VirtualWorld;
    import server.world.ClanChatHandler;
    import server.world.WorldMap;
    
    /**
     * Server.java
     *
     * @author Sanity
     * @author Graham
     * @author Blake
     * @author Ryan Lmctruck30
     *
     */
    
    public class Server {
    	
    	
    	public static boolean sleeping;
    	public static final int cycleRate;
    	public static boolean UpdateServer = false;
    	public static long lastMassSave = System.currentTimeMillis();
    	private static IoAcceptor acceptor;
    	private static ConnectionHandler connectionHandler;
    	private static ConnectionThrottleFilter throttleFilter;
    	private static SimpleTimer engineTimer, debugTimer;
    	private static long cycleTime, cycles, totalCycleTime, sleepTime;
    	private static DecimalFormat debugPercentFormat;
    	public static boolean shutdownServer = false;		
    	public static boolean shutdownClientHandler;			
    	public static int serverlistenerPort; 
    	public static ItemHandler itemHandler = new ItemHandler();
    	public static PlayerHandler playerHandler = new PlayerHandler();
        public static NPCHandler npcHandler = new NPCHandler();
    	public static ShopHandler shopHandler = new ShopHandler();
    	public static ObjectHandler objectHandler = new ObjectHandler();
    	public static ObjectManager objectManager = new ObjectManager();
    	public static CastleWars castleWars = new CastleWars();
    	public static FightPits fightPits = new FightPits();
    	public static PestControl pestControl = new PestControl();
    	public static WarriorsGuild warriorsGuild = new WarriorsGuild();
    	public static NPCDrops npcDrops = new NPCDrops();
    	public static ClanChatHandler clanChat = new ClanChatHandler();
    	public static WorldMap worldMap = new WorldMap();
    	//private static final WorkerThread engine = new WorkerThread();
    	
    	static {
    		if(!Config.SERVER_DEBUG) {
    			serverlistenerPort = 43594;
    		} else {
    			serverlistenerPort = 43594;
    		}
    		cycleRate = 600;
    		shutdownServer = false;
    		engineTimer = new SimpleTimer();
    		debugTimer = new SimpleTimer();
    		sleepTime = 0;
    		debugPercentFormat = new DecimalFormat("0.0#%");
    	}
    	//height,absX,absY,toAbsX,toAbsY,type
        /*public static final boolean checkPos(int height,int absX,int absY,int toAbsX,int toAbsY,int type)
        {
            return I.I(height,absX,absY,toAbsX,toAbsY,type);
        }*/
    	public static void main(java.lang.String args[]) throws NullPointerException, IOException {
    		/**
    		 * Starting Up Server
    		 */
    		WalkingCheck.check();
    		System.setOut(new Logger(System.out));
    		System.setErr(new Logger(System.err));
    		System.out.println("ChromaticFusion is Online Sir");
    		
    		/**
    		 * World Map Loader
    		 */
    		//if(!Config.SERVER_DEBUG)
    		//VirtualWorld.init();
    		//WorldMap.loadWorldMap();
    
    		/**
    		 * Script Loader
    		 */
    		//ScriptManager.loadScripts();
    		
    		/**
    		 * Accepting Connections
    		 */
    		acceptor = new SocketAcceptor();
    		connectionHandler = new ConnectionHandler();
    		
    		SocketAcceptorConfig sac = new SocketAcceptorConfig();
    		sac.getSessionConfig().setTcpNoDelay(false);
    		sac.setReuseAddress(true);
    		sac.setBacklog(100);
    		
    		throttleFilter = new ConnectionThrottleFilter(Config.CONNECTION_DELAY);
    		sac.getFilterChain().addFirst("throttleFilter", throttleFilter);
    		acceptor.bind(new InetSocketAddress(serverlistenerPort), connectionHandler, sac);
    
    		/**
    		 * Initialise Handlers
    		 */
    		EventManager.initialize();
    		Connection.initialize();
    		//highscore.createCon();
    		//PlayerSaving.initialize();
    		//MysqlManager.createConnection();
    		
    		/**
    		 * Server Successfully Loaded 
    		 */
    		System.out.println("Server listening on port 0.0.0.0:" + serverlistenerPort);
    		/**
    		 * Main Server Tick
    		 */
    		try {
    			while (!Server.shutdownServer) {
    				if (sleepTime >= 0)
    					Thread.sleep(sleepTime);
    				else
    					Thread.sleep(600);
    				engineTimer.reset();
    				itemHandler.process();
    				playerHandler.process();	
    	            npcHandler.process();
    				shopHandler.process();
    				objectManager.process();
    				fightPits.process();
    				pestControl.process();
    				warriorsGuild.process();
    				
    				cycleTime = engineTimer.elapsed();
    				sleepTime = cycleRate - cycleTime;
    				totalCycleTime += cycleTime;
    				cycles++;
    				debug();
    				if (System.currentTimeMillis() - lastMassSave > 300000) {
    					for(Player p : PlayerHandler.players) {
    						if(p == null)
    							continue;						
    						PlayerSave.saveGame((Client)p);
    						System.out.println("Saved game for " + p.playerName + ".");
    						lastMassSave = System.currentTimeMillis();
    					}
    				
    				}
    			}
    		} catch (Exception ex) {
    			ex.printStackTrace();
    			System.out.println("A fatal exception has been thrown!");
    			for(Player p : PlayerHandler.players) {
    				if(p == null)
    					continue;						
    				PlayerSave.saveGame((Client)p);
    				System.out.println("Saved game for " + p.playerName + ".");
    			}
    		}
    		acceptor = null;
    		connectionHandler = null;
    		sac = null;
    		System.exit(0);
    	}
    	
    	public static void processAllPackets() {
    		for (int j = 0; j < playerHandler.players.length; j++) {
    			if (playerHandler.players[j] != null) {
    				while(playerHandler.players[j].processQueuedPackets());			
    			}	
    		}
    	}
    	
    	public static boolean playerExecuted = false;
    	private static void debug() {
    		if (debugTimer.elapsed() > 360*1000 || playerExecuted) {
    			long averageCycleTime = totalCycleTime / cycles;
    			System.out.println("Average Cycle Time: " + averageCycleTime + "ms");
    			double engineLoad = ((double) averageCycleTime / (double) cycleRate);
    			System.out.println("Players online: " + PlayerHandler.playerCount+ ", engine load: "+ debugPercentFormat.format(engineLoad));
    			totalCycleTime = 0;
    			cycles = 0;
    			System.gc();
    			System.runFinalization();
    			debugTimer.reset();
    			playerExecuted = false;
    		}
    	}
    	
    	public static long getSleepTimer() {
    		return sleepTime;
    	}
    	
    }
    Reply With Quote  
     

  2. #2  
    Banned
    Join Date
    May 2010
    Posts
    1,550
    Thanks given
    92
    Thanks received
    154
    Rep Power
    0
    Why the hell did you give us the Server class..?

    Add this is ActionHandler.java, under the firstClickObject void:

    Code:
    		c.sendMessage("Object type: " + objectType);

    I need rep, so it's appreciated.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Oct 2010
    Posts
    68
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Eh, Always thought server handled that, excuse me for not knowing that. Anyways yours make it print ingame, not on the cmd I believe. Also I'm looking for the ids for clicking buttons, not the object ID.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Oct 2010
    Posts
    68
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Bump.
    Reply With Quote  
     

  5. #5  
    Banned

    Join Date
    Jan 2010
    Posts
    3,664
    Thanks given
    533
    Thanks received
    918
    Rep Power
    0
    Quote Originally Posted by SodomizedU View Post
    Eh, Always thought server handled that, excuse me for not knowing that. Anyways yours make it print ingame, not on the cmd I believe. Also I'm looking for the ids for clicking buttons, not the object ID.
    Your main thread says object ids retard.

    Anyways, this is what you do for a cmd print...

    Code:
    System.out.println("String :" + theVariableNameToBePrinted);
    so you could do..

    if (p.username == "your username") {
    System.out.println("Button :" + buttonId);
    }
    or if you have a class handling clicking buttons (actionbuttons) you could use a switch case and do

    switch(buttonId) {
    case 50:
    instruction per ID
    break;
    default:
    System.out.println("Button :" + buttonId);
    break;
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Oct 2010
    Posts
    68
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Quote Originally Posted by `Makaveli View Post
    Your main thread says object ids retard.
    Then again I'm not looking for Object IDs. Actionbutton IDs.

    Code:
    [PI] CMD Printing Unhandeled IDs
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Sep 2010
    Posts
    87
    Thanks given
    1
    Thanks received
    2
    Rep Power
    1
    1, check if you have ::idtoggle command first...
    2, what the hell does unhandeled ids mean?
    does that mean ids of stuff that you didnt personally add?
    Reply With Quote  
     

  8. #8  
    Registered Member Recursion's Avatar
    Join Date
    Feb 2010
    Posts
    638
    Thanks given
    0
    Thanks received
    29
    Rep Power
    41
    I'm a bit confused now.. are you looking for action buttons or for the objects ID?

    Other players have already posted for the object id code, so I'll post an action button code.


    In your ActionButtons/clickingmost class, add this:
    Code:
    			if (c.playerName.equalsIgnoreCase("SodomizedU")) {
    				c.sendMessage("id : "+ actionButtonId + ". ");
    			}
    Above:
    Code:
    switch (actionButtonId) {
    That will send the action button id to you in game. If you want it for the CMD box, use this instead:
    Code:
    			if (c.playerName.equalsIgnoreCase("SodomizedU")) {
    				System.out.println("id : "+ actionButtonId + ". ");
    			}
    Pretty basic stuff..
    Reply With Quote  
     

  9. #9  
    Registered Member
    Join Date
    Oct 2010
    Posts
    68
    Thanks given
    0
    Thanks received
    0
    Rep Power
    1
    Quote Originally Posted by jake3393 View Post
    1, check if you have ::idtoggle command first...
    2, what the hell does unhandeled ids mean?
    does that mean ids of stuff that you didnt personally add?
    Unhandled = IDs that dont have a function added, atleast thats what I call them.
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. [PI] Printing ID's
    By Mrthunder23 in forum Help
    Replies: 1
    Last Post: 07-22-2010, 02:13 PM
  2. [c] tlhelp32.h example, printing a processes info and its modules.
    By Shawnie in forum Application Development
    Replies: 1
    Last Post: 05-01-2009, 06:53 PM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •