Thread: Saving keybinds afer logout?

Page 1 of 2 12 LastLast
Results 1 to 10 of 13
  1. #1 Saving keybinds afer logout? 
    Registered Member Og Smoke's Avatar
    Join Date
    Feb 2018
    Posts
    133
    Thanks given
    1
    Thanks received
    3
    Rep Power
    22
    Anyone know how to save keybinds after logging out? You have to reset your keybinds each time you login on my server, and that bothers the shit out of me.


    43 views and not 1 reply, great help section.
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Dec 2016
    Posts
    357
    Thanks given
    20
    Thanks received
    19
    Rep Power
    11
    playersave class or any class that saves ur shit on ur server , and code it , ezpz
    Reply With Quote  
     

  3. #3  
    Registered Member

    Join Date
    Apr 2014
    Posts
    1,708
    Thanks given
    55
    Thanks received
    655
    Rep Power
    969
    Quote Originally Posted by Og Smoke View Post
    Anyone know how to save keybinds after logging out? You have to reset your keybinds each time you login on my server, and that bothers the shit out of me.


    43 views and not 1 reply, great help section.
    kinda hard to help without any code. First off, if your keybinding configurations aren't being sent to the server, do that. (If you wanna save them in the characters file) if not you can save them client sided.. wanna post some code of your keybindings?
    Reply With Quote  
     

  4. #4  
    The One And Only

    01053's Avatar
    Join Date
    Apr 2011
    Age
    23
    Posts
    2,874
    Thanks given
    414
    Thanks received
    869
    Rep Power
    856
    This might set you on the right path.

    [Only registered and activated users can see links. ]


    Reply With Quote  
     

  5. #5  
    Registered Member Og Smoke's Avatar
    Join Date
    Feb 2018
    Posts
    133
    Thanks given
    1
    Thanks received
    3
    Rep Power
    22
    Quote Originally Posted by Zion View Post
    kinda hard to help without any code. First off, if your keybinding configurations aren't being sent to the server, do that. (If you wanna save them in the characters file) if not you can save them client sided.. wanna post some code of your keybindings?
    Code:
    package com.client.graphics.interfaces.impl;
    
    import java.awt.event.KeyEvent;
    
    import com.client.Client;
    import com.client.Configuration;
    import com.client.graphics.interfaces.RSInterface;
    
    /**
     * Handles tab keybinds
     * @author Ghost
     *
     */
    public class Keybinding {
    
    	public static final int MIN_FRAME = 53009;
    	public static final int RESTORE_DEFAULT = 53004;
    	public static final int ESCAPE_CONFIG = 53006;
    	public static final String[] OPTIONS = {"None", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "ESC"};
    
    	public static final int KEYS[] = { -1, KeyEvent.VK_F1, KeyEvent.VK_F2, KeyEvent.VK_F3, KeyEvent.VK_F4, KeyEvent.VK_F5, KeyEvent.VK_F6, KeyEvent.VK_F7, KeyEvent.VK_F8,
    										KeyEvent.VK_F9, KeyEvent.VK_F10, KeyEvent.VK_F11, KeyEvent.VK_F12, KeyEvent.VK_ESCAPE };
    
    
    	public static int KEYBINDINGS[] = {
    			KeyEvent.VK_F1,
    			KeyEvent.VK_F2,
    			KeyEvent.VK_F3,
    			KeyEvent.VK_ESCAPE,
    			KeyEvent.VK_F4,
    			KeyEvent.VK_F5,
    			KeyEvent.VK_F6,
    			KeyEvent.VK_F7,
    			KeyEvent.VK_F8,
    			KeyEvent.VK_F9,
    			-1,
    			KeyEvent.VK_F10,
    			KeyEvent.VK_F11,
    			KeyEvent.VK_F12,
    	};
    
    
    	public static void restoreDefault() {
    		KEYBINDINGS = new int[]{
    				KeyEvent.VK_F1,
    				KeyEvent.VK_F2,
    				KeyEvent.VK_F3,
    				KeyEvent.VK_ESCAPE,
    				KeyEvent.VK_F4,
    				KeyEvent.VK_F5,
    				KeyEvent.VK_F6,
    				KeyEvent.VK_F7,
    				KeyEvent.VK_F8,
    				KeyEvent.VK_F9,
    				-1,
    				KeyEvent.VK_F10,
    				KeyEvent.VK_F11,
    				KeyEvent.VK_F12,	
    		};
    		Configuration.escapeCloseInterface = false;
    	}
    
    	public static void checkDuplicates(int key, int index) {
    		for (int i = 0; i < KEYBINDINGS.length; i++) {
    			if (KEYS[key] == KEYBINDINGS[i] && i != index && KEYBINDINGS[i] != -1) {
    				KEYBINDINGS[i] = -1;
    				RSInterface.interfaceCache[MIN_FRAME+3*i].dropdown.setSelected("None");
    			}
    		}
    		if (index != -1 && KEYS[key] == KeyEvent.VK_ESCAPE && Configuration.escapeCloseInterface) {
    			Configuration.escapeCloseInterface = !Configuration.escapeCloseInterface;
    			RSInterface.interfaceCache[ESCAPE_CONFIG].active = Configuration.escapeCloseInterface;
    		}
    	}
    
    	public static void bind(int index, int key) {
    		checkDuplicates(key, index);
    		KEYBINDINGS[index] = KEYS[key];
    		//Client.instance.savePlayerData();
    	}
    
    	public static boolean isBound(int key) {
    		for(int i = 0; i < KEYBINDINGS.length; i++) {
    			if (key == KEYBINDINGS[i]) {
    				Client.setTab(i);
    				return true;
    			}
    		}
    		return false;
    	}
    
    	public static void updateInterface() {
    
    		for (int i=0; i<OPTIONS.length; i++) {
    
    			int key = KEYBINDINGS[i];
    			String current = "None";
    
    			if (key == -1) {
    				// None
    			} else if (key == 27) {
    				// Esc
    				current = OPTIONS[13];
    			} else {
    				// F1 - F12: 112 - 123
    				current = OPTIONS[key-111];
    			}
    
    			RSInterface.interfaceCache[MIN_FRAME+3*i].dropdown.setSelected(current);
    		}
    		RSInterface.interfaceCache[ESCAPE_CONFIG].active = Configuration.escapeCloseInterface;
    	}
    }
    Reply With Quote  
     

  6. #6  
    Elkoy

    Join Date
    Oct 2010
    Posts
    2,799
    Thanks given
    1,164
    Thanks received
    1,464
    Rep Power
    5000
    Quote Originally Posted by Og Smoke View Post
    Code:
    package com.client.graphics.interfaces.impl;
    
    import java.awt.event.KeyEvent;
    
    import com.client.Client;
    import com.client.Configuration;
    import com.client.graphics.interfaces.RSInterface;
    
    /**
     * Handles tab keybinds
     * @author Ghost
     *
     */
    public class Keybinding {
    
    	public static final int MIN_FRAME = 53009;
    	public static final int RESTORE_DEFAULT = 53004;
    	public static final int ESCAPE_CONFIG = 53006;
    	public static final String[] OPTIONS = {"None", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "ESC"};
    
    	public static final int KEYS[] = { -1, KeyEvent.VK_F1, KeyEvent.VK_F2, KeyEvent.VK_F3, KeyEvent.VK_F4, KeyEvent.VK_F5, KeyEvent.VK_F6, KeyEvent.VK_F7, KeyEvent.VK_F8,
    										KeyEvent.VK_F9, KeyEvent.VK_F10, KeyEvent.VK_F11, KeyEvent.VK_F12, KeyEvent.VK_ESCAPE };
    
    
    	public static int KEYBINDINGS[] = {
    			KeyEvent.VK_F1,
    			KeyEvent.VK_F2,
    			KeyEvent.VK_F3,
    			KeyEvent.VK_ESCAPE,
    			KeyEvent.VK_F4,
    			KeyEvent.VK_F5,
    			KeyEvent.VK_F6,
    			KeyEvent.VK_F7,
    			KeyEvent.VK_F8,
    			KeyEvent.VK_F9,
    			-1,
    			KeyEvent.VK_F10,
    			KeyEvent.VK_F11,
    			KeyEvent.VK_F12,
    	};
    
    
    	public static void restoreDefault() {
    		KEYBINDINGS = new int[]{
    				KeyEvent.VK_F1,
    				KeyEvent.VK_F2,
    				KeyEvent.VK_F3,
    				KeyEvent.VK_ESCAPE,
    				KeyEvent.VK_F4,
    				KeyEvent.VK_F5,
    				KeyEvent.VK_F6,
    				KeyEvent.VK_F7,
    				KeyEvent.VK_F8,
    				KeyEvent.VK_F9,
    				-1,
    				KeyEvent.VK_F10,
    				KeyEvent.VK_F11,
    				KeyEvent.VK_F12,	
    		};
    		Configuration.escapeCloseInterface = false;
    	}
    
    	public static void checkDuplicates(int key, int index) {
    		for (int i = 0; i < KEYBINDINGS.length; i++) {
    			if (KEYS[key] == KEYBINDINGS[i] && i != index && KEYBINDINGS[i] != -1) {
    				KEYBINDINGS[i] = -1;
    				RSInterface.interfaceCache[MIN_FRAME+3*i].dropdown.setSelected("None");
    			}
    		}
    		if (index != -1 && KEYS[key] == KeyEvent.VK_ESCAPE && Configuration.escapeCloseInterface) {
    			Configuration.escapeCloseInterface = !Configuration.escapeCloseInterface;
    			RSInterface.interfaceCache[ESCAPE_CONFIG].active = Configuration.escapeCloseInterface;
    		}
    	}
    
    	public static void bind(int index, int key) {
    		checkDuplicates(key, index);
    		KEYBINDINGS[index] = KEYS[key];
    		//Client.instance.savePlayerData();
    	}
    
    	public static boolean isBound(int key) {
    		for(int i = 0; i < KEYBINDINGS.length; i++) {
    			if (key == KEYBINDINGS[i]) {
    				Client.setTab(i);
    				return true;
    			}
    		}
    		return false;
    	}
    
    	public static void updateInterface() {
    
    		for (int i=0; i<OPTIONS.length; i++) {
    
    			int key = KEYBINDINGS[i];
    			String current = "None";
    
    			if (key == -1) {
    				// None
    			} else if (key == 27) {
    				// Esc
    				current = OPTIONS[13];
    			} else {
    				// F1 - F12: 112 - 123
    				current = OPTIONS[key-111];
    			}
    
    			RSInterface.interfaceCache[MIN_FRAME+3*i].dropdown.setSelected(current);
    		}
    		RSInterface.interfaceCache[ESCAPE_CONFIG].active = Configuration.escapeCloseInterface;
    	}
    }
    That code is mine from like 2016 btw, it's not Ghost's, but for some reason it's his author tag? (edit: looks like he changed updateInterface() for his dropdown menus but still shouldn't have his author tag on it, assuming he was the one who changed it)

    Either way, you literally commented out the saving of the keys? Look at the savePlayerData in the elvarg client you're ripping this from and copy it.

    Code:
    	public static void bind(int index, int key) {
    		checkDuplicates(key, index);
    		KEYBINDINGS[index] = KEYS[key];
    		//Client.instance.savePlayerData();
    	}
    [Only registered and activated users can see links. ]

    [Today 01:29 AM] RSTrials: Nice 0.97 Win/Loss Ratio luke. That's pretty bad.
    [Today 01:30 AM] Luke132: Ok u fucking moron i forgot i could influence misc.random
    Quote Originally Posted by Mille View Post
    but a model program? Would it be possible to use paint?
    Quote Originally Posted by ED3N View Post
    What do you know about Public Void and int without this [] is only 1 integer, why?
    Reply With Quote  
     

  7. Thankful user:


  8. #7  
    Registered Member

    Join Date
    Apr 2014
    Posts
    1,708
    Thanks given
    55
    Thanks received
    655
    Rep Power
    969
    Code:
    package com.client.graphics.interfaces.impl;
    
    import java.awt.event.KeyEvent;
    
    import com.client.Client;
    import com.client.Configuration;
    import com.client.graphics.interfaces.RSInterface;
    
     /**
     * I fear the day technology will surpass our human interaction. The world will have a generation of idiots. -Albert Einstein
     * Date: 6/5/2015
     * Time: 1:58 PM
     *
     * @author Professor Oak
     */
    public class Keybinding {
    
    	public static final int MIN_FRAME = 53009;
    	public static final int RESTORE_DEFAULT = 53004;
    	public static final int ESCAPE_CONFIG = 53006;
    	public static final String[] OPTIONS = {"None", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "F11", "F12", "ESC"};
    
    	public static final int KEYS[] = { -1, KeyEvent.VK_F1, KeyEvent.VK_F2, KeyEvent.VK_F3, KeyEvent.VK_F4, KeyEvent.VK_F5, KeyEvent.VK_F6, KeyEvent.VK_F7, KeyEvent.VK_F8,
    										KeyEvent.VK_F9, KeyEvent.VK_F10, KeyEvent.VK_F11, KeyEvent.VK_F12, KeyEvent.VK_ESCAPE };
    
    
    	public static int KEYBINDINGS[] = {
    			KeyEvent.VK_F1,
    			KeyEvent.VK_F2,
    			KeyEvent.VK_F3,
    			KeyEvent.VK_ESCAPE,
    			KeyEvent.VK_F4,
    			KeyEvent.VK_F5,
    			KeyEvent.VK_F6,
    			KeyEvent.VK_F7,
    			KeyEvent.VK_F8,
    			KeyEvent.VK_F9,
    			-1,
    			KeyEvent.VK_F10,
    			KeyEvent.VK_F11,
    			KeyEvent.VK_F12,
    	};
    
    
    	public static void restoreDefault() {
    		KEYBINDINGS = new int[]{
    				KeyEvent.VK_F1,
    				KeyEvent.VK_F2,
    				KeyEvent.VK_F3,
    				KeyEvent.VK_ESCAPE,
    				KeyEvent.VK_F4,
    				KeyEvent.VK_F5,
    				KeyEvent.VK_F6,
    				KeyEvent.VK_F7,
    				KeyEvent.VK_F8,
    				KeyEvent.VK_F9,
    				-1,
    				KeyEvent.VK_F10,
    				KeyEvent.VK_F11,
    				KeyEvent.VK_F12,	
    		};
    		Configuration.escapeCloseInterface = false;
    	}
    
    	public static void checkDuplicates(int key, int index) {
    		for (int i = 0; i < KEYBINDINGS.length; i++) {
    			if (KEYS[key] == KEYBINDINGS[i] && i != index && KEYBINDINGS[i] != -1) {
    				KEYBINDINGS[i] = -1;
    				RSInterface.interfaceCache[MIN_FRAME+3*i].dropdown.setSelected("None");
    			}
    		}
    		if (index != -1 && KEYS[key] == KeyEvent.VK_ESCAPE && Configuration.escapeCloseInterface) {
    			Configuration.escapeCloseInterface = !Configuration.escapeCloseInterface;
    			RSInterface.interfaceCache[ESCAPE_CONFIG].active = Configuration.escapeCloseInterface;
    		}
    	}
    
    	public static void bind(int index, int key) {
    		checkDuplicates(key, index);
    		KEYBINDINGS[index] = KEYS[key];
    		Client.instance.savePlayerData();
    	}
    
    	public static boolean isBound(int key) {
    		for(int i = 0; i < KEYBINDINGS.length; i++) {
    			if (key == KEYBINDINGS[i]) {
    				Client.setTab(i);
    				return true;
    			}
    		}
    		return false;
    	}
    
    	public static void updateInterface() {
    
    		for (int i=0; i<OPTIONS.length; i++) {
    
    			int key = KEYBINDINGS[i];
    			String current = "None";
    
    			if (key == -1) {
    				// None
    			} else if (key == 27) {
    				// Esc
    				current = OPTIONS[13];
    			} else {
    				// F1 - F12: 112 - 123
    				current = OPTIONS[key-111];
    			}
    
    			RSInterface.interfaceCache[MIN_FRAME+3*i].dropdown.setSelected(current);
    		}
    		RSInterface.interfaceCache[ESCAPE_CONFIG].active = Configuration.escapeCloseInterface;
    	}
    }
    there you go man
    Reply With Quote  
     

  9. Thankful user:


  10. #8  
    Registered Member Og Smoke's Avatar
    Join Date
    Feb 2018
    Posts
    133
    Thanks given
    1
    Thanks received
    3
    Rep Power
    22
    So apparently I don't even have a method for savePlayerData?

    Reply With Quote  
     

  11. #9  
    Elkoy

    Join Date
    Oct 2010
    Posts
    2,799
    Thanks given
    1,164
    Thanks received
    1,464
    Rep Power
    5000
    Quote Originally Posted by Og Smoke View Post
    So apparently I don't even have a method for savePlayerData?


    Here, I took the saving from the original elvarg released but removed everyhting but keybindings.
    If you need something saving client-sided in the future just put it in the methods


    shove them in client class

    Code:
    public void savePlayerData() {
            try {
                File file = new File(SignLink.findcachedir() + "/settings.dat");
                if (!file.exists()) {
                    file.createNewFile();
                }
                DataOutputStream stream = new DataOutputStream(new FileOutputStream(file));
               
               for(int i = 0; i < 14; i++) {
                        stream.writeByte(Keybinding.KEYBINDINGS[i]);
               }
       
               stream.close();
    
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    And on client startup, load the saved data:

    Code:
    private void loadPlayerData() throws IOException {
            File file = new File(SignLink.findcachedir() + "/settings.dat");
            if (!file.exists()) {
                return;
            }
    
            DataInputStream stream = new DataInputStream(new FileInputStream(file));
    
            try {
    
    
    	for(int i = 0; i < Keybinding.KEYBINDINGS.length; i++) {
                    Keybinding.KEYBINDINGS[i] = stream.readByte();
    	}
    
            } catch (IOException e) {
                System.out.println("Unable to load player data.");
                file.delete();
            } finally {
                stream.close();
            }
        }
    [Only registered and activated users can see links. ]

    [Today 01:29 AM] RSTrials: Nice 0.97 Win/Loss Ratio luke. That's pretty bad.
    [Today 01:30 AM] Luke132: Ok u fucking moron i forgot i could influence misc.random
    Quote Originally Posted by Mille View Post
    but a model program? Would it be possible to use paint?
    Quote Originally Posted by ED3N View Post
    What do you know about Public Void and int without this [] is only 1 integer, why?
    Reply With Quote  
     

  12. #10  
    Registered Member Og Smoke's Avatar
    Join Date
    Feb 2018
    Posts
    133
    Thanks given
    1
    Thanks received
    3
    Rep Power
    22
    Quote Originally Posted by Professor Oak View Post
    Here, I took the saving from the original elvarg released but removed everyhting but keybindings.
    If you need something saving client-sided in the future just put it in the methods


    shove them in client class

    Code:
    public void savePlayerData() {
            try {
                File file = new File(SignLink.findcachedir() + "/settings.dat");
                if (!file.exists()) {
                    file.createNewFile();
                }
                DataOutputStream stream = new DataOutputStream(new FileOutputStream(file));
               
               for(int i = 0; i < 14; i++) {
                        stream.writeByte(Keybinding.KEYBINDINGS[i]);
               }
       
               stream.close();
    
            } catch (IOException e) {
                e.printStackTrace();
            }
        }

    And on client startup, load the saved data:

    Code:
    private void loadPlayerData() throws IOException {
            File file = new File(SignLink.findcachedir() + "/settings.dat");
            if (!file.exists()) {
                return;
            }
    
            DataInputStream stream = new DataInputStream(new FileInputStream(file));
    
            try {
    
    
    	for(int i = 0; i < Keybinding.KEYBINDINGS.length; i++) {
                    Keybinding.KEYBINDINGS[i] = stream.readByte();
    	}
    
            } catch (IOException e) {
                System.out.println("Unable to load player data.");
                file.delete();
            } finally {
                stream.close();
            }
        }

    You've got me a bit lost man lol. The error I'm getting is because there's no method for savePlayerData, what exactly do I need to do?
    Reply With Quote  
     

Page 1 of 2 12 LastLast

Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [639] Saving Players on logout
    By furls in forum Help
    Replies: 5
    Last Post: 06-20-2012, 09:37 AM
  2. Saving resets upon logout
    By buttaz54 in forum Help
    Replies: 0
    Last Post: 02-23-2012, 02:03 AM
  3. Saving damage after logout?
    By MarkQ in forum Help
    Replies: 7
    Last Post: 08-03-2011, 07:07 AM
  4. Replies: 4
    Last Post: 01-28-2011, 04:14 AM
  5. Chars arent saving when you logout
    By GwasDdos in forum Help
    Replies: 8
    Last Post: 01-16-2010, 01:36 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
  •