| 03-11-2005, 09:54 AM | #1 |
Hi, i want to make a kind of jukebox, but the function StopSound() cause a de-sync. There is my code : Code:
function Trig_Radio_Actions takes nothing returns nothing
local sound music=null
local sound stop=null
local integer p=GetPlayerId(GetOwningPlayer(GetSpellAbilityUnit()))
if(GetSpellAbilityId()=='A00S')then
if(GetLocalPlayer()==Player(p))then
set stop=udg_PLAYERS_radio[p]
set music=gg_snd_TerranCanal1
endif
elseif(GetSpellAbilityId()=='A00X')then
if(GetLocalPlayer()==Player(p))then
set stop=udg_PLAYERS_radio[p]
set music=gg_snd_TerranCanal2
endif
elseif(GetSpellAbilityId()=='A00Y')then
if(GetLocalPlayer()==Player(p))then
set stop=udg_PLAYERS_radio[p]
set music=gg_snd_TerranCanal3
endif
endif
call StopSoundBJ(stop,true)
if(stop!=null)then
call PolledWait(1.20)
endif
call PlaySoundBJ(music)
if(GetLocalPlayer()==Player(p))then
set udg_PLAYERS_radio[p] = GetLastPlayedSound()
endif
endfunction
//===========================================================================
function InitTrig_Radio takes nothing returns nothing
set gg_trg_Radio = CreateTrigger( )
call TriggerRegisterAnyUnitEventBJ( gg_trg_Radio, EVENT_PLAYER_UNIT_SPELL_EFFECT )
call TriggerAddAction( gg_trg_Radio, function Trig_Radio_Actions )
endfunction
In game, players can play the first music (1st,2nd or 3th), but the second, cause de-sync, because stop variable is not null for each player. Does it exist any solution to my problem ? |
| 03-29-2005, 02:36 PM | #2 |
This snippet causes the desync: if(stop!=null)then call PolledWait(1.20) endif You can never have a wait in a local block, it will naturally desync. Either remove the wait or wait for all players. |
| 03-30-2005, 10:16 PM | #3 |
Thx a lot :) |
