Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

[Tut - A] [ 508] Leveling up

Junior Spellweaver
Joined
May 17, 2007
Messages
131
Reaction score
2
Credit's go to Ian... from rune-server


This will guide you to adding fully working leveling up to ur server.
Its based on Palidino76'508, but i remove the palidino76 package :).
Images;
- Simple Levelup Interface with the Text and Skill Icon Added.
super man - [Tut - A] [ 508] Leveling up - RaGEZONE Forums
- Flashing Skill Icons. (Credit to Lumby for the frame 1179 tip.(I thaught it was just image on chatbox lol(Also im Missing Agility :s))
super man - [Tut - A] [ 508] Leveling up - RaGEZONE Forums
- Simple Message Received :).
super man - [Tut - A] [ 508] Leveling up - RaGEZONE Forums

- And Ofcause the Main, You can now make interface.
super man - [Tut - A] [ 508] Leveling up - RaGEZONE Forums
Tutorial;

First of all make a new folder called 'content' and add all the stuff to your compiler.
Secondly go into the 'content' folder and make a new .java file named LevelUp and add the folowing into it ;
Code:
package palidino76.rs2.content;
import palidino76.rs2.players.*;
import palidino76.rs2.util.Misc;
public class Levelup {
 public Levelup(){
 }
 
 public Levelup(Player p, int skillID) {
  if(p == null || skillID < 0 || skillID > 23) {
   return;
  }
  p.leveledUpSkill = skillID;
  p.leveledUp[skillID] = true;
  p.requestGFX(199,100);
  p.frames.sendMessage(p, "You've just advanced a " + Misc.getSkillName(skillID) + " level! You have reached level " + p.skillLvl[skillID] + ".");
  p.frames.setString(p, "Congratulations, you have just advanced a " + Misc.getSkillName(skillID) + " level!", 740, 0);
  p.frames.setString(p, "You have now reached level " + p.skillLvl[skillID] + "!", 740, 1);
  p.frames.setConfig(p, 1179, Misc.getSkillIcon(skillID));
  p.frames.showChatboxInterface(p, 740);
    }
}
Now, go into your palidino76/rs2/util/ Misc.java and add these 3 methods.
Code:
 public static int getFlashingIcon(int skillID) {
  switch(skillID) {
            case 0: //Attack
    return 1;
            case 1: //Defence
    return 4;
            case 2: //Strength
    return 2;
            case 3: //Hitpoints
    return 64;
            case 4: //Ranging
    return 8;
            case 5: //Prayer
    return 16;
            case 6: //Magic
    return 32;
            case 7: //Cooking
    return 32768;
            case 8: //Woodcutting
    return 131072;
            case 9: //Fletching
    return 2048;
            case 10: //Fishing
    return 16384;
            case 11: //Firemaking
    return 65536;
            case 12: //Crafting
    return 1024;
            case 13: //Smithing
    return 8192;
            case 14: //Mining
    return 4096;
            case 15: //Herblore
    return 256;
            case 16: //Agility
    return -1; // NEED THIS
            case 17: //Thieving
    return 512;
            case 18: //Slayer
    return 524288;
            case 19: //Farming
    return 1048576;
            case 20: //Runecrafting
    return 262144;
            case 21: //Construction
    return 2097152;
   case 22: //Hunter
    return 4194304;
   case 23: //Summoning
    return 8388608;
   default:
    return -1;
  }
 }
 
 public static int getSkillIcon(int skillID) {
  switch(skillID) {
            case 0: //Attack
    return 100000000;
            case 1: //Defence
    return 400000000;
            case 2: //Strength
    return 200000000;
            case 3: //Hitpoints
    return 450000000;
            case 4: //Ranging
    return 250000000;
            case 5: //Prayer
    return 500000000;
            case 6: //Magic
    return 300000000;
            case 7: //Cooking
    return 1100000000;
            case 8: //Woodcutting
    return 1250000000;
            case 9: //Fletching
    return 1300000000;
            case 10: //Fishing
    return 1050000000;
            case 11: //Firemaking
    return 1200000000;
            case 12: //Crafting
    return 800000000;
            case 13: //Smithing
    return 1000000000;
            case 14: //Mining
    return 900000000;
            case 15: //Herblore
    return 650000000;
            case 16: //Agility
    return 600000000;
            case 17: //Thieving
    return 700000000;
            case 18: //Slayer
    return 1400000000;
            case 19: //Farming
    return 1450000000;
            case 20: //Runecrafting
    return 850000000;
            case 21: //Construction
    return 1500000000;
   case 22: //Hunter
    return 1600000000;
   case 23: //Summoning
    return 1650000000;
   default:
    return -1;
  }
 }
 
 public static String getSkillName(int skillID) {
  switch(skillID) {
   case 0: return "Attack";
   case 1: return "Defence";
   case 2: return "Strength";
   case 3: return "Hitpoints";
   case 4: return "Ranging";
   case 5: return "Prayer";
   case 6: return "Magic";
   case 7: return "Cooking";
   case 8: return "Woodcutting";
   case 9: return "Fletching";
   case 10: return "Fishing";
   case 11: return "Firemaking";
   case 12: return "Crafting";
   case 13: return "Smithing";
   case 14: return "Mining";
   case 15: return "Herblore";
   case 16: return "Agility";
   case 17: return "Thieving";
   case 18: return "Slayer";
   case 19: return "Farming";
   case 20: return "Runecrafting";
   case 21: return "Construction";
   case 22: return "Hunter";
   case 23: return "Summoning";
   default: return "null";
  }
 }
Note: They can go anyware in Misc.java to be honest.
Now, Open ActionButtons.java in palidino76/rs2/io/packets and add these buttons;
Code:
   case 320: // Skills Tab.
    boolean lvlup = false;
    switch(buttonId) {
     case 125: //Attack
      if(!p.leveledUp[0]){
       p.skillMenu = 1;
       p.frames.setConfig(p, 965, 1);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 10);
      }
            break;
        case 126: //Strength
      if(!p.leveledUp[2]){
       p.skillMenu = 2;
       p.frames.setConfig(p, 965, 2);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 20);
      }
            break;
        case 127: //Defence
      if(!p.leveledUp[1]){
       p.skillMenu = 5;
       p.frames.setConfig(p, 965, 5);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 40);
      }
            break;
        case 128: //Ranged
      if(!p.leveledUp[4]){
       p.skillMenu = 3;
       p.frames.setConfig(p, 965, 3);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 30);
      }
            break;
        case 129: //Prayer
      if(!p.leveledUp[5]){
       p.skillMenu = 7;
       p.frames.setConfig(p, 965, 7);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 60);
      }
            break;
        case 130: //Magic
      if(!p.leveledUp[6]){
       p.skillMenu = 4;
       p.frames.setConfig(p, 965, 4);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 33);
      }
            break;
        case 131: //Runecrafting
      if(!p.leveledUp[20]){
       p.skillMenu = 12;
       p.frames.setConfig(p, 965, 12);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 100);
      }
            break;
        case 132: //Construction
      if(!p.leveledUp[21]){
       p.skillMenu = 22;
       p.frames.setConfig(p, 965, 22);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 698);
      }
            break;
        case 133: //Hitpoints
      if(!p.leveledUp[3]){
       p.skillMenu = 6;
       p.frames.setConfig(p, 965, 6);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 50);
      }
            break;
        case 134: //Agility
      if(!p.leveledUp[16]){
       p.skillMenu = 8;
       p.frames.setConfig(p, 965, 8);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 65);
      }
            break;
        case 135: //Herblore
      if(!p.leveledUp[15]){
       p.skillMenu = 9;
       p.frames.setConfig(p, 965, 9);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 75);
      }
            break;
        case 136: //Thieving
      if(!p.leveledUp[17]){
       p.skillMenu = 10;
       p.frames.setConfig(p, 965, 10);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 80);
      }
            break;
        case 137: //Crafting
      if(!p.leveledUp[12]){
       p.skillMenu = 11;
       p.frames.setConfig(p, 965, 11);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 90);
      }
            break;
        case 138: //Fletching
      if(!p.leveledUp[9]){
       p.skillMenu = 19;
       p.frames.setConfig(p, 965, 19);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 665);
      }
            break;
        case 139: //Slayer
      if(!p.leveledUp[18]){
       p.skillMenu = 20;
       p.frames.setConfig(p, 965, 20);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 673);
      }
            break;
        case 140: //Hunter
      if(!p.leveledUp[22]){
       p.skillMenu = 23;
       p.frames.setConfig(p, 965, 23);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 689);
      }
            break;
        case 141: //Mining
      if(!p.leveledUp[14]){
       p.skillMenu = 13;
       p.frames.setConfig(p, 965, 13);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 110);
      }
            break;
        case 142: //Smithing
      if(!p.leveledUp[13]){
       p.skillMenu = 14;
       p.frames.setConfig(p, 965, 14);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 115);
      }
            break;
        case 143: //Fishing
      if(!p.leveledUp[10]){
       p.skillMenu = 15;
       p.frames.setConfig(p, 965, 15);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 120);
      }
            break;
        case 144: //Cooking
      if(!p.leveledUp[7]){
       p.skillMenu = 16;
       p.frames.setConfig(p, 965, 16);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 641);
      }
            break;
        case 145: //Firemaking
      if(!p.leveledUp[11]){
       p.skillMenu = 17;
       p.frames.setConfig(p, 965, 17);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 649);
      }
            break;
        case 146: //Woodcutting
      if(!p.leveledUp[8]){
       p.skillMenu = 18;
       p.frames.setConfig(p, 965, 18);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 660);
      }
            break;
        case 147: //Farming
      if(!p.leveledUp[19]){
       p.skillMenu = 21;
       p.frames.setConfig(p, 965, 21);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 681);
      }
            break;
        case 148: //Summoning
      if(!p.leveledUp[23]){
       p.skillMenu = 24;
       p.frames.setConfig(p, 965, 24);
      } else {
       lvlup = true;
       p.frames.setConfig(p, 1230, 705);
      }
            break;
    }
    if(!lvlup){
     p.frames.showInterface(p, 499);
    } else {
     p.frames.showInterface(p, 741);
    }
    lvlup = false;
    for(int i = 0; i < 24; i++)
     p.leveledUp[i] = false;
    break;
    
   case 499: // Skill Information.
    switch(buttonId) {
     case 10:
                  p.frames.setConfig(p, 965, p.skillMenu);
      break;
              case 11:
                  p.frames.setConfig(p, 965, 1024 + p.skillMenu);
               break;
              case 12:
                  p.frames.setConfig(p, 965, 2048 + p.skillMenu);
      break;
              case 13:
                  p.frames.setConfig(p, 965, 3072 + p.skillMenu);
      break;
              case 14:
                  p.frames.setConfig(p, 965, 4096 + p.skillMenu);
      break;
              case 15:
                  p.frames.setConfig(p, 965, 5120 + p.skillMenu);
      break;
              case 16:
                  p.frames.setConfig(p, 965, 6144 + p.skillMenu);
      break;
              case 17:
                  p.frames.setConfig(p, 965, 7168 + p.skillMenu);
      break;
              case 18:
                  p.frames.setConfig(p, 965, 8192 + p.skillMenu);
      break;
              case 19:
                  p.frames.setConfig(p, 965, 9216 + p.skillMenu);
      break;
              case 20:
                  p.frames.setConfig(p, 965, 10240 + p.skillMenu);
      break;
              case 21:
                  p.frames.setConfig(p, 965, 11264 + p.skillMenu);
      break;
              case 22:
                  p.frames.setConfig(p, 965, 12288 + p.skillMenu);
      break;
              case 23:
                  p.frames.setConfig(p, 965, 13312 + p.skillMenu);
      break;
     default:
               break;
    }
    break;
Note: Credit to Danno for the 503 skill menu's.
Now go into PacketHandler.java in palidino76/rs2/io and search for;
Code:
        case 108:
            /*
             * Remove open window interfaces.
             */
            p.frames.removeShownInterface(p);
            break;
Now open Frames.java and find;
Code:
    /**
     * Display an interface on the chatbox.
     * @param p The Player which the frame should be created for.
     * @param childId The interface to display on the chatbox.
     */
    public void showChatboxInterface(Player p, int childId) {
        setTab(p, 68, childId);
        p.chatboxInterfaceId = childId;
    }
    /**
     * Set the chatbox back removing any interfaces on it.
     * @param p The Player which the frame should be created for.
     */
    public void removeChatboxInterface(Player p) {
        setTab(p, 68, 752);
        p.chatboxInterfaceId = -1;
    }
Now Replace the above with;
Code:
    /**
     * Display an interface on the chatbox.
     * @param p The Player which the frame should be created for.
     * @param childId The interface to display on the chatbox.
     */
    public void showChatboxInterface(Player p, int childId) {
        setInterface(p, 1, 752, 8, childId);
        p.chatboxInterfaceId = childId;
    }
    /**
     * Set the chatbox back removing any interfaces on it.
     * @param p The Player which the frame should be created for.
     */
    public void removeChatboxInterface(Player p) {
        setInterface(p, 1, 752, 8, 137);
        p.chatboxInterfaceId = -1;
    }
Replace the above with this;
Code:
        case 108:
            /*
             * Remove open window interfaces.
             */
   if(p.interfaceId == 741) {
    p.frames.setConfig(p, 1179, 0);
    p.leveledUpSkill = -1;
   }
            p.frames.removeShownInterface(p);
            break;
  case 63:
      /*
             * Remove open window interfaces.
             */
   if(p.chatboxInterfaceId == 740) {
    p.frames.setConfig(p, 1179, Misc.getFlashingIcon(p.leveledUpSkill));
   }
   p.frames.removeChatboxInterface(p);
   break;
Note: Edits made to packet 108 are just so when you close interface 741 it stops the flashing skill icon.
Note: Packet 63 basicaly adds the 'click here to continue' button on chatbox interfaces to remove an set interface, unless its Index is 740 then it will set the flashing icon.
Now, go into palidino76/rs2/players/ Player.java and add these variables.
Code:
 /**
     * Set leveled up
     */
 public boolean[] leveledUp = new boolean[24];
 public int leveledUpSkill = 0;
 public int skillMenu = 0;
Also you will need to add this import;
Code:
import palidino76.rs2.content.*;
Also if you DONT or DO have a 'addSkillXP' Method, Add/Replace it with this one.
Code:
    /**
     * Add experiance to a specific skill.
     * @param amount The amoubt of XP you want to add.
     * @param skill The skill id you want to add it to.
     */
 public void addSkillXP(double amount, int skill) {
        if(skill > skillXP.length || skill < 0) {
            return;
        }
        int oldLevel = getLevelForXP(skill);
        skillXP[skill] += amount;
        int newLevel = getLevelForXP(skill);
        if(oldLevel < newLevel) {
            if(skill == 3) {
                updateHP(newLevel - oldLevel, true);
            } else {
                skillLvl[skill] += (newLevel - oldLevel);
            }
   frames.setSkillLvl(this, skill);
   Levelup levelup = new Levelup(this, skill);
            appearanceUpdateReq = true;
            updateReq = true;
   levelup = null;
        }
        frames.setSkillLvl(this, skill);
    }

Note: Below is a misc 'addxp' command i used to test this.
Code:
[I]
                if(cmd[0].equals("addxp")) {
                    p.addSkillXP((double)Integer.parseInt(cmd[2]), Integer.parseInt(cmd[1]));
                }
[/I]
I Think that about covers everything.
NOTE: Here is Both setConfigs, credit to Danno for releasing on us :)
Code:
    /**
     * Setting client configs.
     * <p>This is used for setting prayers, running, etc.
     * @param p The Player which the frame should be created for.
     * @param id The config id to set.
     * @param set What to set the config.
     */
    public void setConfig(Player p, int id, int set) 
    {
        if (p == null || p.stream == null || p.disconnected[0]) 
 {
            return;
        }
 if(set < 128)
     setConfig1(p, id, set);
 else
     setConfig2(p, id, set);
    }
    public void setConfig1(Player p, int id, int set) 
    {
 p.stream.createFrame(100);
        p.stream.writeWordA(id);
        p.stream.writeByteA(set);
    }
    public void setConfig2(Player p, int id, int set) 
    {
 p.stream.createFrame(161);
        p.stream.writeWord(id);
        p.stream.writeDWord_v1(set);
    }
 
Last edited by a moderator:
Newbie Spellweaver
Joined
Feb 5, 2008
Messages
81
Reaction score
0
Re: [508] Leveling up

You've never wasted time; first post. ;p

Good to have someone like you is very helpful.
 
Junior Spellweaver
Joined
Jan 6, 2009
Messages
136
Reaction score
0
Re: [Tut - 508] Leveling up

i just got a question.. how many workin skills does palidino76's starting source have?

nice tut btw...
 
Last edited:
Newbie Spellweaver
Joined
Oct 28, 2004
Messages
5
Reaction score
0
what is the gfx for the requestgfx public? i guess the forum just understando that was a bad word...
 
Junior Spellweaver
Joined
Nov 18, 2007
Messages
173
Reaction score
5
There's a mayor bug in the public void which calls level up:

Code:
	  p.frames.setConfig(p, 1179, Misc.getSkillIcon(skillID));

needs to be replaced by:

Code:
	  p.frames.setConfig(p, 965, Misc.getSkillIcon(skillID));
	  p.frames.setConfig(p, 1179, Misc.getFlashingIcon(p.leveledUpSkill));

Or the skillIcon won't show and it will annoyingly randomly flash icons.

---------- Post added at 02:36 PM ---------- Previous post was at 01:54 PM ----------

There's a mayor bug in the public void which calls level up:

Code:
	  p.frames.setConfig(p, 1179, Misc.getSkillIcon(skillID));

needs to be replaced by:

Code:
	  p.frames.setConfig(p, 965, Misc.getSkillIcon(skillID));
	  p.frames.setConfig(p, 1179, Misc.getFlashingIcon(p.leveledUpSkill));

Or the skillIcon won't show and it will annoyingly randomly flash icons.
 
Back
Top