Thread: pest control pi rep++

Results 1 to 3 of 3
  1. #1 pest control pi rep++ 
    Extreme Donator

    sexyrussian's Avatar
    Join Date
    Nov 2009
    Posts
    887
    Thanks given
    47
    Thanks received
    23
    Rep Power
    0
    okay so i tried to add a demon boss in pest control to make it more exciting

    but its backfiring on me.

    the interface that shows portal health points will show current life and then blink and show 200 every half a second.

    also this was an old bug, but, when u finish a portal, it will say 200 life.

    heres my pest control minigame file.

    for help ill thank, for solution ill rep.

    Code:
    package server.model.minigames;
    
    import server.model.players.Client;
    import server.Server;
    
    /**
     * @author Sanity
     */
    
    public class PestControl {
    	
    	public PestControl() {
    		
    	}
    	
    	public final int GAME_TIMER = 70; //5 minutes
    	public final int WAIT_TIMER = 7;
    	
    	public int gameTimer = -1;
    	public int waitTimer = 15;
    	public int properTimer = 0;
    	
    	public void process() {
    		setInterface();
    		if (properTimer > 0) {
    			properTimer--;
    			return;
    		} else {
    			properTimer = 4;
    		}
    		if (waitTimer > 0)
    			waitTimer--;
    		else if (waitTimer == 0)
    			startGame();
    		if (gameTimer > 0) {
    			gameTimer--;
    			if (allPortalsDead()) {
    				endGame(true);
    			}
    		} else if (gameTimer == 0)
    			endGame(false);
    	}
    	
    	public void startGame() {
    		if (playersInBoat() > 0) {
    			gameTimer = GAME_TIMER;
    			waitTimer = -1;
    			//spawn npcs
    			spawnNpcs();	
    			//move players into game
    			for (int j = 0; j < Server.playerHandler.players.length; j++) {
    				if (Server.playerHandler.players[j] != null) {
    					if (Server.playerHandler.players[j].inPcBoat()) {
    						movePlayer(j);
    					}			
    				}		
    			}
    		} else {
    			waitTimer = WAIT_TIMER;
    			for (int j = 0; j < Server.playerHandler.players.length; j++) {
    				if (Server.playerHandler.players[j] != null) {
    					if (Server.playerHandler.players[j].inPcBoat()) {
    						Client c = (Client)Server.playerHandler.players[j];
    						//c.sendMessage("There need to be at least 3 players to start a game of pest control.");
    					}			
    				}		
    			}
    		}
    	}
    
    	public void setInterface() {
    		for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				if (Server.playerHandler.players[j].inPcBoat()) {
    					Client c = (Client) Server.playerHandler.players[j];
    					c.getPA().sendFrame126("Next Departure: "+waitTimer+"", 21006);
    					c.getPA().sendFrame126("Players Ready: "+playersInBoat()+"", 21007);
    					c.getPA().sendFrame126("(Need 1 to 25 players)", 21008);
    					c.getPA().sendFrame126("Pest Points: "+c.pcPoints+"", 21009);
    				}
     				if (Server.playerHandler.players[j].inPcGame()) {
    					Client c = (Client) Server.playerHandler.players[j];
    					for (j = 0; j < Server.npcHandler.npcs.length; j++) {
    						if (Server.npcHandler.npcs[j] != null) {
    							if (Server.npcHandler.npcs[j].npcType == 6142)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP + "", 21111);
    							if (Server.npcHandler.npcs[j].npcType == 6143)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP + "", 21112);
    							if (Server.npcHandler.npcs[j].npcType == 6144)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP + "", 21113);
    							if (Server.npcHandler.npcs[j].npcType == 6145)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP + "", 21114);
    						}
    					}
    					c.getPA().sendFrame126("0", 21115);
    						if (c.pcDamage < 10) {
    c.getPA().sendFrame126("@red@"+c.pcDamage+".", 21116);
    	} else {
    c.getPA().sendFrame126("@gre@"+c.pcDamage+".", 21116);
    }
    					c.getPA().sendFrame126("Time remaining: "+gameTimer+"", 21117);
    				}
    			}
    		}
    	}
    	
    	public int playersInBoat() {
    		int count = 0;
    		for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				if (Server.playerHandler.players[j].inPcBoat()) {
    						count++;
    				}
    			}
    		}
    		return count;
    	}
    	
    	public void endGame(boolean won) {
    		gameTimer = -1;
    		waitTimer = WAIT_TIMER;
    		for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				if (Server.playerHandler.players[j].inPcGame()) {
    					Client c = (Client)Server.playerHandler.players[j];
    					c.getPA().movePlayer(2657, 2639, 0);
    					if (won && c.pcDamage > 5) {
    						c.sendMessage("You have won the pest control game and have been awarded 100 pest control points.");
    						c.pcPoints += 100;
    						c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
    						c.playerLevel[5] = c.getLevelForXP(c.playerXP[5]);
    						c.specAmount = 10;
    						c.getItems().addItem(995, c.combatLevel * 500000);
    						c.getPA().refreshSkill(3);
    						c.getPA().refreshSkill(5);
    					} else if (won) {
    						c.sendMessage("The void knights notice your lack of zeal.");
    					} else {
    						c.sendMessage("You failed to kill all the portals in 5 minutes and have not been awarded any points.");
    					}
    					c.pcDamage = 0;
    					c.getItems().addSpecialBar(c.playerEquipment[c.playerWeapon]);
    					c.getCombat().resetPrayers();
    				}			
    			}		
    		}
    
    		for (int j = 0; j < Server.npcHandler.npcs.length; j++) {
    			if (Server.npcHandler.npcs[j] != null) {
    				if (Server.npcHandler.npcs[j].npcType == 6142 && Server.npcHandler.npcs[j].npcType == 6143 && Server.npcHandler.npcs[j].npcType == 6144 && Server.npcHandler.npcs[j].npcType == 6145 && Server.npcHandler.npcs[j].npcType == 9900)
    					Server.npcHandler.npcs[j] = null;
    			}			
    		}
    	}
    	
    	public boolean allPortalsDead() {
    		int count = 0;
    		for (int j = 0; j < Server.npcHandler.npcs.length; j++) {
    			if (Server.npcHandler.npcs[j] != null) {
    				if (Server.npcHandler.npcs[j].npcType == 6142 && Server.npcHandler.npcs[j].npcType == 6143 && Server.npcHandler.npcs[j].npcType == 6144 && Server.npcHandler.npcs[j].npcType == 6145 && Server.npcHandler.npcs[j].npcType == 9900)
    					if (Server.npcHandler.npcs[j].needRespawn)
    						count++;		
    			}			
    		}
    		return count >= 5;	
    	}
    	
    	public void movePlayer(int index) {
    		Client c = (Client)Server.playerHandler.players[index];
    		if (c.combatLevel < 40) {
    			c.sendMessage("You must be at least combat level 40 to enter this boat.");
    			return;
    		}
    		c.getPA().movePlayer(2658,2611,0);
    	}
    	
    	public void spawnNpcs() {
    		Server.npcHandler.spawnNpc2(6142,2628,2591,0,0,200,0,0,100);
    		Server.npcHandler.spawnNpc2(6143,2680,2588,0,0,200,0,0,100);
    		Server.npcHandler.spawnNpc2(6144,2669,2570,0,0,200,0,0,100);
    		Server.npcHandler.spawnNpc2(6145,2645,2569,0,0,200,0,0,100);
    
    		Server.npcHandler.spawnNpc2(9900,2628,2591,0,0,9000,80,200,400);
    
    	}
    
    
    }
    Reply With Quote  
     

  2. #2  


    RS Wiki's Avatar
    Join Date
    Mar 2011
    Age
    29
    Posts
    9,688
    Thanks given
    1,752
    Thanks received
    3,103
    Rep Power
    5000
    this is mine, if it works then yay
    probebly the same, maybe not idunno to lazy to look back-and-forth...

    Code:
    package server.model.minigames;
    
    import server.model.players.Client;
    import server.Server;
    
    /**
     * @author Sanity
     */
    
    public class PestControl {
    	
    	public PestControl() {
    		
    	}
    	
    	public final int GAME_TIMER = 70; //5 minutes
    	public final int WAIT_TIMER = 7;
    	
    	public int gameTimer = -1;
    	public int waitTimer = 15;
    	public int properTimer = 0;
    	
    	public void process() {
    		setInterface();
    		if (properTimer > 0) {
    			properTimer--;
    			return;
    		} else {
    			properTimer = 4;
    		}
    		if (waitTimer > 0)
    			waitTimer--;
    		else if (waitTimer == 0)
    			startGame();
    		if (gameTimer > 0) {
    			gameTimer--;
    			if (allPortalsDead()) {
    				endGame(true);
    			}
    		} else if (gameTimer == 0)
    			endGame(false);
    	}
    	
    	public void startGame() {
    		if (playersInBoat() > 0) {
    			gameTimer = GAME_TIMER;
    			waitTimer = -1;
    			//spawn npcs
    				
    			//move players into game
    			for (int j = 0; j < Server.playerHandler.players.length; j++) {
    				if (Server.playerHandler.players[j] != null) {
    					if (Server.playerHandler.players[j].inPcBoat()) {
    						movePlayer(j);
    						spawnNpcs();
    					}			
    				}		
    			}
    		} else {
    			waitTimer = WAIT_TIMER;
    			for (int j = 0; j < Server.playerHandler.players.length; j++) {
    				if (Server.playerHandler.players[j] != null) {
    					if (Server.playerHandler.players[j].inPcBoat()) {
    						Client c = (Client)Server.playerHandler.players[j];
    						c.sendMessage("There need to be at least 3 players to start a game of pest control.");
    					}			
    				}		
    			}
    		}
    	}
    
    	public void setInterface() {
    		for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				if (Server.playerHandler.players[j].inPcBoat()) {
    					Client c = (Client) Server.playerHandler.players[j];
    					c.getPA().sendFrame126("Next Departure: "+waitTimer+"", 21120);
    					c.getPA().sendFrame126("Players Ready: "+playersInBoat()+"", 21121);
    					c.getPA().sendFrame126("(Need 3 to 25 players)", 21122);
    					c.getPA().sendFrame126("Pc Points: "+c.pcPoints+"", 21123);
    				}
     				if (Server.playerHandler.players[j].inPcGame()) {
    					Client c = (Client) Server.playerHandler.players[j];
    					for (j = 0; j < Server.npcHandler.npcs.length; j++) {
    						if (Server.npcHandler.npcs[j] != null) {
    							if (Server.npcHandler.npcs[j].npcType == 6142)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP + "", 21111);
    							if (Server.npcHandler.npcs[j].npcType == 6143)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP + "", 21112);
    							if (Server.npcHandler.npcs[j].npcType == 6144)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP + "", 21113);
    							if (Server.npcHandler.npcs[j].npcType == 6145)
    								c.getPA().sendFrame126("" + Server.npcHandler.npcs[j].HP + "", 21114);
    						}
    					}
    					c.getPA().sendFrame126("0", 21115);
    						if (c.pcDamage < 10) {
    c.getPA().sendFrame126("@red@"+c.pcDamage+".", 21116);
    	} else {
    c.getPA().sendFrame126("@gre@"+c.pcDamage+".", 21116);
    }
    					c.getPA().sendFrame126("Time remaining: "+gameTimer+"", 21117);
    				}
    			}
    		}
    	}
    	
    	public int playersInBoat() {
    		int count = 0;
    		for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				if (Server.playerHandler.players[j].inPcBoat()) {
    						count++;
    				}
    			}
    		}
    		return count;
    	}
    	
    	public void endGame(boolean won) {
    		gameTimer = -1;
    		waitTimer = WAIT_TIMER;
    		for (int j = 0; j < Server.playerHandler.players.length; j++) {
    			if (Server.playerHandler.players[j] != null) {
    				if (Server.playerHandler.players[j].inPcGame()) {
    					Client c = (Client)Server.playerHandler.players[j];
    					c.getPA().movePlayer(2657, 2639, 0);
    					if (won && c.pcDamage > 10) {
    						c.sendMessage("<shad=6081134>You have won the Minigame and won 4 Pest Control Points!");
    						c.pcPoints += 4;
    						c.playerLevel[3] = c.getLevelForXP(c.playerXP[3]);
    						c.playerLevel[5] = c.getLevelForXP(c.playerXP[5]);
    						c.specAmount = 10;
    						c.getItems().addItem(995, c.combatLevel * 50);
    						c.getPA().refreshSkill(3);
    						c.getPA().refreshSkill(5);
    					} else if (won) {
    						c.sendMessage("The void knights notice your lack of zeal.");
    					} else {
    						c.sendMessage("You failed to kill all the portals in 5 minutes and have not been awarded any points.");
    					}
    					c.pcDamage = 0;
    					c.getItems().addSpecialBar(c.playerEquipment[c.playerWeapon]);
    					c.getCombat().resetPrayers();
    				}			
    			}		
    		}
    
    		for (int j = 0; j < Server.npcHandler.npcs.length; j++) {
    			if (Server.npcHandler.npcs[j] != null) {
    				if (Server.npcHandler.npcs[j].npcType >= 6142 && Server.npcHandler.npcs[j].npcType <= 6145)
    					Server.npcHandler.npcs[j] = null;
    			}			
    		}
    	}
    	
    	public boolean allPortalsDead() {
    		int count = 0;
    		for (int j = 0; j < Server.npcHandler.npcs.length; j++) {
    			if (Server.npcHandler.npcs[j] != null) {
    				if (Server.npcHandler.npcs[j].npcType >= 6142 && Server.npcHandler.npcs[j].npcType <= 6145)
    					if (Server.npcHandler.npcs[j].needRespawn)
    						count++;		
    			}			
    		}
    		return count >= 4;	
    	}
    	
    	public void movePlayer(int index) {
    		Client c = (Client)Server.playerHandler.players[index];
    		if (c.combatLevel < 40) {
    			c.sendMessage("You must be at least combat level 40 to enter this boat.");
    			return;
    		}
    		c.getPA().movePlayer(2658,2611,0);
    	}
    	
    	public void spawnNpcs() {
    		Server.npcHandler.spawnNpc2(6142,2628,2591,0,0,200,0,0,100);
    		Server.npcHandler.spawnNpc2(6143,2680,2588,0,0,200,0,0,100);
    		Server.npcHandler.spawnNpc2(6144,2669,2570,0,0,200,0,0,100);
    		Server.npcHandler.spawnNpc2(6145,2645,2569,0,0,200,0,0,100);
    	}
    
    
    }
    All the best,
    Wiki




    coming soon
    Reply With Quote  
     

  3. #3  
    Extreme Donator

    sexyrussian's Avatar
    Join Date
    Nov 2009
    Posts
    887
    Thanks given
    47
    Thanks received
    23
    Rep Power
    0
    the diffrence is that i tried to add (Server.npcHandler.npcs[j].npcType >= 6142 && Server.npcHandler.npcs[j].npcType <= 6145)
    1 by 1 and added another npc 9900
    but it didnt work
    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] Pest Control
    By TrainWrecked in forum Help
    Replies: 9
    Last Post: 08-01-2011, 04:42 AM
  2. pest control
    By sexyrussian in forum Help
    Replies: 0
    Last Post: 05-23-2010, 02:06 AM
  3. Pest control
    By Zee Best in forum Show-off
    Replies: 48
    Last Post: 07-20-2009, 04:41 PM
  4. Pest control [HELP]
    By Coder Alex in forum Help
    Replies: 1
    Last Post: 07-07-2009, 05:07 PM
  5. Pest Control like 25%
    By t3aowner in forum Tutorials
    Replies: 5
    Last Post: 01-03-2009, 11:13 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •