Jump to content

Welcome to DreamBot

VIP Enhancement

Want to upgrade your DreamBot experience? Consider signing up for VIP!
VIP allows you to run as many accounts as you want, view the forums ad-free, receive 10% off all script purchases, and so much more!
Visit the store to learn about all of these great features!

Upgrade to VIP Now
Frequently Asked Questions
  • Are you not able to open the client? Make sure you have Java 8 installed
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS gold? You can purchase vouchers from another users
  • Try asking for help in the chatbox

DreamBot is the only Deadman Mode supported bot on the market!

Download the DreamBot client today!





scape2code

Using Reflection to get values of rsps client

Recommended Posts

Just started learning about reflection and was trying to use it to get an array of players that are logged in a 718 rsps. In the client.class I found a field which I thougth would contain this called aClass365_Sub1_Sub1_Sub2_Sub2Array8805 when I try to access this variable I get 2048 null values no mater how many people are logged into the client. After I get this to work would like to find the field for the players usernames and then print those out instead of the reference to the player but I need to get this part working first. My current code is

import java.net.MalformedURLException;
import java.util.ArrayList;

public class test {

	public static void main(String[] args) throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, MalformedURLException {
		
		
		for(Player2 player : getLoaded())
		{
			System.out.println(player);
		}
		
	}	
	public static Player2[] getLoaded() throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, MalformedURLException {

			ArrayList<Player2> players = new ArrayList<Player2>();
			
		 Object[] oPlayers = Reflection1.getPlayerArray(); //Assuming the player array method is stored in the class client
		// System.out.println(oPlayers.length);
		 int i = 0;
			for(Object o : oPlayers) {
				if(o != null) {
				System.out.println("o != null");
				Player2 cur = new Player2(o);
				System.out.println(cur);
				players.add(cur);
			}
				System.out.println( i + " " + "o = null");
				i++;
			}
			
			return players.toArray(new Player2[players.size()]);
	}
	}
import java.io.File;
import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;

public class Reflection1 {
	public static Object[] getPlayerArray() throws ClassNotFoundException, NoSuchFieldException, SecurityException, IllegalArgumentException, IllegalAccessException, MalformedURLException {
		
		File file = new File("C:\\Users\\accen\\Desktop\\718\\Matrix Package\\Matrix Client\\bin");
		URL url = file.toURI().toURL();
		URL[] urls = {url};
		ClassLoader loader = new URLClassLoader(urls);
		Class myClass = loader.loadClass("client");
		System.out.println(myClass.getName());
		Field field1 = myClass.getDeclaredField("aClass365_Sub1_Sub1_Sub2_Sub2Array8805");//Believe this holds the players that are logged into server
		field1.setAccessible(true);
		Object[] players = (Object[]) field1.get(null);
		System.out.println(players.length); // it is set to 2048 in the client class
		// should return a player Object
		
		return (Object[]) field1.get(null);// returns 2048 null value*/
		
	}
	
}
import java.io.File;
import java.lang.reflect.Field;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLClassLoader;
import java.util.ArrayList;

public class Player2 {
	private Object player;

	
	public Player2(Object player){
	this.player = player;
	}
	
/*
 * Not sure what  field is username yet just guessing aString10197
 * currently not implemented will try and use later when everything else works
 */
	public String getUserName() throws IllegalArgumentException, IllegalAccessException, MalformedURLException, ClassNotFoundException, NoSuchFieldException, SecurityException {
		File file = new File("C:\\Users\\accen\\Desktop\\718\\Matrix Package\\Matrix Client\\bin");
		URL url = file.toURI().toURL();
		URL[] urls = {url};
		ClassLoader loader = new URLClassLoader(urls);
		Class myClass = loader.loadClass("Player");
		Field f = myClass.getDeclaredField("aString10195");
		f.setAccessible(true);
		System.out.println(f.get(player));
	return (String) f.get(player);
	}
}
	

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...