|
I was doing some stuff with my Elvarg source (started a new one, old one was messed up bad). I wanted game sounds and they didnt work so here is the fixed packet. This will work for any 317, make ajustments where needed.
Place this in PacketSender (or wherever you send your packets from)
If you want a neat class to handle it with copy this and add whereever.Code:public PacketSender sendSound(int id, int delay, int volume) { PacketBuilder out = new PacketBuilder(174); out.putShort(id); out.putShort(delay); out.putShort(volume); player.getSession().write(out); return this; }
Some sounds can be found here https://www.rune-server.ee/runescape...sound-ids.htmlCode:public class Sound { public Sound(int id){ this(id,0,10); } public Sound(int id, int delay, int vol) { this.id = id; this.delay = delay; this.vol = vol; } public static Sound create(Player plr,int id) { return create(plr,id,0,10); } public static Sound create(Player plr,int id, int delay, int vol) { this.plr = plr; return new Sound(id,delay,vol); } public Sound send() { if (plr != null) { plr.getPacketSender().sendSound(id,delay,vol); } return this; } }
A sound system can be found here https://www.rune-server.ee/runescape...nds-music.html
As Harrison already pointed out, it won't compile.
All the variables you're trying to define here, starting with 'this.' do not exist. They're nowhere to be found inside the Sound class. Also, the create method is currently problematic due to the Player field being static.
You should keep it simple, I'll give you an example:
& in packet sender...Code:public final class Sound { private final int id, delay, vol; public Sound(int id){ this(id, 0, 10); } public Sound(int id, int delay){ this(id, delay, 10); } public Sound(int id, int delay, int vol) { this.id = id; this.delay = delay; this.vol = vol; } public int getId() { return id; } public int getDelay() { return delay; } public int getVolume() { return vol; } }
Code:public PacketSender sendSound(Sound sound) { PacketBuilder out = new PacketBuilder(174); out.putShort(sound.getId()); out.putShort(sound.getDelay()); out.putShort(sound.getVolume()); player.getSession().write(out); return this; }
To send a sound, you'd simply use the following line: player.getPacketSender().sendSound(new Sound(id, delay, vol));
Ah thanks. Quickly made it in the text box here. Thanks these issues have been resolved
Why do we need to call the player object?Code:public PacketSender sendSound(Player player,int id, int delay, int volume) { PacketBuilder out = new PacketBuilder(174); out.putShort(id); out.putShort(delay); out.putShort(volume); player.getSession().write(out); return this; }
Don't you have to call player before entering the packet handler?
i.e - player.getPacketSender().sendSound(delay, volume);
You don't need the player param, the PacketSender already holds the player.Code:public PacketSender sendSound(int id, int delay, int volume) { PacketBuilder out = new PacketBuilder(174); out.putShort(id); out.putShort(delay); out.putShort(volume); player.getSession().write(out); return this; }
Also not worth making a class to hold data which you can simply pass to the method lol.
Thanks though, nice contribution. Didn't know that the packet was broken.
Take a look at my old sound system release if you're adding sounds, it may be helpful
Nice release, thanks for this.
« Previous Thread | Next Thread » |
Thread Information |
Users Browsing this ThreadThere are currently 1 users browsing this thread. (0 members and 1 guests) |