Thread: Better way of custom mod icons

Results 1 to 10 of 10
  1. #1 Better way of custom mod icons 
    Registered Member
    Kamiel's Avatar
    Join Date
    Jul 2010
    Age
    28
    Posts
    1,272
    Thanks given
    66
    Thanks received
    166
    Rep Power
    295
    After doing this tutorial, you will be able to easily add more crowns/icons without the need of editing a lot of client code.
    This also removes a lot of code in your client.

    I made this quite a long time ago, so if there's anything wrong, please post so I can change the code and fix it. I want this to be working correctly for everyone

    First add these in Client.java:
    Code:
    	public Sprite getIcon(int rights)
    	{
    		if (rights > 0)
    			return modIcons[rights - 1];
    
    		return null;
    	}
    	
    	public String getNameWithoutRights(String text)
    	{
    		if (text.length() > 0)
    			return text.substring(6);
    		
    		return text;
    	}
    	
    	public String getIconCode(int rights)
    	{
    		switch (rights)
    		{
    		case 1:
    			return "@mod1@";
    			
    		case 2:
    			return "@mod2@";
    			
    		case 3:
    			return "@adm1@";
    			
    		default:
    			return "";
    		}
    	}
    	
    	public byte getPlayerRights(String s)
    	{
    		if (s == null)
    			return 0;
    		
    		if (s.startsWith("@mod1@"))
    			return 1;
    		
    		if (s.startsWith("@mod2@"))
    			return 2;
    		
    		if (s.startsWith("@adm1@"))
    			return 3;
    		
    		return 0;
    	}
    Search "String s1 = chatNames[k];" and replace something like this:
    Code:
    byte playerRights = getPlayerRights(s1);
    f (s1 != null && s1.startsWith("@cr1@")) {
    	s1 = s1.substring(5);
    	playerRights = 1;
    } else if (s1 != null && s1.startsWith("@cr2@")) {
    	s1 = s1.substring(5);
    	playerRights = 2;
    }
    with this:
    Code:
    byte playerRights = getPlayerRights(s1);
    if(playerRights > 0)
    	s1 = s1.substring(6);
    Now search for, it's a little bit down, "(chatType == 1 || chatType == 2)" or "(l == 1 || l == 2)" and replace the whole part with "modIcons[#].drawSprite" (all of those)
    Spoiler for looks something like this:
    Code:
                                if (byte0 == 1) {
                                    modIcons[0].drawBackground(xPos, yPos - 12);
                                    xPos += 14;
                                }
                                if (byte0 == 2) {
                                    modIcons[1].drawBackground(xPos, yPos - 12);
                                    xPos += 14;
                                }

    with this:

    Code:
    	Sprite icon = getIcon(playerRights);
    	if(icon != null)
    	{
    		icon.drawSprite(xPos + 1, yPos - 12);
    		xPos += 14;
    	}
    Scroll a bit down to "(chatType == 3 || chatType == 7)" or "(l == 3 || l == 7)" and replace the same modIcons stuff with this:
    Code:
    	Sprite icon = getIcon(playerRights);
    	if (icon != null)
    	{
    		icon.drawSprite(xPos + 1, yPos - 12);
    		xPos += 14;
    	}
    Now search "(publicChatMode == 2)" and above there you'll see something like
    Code:
    if (myPrivilege == 2)
    		pushMessage(myPlayer.textSpoken, 2, "@cr2@" + myPlayer.name);
    	else if (myPrivilege == 1)
    		pushMessage(myPlayer.textSpoken, 2, "@cr1@" + myPlayer.name);
    	else
    		pushMessage(myPlayer.textSpoken, 2, myPlayer.name);
    Replace all that with this:
    Code:
    pushMessage(myPlayer.textSpoken, 2, getIconCode(myPrivilege) + myPlayer.name);
    Search for "pushMessage(s, 2, " in method73 and replace the whole shit
    Spoiler for looks like this:
    Code:
    if (j2 == 2 || j2 == 3)
                                pushMessage(s, 1, "@cr2@" + player.name);
                            else if (j2 == 1)
                                pushMessage(s, 1, "@cr1@" + player.name);
                            else
                                pushMessage(s, 2, player.name);

    with the following:
    Code:
    	if (j2 > 0)
    		pushMessage(s, 1, getIconCode(j2) + player.name);
    	else
    		pushMessage(s, 2, player.name);
    Find "pushMessage(s9, 3, " and again, replace all the pushMessage with:
    Code:
    	if (l21 > 0)
    		pushMessage(s9, 7, getIconCode(l21) + TextClass.fixName(TextClass.nameForLong(l5)));
    	else
    		pushMessage(s9, 3, TextClass.fixName(TextClass.nameForLong(l5)));
    Got to void drawSplitPrivateChat(), replace
    Spoiler for this:
    Code:
                    byte byte1 = 0;
                    if (s != null && s.startsWith("@cr1@")) {
                        s = s.substring(5);
                        byte1 = 1;
                    }
                    if (s != null && s.startsWith("@cr2@")) {
                        s = s.substring(5);
                        byte1 = 2;
                    }

    with
    Code:
    	byte playerRights = getPlayerRights(s);
    	s = getNameWithoutRights(s);
    Still in there, replace
    Code:
                        if (byte1 == 1) {
                            modIcons[0].drawBackground(k1, l - 12);
                            k1 += 14;
                        }
                        if (byte1 == 2) {
                            modIcons[1].drawBackground(k1, l - 12);
                            k1 += 14;
                        }
    with this:
    Code:
    	Sprite icon = getIcon(playerRights);
    	if (icon != null)
    	{
    		icon.drawSprite(k1 + 1, l - 12);
    		k1 += 14;
    	}
    Got to "buildPublicChat" or "buildChatAreaMenu" and replace
    Code:
                flag = false;
                if (s != null && s.startsWith("@cr1@")) {
                    s = s.substring(5);
                    flag1 = true;
                }
                if (s != null && s.startsWith("@cr2@")) {
                    s = s.substring(5);
                    byte0 = 2;
                }
    with:
    Code:
    s = getNameWithoutRights(s);
    do the same at "buildFriendChat" or "buildSplitPrivateChatMenu", and also at "buildDuelorTrade".
    If you can't find it, search for "@cr1@" and everytime you find it, there you need to replace it.

    Compile and run. Test if it works. If not please say what's wrong so I can attempt to fix it (or fix it yourself, I'm NOT gonna help u if there's something like "cannot find s9", look trough your code and fix it urself)

    Look in the post below how to add more crowns.


    CREDITS:
    99% me for the code.
    1% JageX for the client and code we ripped from them.
    Reply With Quote  
     


  2. #2  
    Registered Member
    Kamiel's Avatar
    Join Date
    Jul 2010
    Age
    28
    Posts
    1,272
    Thanks given
    66
    Thanks received
    166
    Rep Power
    295
    Alright, here is how you add more crowns. You must be loading them already, there are a lot of tuts on this so I won't help you with that.

    go to "getIconCode" and add a new case like this:
    Code:
    case 4: //player rights value
    	return "@don1@"; //donor icon 1, replace with what you want
    now go to "getPlayerRights" and create a new part like this:
    Code:
    if (s.startsWith("@don1@")) //donor icon 1, again replace with what you want
    	return 4; //player rights value
    You can change the player rights to what you want. Make sure the returning value and the case value are the same, also the "@....@" must be the same.

    That's all. Easy right? You can add more now, with just adding two little pieces of code to your client!

    NOTE: the "code" betweet the '@' must be 4 characters long, else it'll get fucked up and not work.

    here's a tut where you can find mod icons and how to add them. Do not do the first parts with all the code tho, as that's covered in this tutorial.
    http://www.rune-server.org/runescape...-conventi.html





    If you used this tutorial, leave a post or thanks so that I know people us it. Else I will just remove it again as it is not seen as a useful contribution to this communety.
    Reply With Quote  
     

  3. Thankful users:


  4. #3  
    JavaScript Heathen 👹

    frostbit3's Avatar
    Join Date
    Mar 2012
    Age
    29
    Posts
    404
    Thanks given
    381
    Thanks received
    90
    Rep Power
    78
    This is fucking great, bravo. This will make it so much easier for adding client rankings. Will add later.
    >> real life is pretty much the same as code. off-by-one, naming, and unterminated recursion
    Reply With Quote  
     

  5. #4  
    強い者は生き残る
    Ashpire's Avatar
    Join Date
    Mar 2012
    Age
    27
    Posts
    2,721
    Thanks given
    914
    Thanks received
    1,897
    Rep Power
    2231
    Looking epic.
    Attached image
    Reply With Quote  
     

  6. #5  
    Registered Member
    Sieu's Avatar
    Join Date
    Dec 2011
    Age
    30
    Posts
    1,167
    Thanks given
    186
    Thanks received
    131
    Rep Power
    160
    Code:
    client.java:54: incompatible types
    found   : Background
    required: Sprite
                            return modIcons[rights - 1];
                                           ^
    client.java:293: cannot find symbol
    symbol  : variable playerRights
    location: class client
                                                            Sprite icon = getIcon(pl
    ayerRights);
                                                                                  ^
    client.java:313: cannot find symbol
    symbol  : variable playerRights
    location: class client
                                                            Sprite icon = getIcon(pl
    ayerRights);
                                                                                  ^
    client.java:316: cannot find symbol
    symbol  : variable xPos
    location: class client
                                                                    icon.drawSprite(
    xPos + 1, yPos - 12);
    
    ^
    client.java:316: cannot find symbol
    symbol  : method drawSprite(<nulltype>,int)
    location: class Sprite
                                                                    icon.drawSprite(
    xPos + 1, yPos - 12);
                                                                        ^
    client.java:317: cannot find symbol
    symbol  : variable xPos
    location: class client
                                                                    xPos += 14;
                                                                    ^
    Note: client.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    6 errors
    Press any key to continue . . .
    Reply With Quote  
     

  7. #6  
    Banned

    Join Date
    Jul 2012
    Posts
    130
    Thanks given
    76
    Thanks received
    16
    Rep Power
    0
    I thought you said this was better.
    Reply With Quote  
     

  8. #7  
    Registered Member
    Kamiel's Avatar
    Join Date
    Jul 2010
    Age
    28
    Posts
    1,272
    Thanks given
    66
    Thanks received
    166
    Rep Power
    295
    Quote Originally Posted by MMMM View Post
    Code:
    client.java:54: incompatible types
    found   : Background
    required: Sprite
                            return modIcons[rights - 1];
                                           ^
    client.java:293: cannot find symbol
    symbol  : variable playerRights
    location: class client
                                                            Sprite icon = getIcon(pl
    ayerRights);
                                                                                  ^
    client.java:313: cannot find symbol
    symbol  : variable playerRights
    location: class client
                                                            Sprite icon = getIcon(pl
    ayerRights);
                                                                                  ^
    client.java:316: cannot find symbol
    symbol  : variable xPos
    location: class client
                                                                    icon.drawSprite(
    xPos + 1, yPos - 12);
    
    ^
    client.java:316: cannot find symbol
    symbol  : method drawSprite(<nulltype>,int)
    location: class Sprite
                                                                    icon.drawSprite(
    xPos + 1, yPos - 12);
                                                                        ^
    client.java:317: cannot find symbol
    symbol  : variable xPos
    location: class client
                                                                    xPos += 14;
                                                                    ^
    Note: client.java uses unchecked or unsafe operations.
    Note: Recompile with -Xlint:unchecked for details.
    6 errors
    Press any key to continue . . .
    add this somewhere:
    Code:
    public final Sprite[] modIcons;
    go to "client()" and add:
    Code:
    modIcons = new Sprite[2];
    search for "mapdots" and add this somewhere between there:
    Code:
    for (int count = 0; count < 2; count++)
    	modIcons[count] = new Sprite(streamLoader_2, "mod_icons", count);
    replace all xPos with "j2" and all yPos with "i1". That should fix it.
    Reply With Quote  
     

  9. #8  
    Donator


    Join Date
    Sep 2011
    Posts
    2,730
    Thanks given
    1,150
    Thanks received
    907
    Rep Power
    668
    I'll definitely take a look at this in the future. Looks good, nice release.
    Reply With Quote  
     

  10. #9  
    Registered Member
    thim slug's Avatar
    Join Date
    Nov 2010
    Age
    28
    Posts
    4,132
    Thanks given
    1,077
    Thanks received
    1,137
    Rep Power
    5000
    The @admin@ one wont work since it's 7 characters long and you set the substring at 6.
    Reply With Quote  
     

  11. #10  
    Banned

    Join Date
    Sep 2011
    Age
    27
    Posts
    801
    Thanks given
    511
    Thanks received
    158
    Rep Power
    0
    This is similar to how I did it.
    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. new mod icons
    By Romania Clan in forum Help
    Replies: 1
    Last Post: 06-15-2010, 12:13 PM
  2. custom mod icons not showing up [non]
    By mige5 in forum Help
    Replies: 2
    Last Post: 07-28-2009, 09:10 PM
  3. mod icons
    By Flippy in forum Show-off
    Replies: 4
    Last Post: 05-30-2009, 03:34 AM
  4. How to add Custom Mod/Admin Icons(for those who dont know)
    By newservermaker in forum Tutorials
    Replies: 32
    Last Post: 05-10-2008, 08:09 AM
  5. Replies: 14
    Last Post: 04-05-2008, 05:07 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
  •