- Joined
- Jan 1, 2011
- Messages
- 1,534
This nifty system detects when a player actually enters the game through the first firing of EVENT_PLAYER_MOUSE_MOVE event. It is guaranteed to fire once the player physically enters the game by setting War3 as the main focus.
I've tested this in lan and it doesn't desync (in a map that has a lot going on).
I've tested this in lan and it doesn't desync (in a map that has a lot going on).
JASS:
library GameEnterEvent initializer init
globals
private constant integer MAX_PLAYER_ID = 23
private constant string SYNC_PREFIX = "GameEnterEvent_Sync"
endglobals
public function onEnter takes nothing returns boolean
//triggerPlayer just entered the game, do actions here
return false
endfunction
private function OnGameEnter takes nothing returns nothing
call DisableTrigger(GetTriggeringTrigger())
call BlzSendSyncData(SYNC_PREFIX,"")
endfunction
private function init takes nothing returns nothing
local integer i = 0
local trigger t = CreateTrigger()
call TriggerRegisterPlayerEvent(t, GetLocalPlayer(), EVENT_PLAYER_MOUSE_MOVE)
call TriggerAddCondition(t, function OnGameEnter )
set t = CreateTrigger()
loop
exitwhen i > MAX_PLAYER_ID
call BlzTriggerRegisterPlayerSyncEvent(t, Player(i), SYNC_PREFIX, false)
set i = i + 1
endloop
call TriggerAddCondition(t, function onEnter)
set t = null
endfunction
endlibrary
Last edited: