Jump to content
  • 0

[Help - Request] On enter play custom sound


Question

Posted

Hi guys could you help me with a java code which will play a custom sound when player logs in but wont reapeat! thanks

6 answers to this question

Recommended Posts

  • 0
Posted

Sounds are client side, not server.

but on enter char u need core side to use this effect, retail l2 client doesnt have it -.-
  • 0
Posted

As following :

benefactor.sendPacket(new PlaySound("package.sound"));

Where "benefactor" is the ppl who receives the sound, "package" is the package where the sound is stored, and "sound" is the name of the sound itself.

 

Then you can apply different rules, such as broadcastPacket (which will send to all ppl in a radius around the player), or even using Broadcast.java methods (to all players online, to all players in X radius, etc).

 

If benefactor is a NPC and you use sendPacket, nothing will happen. But if you broadcastPacket, it will send to all ppls around that NPC, and so there is a use.

 


 

About custom client ask itself, can't help here. Go on client section.

  • 0
Posted

As following :

benefactor.sendPacket(new PlaySound("package.sound"));

Where "benefactor" is the ppl who receives the sound, "package" is the package where the sound is stored, and "sound" is the name of the sound itself.

 

Then you can apply different rules, such as broadcastPacket (which will send to all ppl in a radius around the player), or even using Broadcast.java methods (to all players online, to all players in X radius, etc).

 

If benefactor is a NPC and you use sendPacket, nothing will happen. But if you broadcastPacket, it will send to all ppls around that NPC, and so there is a use.

 


 

About custom client ask itself, can't help here. Go on client section.

where should i work this code? EnterWorld? can u pass me the location pls.

Also will the sound repeat? cuz i want smth like when a player logs in custom sound plays once "WELCOME" or "pitbulll - lalala song"

  • 0
Posted

EnterWorld is eventually the good place, but you perhaps will have to delay it with a task (in all cases, put it at the top end). And no, no sound repetition.

 

About tasks (in case sound is played during loading screen), search ThreadPoolManager.

  • 0
Guest Elfocrash
Posted

I recommend you to add a delay for the playsound because places will trigger another "town sound" after your song is played so you will probably listen to the song for 2 seconds and then the town music will cover it.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...