Thread: [ANY] Crowns/Icons on minimap (Used Ruse)

Results 1 to 6 of 6
  1. #1 [ANY] Crowns/Icons on minimap (Used Ruse) 
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    Hi there,

    I've seen many people struggle having this to work with their client, although the concept sounds complex to some people (which it is not)
    perhaps because they're lazy or just couldn't think of a way of doing it.

    Pretty much that colored dots that you see on the minimap are a sprite, from there you could simply have a boolean that detects whether the player is ranked (so there is an icon to display)
    and then determine that sprite by their player rights and that will be the crown shows on the minimap (usually, the icons/crowns are defined as modIcons, it is an array of sprites contain all the crowns/icons,
    the array numberos is organized by player rights, so modIcons[1] would be Moderator in this case, you could simply use playerRights to define the icon as long as the ordinal number of the playerRights id is the same as the icon/crown.

    * (usually) modIcons is the array of sprites that holds the Icon / Crowns (I refer this as Icons/Crowns)

    This explanation was simply to set people's mind of how doing it so they could use it on their client's base, but yet again, it's something simple.

    So for Ruse as far as you haven't modificated your player rights order it should be the same, anyhow, I made it to display the player icon as long as their player rights are above 0, you could
    make it only show for staff by setting their player rights tho.


    @Class MapArea.java ->

    @method
    Code:
    	protected void render(Client client, ScreenMode screenMode)
    @above
    Code:
    					boolean isInTeam = false;
    @add
    Code:
    					boolean isModIcon = (Configuration.crownsMinimap && player.playerRights > 0);
    @replace
    Code:
    if (isInFriends) {
    						client.markMinimap(client.mapDotFriend, x, y);
    					} else if (isInClan) {
    						client.markMinimap(client.mapDotClan, x, y);
    					} else if (isInTeam) {
    						client.markMinimap(client.mapDotTeam, x, y);
    					} else {
    						client.markMinimap(client.mapDotPlayer, x, y);
    					}
    @with
    Code:
    				if (isModIcon) {
    						client.markMinimap(client.modIcons[player.playerRights -1], x, y);
    					} else if (isInFriends) {
    						client.markMinimap(client.mapDotFriend, x, y);
    					} else if (isInClan) {
    						client.markMinimap(client.mapDotClan, x, y);
    					} else if (isInTeam) {
    						client.markMinimap(client.mapDotTeam, x, y);
    					} else {
    						client.markMinimap(client.mapDotPlayer, x, y);
    					}


    Thanks & rep would be appreciated if you find this useful or use it
    Reply With Quote  
     

  2. #2  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    I did this years ago, to correct this.

    Code:
    playerRights
    If for say you wanted to display a crown based on the rights of players around you; the client has no idea what the rights are of those players.

    The only times it knows the rights of those players is when a player talks in chat. All other times the client only references the players rights (e.g private chat). You can see in the code below the server encodes the players rights after a user typed in chat, the rights are appended to the player updating via the chat mask which then the player updating gets sent to the client the client updates it then.
    Code:
    /**
     * The [PlayerUpdateBlock] implementation encodes the [Player] chat mask.
     *
     * @author Seven
     */
    class PlayerChatUpdateBlock : PlayerUpdateBlock(0x80, UpdateFlag.CHAT) {
    
        override fun encode(player: Player, builder: GamePacketBuilder) {
            val msg = player.chatMessage
            val bytes = msg.text
    
            builder.writeShort((msg.color and 0xFF shl 8) + (msg.effect and 0xFF), ByteOrder.LITTLE)
    		.write(player.rights.protocolValue)
    		.write(bytes!!.size, ByteModification.NEGATION)
    		.writeBytesReverse(bytes)
        }
    
    }
    Here you can see the client actually assigns the rights after the chat mask has been received.
    Code:
                if ((mask & 0x80) != 0) {
                      int textInfo = buffer.readLEUShort();
                      int privilege = buffer.readUnsignedByte();
                      int offset = buffer.readNegUByte();
                      int off = buffer.currentPosition;
                      if (player.name != null && player.visible) {
                            long name = StringUtils.encodeBase37(player.name);
                            boolean ignored = false;
                            if (privilege <= 1) {
                                  for (int count = 0; count < ignoreCount; count++) {
                                        if (ignoreListAsLongs[count] != name)
                                              continue;
                                        ignored = true;
                                        break;
                                  }
    
                            }
                            if (!ignored && onTutorialIsland == 0)
                                  try {
                                        chatBuffer.currentPosition = 0;
                                        buffer.readReverseData(chatBuffer.payload, offset, 0);
                                        chatBuffer.currentPosition = 0;
                                        String text = ChatMessageCodec.decode(offset, chatBuffer);
                                        player.spokenText = text;
                                        player.textColour = textInfo >> 8;
                                        player.privelage = privilege;
                                        player.textEffect = textInfo & 0xff;
                                        player.textCycle = 150;
                                        if (privilege == 2 || privilege == 3) {
                                              displayChatMessage(text, 1, "@cr2@" + player.name);                                          
                                        } else if (privilege == 1) {
                                              displayChatMessage(text, 1, "@cr1@" + player.name);
                                        } else {
                                              displayChatMessage(text, 2, player.name);
                                        }
                                  } catch (Exception exception) {
                                        SignLink.reporterror("cde2");
                                  }
                      }
                      buffer.currentPosition = off + offset;
                }
    To show you the private message rights reference. Server encodes the message.

    Code:
    class SendPrivateMessageOutgoingPacket(private val name: Long, private val rights: PlayerRights, private val message: ByteArray, private val messageLength: Int) : OutgoingPacket(196, PacketHeader.VARIABLE_BYTE) {
    
        override fun writePacket(player: Player): GamePacketBuilder {
            builder.writeLong(name)
    		.writeInt(player.lastMessage++)
    		.write(rights.protocolValue)
    		.writeBytes(message, messageLength)
            return builder
        }
    
    }
    Here you can see the client decodes this packet, the rights doesn't even get assigned it's only referenced.
    Code:
                      if (opcode == PacketConstants.SEND_RECEIVED_PRIVATE_MESSAGE) {
                            long encodedName = incoming.readLong();
                            int messageId = incoming.readInt();
                            int rights = incoming.readUnsignedByte();
                            boolean ignoreRequest = false;
                            for (int index = 0; index < 100; index++) {
                                  if (privateMessageIds[index] != messageId) {
                                        continue;
                                  }
                                  ignoreRequest = true;
    
                            }
                            if (rights <= 1) {
                                  for (int index = 0; index < ignoreCount; index++) {
                                        if (ignoreListAsLongs[index] != encodedName) {
                                              continue;
                                        }
                                        ignoreRequest = true;
    
                                  }
                            }
                            if (!ignoreRequest && onTutorialIsland == 0)
                                  try {
                                        privateMessageIds[privateMessageCount] = messageId;
                                        privateMessageCount = (privateMessageCount + 1) % 100;
                                        String message = ChatMessageCodec.decode(packetSize - 13, incoming);
    
                                        if (rights == 2 || rights == 3) {
                                              pushMessage(message, 7, "@cr2@" + StringUtils.formatUsername(StringUtils.decodeBase37(encodedName)));
                                        } else if (rights == 1) {
                                              pushMessage(message, 7, "@cr1@" + StringUtils.formatUsername(StringUtils.decodeBase37(encodedName)));
                                        } else {
                                              pushMessage(message, 3, StringUtils.formatUsername(StringUtils.decodeBase37(encodedName)));
                                        }
                                  } catch (Exception ex) {
                                        SignLink.reporterror("cde1");
                                  }
                            opcode = -1;
                            return true;
                      }
    Therefore in some cases you may not see the correct sprite on the map for a player. When players are updated via player updating, you can send the rights with player appearance. That is so the client updates the rights when a player is updated. So in some cases for example.. A moderator logged in, then you login you won't see their crown because they haven't talked in chat. Well now when you login you will see their crown right away because when you login your player updating gets all the information about your local players and sends it to the client so now the client will update it.

    Code:
    		combatLevel = stream.readUnsignedByte();
                    // the index of the crown in the array to display
    		crownId= stream.readUnsignedByte();
    		skill = stream.readUShort();
    		visible = true;
    		appearanceHash = 0L;
    Which means now in the server you will have to write this variable right below combatLevel in the player appearance.

    Code:
    crownId
    Attached image
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    Quote Originally Posted by Seven View Post
    I did this years ago, to correct this.

    Code:
    playerRights
    If for say you wanted to display a crown based on the rights of players around you; the client has no idea what the rights are of those players.

    The only times it knows the rights of those players is when a player talks in chat. All other times the client only references the players rights (e.g private chat). You can see in the code below the server encodes the players rights after a user typed in chat, the rights are appended to the player updating via the chat mask which then the player updating gets sent to the client the client updates it then.
    Code:
    /**
     * The [PlayerUpdateBlock] implementation encodes the [Player] chat mask.
     *
     * @author Seven
     */
    class PlayerChatUpdateBlock : PlayerUpdateBlock(0x80, UpdateFlag.CHAT) {
    
        override fun encode(player: Player, builder: GamePacketBuilder) {
            val msg = player.chatMessage
            val bytes = msg.text
    
            builder.writeShort((msg.color and 0xFF shl 8) + (msg.effect and 0xFF), ByteOrder.LITTLE)
    		.write(player.rights.protocolValue)
    		.write(bytes!!.size, ByteModification.NEGATION)
    		.writeBytesReverse(bytes)
        }
    
    }
    Here you can see the client actually assigns the rights after the chat mask has been received.
    Code:
                if ((mask & 0x80) != 0) {
                      int textInfo = buffer.readLEUShort();
                      int privilege = buffer.readUnsignedByte();
                      int offset = buffer.readNegUByte();
                      int off = buffer.currentPosition;
                      if (player.name != null && player.visible) {
                            long name = StringUtils.encodeBase37(player.name);
                            boolean ignored = false;
                            if (privilege <= 1) {
                                  for (int count = 0; count < ignoreCount; count++) {
                                        if (ignoreListAsLongs[count] != name)
                                              continue;
                                        ignored = true;
                                        break;
                                  }
    
                            }
                            if (!ignored && onTutorialIsland == 0)
                                  try {
                                        chatBuffer.currentPosition = 0;
                                        buffer.readReverseData(chatBuffer.payload, offset, 0);
                                        chatBuffer.currentPosition = 0;
                                        String text = ChatMessageCodec.decode(offset, chatBuffer);
                                        player.spokenText = text;
                                        player.textColour = textInfo >> 8;
                                        player.privelage = privilege;
                                        player.textEffect = textInfo & 0xff;
                                        player.textCycle = 150;
                                        if (privilege == 2 || privilege == 3) {
                                              displayChatMessage(text, 1, "@cr2@" + player.name);                                          
                                        } else if (privilege == 1) {
                                              displayChatMessage(text, 1, "@cr1@" + player.name);
                                        } else {
                                              displayChatMessage(text, 2, player.name);
                                        }
                                  } catch (Exception exception) {
                                        SignLink.reporterror("cde2");
                                  }
                      }
                      buffer.currentPosition = off + offset;
                }
    To show you the private message rights reference. Server encodes the message.

    Code:
    class SendPrivateMessageOutgoingPacket(private val name: Long, private val rights: PlayerRights, private val message: ByteArray, private val messageLength: Int) : OutgoingPacket(196, PacketHeader.VARIABLE_BYTE) {
    
        override fun writePacket(player: Player): GamePacketBuilder {
            builder.writeLong(name)
    		.writeInt(player.lastMessage++)
    		.write(rights.protocolValue)
    		.writeBytes(message, messageLength)
            return builder
        }
    
    }
    Here you can see the client decodes this packet, the rights doesn't even get assigned it's only referenced.
    Code:
                      if (opcode == PacketConstants.SEND_RECEIVED_PRIVATE_MESSAGE) {
                            long encodedName = incoming.readLong();
                            int messageId = incoming.readInt();
                            int rights = incoming.readUnsignedByte();
                            boolean ignoreRequest = false;
                            for (int index = 0; index < 100; index++) {
                                  if (privateMessageIds[index] != messageId) {
                                        continue;
                                  }
                                  ignoreRequest = true;
    
                            }
                            if (rights <= 1) {
                                  for (int index = 0; index < ignoreCount; index++) {
                                        if (ignoreListAsLongs[index] != encodedName) {
                                              continue;
                                        }
                                        ignoreRequest = true;
    
                                  }
                            }
                            if (!ignoreRequest && onTutorialIsland == 0)
                                  try {
                                        privateMessageIds[privateMessageCount] = messageId;
                                        privateMessageCount = (privateMessageCount + 1) % 100;
                                        String message = ChatMessageCodec.decode(packetSize - 13, incoming);
    
                                        if (rights == 2 || rights == 3) {
                                              pushMessage(message, 7, "@cr2@" + StringUtils.formatUsername(StringUtils.decodeBase37(encodedName)));
                                        } else if (rights == 1) {
                                              pushMessage(message, 7, "@cr1@" + StringUtils.formatUsername(StringUtils.decodeBase37(encodedName)));
                                        } else {
                                              pushMessage(message, 3, StringUtils.formatUsername(StringUtils.decodeBase37(encodedName)));
                                        }
                                  } catch (Exception ex) {
                                        SignLink.reporterror("cde1");
                                  }
                            opcode = -1;
                            return true;
                      }
    Therefore in some cases you may not see the correct sprite on the map for a player. When players are updated via player updating, you can send the rights with player appearance. That is so the client updates the rights when a player is updated. So in some cases for example.. A moderator logged in, then you login you won't see their crown because they haven't talked in chat. Well now when you login you will see their crown right away because when you login your player updating gets all the information about your local players and sends it to the client so now the client will update it.

    Code:
    		combatLevel = stream.readUnsignedByte();
                    // the index of the crown in the array to display
    		crownId= stream.readUnsignedByte();
    		skill = stream.readUShort();
    		visible = true;
    		appearanceHash = 0L;
    Which means now in the server you will have to write this variable right below combatLevel in the player appearance.

    Code:
    crownId
    It does.

    'player' is definded as the other player on the minimap, simply just the same way as it detects the entity as a clan-member and gives it the purple dot then you use
    the same entity to trace its playerRights
    Reply With Quote  
     

  5. #4  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    Quote Originally Posted by Tyrant View Post
    It does.

    'player' is definded as the other player on the minimap, simply just the same way as it detects the entity as a clan-member and gives it the purple dot then you use
    the same entity to trace its playerRights
    I don't think you understand what my whole post was explaining. The point is, if you try to assign crowns based on some other players rights it won't work correctly because the rights is only updated when that players talks in chat. To make it work properly you have to add the rights to player appearance so the rights is updated right away.

    you can simply debug this by logging in player 1 (who has a crown) log player 2 in (player 2 can't see player 1's crown on minimap) player 1 talks (now player 2 can see the crown)

    Quote Originally Posted by Tyrant View Post
    'player' is definded as the other player on the minimap
    'player' is the player in your local player list. (what you call the other player on the minimap)

    Quote Originally Posted by Tyrant View Post
    simply just the same way as it detects the entity as a clan-member and gives it the purple dot
    purple dot has nothing to do with a players rights, it's not the same way.

    flag that denotes this local player is a clan member (referencing 'name' from the local player)
    Code:
                            boolean clanMember = false;
                            for (int clan = 0; clan < clanList.length; clan++) {
                                  if (clanList[clan] == null) {
                                        continue;
                                  }
                                  if (!clanList[clan].equalsIgnoreCase(player.name)) {
                                        continue;
                                  }
                                  clanMember = true;
                                  break;
                            }
    flag that denotes friend (green dot) (referencing 'name' from the local player)

    Code:
                            long nameHash = StringUtils.encodeBase37(player.name);
                            for (int f = 0; f < friendsCount; f++) {
                                  if (nameHash != friendsListAsLongs[f] || friendsNodeIDs[f] == 0) {
                                        continue;
                                  }
                                  friend = true;
                                  break;
                            }
    flag that denotes team (referencing variable 'team' from the local player)

    Code:
                            boolean team = false;
                            if (localPlayer.team != 0 && player.team != 0
                                        && localPlayer.team == player.team) {
                                  team = true;
                            }
    Attached image
    Reply With Quote  
     

  6. #5  
    Software Developer

    Tyrant's Avatar
    Join Date
    Jul 2013
    Age
    24
    Posts
    1,562
    Thanks given
    678
    Thanks received
    423
    Rep Power
    1060
    Quote Originally Posted by Seven View Post
    I don't think you understand what my whole post was explaining. The point is, if you try to assign crowns based on some other players rights it won't work correctly because the rights is only updated when that players talks in chat. To make it work properly you have to add the rights to player appearance so the rights is updated right away.

    you can simply debug this by logging in player 1 (who has a crown) log player 2 in (player 2 can't see player 1's crown on minimap) player 1 talks (now player 2 can see the crown)



    'player' is the player in your local player list. (what you call the other player on the minimap)



    purple dot has nothing to do with a players rights, it's not the same way.

    flag that denotes this local player is a clan member (referencing 'name' from the local player)
    Code:
                            boolean clanMember = false;
                            for (int clan = 0; clan < clanList.length; clan++) {
                                  if (clanList[clan] == null) {
                                        continue;
                                  }
                                  if (!clanList[clan].equalsIgnoreCase(player.name)) {
                                        continue;
                                  }
                                  clanMember = true;
                                  break;
                            }
    flag that denotes friend (green dot) (referencing 'name' from the local player)

    Code:
                            long nameHash = StringUtils.encodeBase37(player.name);
                            for (int f = 0; f < friendsCount; f++) {
                                  if (nameHash != friendsListAsLongs[f] || friendsNodeIDs[f] == 0) {
                                        continue;
                                  }
                                  friend = true;
                                  break;
                            }
    flag that denotes team (referencing variable 'team' from the local player)

    Code:
                            boolean team = false;
                            if (localPlayer.team != 0 && player.team != 0
                                        && localPlayer.team == player.team) {
                                  team = true;
                            }
    Mhm right, I didn't test it honestly I was literally helping a friend and decided to release it out,
    didn't know it does not update instantly
    Reply With Quote  
     

  7. #6  
    Ex Rune-Scaper

    Join Date
    Jun 2008
    Posts
    3,534
    Thanks given
    457
    Thanks received
    1,257
    Rep Power
    990
    Here's an extremely old tutorial.

    https://www.rune-server.org/runescap...-finder-2.html

    Galkon did it the same way I did.

    Quote Originally Posted by Tyrant View Post
    Mhm right, I didn't test it honestly I was literally helping a friend and decided to release it out,
    didn't know it does not update instantly
    Yeah trust me I've done this multiple times. haha

    This is exactly what you have.
    https://www.rune-server.org/runescap...s-minimap.html



    but what I didn't realize was what the other client couldn't see.
    Attached image
    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. Most Bank Coords, Perfected(Can be used for PVP)
    By George in forum Configuration
    Replies: 21
    Last Post: 04-11-2013, 08:33 PM
  2. Replies: 11
    Last Post: 12-07-2011, 10:35 PM
  3. Hyperion Trading ~ 474 can be used for 317
    By Vastiko in forum Snippets
    Replies: 28
    Last Post: 02-17-2011, 02:22 AM
  4. Replies: 2
    Last Post: 07-25-2009, 04:31 PM
  5. Rewards System, can be used for anything
    By Ultimate in forum Tutorials
    Replies: 3
    Last Post: 07-22-2008, 02:45 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
  •