Thread: [CS] Problem with Dueling.

Results 1 to 8 of 8
  1. #1 [CS] Problem with Dueling. 
    Registered Member
    Join Date
    Jun 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    3
    Rep Power
    1
    So when I duel and I am about to win.. instead of watching the other person die, it just automatically teleports me out collects the winnings, and what not.

    isn't it suppose to be, your suppose to stay there till the last hit, watch him die AND then teleport out?

    heres the code

    Code:
    package server.model.player;
    
    import java.util.concurrent.CopyOnWriteArrayList;
    import server.events.Event;
    import server.events.EventContainer;
    import server.events.EventManager;
    import server.model.player.Client;
    import server.model.Item;
    import server.model.item.GameItem;
    import server.model.Trade;
    import server.world.PlayerManager;
    import server.Server;
    import server.util.Misc;
    import server.model.player.PlayerConstants;
    import server.events.Event;
    import server.events.EventContainer;
    import server.events.EventManager;
    
    	/**
    	* Dueling
    	**/
    
    public class Dueling {
    
    	private static Dueling singleton = null;
    
    	public static Dueling getSingleton() {
    		if (singleton == null) {
    			singleton = new Dueling();
    		}
    		return singleton;
    	}
    
    	public void requestFUNDuel(Client client, int id){
    		Client other = (Client) Server.getPlayerManager().players[id];
    		if(other == null || client.duelStatus > 0 || !client.goodDistance(other.getAbsX(), other.getAbsY(), client.getAbsX(), client.getAbsY(), 2)){
    			return;
    		}
    		if(other.duelStatus > 0 || client.checkBusy()){
    			client.getActionAssistant().sendMessage("This player is busy and may no reply.");
    			return;	
    		}
    		if(other.getTradeAssistant().getCurrentTrade() != null) {
    			if(other.getTradeAssistant().getCurrentTrade().isOpen()) {
    				client.getActionAssistant().sendMessage("This player is busy and may no reply.");
    				return;	
    			}
    		}
    		if(other.getTradeAssistant().getCurrentTrade() != null) {
    			if(other.getTradeAssistant().getCurrentTrade().isOpen()) {
    			client.getActionAssistant().sendMessage("This player is busy.");
    			return;		
    			}
    		}
    		client.reqDuelToID = id;
    		if(client.playerId == other.reqDuelToID){
    		        client.acceptedFUNDuel = true;
    			other.acceptedFUNDuel = true;
    			client.getDueling().acceptDuelReq(client, other);
    			other.getDueling().acceptDuelReq(other, client);
    			client.reqDuelToID = -1;
    			other.reqDuelToID = -1;
    			return;
    		}
    		other.getActionAssistant().sendMessage(client.playerName+" :duelreq:");
    		client.getActionAssistant().sendMessage("Sending duel request...");
    		client.duelStatus = 0;
    		other.duelStatus = 0;
    	}
    
    	public void requestDuel(Client client, int id){
    		Client other = (Client) Server.getPlayerManager().players[id];
    		if(other == null || client.duelStatus > 0){
    			return;
    		}
    		if(other.duelStatus > 0){
    			client.getActionAssistant().sendMessage("This player is busy and may no reply.");
    			return;	
    		}
    		if(other.getTradeAssistant().getCurrentTrade() != null) {
    			if(other.getTradeAssistant().getCurrentTrade().isOpen()) {
    			client.getActionAssistant().sendMessage("This player is busy.");
    			return;		
    			}
    		}
    		client.reqDuelToID = id;
    		if(client.playerId == other.reqDuelToID){
    			client.getDueling().acceptDuelReq(client, other);
    			other.getDueling().acceptDuelReq(other, client);
    			client.reqDuelToID = -1;
    			other.reqDuelToID = -1;
    			return;
    		}
    		other.getActionAssistant().sendMessage(client.playerName+" :duelreq:");
    		client.getActionAssistant().sendMessage("Sending duel request...");
    		client.duelStatus = 0;
    		other.duelStatus = 0;
    	}
    
    	public void acceptDuelReq(final Client client, final Client other){
    		if(other == null || other.disconnected || client == null) {
    			return;
    		}
    	if(client.acceptedFUNDuel){
    		client.stopMovement();
    		client.resetWalkingQueue();
    		client.setCanWalk(false);
    		client.duelingWithID = other.playerId;
    		client.getActionAssistant().sendMessage("Accepted.");
    		EventManager.getSingleton().addEvent(null, new Event() {
    			@Override
    			public void execute(EventContainer cx) {
    				if(client == null || other == null){
    				       client.setCanWalk(true);
    				       client.acceptedFUNDuel = false;
    				       return;
    				}
    				client.forcedChat("FIGHT!");
    				cx.stop();
    			}
    
    			@Override
    			public void stop() {
    			}
    		}, 1000);
    	} else {
    		client.duelingWithID = other.playerId;
    		other.duelingWithID = client.playerId;
    		client.getActionAssistant().sendMessage("Accepted.");
    
    		client.duelStatus = 1;
    		refreshduelRules(client);
    		refreshDuelScreen(client);
    		for (int i = 0; i < client.playerEquipment.length; i++) {
    			sendDuelEquipment(client, client.playerEquipment[i], client.playerEquipmentN[i], i);
    		}
    		client.getActionAssistant().sendFrame126("Dueling with: " + other.playerName + " (level-" + other.combatLevel + ")", 6671);
    		client.getActionAssistant().sendFrame126("", 6684);
    		client.getActionAssistant().sendFrame248(6575, 3321);
    		client.getActionAssistant().resetItems(3322);
    	}
    	}
    	
    	public void refreshduelRules(Client c) {
    		for(int i = 0; i < c.duelRule.length; i++) {	
    			c.duelRule[i] = false;
    		}
    		c.getActionAssistant().sendFrame87(286, 0);
    		c.duelOption = 0;
    	}
    
    	public void sendDuelEquipment(Client client, int itemId, int amount, int slot) {
    		if(client.getOutStream() == null){
    			return;
    		}
    		client.isDuelWinner = false;
    		if(slot >= 0 || slot <= 5 || slot == 7 || slot == 9 || slot == 10 || slot == 12 || slot == 13){
    			client.getOutStream().createFrameVarSizeWord(34);
    			client.getOutStream().writeWord(13824);
    			client.getOutStream().writeByte(slot);
    			client.getOutStream().writeWord(itemId+1);
    
    			if (amount > 254) {
    				client.getOutStream().writeByte(255);
    				client.getOutStream().writeDWord(amount);
    			} else {
    				client.getOutStream().writeByte(amount);
    			}
    			client.getOutStream().endFrameVarSizeWord();
    			client.flushOutStream();
    		}
    	}
    
    	public void changeDuelStuff(Client c) {
    		Client o = (Client) Server.getPlayerManager().players[c.duelingWithID];
    		if(o == null || o.disconnected) {
    			declineDuel(c);
    			return;
    		}
    		o.duelStatus = 1;
    		c.duelStatus = 1;
    		o.getActionAssistant().sendFrame126("", 6684);
    		c.getActionAssistant().sendFrame126("", 6684);
    	}
    
    	public void selectRule(Client c, int i) { // rules
    		Client o = (Client) Server.getPlayerManager().players[c.duelingWithID];
    		if(o == null || o.disconnected) {
    			declineDuel(c);
    			return;
    		}
    		changeDuelStuff(c);
    		int neededSlots = GetDuelItemSlots(c);
    		int neededSlotsO = GetDuelItemSlots(o);
    		o.duelSlot = c.duelSlot;
    		if(i >= 11 && c.duelSlot > -1) {
    			if(c.playerEquipment[c.duelSlot] > 0) {
    				if(!c.duelRule[i]) {
    					c.duelSpaceReq++;	
    				} else {
    					c.duelSpaceReq--;
    				}
    			}	
    			if(o.playerEquipment[o.duelSlot] > 0) {
    				if(!o.duelRule[i]) {
    					o.duelSpaceReq++;
    				} else {
    					o.duelSpaceReq--;
    				}
    			}
    		}
    
    		if(i >= 11) {
    			if(c.getActionAssistant().freeSlots() < (c.duelSpaceReq+neededSlots) || o.getActionAssistant().freeSlots() < (o.duelSpaceReq+neededSlotsO)) {
    				c.getActionAssistant().sendMessage("You or your opponent don't have the required space to set this rule.");
    				if(c.playerEquipment[c.duelSlot] > 0) {
    					c.duelSpaceReq--;
    				}
    				if(o.playerEquipment[o.duelSlot] > 0) {
    					o.duelSpaceReq--;
    				}
    				return;
    			}
    		}
    		
    		if(!c.duelRule[i]) {
    			c.duelRule[i] = true;
    			c.duelOption += c.DUEL_RULE_ID[i];
    		} else {	
    			c.duelRule[i] = false;
    			c.duelOption -= c.DUEL_RULE_ID[i];
    		}
    
    		c.getActionAssistant().sendFrame87(286, c.duelOption);
    		o.duelOption = c.duelOption;
    		o.duelRule[i] = c.duelRule[i];
    		o.getActionAssistant().sendFrame87(286, o.duelOption);
    		
    		if(c.duelRule[8]){	
    			if(c.duelRule[1]) {
    				c.duelTeleX = 3366 + Misc.random(12);
    				o.duelTeleX = c.duelTeleX-1;
    				c.duelTeleY = 3246 + Misc.random(6);
    				o.duelTeleY = c.duelTeleY;
    			}
    		} else {
    			if(c.duelRule[1]) {
    				c.duelTeleX = 3335 + Misc.random(12);
    				o.duelTeleX = c.duelTeleX-1;
    				c.duelTeleY = 3246 + Misc.random(6);
    				o.duelTeleY = c.duelTeleY;
    			}
    		}
    	}
    
    	public void RemoveAllDuelItems(Client client) {
    		for (int i = 0; i < client.duelItems.length; i++) {
    			if (client.duelItems[i] > 0) {
    				fromDuel(client, client.duelItems[i] - 1, client.getActionAssistant().getItemSlot(client.duelItems[i] - 1), client.duelItemsN[i]);
    			}
    		}
    	}
    
    	public int GetDuelItemSlots(Client c) {
    		int Slots = 0;
    		for (int i = 0; i < c.duelItems.length; i++) {
    			if (c.duelItems[i] > 0) {
    				//if((Item.itemStackable[c.duelItems[i] - 1] || Item.itemIsNote[c.duelItems[i] - 1]) && c.getActionAssistant().playerHasItem(c.duelItems[i] - 1,1)){
    				//} else {
    				Slots++;
    				//}
    			}
    		}
    		for (int i = 0; i < c.otherDuelItems.length; i++) {
    			if (c.otherDuelItems[i] > 0) {
    				//if((Item.itemStackable[c.otherDuelItems[i] - 1] || Item.itemIsNote[c.otherDuelItems[i] - 1]) && c.getActionAssistant().playerHasItem(c.otherDuelItems[i] - 1,1)){
    				//} else {
    				Slots++;
    				//}
    			}
    		}
    		return Slots;
    	}
    	
    				public void confirmDuel(Client c){
    					Client o = (Client) Server.getPlayerManager().players[c.duelingWithID];
    					if(o == null || o.disconnected) {
    						declineDuel(c);
    					return;
    					}
    					if(c.duelStatus == 2 && o.duelStatus == 2){
    						c.getDueling().confirmDuel2(c);
    						o.getDueling().confirmDuel2(o);
    						c.duelStatus = 3;
    						o.duelStatus = 3;
    					}
    				}
    
    	public void confirmDuel2(Client c) {
    		Client o = (Client) Server.getPlayerManager().players[c.duelingWithID];
    		if(o == null || o.disconnected) {
    			declineDuel(c);
    			return;
    		}
    		String itemId = "";
    		for (int i = 0; i < c.duelItems.length; i++) {
    			if(c.duelItems[i] > 0 && (Item.itemStackable[c.duelItems[i] - 1] || Item.itemIsNote[c.duelItems[i] - 1])) {
    				itemId += Server.getItemManager().getItemDefinition(c.duelItems[i] - 1).getName() + " x " + c.duelItemsN[i] +"\\n";
    			}  else  {
    				if(c.duelItems[i] > 0)
    				itemId += Server.getItemManager().getItemDefinition(c.duelItems[i] - 1).getName() + "\\n";
    			}
    		}
    		c.getActionAssistant().sendFrame126(itemId, 6516);
    		itemId = "";
    		for (int i = 0; i < o.duelItems.length; i++) {
    			if(o.duelItems[i] > 0 && (Item.itemStackable[o.duelItems[i] - 1] || Item.itemIsNote[o.duelItems[i] - 1])) {
    				itemId += Server.getItemManager().getItemDefinition(o.duelItems[i] - 1).getName() + " x " + o.duelItemsN[i] +"\\n";
    			}  else  {
    				if(o.duelItems[i] > 0)
    				itemId += Server.getItemManager().getItemDefinition(o.duelItems[i] - 1).getName() + "\\n";
    			}
    		}
    		c.getActionAssistant().sendFrame126(itemId, 6517);
    		c.getActionAssistant().sendFrame126("", 8242);
    		for(int i = 8238; i <= 8253; i++) {
    			c.getActionAssistant().sendFrame126("", i);
    		}
    		c.getActionAssistant().sendFrame126("Hitpoints will be restored.", 8250);
    		c.getActionAssistant().sendFrame126("Boosted stats will be restored.", 8238);
    		if(c.duelRule[8]) {
    			c.getActionAssistant().sendFrame126("There will be obstacles in the arena.", 8240);
    		} 
    		if(c.duelRule[10]) {
    			c.getActionAssistant().sendFrame126("Special attacks have been disabled.", 8239);
    		}
    		c.getActionAssistant().sendFrame126("", 8241);
    		
    		String[] rulesOption = {"Players cannot forfeit!", "Players cannot move.", "Players cannot use range.", "Players cannot use melee.", "Players cannot use magic.",  "Players cannot drink pots.",  "Players cannot eat food.", "Players cannot use prayer.", "Fun weapons", "No special attacks"};
    		
    		int lineNumber = 8242;
    		for(int i = 0; i < 8; i++) {
    			if(c.duelRule[i]) {
    				c.getActionAssistant().sendFrame126(""+rulesOption[i], lineNumber);
    				lineNumber ++;
    			}
    		}
    		c.getActionAssistant().sendFrame126("", 6571);
    		c.getActionAssistant().showInterface(6412);
    		c.getActionAssistant().sendFrame248(6412, 197);
    	}
    
    	public void startDuel(Client c) {
    		Client o = (Client) Server.getPlayerManager().players[c.duelingWithID];
    		if(o == null) {
    			declineDuel(c);
    			return;
    		}
    		for (int i = 0; i < 7; i++){
    			c.playerLevel[i] = c.getActionAssistant().getLevelForXP(c.playerXP[i]);
    		}
    		if(c.duelRule[7]){
    			c.getActionAssistant().resetPrayers();
    		}		
    		if(c.duelRule[10]) {
    			//c.DuelNoSpec = true;
    		}
    		if(c.duelRule[11]) {
    			c.getActionAssistant().remove(c.playerEquipment[0], 0);
    		}
    		if(c.duelRule[12]) {
    			c.getActionAssistant().remove(c.playerEquipment[1], 1);
    		}
    		if(c.duelRule[13]) {
    			c.getActionAssistant().remove(c.playerEquipment[2], 2);
    		}
    		if(c.duelRule[14]) {
    			c.getActionAssistant().remove(c.playerEquipment[3], 3);
    		}
    		if(c.duelRule[15]) {
    			c.getActionAssistant().remove(c.playerEquipment[4], 4);
    		}
    		if(c.duelRule[16]) {
    			c.getActionAssistant().remove(c.playerEquipment[5], 5);
    		}
    		if(c.duelRule[17]) {
    			c.getActionAssistant().remove(c.playerEquipment[7], 7);
    		}
    		if(c.duelRule[18]) {
    			c.getActionAssistant().remove(c.playerEquipment[9], 9);
    		}
    		if(c.duelRule[19]) {
    			c.getActionAssistant().remove(c.playerEquipment[10], 10);
    		}
    		if(c.duelRule[20]) {
    			c.getActionAssistant().remove(c.playerEquipment[12], 12);
    		}
    		if(c.duelRule[21]) {
    			c.getActionAssistant().remove(c.playerEquipment[13], 13);
    		}	
    		c.getCombatManager().calculateBonus();	
    		c.duelStatus = 4;
    		c.getActionAssistant().removeAllWindows();
    		if(c.duelRule[8]){	
    			if(c.duelRule[1]) {
    				c.teleportToX = c.duelTeleX;
    				c.teleportToY = c.duelTeleY;
    				c.setHeightLevel(0);
    			} else {
    				c.teleportToX = 3366 + Misc.random(12);
    				c.teleportToY = 3246 + Misc.random(6);
    				c.setHeightLevel(0);
    			}
    		} else {
    			if(c.duelRule[1]) {
    				c.teleportToX = c.duelTeleX;
    				c.teleportToY = c.duelTeleY;
    				c.setHeightLevel(0);
    			} else {	
    				c.teleportToX = 3335 + Misc.random(12);
    				c.teleportToY = 3246 + Misc.random(6);
    				c.setHeightLevel(0);
    			}
    		}
    		c.specAmount = 10;
    		c.getActionAssistant().updateSpecialBar();
    		c.duelTimer = 4;
    		startDuelTimer(c);
    		c.getActionAssistant().createArrow(10, o.playerId);
    	}
    
    	public void startDuelTimer(final Client c){
    		if(c == null){
    		   declineDuel(c);
    			return;
    		}
    		EventManager.getSingleton().addEvent(null, new Event() {
    			@Override
    			public void execute(EventContainer cx) {
    				if(c == null){
    		  		 declineDuel(c);
    				return;
    				}
    				if(c.duelTimer > 0){
    					c.duelTimer--;
    					c.forcedChat(""+c.duelTimer);
    				}
    				if(c.duelTimer == 0){
    					cx.stop();
    				}
    			}
    
    			@Override
    			public void stop() {
    				c.forcedChat("FIGHT!");
    			}
    		}, 1000);
    	}
    
    	public void duelVictory(Client c) {
    		Client o = (Client) Server.getPlayerManager().players[c.duelingWithID];
    		if(o != null) {
    			c.getActionAssistant().sendFrame126(""+o.combatLevel, 6839);
    			c.getActionAssistant().sendFrame126(o.playerName, 6840);
    			o.duelStatus = 0;
    		} else {
    			c.getActionAssistant().sendFrame126("", 6839);
    			c.getActionAssistant().sendFrame126("", 6840);
    		}
    		if(Misc.random(3) == 0){
    			c.teleportToX = 3362+Misc.random(11);
    			c.teleportToY = 3264+Misc.random(6);
    		} else {
    			c.teleportToX = 3360+Misc.random(18);
    			c.teleportToY = 3274+Misc.random(3);
    		}
    		if(o != null){
    			o.specAmount = 10;
    			o.getActionAssistant().updateSpecialBar();
    			o.getActionAssistant().sendMessage("You have lost the duel.");
    			o.getActionAssistant().follow(0, 3, 1);
    			c.getActionAssistant().follow(0, 3, 1);
    			c.getActionAssistant().sendMessage("You are victorious!");
    		}
    		if(o != null){
    		o.getActionAssistant().createArrow(0, 0);
    		o.duelStatus = -1;
    		o.duelingWithID = -1;
    		o.getActionAssistant().resetPrayers();
    		if(o.duelArrows > 0){
    			o.getActionAssistant().addItem(o.duelArrows, o.duelArrowsN);
    			o.duelArrows = -1;
    			o.duelArrowsN = -1;
    		}
    		}
    		c.duelStatus = -1;
    		c.duelingWithID = -1;
    		c.poisonHitdmg = 0;
    		for (int i = 0; i < 7; i++){
    			c.playerLevel[i] = c.getActionAssistant().getLevelForXP(c.playerXP[i]);
    			c.getActionAssistant().refreshSkill(i);
    		}
    		for (int i9 = 0; i9 < c.duelItems.length; i9++){
    			if (c.duelItems[i9] > 0)
    				c.getActionAssistant().addItem(c.duelItems[i9]-1, c.duelItemsN[i9]);
    		}
    		for (int i9 = 0; i9 < c.otherDuelItems.length; i9++){
    			if (c.otherDuelItems[i9] > 0)
    				c.getActionAssistant().addItem(c.otherDuelItems[i9]-1, c.otherDuelItemsN[i9]);
    		}
    		if(c.duelArrows > 0){
    			c.getActionAssistant().addItem(c.duelArrows, c.duelArrowsN);
    			c.duelArrows = -1;
    			c.duelArrowsN = -1;
    		}
    		c.specAmount = 10;
    		c.getActionAssistant().addSpecialBar(c.playerEquipment[3]);
    		c.getActionAssistant().resetPrayers();
    		c.setCanWalk(true);
    		c.attackTimer = 1;
    		c.getActionAssistant().createArrow(0, 0);
    		c.getActionAssistant().startAnimation(-1);
    		itemsToVScreen(c);
    		c.getActionAssistant().showInterface(6733);
    		resetDuel(c);
    	}
    
    	public void itemsToVScreen(Client c) {
    		if (c == null) {
    			return;
    		}
    		c.getOutStream().createFrameVarSizeWord(53);
    		c.getOutStream().writeWord(6822);
    		c.getOutStream().writeWord(c.otherDuelItems.length);
    		for (int i = 0; i < c.otherDuelItems.length; i++) {
    			if (c.otherDuelItemsN[i] > 254) {
    				c.getOutStream().writeByte(255);
    				c.getOutStream().writeDWord_v2(c.otherDuelItemsN[i]);
    			} else {
    				c.getOutStream().writeByte(c.otherDuelItemsN[i]);
    			}
    			c.getOutStream().writeWordBigEndianA(c.otherDuelItems[i]);
    		}
    		c.getOutStream().endFrameVarSizeWord();
    	}
    
    	public void declineDuel(Client c) {
     		Client o = (Client) Server.getPlayerManager().players[c.duelingWithID];
    		if (/*c.duelStatus == 3 || */c.duelStatus == -1)
    		{
    			return;
    		}
    		if(c.duelStatus == 4){
    		if(Misc.random(3) == 0){
    			c.teleportToX = 3362+Misc.random(11);
    			c.teleportToY = 3264+Misc.random(6);
    		} else {
    			c.teleportToX = 3360+Misc.random(18);
    			c.teleportToY = 3274+Misc.random(3);
    		}
    		}
    		c.getActionAssistant().sendMessage("You decline the duel.");
    		c.getActionAssistant().removeAllWindows();
    		if (o != null && c.duelingWithID > 0)
    		{
    			o.getActionAssistant().sendMessage("The other player declined rules and stake options.");
    			o.getActionAssistant().removeAllWindows();
    			for (int i = 0; i < o.duelItems.length; i++)
    			{
    				if (o.duelItems[i] != 0)
    				{
    					o.getActionAssistant().addItem(o.duelItems[i] - 1, o.duelItemsN[i]);
    				}
    			}
    			o.getActionAssistant().resetItems(3214);
    			resetDuel(o);
    			o.duelingWithID = 0;
    			o.duelStatus = -1;
    		}
    		for (int i = 0; i < c.duelItems.length; i++)
    		{
    			if (c.duelItems[i] != 0)
    			{
    				c.getActionAssistant().addItem(c.duelItems[i] - 1, c.duelItemsN[i]);
    			}
    		}
    		c.getActionAssistant().createArrow(0, 0);
    		c.duelingWithID = 0;
    		c.duelStatus = -1;
    		c.getActionAssistant().resetItems(3214);
    		resetDuel(c);
    	}
    
    	public void resetDuel(Client c) {
    		c.duelingWithID = 0;
    		c.duelStatus = -1;
                    for (int i = 0; i < c.duelRule.length; i++) {
                        c.duelRule[i] = false;
                    }
    		for (int i = 0; i < c.duelItems.length; i++) {
    			c.duelItems[i] = 0;
    			c.otherDuelItems[i] = 0;
    			c.duelItemsN[i] = 0;
    			c.otherDuelItemsN[i] = 0;
    		}
    		c.duelSpaceReq = 0;
    	}
    
    	public boolean stakeItem(Client c, int itemId, int itemSlot, int itemAmount)
            {
     	    Client o = (Client) Server.getPlayerManager().players[c.duelingWithID];
    		if(o == null || o.disconnected) {
    			declineDuel(c);
    			return false;
    		}
    		if(c.destroyItem(itemId)){
    		    c.getActionAssistant().sendMessage("You can not stake that item.");
    			return false;
    		}
    		if(c.getActionAssistant().freeSlots() < (c.duelSpaceReq+GetDuelItemSlots(c)+1)) {
    			c.getActionAssistant().sendMessage("You don't have the required space to stake this item.");
    			return false;
    		}
    		if(o.getActionAssistant().freeSlots() < (o.duelSpaceReq+GetDuelItemSlots(o)+1)){
    			c.getActionAssistant().sendMessage("Other player don't have the required space to stake this item.");
    			return false;
    		}
                if (itemAmount <= 0)
                    itemAmount = 1;
    
                if (o == null || o.disconnected || c == null || c.disconnected)
                {
                    //if (combatDelay <= 0 && deathDelay < 0)
                    //    disconnected = true;
                    return false;
                }
    
                boolean inDuel = false;
    
                if (itemId + 1 == c.playerItems[itemSlot])
                {
                    if (itemAmount > c.playerItemsN[itemSlot] && (Item.itemStackable[c.playerItems[itemSlot] - 1] || Item.itemIsNote[c.playerItems[itemSlot] - 1]))
                    {
                        itemAmount = c.playerItemsN[itemSlot];
    		    c.getActionAssistant().sendMessage("Item Amount Changed.");
                    }
    		else if (itemAmount > c.getActionAssistant().getItemAmount(itemId) && !Item.itemStackable[c.playerItems[itemSlot] - 1] && !Item.itemIsNote[c.playerItems[itemSlot] - 1]) {
    			int amt2 = 0;
    			for (int q = 0; q < c.playerItems.length; q++) {
    				if (c.playerItems[q] == itemId+1)
    					amt2++;
    			}
    			if (itemAmount > amt2)
                            {
    				itemAmount = amt2;
                                    c.getActionAssistant().sendMessage("Non stack change.");
                            }
    		}
    
                    if (Item.itemStackable[c.playerItems[itemSlot] - 1] || Item.itemIsNote[c.playerItems[itemSlot] - 1])
                    {
                        for (int i = 0; i < c.duelItems.length; i++)
                        {
                            if (c.duelItems[i] == c.playerItems[itemSlot])
                            {
                                c.duelItemsN[i] += itemAmount;
                                if (o != null)
                                    o.otherDuelItemsN[i] += itemAmount;
                                inDuel = true;
                                break;
                            }
                        }
                    }
                    if (!inDuel)
                    {
                        int itmAmt = itemAmount;
                        if (Item.itemStackable[c.playerItems[itemSlot] - 1] || Item.itemIsNote[c.playerItems[itemSlot] - 1])
                        {
                            for (int i = 0; i < c.duelItems.length; i++)
                            {
                                if (c.duelItems[i] == 0)
                                {
                                    c.duelItems[i] = itemId + 1;
                                    c.duelItemsN[i] = itemAmount;
                                    if (o != null)
                                    {
                                        o.otherDuelItems[i] = itemId + 1;
                                        o.otherDuelItemsN[i] = itemAmount;
                                    }
                                    break;
                                }
                            }
                        }
                        else
                        {
                            for (int i = 0; i < c.duelItems.length; i++)
                            {
                                if (c.duelItems[i] == 0 && itmAmt > 0)
                                {
                                    if (c.getActionAssistant().getItemAmount(itemId) > 0)
                                    {
                                        itmAmt--;
                                        c.duelItems[i] = itemId + 1;
                                        c.duelItemsN[i] = 1;
                                        if (o != null)
                                        {
                                            o.otherDuelItems[i] = itemId + 1;
                                            o.otherDuelItemsN[i] = 1;
                                        }
                                    }
                                    else
                                        break;
                                }
                            }
                            //itemAmount -= itemAmount - itmAmt;
                        }
                    }
    
                    c.getActionAssistant().deleteItem(c.playerItems[itemSlot] - 1, itemSlot, itemAmount);
    
                    c.duelStatus = 1;
                    c.getActionAssistant().resetItems(3214);
                    c.getActionAssistant().resetItems(3322);
                    c.getActionAssistant().sendFrame126("", 6684);
                    refreshDuelScreen(c);
                    c.getActionAssistant().sendFrame248(6575, 3321);
    
                    if (o != null)
                    {
                        o.duelStatus = 1;
                        o.getActionAssistant().resetItems(3214);
                        o.getActionAssistant().resetItems(3322);
                        refreshDuelScreen(o);
                   	    o.getActionAssistant().sendFrame126("", 6684);
                        o.getActionAssistant().sendFrame248(6575, 3321);
                    }
                    return true;
                }
                return false;
    	}
    
    	public void refreshDuelScreen(Client c) {
     		Client otherPlr = (Client) Server.getPlayerManager().players[c.duelingWithID];
    		if(otherPlr == null || otherPlr.disconnected || c == null) {
    			declineDuel(c);
    			return;
    		}
    		c.getOutStream().createFrameVarSizeWord(53);
    		c.getOutStream().writeWord(6669);
    		c.getOutStream().writeWord(c.duelItems.length);
    		for (int i = 0; i < c.duelItems.length; i++) {
    			if (c.duelItemsN[i] > 254) {
    				c.getOutStream().writeByte(255);
    				c.getOutStream().writeDWord_v2(c.duelItemsN[i]);
    			} else {
    				c.getOutStream().writeByte(c.duelItemsN[i]);
    			}
    			c.getOutStream().writeWordBigEndianA(c.duelItems[i]);
    		}
    		c.getOutStream().endFrameVarSizeWord();
    		c.getOutStream().createFrameVarSizeWord(53);
    		c.getOutStream().writeWord(6670);
    		c.getOutStream().writeWord(c.otherDuelItems.length);
    		for (int i = 0; i < c.otherDuelItems.length; i++) {
    			if (c.otherDuelItemsN[i] > 254) {
    				c.getOutStream().writeByte(255);
    				c.getOutStream().writeDWord_v2(c.otherDuelItemsN[i]);
    			} else {
    				c.getOutStream().writeByte(c.otherDuelItemsN[i]);
    			}
    			c.getOutStream().writeWordBigEndianA(c.otherDuelItems[i]);
    		}
    		c.getOutStream().endFrameVarSizeWord();
    	}
    
    	public boolean fromDuel(Client c, int itemId, int itemSlot, int itemAmount)
            {
    		try {
    		if(Server.getPlayerManager().players[c.duelingWithID] == null || Server.getPlayerManager().players[c.duelingWithID].disconnected) {
    			declineDuel(c);
    			return false;
    		}
                if (itemAmount <= 0 && itemAmount != -924)
                    itemAmount = 1;
                if (c == null || c.disconnected || Server.getPlayerManager().players[c.duelingWithID] == null || Server.getPlayerManager().players[c.duelingWithID].disconnected)
                {
                    //if (combatDelay <= 0 && deathDelay < 0)
                        return false;
                }
                if (itemId + 1 == c.duelItems[itemSlot])
                {
                    if (itemAmount > c.duelItemsN[itemSlot] && (Item.itemStackable[c.duelItems[itemSlot] - 1] || Item.itemIsNote[c.duelItems[itemSlot] - 1]) || itemAmount == -924)
                    {
                        itemAmount = c.duelItemsN[itemSlot];
                    }
    		else {
                        int amt2 = 0;
                        for (int g = 0; g < c.duelItems.length; g++) {
    			if ((c.duelItems[g] - 1) == itemId) {
    				amt2++;
    			}
    		    }
    		    if (itemAmount > amt2)
    			itemAmount = amt2;
                    }
    
                    if (itemAmount == -924 && !Item.itemStackable[c.duelItems[itemSlot] - 1] && !Item.itemIsNote[c.duelItems[itemSlot] - 1])
                    {
                        itemAmount = 0;
                        for (int f = 0; f < c.duelItems.length; f++)
                        {
                            if (c.duelItems[f] == itemId + 1)
                            {
                                c.getActionAssistant().addItem(c.duelItems[itemSlot] - 1, 1);
                                itemAmount++;
                            }
                        }
                    }
                    else
                        c.getActionAssistant().addItem(c.duelItems[itemSlot] - 1, itemAmount);
    
                    if (Item.itemStackable[c.duelItems[itemSlot] - 1] || Item.itemIsNote[c.duelItems[itemSlot] - 1])
                    {
                        if (itemAmount == c.duelItemsN[itemSlot])
                        {
                            c.duelItems[itemSlot] = 0;
                            if (Server.getPlayerManager().players[c.duelingWithID] != null)
                                Server.getPlayerManager().players[c.duelingWithID].otherDuelItems[itemSlot] = 0;
                        } else {
                            c.duelItemsN[itemSlot] -= itemAmount;
                            if (Server.getPlayerManager().players[c.duelingWithID] != null)
                                Server.getPlayerManager().players[c.duelingWithID].otherDuelItemsN[itemSlot] -= itemAmount;
                        }
                    }
                    else if (!Item.itemStackable[c.duelItems[itemSlot] - 1] && !Item.itemIsNote[c.duelItems[itemSlot] - 1])
                    {
                        int itmAmt = itemAmount;
                        for (int i = 0; i < c.duelItems.length; i++)
                        {
                            if (c.duelItems[i] - 1 == itemId && itmAmt > 0)
                            {
                                itmAmt--;
                                c.duelItems[i] = 0;
                                if (Server.getPlayerManager().players[c.duelingWithID] != null)
                                    Server.getPlayerManager().players[c.duelingWithID].otherDuelItems[i] = 0;
                            }
                        }
                    }
                    c.duelStatus = 1;
                    c.getActionAssistant().resetItems(3214);
                    c.getActionAssistant().resetItems(3322);
                    refreshDuelScreen(c);
                    c.getActionAssistant().sendFrame126("", 6684);
                    c.getActionAssistant().sendFrame248(6575, 3321);
    
                    if (Server.getPlayerManager().players[c.duelingWithID] != null)
                    {
                        Client otherPlr = (Client) Server.getPlayerManager().players[c.duelingWithID];
                        otherPlr.duelStatus = 1;
                        otherPlr.getActionAssistant().resetItems(3214);
                        otherPlr.getActionAssistant().resetItems(3322);
                        refreshDuelScreen(otherPlr);
                        otherPlr.getActionAssistant().sendFrame126("", 6684);
                        otherPlr.getActionAssistant().sendFrame248(6575, 3321);
                    }
                    return true;
                }
    	} catch(Exception e) {}
                return false;
    	}
    	
    
    }

    I almost had it fixed but then it caused another problem so here, I'm bringing it to the 'pros' I hope

    So whats wrong here?
    Reply With Quote  
     

  2. #2  
    Banned

    Join Date
    Jan 2009
    Age
    31
    Posts
    2,661
    Thanks given
    66
    Thanks received
    207
    Rep Power
    0
    remove whatever does the teleport and then make somthing like this

    Code:
    if (duelPartner != null) {
         duelPartner.teleport(x,y,z);
         duelPartner.sendMessage("You won");
    }
    somwhere in the death stage of where they teleport. you'll need to modify it i never looked at that source so idk how you need the code to be or where.
    Reply With Quote  
     

  3. #3  
    Registered Member
    Join Date
    Jun 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    3
    Rep Power
    1
    It's a shard base source.
    Reply With Quote  
     

  4. #4  
    Registered Member
    Join Date
    Jun 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    3
    Rep Power
    1
    Anyone know anything more clearly about this?
    Reply With Quote  
     

  5. #5  
    Registered Member
    Join Date
    Jun 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    3
    Rep Power
    1
    Tried another attempt again, haha.. fail D;
    Reply With Quote  
     

  6. #6  
    Registered Member
    Join Date
    Jun 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    3
    Rep Power
    1
    One last bump, if not then oh wellz.
    Reply With Quote  
     

  7. #7  
    Registered Member
    Join Date
    Sep 2007
    Posts
    128
    Thanks given
    23
    Thanks received
    1
    Rep Power
    1
    you could make a timer so once the enemies hp hits 0 it will start the timer..
    then make it check if the player is dead and the timer hit 0, and teleport the enemy out..
    When shot down, turn right around.
    If you have ever been told you can't, but you have exceeded the expectations.. Put this in your signature.
    Reply With Quote  
     

  8. #8  
    Registered Member
    Join Date
    Jun 2010
    Posts
    129
    Thanks given
    0
    Thanks received
    3
    Rep Power
    1
    Quote Originally Posted by lkc cheat service View Post
    you could make a timer so once the enemies hp hits 0 it will start the timer..
    then make it check if the player is dead and the timer hit 0, and teleport the enemy out..
    I could... but I know that there's an easier way to do this lol, I just.. don't know how to get started =]
    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

Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •