• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Play sound for player (player group)

Status
Not open for further replies.
Level 9
Joined
May 30, 2008
Messages
430
JASS:
StartSoundForPlayerBJ
JASS:
function StartSoundForPlayerBJ takes player whichPlayer, sound soundHandle returns nothing
    if (whichPlayer == GetLocalPlayer()) then
        call StartSound(soundHandle)
    endif
endfunction

i don't know nothing about this stupid program and the program itself don't help me alot, but to play sound for a only 1 player or player within a group i need jass. So i end um with this trigger/script line/command or whatever are those things in jass. So can some one tell me how to fill up the gaps here and to tell me everything about how i can manage this command. I hope atleast one of you get my point (my point is to play a sound .mp3 format for 1 player or for palyer in player group) so can some one tell me what to DO:spell_breaker::spell_breaker:

btw i have to insert this thing with costum script or what? becouse looks weird when i insert it with costum script and i have the feeling that i screw up
 
Level 18
Joined
Oct 18, 2007
Messages
930
For one player you'd be using
Code:
call StartSoundForPlayerBJ(Player(0), gg_snd_Hint)

no, BJ's are stupid.

Just copy the content of that BJ function into you're code.

Edit:

I made this nifty function for you to use ;)
JASS:
function StartSoundForPlayer takes player wichPlayer, string soundName returns nothing
    local sound soundHandle = CreateSound(soundName, false, false, true, 12700, 12700, "")
    
    if GetLocalPlayer() == wichPlayer then
        call StartSound(soundHandle)
    endif
    
    call KillSoundWhenDone(soundHandle)
endfunction
 
Level 9
Joined
May 30, 2008
Messages
430
i end up having this

JASS:
function StartSoundForPlayerBJ takes player (0), sound MeltWithYou <gen> returns nothing

JASS:
if (0 == GetLocalPlayer(0)) then

JASS:
call StartSound(call StartSound(MeltWithYou <gen>))

those are 3 costum scripts (separete) and it gives me error. As you guys maybe already get i am uber noob in JASS and this is my first script that i am trying to get it work. So what to type at sound menu player 1 is 0 right?
and why when i click at syntax cheker it says "Statement outside of function"


Edit1: i end up with having this
JASS:
function StartSoundForPlayerBJ takes Player(0), sound  gg_snd_Melt_With_You  returns nothing
    if (whichPlayer(0) == GetLocalPlayer(0)) then
        call StartSound( gg_snd_Melt_With_You )
    endif
endfunction
and i put it when i conver trigger to costum text but still give me a error

the original code is
JASS:
function StartSoundForPlayerBJ takes player whichPlayer, sound soundHandle returns nothing
    if (whichPlayer == GetLocalPlayer()) then
        call StartSound(soundHandle)
    endif
endfunction
 
Last edited:
Level 9
Joined
May 30, 2008
Messages
430
This trigger keep giving me error at first line
JASS:
if GetLocalPlayer(0) == udg_Player(0) then

if some one wonna help me send me the trigger that is set for player 1. As i say i am not good at crosswords and jass is exactly that a crosswords and becouse of that most ppls say it's hard to learn. For the next who wonna help me fill the text in the script where is missing other wise don't post i can always ask for help in the other 3 sites (ppls in this site can do only spells and sliding triggers in JASS). Peoples give you the script and say there u go in matter of fact jass also give me this script the problem is i don't know how to fill the gaps becouse i don't know JASS
 
Level 9
Joined
May 30, 2008
Messages
430
ok it's working and one more think before i give you rep :wink:
JASS:
if IsPlayerInForce(GetLocalPlayer(), udg_YourPlayerGroup) then
JASS:
call StartSound(gg_snd_Melt_With_You)
i wonna if player is not i player group to stop the sound is that posible?

Edit: i found the code
JASS:
call StopSound(soundHandle, false, fadeOut)
how to fill it up (i use the first line from the first script but players are in diferent group
 
Last edited:
Level 9
Joined
May 30, 2008
Messages
430
JassCraft say
Undeclared variable: fadeOut
For this line
JASS:
call StopSound(gg_snd_Melt_With_You, false, fadeOut)
World editor also give me error : Expected a name

Edit1: i make it like this
JASS:
call StopSoundBJ( gg_snd_Melt_With_You, true )
(by converting to soctum text and copy the text)
i will test the map now and will tell if all is ok

Edit2: all is working trigger is MPI i like that. Tnx to you Element of Water i will begin learning now JASS it's not that hard but i will learn how to fill those crosswords +rep
 
Last edited:
You don't get it do you? You need to put false (or true if you want it to fade out) again after another comma. The function takes a sound, and two booleans. You are only passing it one boolean.
And why not use BJs? Each time you make a function call, it takes time. When you use a BJ, it does 2 or more function calls (you call the BJ, the BJ calls the native - two calls) when you can do the same thing using just one native. This means your code takes longer than it could to execute, causing lag if you use too many of them within a small amount of time.
 
Level 9
Joined
May 30, 2008
Messages
430
I was having problem with this
Code:
 boolean fadeOut
but now i get it bolleans are real or true and 10x again for this help now the line looks like that
JASS:
call StopSound(gg_snd_Melt_With_You, false, true)

btw this is MPI as far as i can see it :D

yupiiiiiiii my very first JASS script :cute:
i will learn jass some day i can do it
 
Status
Not open for further replies.
Top