718 Zoom

May 12, 2018
19
4
0
Spoiler for Read before you rate/hate/discriminate below:

**This can probably be used for different revisions but I only tested it on my 718.**
**This is my first Rune-server snippet post. If I didn't format it correctly that's why. Correct me in PM or comments.**
**This can probably be coded way better, but not by me :aware::aware:**
**I searched all of rune-server for this and only got bits/pieces and made my own type of zoom. I couldn't find this released anywhere.**

What you will be adding:
- Holding shift and using mouse wheel to zoom in and/or out
- Holding shift and clicking mouse wheel in to reset zoom
- Command "resetzoom" to reset zoom amount. Useful if players are on laptops and can scroll with touchpad but do not have a button to reset back zoom.

Client sided:
Class319_Sub1.java
- Find code
Code:
	public synchronized void mouseClicked(MouseEvent mouseevent) {
		try {


- Add code below try {
Code:
			if (mouseevent.isShiftDown()) {
				String resetzoom = "resetzoom";
				System.out.println(resetzoom);
				Class419.method5605(resetzoom, true, false, 1405738364);
				}


- Find code
Code:
	public synchronized void mouseWheelMoved(MouseWheelEvent mousewheelevent) {
		try {


- Add code below try {
Code:
		if (mousewheelevent.isShiftDown()) {
			int z = mousewheelevent.getWheelRotation();
			if (mousewheelevent.getWheelRotation() == +1) {
				try {
					String string = new StringBuilder().append("zoomout ").append(16).toString();
					System.out.println(string);
					Class419.method5605(string, true, false, 1405738364);
				} catch (RuntimeException runtimeexception) {
					throw Class346.method4175(runtimeexception, new StringBuilder().append("zm.gd(").append(')').toString());
				}
			}
			if (mousewheelevent.getWheelRotation() == -1){
				try {
					String string = new StringBuilder().append("zoomin ").append(16).toString();
					System.out.println(string);
					Class419.method5605(string, true, false, 1405738364);
				} catch (RuntimeException runtimeexception) {
					throw Class346.method4175(runtimeexception, new StringBuilder().append("zm.gd(").append(')').toString());
				}
			}
		}



Server sided:
Player.java
- Find a "Public int" and add code below line:
Code:
    public int zoom = 226;

Open your regular player commands .java (Regular.java)?
- Find code
Code:
		if (clientCommand) {

Spoiler for If code was not found open this, if not, continue below:

- Find code
Code:
	public static boolean processCommand
and replace the entire line with:
Code:
	public static boolean processCommand(final Player player, String[] cmd, boolean console, boolean clientCommand) {
- Below that line add code:
Code:
		if (clientCommand) {

			return true;
			}

Add code below:
Code:
			if (cmd[0].equals("zoomout")) {
				cmd = cmd[1].split(" ");
				player.zoom = player.zoom-Integer.valueOf(cmd[0]);
				int setZoom = player.zoom;
				if (player.zoom <= 49) {
					player.zoom = 50;
					player.getPackets().sendGlobalConfig(184, 50);
					player.getPackets().sendGameMessage("You can not zoom out that much!");
				}
				player.getPackets().sendGlobalConfig(184, setZoom);
				//player.getPackets().sendGameMessage("Player zoom: (out) "+player.zoom+"");
				return true;
			}
			
			if (cmd[0].equals("zoomin")) {
				cmd = cmd[1].split(" ");
				player.zoom = player.zoom+Integer.valueOf(cmd[0]);
				int setZoom = player.zoom;
				if (player.zoom >= 2500) {
					player.zoom = 2500;
					player.getPackets().sendGlobalConfig(184, 2500);
					player.getPackets().sendGameMessage("You can not zoom in that much!");
				}
				player.getPackets().sendGlobalConfig(184, setZoom);
				//player.getPackets().sendGameMessage("Player zoom: (in) "+player.zoom+"");
				return true;
			}
			if (cmd[0].equals("resetzoom")) {
				player.zoom = 226;
				player.getPackets().sendGlobalConfig(184, 0);
				return true;
			}


Find your home command and add above:
Code:
			if (cmd[0].equals("resetzoom")) {
				player.zoom = 226;
				player.getPackets().sendGlobalConfig(184, 0);
				return true;
			}

You're done! See below for notes about what you added.


Spoiler for A few useful notes:

Increments are set at +16 or -16 from the client Class319_Sub1.java class add-in at code:
Code:
append([COLOR="#00FFFF"][SIZE=4]16[/SIZE][/COLOR]).toString();
You can adjust as wanted. I felt that 16 was a steady number to + or -.

Player zoom is defaulted to 226 from the Player.java add in zoom = 226;. (Same as the resetzoom command)
You can adjust as wanted.

When logging back in the player zoom will reset until they re-adjust zoom with shift + mouse wheel.
- To fix this you can add "getPackets().sendGlobalConfig(184, zoom);" to the login code.


Zoom amounts are limited to 50 through 2500. You can adjust as wanted in your commands code.


Rate/hate/discriminate below! Let me know if you enjoyed it, if it was not useful, if I made a mistake, if you have an error, or how I can improve my code. :3::D
 
Goodjob, you can also use the console of the client as output . In 667 it's Node_Sub7
 
Code:
		if (cmd[0].equals("zoomout")) {
				cmd = cmd[1].split(" ");
				player.zoom = player.zoom-Integer.valueOf(cmd[0]);
				int setZoom = player.zoom;
				if (player.zoom <= 49) {
					player.zoom = 50;
					player.getPackets().sendGlobalConfig(184, 50);
					player.getPackets().sendGameMessage("You can not zoom out that much!");
				}
				player.getPackets().sendGlobalConfig(184, setZoom);
				//player.getPackets().sendGameMessage("Player zoom: (out) "+player.zoom+"");
				return true;
			}
			
			if (cmd[0].equals("zoomin")) {
				cmd = cmd[1].split(" ");
				player.zoom = player.zoom+Integer.valueOf(cmd[0]);
				int setZoom = player.zoom;
				if (player.zoom >= 2500) {
					player.zoom = 2500;
					player.getPackets().sendGlobalConfig(184, 2500);
					player.getPackets().sendGameMessage("You can not zoom in that much!");
				}
				player.getPackets().sendGlobalConfig(184, setZoom);
				//player.getPackets().sendGameMessage("Player zoom: (in) "+player.zoom+"");
				return true;
			}
			if (cmd[0].equals("resetzoom")) {
				player.zoom = 226;
				player.getPackets().sendGlobalConfig(184, 0);
				return true;
			}
You don't really need the setZoom integer here, but if you want it, then you will also want to replace the player.zoom calls after it. Also you can use -= and += instead of = then subtracting or adding. You are also sending the global config twice if the condition is true, cause you don't return the method. And why are you sending the config with a value of 0 in the resetZoom command? I believe it should contain the value of the zoom which is 226? Ex:
Code:
		if (cmd[0].equals("zoomout")) {
				cmd = cmd[1].split(" ");
				player.zoom -= Integer.valueOf(cmd[0]);
				if (player.zoom <= 49) {
					player.zoom = 50;
					player.getPackets().sendGameMessage("You can not zoom out that much!");
				}
				player.getPackets().sendGlobalConfig(184, player.zoom);
				//player.getPackets().sendGameMessage("Player zoom: (out) "+player.zoom+"");
				return true;
			}
			
			if (cmd[0].equals("zoomin")) {
				cmd = cmd[1].split(" ");
				player.zoom += Integer.valueOf(cmd[0]);
				if (player.zoom >= 2500) {
					player.zoom = 2500;
					player.getPackets().sendGameMessage("You can not zoom in that much!");
				}
				player.getPackets().sendGlobalConfig(184, player.zoom);
				//player.getPackets().sendGameMessage("Player zoom: (in) "+player.zoom+"");
				return true;
			}
			if (cmd[0].equals("resetzoom")) {
				player.zoom = 226;
				player.getPackets().sendGlobalConfig(184, player.zoom);
				return true;
			}
Also should get used to using camel case for best coding habits.
Code:
String resetzoom
should be
String resetZoom
Just a few things I noticed, but goodjob overall for a first snippet. (Although it has been released before)
 
I see how you're doing this, which is having the commands do the client zooming for you and then scrolling with the wheel inputs those variables into the developer console client-sided, but you have to change:

Class419.method5605(string, true, false, 1405738364);
to this:

Class419.method5605(string, false, false, 1405738364);

You'll end up with this, instead.
unknown.png


BUT, you will also need to edit the mouse wheel click. This will reset the zoom to the default.
unknown.png
 
Last edited:
UPDATE: Also, in order for your REGULAR players to use this, as most clients require console server commands to only be utilized by players with rank 2+ (admin), you will have to change a few other things.

So, in your client files, search for:

method5605
[/code]
~or~
Code:
getcamerapos

Scroll down a bit an you'll see a something like this:
unknown.png


It will actually say "client.playerRights >= 2"
But, for regular players to be able zoom in or out, via the scroll option client sided, they will need access to the dev console as this is where the command is executed.
So, simply change that to what I have above -"client.playerRights >=0".

TADA!
unknown.png
 
I've done this a few times as well, but what I'd recommend is tying the function of zooming in/out to an easy-to-access button via the client. It's so much better design-wise to clicking in to zoom in/out as it is to remembering the key combos to zoom/reset.
 
Just implemented this into my 718 server with relative ease and included the suggested fixes.

Wanted to say thanks:

Joshwood22 - Original Snippet
Banners - Snippet Improvements (code cleanup)
'Kyle - Snippet Implementation Fixes (polishing up the execution)

You guys seriously helped me include a fantastic function in my little private server I run for my family (got 5 of us that play on this thing)
 
Why does this scroll other interfaces?

Ex] When you scroll while within the bank, it still zooms out the screen.
 
Why does this scroll other interfaces?

Ex] When you scroll while within the bank, it still zooms out the screen.

Well you could add a check that disables the control when the player is in a view (like a message prompt such as bank or other type)

This simply did not come with that functionality. Personally I don't really care too much about that personal preference but if someone wants to bother making a snippet for that specific thing I'd probably add it into my server tbh.

I personally would do it as well myself but I am trying to first build my server up to be fully featured before cleaning things of that nature up.
 
Well you could add a check that disables the control when the player is in a view (like a message prompt such as bank or other type)

This simply did not come with that functionality. Personally I don't really care too much about that personal preference but if someone wants to bother making a snippet for that specific thing I'd probably add it into my server tbh.

I personally would do it as well myself but I am trying to first build my server up to be fully featured before cleaning things of that nature up.

IK this is old but i get what he means,
e256bd4369ca17f4b73aaa8c69784305.gif
 
Check if an interface contains a scrollbar script if so ignore scroll event. easy.
Other ways of doing it yes
 
IK this is old but i get what he means,
e256bd4369ca17f4b73aaa8c69784305.gif

Old doesn't mean dead haha

If you're looking for a solution to this I could take another whack at it. It's been 5 years and I understand more things since then. Let me know and I'll poke around the client again and see about making it more polished.

EDIT: I have mine set to shift+scroll which doesn't scroll in interfaces unless I'm holding shift as well
 
Check if an interface contains a scrollbar script if so ignore scroll event. easy.
Other ways of doing it yes

Hmm could work but, it actually needs a client screen check

Old doesn't mean dead haha

If you're looking for a solution to this I could take another whack at it. It's been 5 years and I understand more things since then. Let me know and I'll poke around the client again and see about making it more polished.

EDIT: I have mine set to shift+scroll which doesn't scroll in interfaces unless I'm holding shift as well

Shift+scroll is one way but then if you had shift drop metbod coded in client that would disturb
 
Hmm could work but, it actually needs a client screen check



Shift+scroll is one way but then if you had shift drop metbod coded in client that would disturb

True! But this could be tied to any button such as ctrl or something else was my thought.
 
True! But this could be tied to any button such as ctrl or something else was my thought.

i managed to solve it, i asked many developers but no one knew how to solve it. but i did hehehe :p
df8d4e674ad9b9f0e9d01ba39325f6e4.gif




edit: just one small problem, scrolling while interface is open still an issue but hopefully to get the right ID later on when i have time to dig more into it
 
i managed to solve it, i asked many developers but no one knew how to solve it. but i did hehehe :p
df8d4e674ad9b9f0e9d01ba39325f6e4.gif




edit: just one small problem, scrolling while interface is open still an issue but hopefully to get the right ID later on when i have time to dig more into it

i have the solution dm
 
- Add code below try {
Code:
		if (mousewheelevent.isShiftDown()) {
			int z = mousewheelevent.getWheelRotation();
			if (mousewheelevent.getWheelRotation() == +1) {
				try {
					String string = new StringBuilder().append("zoomout ").append(16).toString();
					System.out.println(string);
					Class419.method5605(string, true, false, 1405738364);
				} catch (RuntimeException runtimeexception) {
					throw Class346.method4175(runtimeexception, new StringBuilder().append("zm.gd(").append(')').toString());
				}
			}
			if (mousewheelevent.getWheelRotation() == -1){
				try {
					String string = new StringBuilder().append("zoomin ").append(16).toString();
					System.out.println(string);
					Class419.method5605(string, true, false, 1405738364);
				} catch (RuntimeException runtimeexception) {
					throw Class346.method4175(runtimeexception, new StringBuilder().append("zm.gd(").append(')').toString());
				}
			}
		}
While the code works, there is no reason to have multiple try/catches in the same method here. You could easily simplify this code with the following:
Code:
if (mousewheelevent.isShiftDown()) {
    int z = mousewheelevent.getWheelRotation();

    String action = null;
    if (z == 1) {
        action = "zoomout 16";
    } else if (z == -1) {
        action = "zoomin 16";
    }

    if (action != null) {
        System.out.println(action);
        try {
            Class419.method5605(action, true, false, 1405738364);
        } catch (RuntimeException runtimeException) {
            throw Class346.method4175(runtimeException, "zm.gd()");
        }
    }
}

Edit: I just realized how old this thread is, please ignore.
 
Last edited:

Users who are viewing this thread (total: 1, members: 0, guests: 1)