function H2I takes handle h returns integer
return h
return 0
endfunction
function GetNextChatMsg_Child takes nothing returns nothing
if( GetTriggerExecCount(GetTriggeringTrigger()) == 1 ) then
call StoreString( InitGameCache("chatevent.w3v"), I2S(H2I(GetTriggeringTrigger())), "string", GetEventPlayerChatString() )
endif
endfunction
function GetNextChatMsg takes player WhichPlayer, real TimeOut, string SubS returns string
local gamecache GC = InitGameCache("chatevent.w3v")
local trigger trig = CreateTrigger()
local string s = I2S(H2I(trig))
local string Msg = ""
local timer t
if (SubString
if (TimeOut > 0)then
set t = CreateTimer()
call TimerStart(t, TimeOut, false, null)
endif
call TriggerRegisterPlayerChatEvent( trig, WhichPlayer, SubS, false )
call TriggerAddAction( trig, function GetNextChatMsg_Child )
loop
call TriggerSleepAction(0)
if (GetTriggerExecCount(trig) > 0) then
set Msg = GetStoredString( GC, s, "string" )
endif
exitwhen Msg != "" or ( TimeOut>0 and TimerGetRemaining(t)==0 )
endloop
call DestroyTrigger(trig)
set trig = null
if ( Msg == "" ) then
call DestroyTimer(t)
set t = null
return ""
endif
set Msg = GetStoredString( GC, s, "string" )
call FlushStoredMission( GC, s )
return Msg
endfunction