So, I made this by having the idea of; when someone writes -spartacus, a voice will start. Which works, but it overlaps. I could use PolledWait to avoid the tracks overlapping, but I really dislike PolledWait. So what I did was so that when this function plays the sound, it disables the trigger. Then a timer which has 15 seconds, once it runs out it calls to my other function which is called "EnableThisTrigger" that enables the disabled trigger. So that when writing -spartacus again, it will play the sound.
My purpose is that, when people write -spartacus, the sound will only play once every 15 seconds.
And yes, right now only a player with the name "null" can use this, but pay that no mind.
Thanks.
My purpose is that, when people write -spartacus, the sound will only play once every 15 seconds.
And yes, right now only a player with the name "null" can use this, but pay that no mind.
JASS:
function EnableThisTrigger takes nothing returns nothing
local integer i = 0
loop
call DisplayTimedTextToPlayer(Player(i), 0, 0, 60, "It has been fifteen seconds since EnableThisTrigger was executed.")
set i = i + 1
exitwhen i == bj_MAX_PLAYERS
endloop
call EnableTrigger(name of the trigger of castauraforwolkern2)
endfunction
function CastAuraForWolkern2 takes nothing returns nothing
local player TrigPlayer = GetTriggerPlayer()
local integer ip = GetPlayerId(TrigPlayer)
local timer t = CreateTimer()
if GetPlayerName(TrigPlayer)== "null" then
set SpartacusVoice = CreateSound("null\\KoreWaSpartacusDeAru.mp3", false, false, true, 12700, 12700, "DefaultEAXON")
set bj_lastPlayedSound = SpartacusVoice
if SpartacusVoice != null then
call StartSound(SpartacusVoice)
endif
call DisableTrigger( - name of this functions trigger)
call TimerStart(t, 15.00, false, function EnableThisTrigger)
endif
set TrigPlayer = null
set t = null
endfunction
function AuraForWolkern2Init takes nothing returns nothing
local trigger t=CreateTrigger()
local integer i=0
loop
call TriggerRegisterPlayerChatEvent(t, Player(i), "-spartacus", true)
set i = i + 1
exitwhen i == bj_MAX_PLAYERS
endloop
call TriggerAddAction(t,function CastAuraForWolkern2)
set t=null
endfunction
Thanks.