Azlier
Old World Ghost
- Reaction score
- 461
So, now that I've gone totally insane, I would like one more thing to be tested.
Online (LAN or Battle.net doesn't matter) would be nice, because I want to test if this desyncs. Or works at all.
Save the game, it's supposed to display the name of the player who saved it. If you get syntax errors, report them with the errors you get and which line it's on.
Note: This is terribly inefficient with some unnecessary handles. But it should work. Hopefully.
[lJASS]requires[/lJASS] Event
Online (LAN or Battle.net doesn't matter) would be nice, because I want to test if this desyncs. Or works at all.
Save the game, it's supposed to display the name of the player who saved it. If you get syntax errors, report them with the errors you get and which line it's on.
Note: This is terribly inefficient with some unnecessary handles. But it should work. Hopefully.
[lJASS]requires[/lJASS] Event
JASS:
library GetSavingPlayer initializer Init requires Event //Note to self: needs polishing.
globals
private Event Ev
private player SavingPlayer = null
private unit array U
private integer LocalId
endglobals
constant function GetSavingPlayer takes nothing returns player
return SavingPlayer
endfunction
function TriggerRegisterGameSaved takes trigger t returns nothing
call Ev.register(t)
endfunction
private function OnClick takes nothing returns boolean
set SavingPlayer = GetOwningPlayer(GetTriggerUnit())
call Ev.fire()
////////////////////////////////////////////
call BJDebugMsg(GetPlayerName(SavingPlayer))
////////////////////////////////////////////
set SavingPlayer = null
return false
endfunction
private function OnSave takes nothing returns boolean
call SelectUnit(U[LocalId], true)
call SelectUnit(U[LocalId], false)
return false
endfunction
private function Init takes nothing returns nothing
local trigger t
local integer i = 11
set LocalId = GetPlayerId(GetLocalPlayer())
set Ev = Event.create()
loop
set t = CreateTrigger()
call TriggerRegisterGameEvent(t, EVENT_GAME_SAVE)
call TriggerAddCondition(t, Condition(function OnSave))
if GetLocalPlayer() != Player(i) then
call DisableTrigger(t)
endif
set t = CreateTrigger()
set U<i> = CreateUnit(Player(i), 039;hfoo039;, 10000, 10000, 270)
call PauseUnit(U<i>, true)
call TriggerRegisterUnitEvent(t, U<i>, EVENT_UNIT_SELECTED)
call TriggerAddCondition(t, Condition(function OnClick))
exitwhen i == 0
set i = i - 1
endloop
endfunction
endlibrary</i></i></i>