play_server_named_sound_effect Packet

  • Welcome to skUnity!

    Welcome to skUnity! This is a forum where members of the Skript community can communicate and interact. Skript Resource Creators can post their Resources for all to see and use.

    If you haven't done so already, feel free to join our official Discord server to expand your level of interaction with the community!

    Now, what are you waiting for? Join the community now!

  • LOOKING FOR A VERSION OF SKRIPT?

    You can always check out skUnity Downloads for downloads and any other information about Skript!

Status
Not open for further replies.

AsuDev

VIP
Jan 27, 2017
240
22
18
United States
How can I get the ID or name of the sound that was played?

All I got so far. Not sure how to get the Id or sound though...

on packet event play_server_named_sound_effect:
 
depends on your version, at least in 1.8 its string pinfo 0
 
Ver is 1.12.2 using latest bensku fork
Put this in your script:
code_language.skript:
packet aliases for play_server_named_sound_effect:

  sound of %packet% = "Sound" penum 0 of %packet%
  [sound] category of %packet% = "SoundCategory" penum 0 of %packet%

  [sound] x-pos[ition] of %packet% = int pnum 0 of %packet%
  [sound] y-pos[ition] of %packet% = int pnum 1 of %packet%
  [sound] z-pos[ition] of %packet% = int pnum 2 of %packet%
 
  [sound] volume of %packet% = float pnum 0 of %packet%
  [sound] pitch of %packet% = float pnum 1 of %packet%

And then you can do the following:
code_language.skript:
on packet play_server_named_sound_effect:

  if sound of event-packet is "BLOCK_ANVIL_HIT":
    set volume of event-packet to 0 #you can also cancel the event, if you want.
By the way, it uses Spigot's Sound enum so you may want look here for the sound names:
https://hub.spigotmc.org/javadocs/spigot/org/bukkit/Sound.html
 
Status
Not open for further replies.