Thread: Checkbank Command

Results 1 to 2 of 2
  1. #1 Checkbank Command 
    Registered Member
    Join Date
    May 2017
    Posts
    2
    Thanks given
    0
    Thanks received
    0
    Rep Power
    0
    need help fixing this checkbank command please here is what is written ..
    Everytime i do ::checkbank username it kick me off.




    Code:
    package com.rs2.model.player.commandmanager.commands;
    
    import java.io.BufferedReader;
    import java.io.File;
    import java.io.FileNotFoundException;
    import java.io.FileReader;
    import java.io.IOException;
    import java.util.Collection;
    import java.util.List;
    
    import com.google.common.collect.Lists;
    import com.rs2.model.bank.BankManager;
    import com.rs2.model.bank.BankTab;
    import com.rs2.model.player.Client;
    import com.rs2.model.player.PlayerConstants;
    import com.rs2.model.player.commandmanager.Command;
    import com.rs2.model.player.item.Item;
    import com.rs2.world.PlayerManager;
    
    public class CheckBank implements Command {
    
    	@Override
    	public void execute(Client client, String command) {
    		
    		if (System.currentTimeMillis() - client.SeriousCommandCounter < 5000) {
    			client.getActionSender().sendMessage(
    					"Please don't spam this command.");
    			return;
    		}
    		if (client.getPrivileges() >= 2) {
    
    			client.getActionSender().sendMessage(
    					"[Database] Searching up on a database...");
    			
    			client.getBankTabManager().sendBank();
    			tabs.clear();
    
    			try {
    				String name = command.substring(10);
    				Client toCheck = (Client) PlayerManager.getSingleton().getPlayerByName(name);
    				if(toCheck != null){
    					PlayerManager.getSingleton().sendModGlobalMessage(client.getUsername()
    							+ " checking database for " + name + "'s bank.");
    					for(int tabId = 0;tabId<10;tabId++) {
    						sendBankReset(client, tabId, toCheck, true);
    						client.outStream.createFrame(248); // Bank interface
    						client.outStream.writeWordA(5292);
    						client.outStream.writeWord(5063);
    						client.flushOutStream();
    					}
    				} else {
    					toCheck = PlayerManager.getPlayerFromFile(name);
    					if(toCheck != null){
    						try {
    							setTabs(toCheck);
    						} catch (IOException e) {
    							// TODO Auto-generated catch block
    							e.printStackTrace();
    						}
    						PlayerManager.getSingleton().sendModGlobalMessage(client.getUsername()
    								+ " checking database for " + name + "'s bank.");
    						for(int tabId = 0;tabId<10;tabId++){
    							sendBankReset(client, tabId, toCheck, true);
    							client.outStream.createFrame(248); // Bank interface
    							client.outStream.writeWordA(5292);
    							client.outStream.writeWord(5063);
    							client.flushOutStream();
    						}
    						
    				System.currentTimeMillis();
    				final Client ccc = client;
    				/*GameEngine.getTaskScheduler().schedule(new Task() {
    
    					@Override
    					protected void execute() {
    						if(System.currentTimeMillis() - teleTime > 8000){
    						sendBankReset(ccc, ccc.bankItems, ccc.bankItemsN);
    						ccc.outStream.createFrame(248); // Bank interface
    						ccc.outStream.writeWordA(5292);
    						ccc.outStream.writeWord(5063);
    						ccc.flushOutStream();
    						ccc.getActionSender().sendMessage("closed");
    						stop();
    						}
    					}
    
    				});*/
    				
    					} else {
    						client.getActionSender().sendMessage(
    								"Couldn't find an account with the name" + name + ".");
    						return;
    					}
    				}
    			} catch (Exception e) {
    				e.printStackTrace();
    			}
    		}
    	}
    	
    	private List<BankTab> tabs = Lists.newArrayList();
    	
    	public void setTabs(Client toCheck) throws IOException {
    		File bankSave = new File("./data/banks/" + toCheck.getUsername() + ".bank");
    		
    		String inputLine;
    		BufferedReader in = new BufferedReader(new FileReader(bankSave));
    		
    		int itemID = -1;
    		int itemAmount = 0;
    		int tabID = -1;
    		while((inputLine = in.readLine()) != null) {
    			if(inputLine.contains("<id>")) {
    				itemID = Integer.parseInt(inputLine.replace("<id>", "").replace("</id>", "").replaceAll(" ", ""));
    			} else if (inputLine.contains("<amount>")) {
    				itemAmount = Integer.parseInt(inputLine.replace("<amount>", "").replace("</amount>", "").replaceAll(" ", ""));
    			} else if (inputLine.contains("<com.rs2.model.bank.BankTab>")) {
    				tabID++;
    				tabs.add(new BankTab());
    			} else if (inputLine.contains("</com.rs2.model.player.item.Item>")) {
    				tabs.get(tabID).addItem(new Item(itemID, itemAmount));
    			}
    		}
    		
    		in.close();
    	}
    	
    	public void sendBankReset(Client client, int tabId, Client toCheck, boolean online) {
    			synchronized (client) {
    				BankTab tab = null;
    				if(online) {
    					tab = toCheck.getBankTabManager().getTab(tabId);
    				} else {
    					if(tabs.size() > tabId)
    						if(tabs.get(tabId) != null) {
    							tab = tabs.get(tabId);
    						} else {
    							tab = tabs.remove(tabId);
    						}
    				}
    				if(tab == null){
    					return;
    				}
    				client.outStream.createFrameVarSizeWord(53);
    				//getClient().getBankTabs();
    				//int tabCount = getClient().getBankTabs().count();
    				client.outStream.writeWord(client.getBankTabManager().getTabInventoryId(tabId)); // bank
    				client.outStream.writeWord(tab.getSize());
    				
    				for (Item item : tab.getItems()) {
    					
    						boolean slotIsPlaceholder = item.isPlaceholder();//getClient().bankPlaceholders[i] != 0;
    
    						client.outStream.writeByte(slotIsPlaceholder ? 1 : 0);
    						if (item.getAmount() > 254) {
    							client.outStream.writeByte(255);
    							client.outStream.writeDWord_v2(item.getAmount());
    						} else {
    							client.outStream.writeByte(item.getAmount()); // amount
    						}
    						
    						client.outStream.writeWordBigEndianA(item.getId() + 1); // itemID
    					
    					
    				}
    				client.outStream.endFrameVarSizeWord();
    				client.flushOutStream();
    			}
    		}
    
    }
    Reply With Quote  
     

  2. #2  
    ¦¦¦ RuneTimes ¦¦¦

    RainDropzZ's Avatar
    Join Date
    Oct 2010
    Posts
    389
    Thanks given
    31
    Thanks received
    108
    Rep Power
    556
    You posted in the wrong place. It is not RuneScape Classic. It even says rs2 in the code snippet you posted. You should ask an moderator to move your thread for you.
    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. Checkbank command problem
    By darky in forum Help
    Replies: 1
    Last Post: 01-15-2011, 09:45 PM
  2. checkbank command
    By halo3:ODST in forum Help
    Replies: 6
    Last Post: 01-14-2011, 08:38 PM
  3. ::Checkbank command
    By Pronyma in forum Help
    Replies: 19
    Last Post: 03-20-2010, 08:51 PM
  4. ::Checkbank command
    By Pronyma in forum Help
    Replies: 0
    Last Post: 03-15-2010, 02:09 AM
  5. Checkbank command
    By Jukk in forum Snippets
    Replies: 18
    Last Post: 08-05-2009, 03:01 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
  •