Well, I can tell you right now why it's doing what it's doing
You have to synchronize the data. File I/O has no synchronization in it, you have to do it yourself.
I suggest you start with something a little less daunting.
call file.write("123456")
local integer i = S2I(file.read())
local Packet packet = Packet.broadcast(i, i != 0)
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000,I2S(packet[0])) //assuming you are player 0
After you successfully do 1 integer, then try a stream of integers
call file.write("1")
call file.write("2")
struct Test extends array
private File file
private method getNextBroadcast takes nothing returns integer
return S2I(file.read())
endmethod
implement StreamMod
static method sync takes nothing returns nothing
local integer i = 0
local thistype this
local File file = File.open(...)
if (GetLocalPlayer() == Player(0)) then
set i = 2
endif
set this = allocate(i)
call synchronize()
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000,I2S(read(0, 0))) //1
call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60000,I2S(read(0, 1))) //2
call file.close()
call deallocate()
endmethod
endstruct