Author Topic: Mod Icons above head, ANY BASE  (Read 133 times)

Offline Wet Dreams

  • Administrator
  • Member
  • *****
  • Posts: 52
  • Rep +65535/-0
  • Sup
    • View Profile
Mod Icons above head, ANY BASE
« on: January 24, 2012, 09:15:06 pm »
Player class (client sided): Declare this with the others at the bottom of the class:
Code: [Select]
public int modHeadIcon;
then still in Player.java, find
Code: [Select]
public void updatePlayer(
right underneath that there should be
Code: [Select]
headIcon = stream.readByte();
skullIcon = stream.readByte();

add underneath them:
Code: [Select]
modHeadIcon = stream.readByte();
Save and close your Player.java.
Then go to your client class find:
Code: [Select]
void updateEntitiesscroll down abit until you find:
Code: [Select]
int l = 30;
Player player = (Player) obj;
if (player.headIcon >= 0 || player.skullIcon >= 0)

change the:
Code: [Select]
if (player.headIcon >= 0 || player.skullIcon >= 0)
to:
Code: [Select]
if (player.headIcon >= 0 || player.skullIcon >= 0 || player.modHeadIcon >= 0)
Then in the same place, at:
Code: [Select]
if (player.headIcon < 7 && player.headIcon != -1) {
headIcons[player.headIcon].drawSprite(
spriteDrawX - 12, spriteDrawY - l);
l += 18;
}
under it add:
Code: [Select]
if (player.modHeadIcon < 6 && player.modHeadIcon != -1) {
modIcons[player.modHeadIcon].drawSprite(spriteDrawX - 8, spriteDrawY - l);
l += 18;
}

For people who get this error:
Code: [Select]
client.java:1730: cannot find symbol
symbol : method drawSprite(int,int)
location: class Background
modIcons[player.
modHeadIcon].drawSprite(spriteDrawX - 12, spriteDrawY - l);

^
Note: client.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
Tryck ned valfri tangent f?r att forts?tta...

Use this code:
Code: [Select]
if (player.modHeadIcon < 6 && player.modHeadIcon != -1) {
modIcons[player.modHeadIcon].drawBackground(spriteDrawX - 8, spriteDrawY - l);
l += 18;
}

Now were done client sided. Lets move to server.


Go to your Player class (server sided!) find:
Code: [Select]
void appendPlayerAppearance(
there will be
Code: [Select]
playerProps.writeByte(headIcon);
playerProps.writeByte(skullIcon);
add underneath:
Code: [Select]
playerProps.wriiteByte(modHeadIcon);It might not be the same, it looks this for shard though, just copy the others but with
Code: [Select]
modHeadIconAlse:
Code: [Select]
public int modHeadIcon = -1;
with the others, in the playerclass
Then head into your client class(server sided!) Go to your initialize method and add:
Code: [Select]
switch(getPrivileges()) {
case 3:
modHeadIcon = 2;
break;
case 2:
modHeadIcon = 1;
break;
case 1:
modHeadIcon = 0;
break;
}

If you're using pi:

Code: [Select]
switch(c.playerRights) {
case 3:
modHeadIcon = 2;
break;
case 2:
modHeadIcon = 1;
break;
case 1:
modHeadIcon = 0;
break;
}

Wallah. we're done.

Share on Bluesky Share on Facebook


Offline Neroxx

  • Global Moderator
  • Senior Member
  • *****
  • Posts: 136
  • Rep +202/-1
  • Live your life, code what you want.
  • Location: Norway
    • View Profile
Re: Mod Icons above head, ANY BASE
« Reply #1 on: January 25, 2012, 05:47:40 am »
This could be useful for PI'coders :) Good job ;)

Offline magicana89

  • Senior Member
  • ****
  • Posts: 105
  • Rep +4/-0
  • Xtracode's Master Poster
    • View Profile
Re: Mod Icons above head, ANY BASE
« Reply #2 on: January 25, 2012, 08:21:42 am »
hmm nice useful if a busy server but a good pickup might user later on:D