I'm pushing 5 floats, and then a word (to identify what message I'm sending). Also take note of what I added onto my previous post. Here is the code for pushing...
if timer()-G_UpdateTime > G_UpdateRate
`Send player state message to server
net push float G_Character(G_Player.character).position.x
net push float G_Character(G_Player.character).position.y
net push float G_Character(G_Player.character).position.z
net push float G_Character(G_Player.character).rotation.x
net push float G_Character(G_Player.character).rotation.y
net push word NET_PLAYERSTATE
net send 0
G_UpdateTime = timer()
endif
It sends the data every 100 ms. Here is the popping...
if net receive(x)
amount = net get msg amount()
for y = 1 to amount
tmp = net get msg()
id = net pop word()
select id
case NET_PLAYERSTATE
if G_Player(x).initialized
rot.y = net pop float()
rot.x = net pop float()
pos.z = net pop float()
pos.y = net pop float()
pos.x = net pop float()
G_Character(G_Player(x).character).position = pos
G_Character(G_Player(x).character).rotation = rot
NDB_BuildMatrix rot.x, rot.y, 0.0, pos.x, pos.y, pos.z
NDB_NewtonBodySetMatrix G_Character(G_Player(x).character).NewtonBody
endif
endcase
endselect
next y
endif
It reads the word, and then checks what it is, and then reads the data depending on it. Weird thing is, with 4 floats it works fine, but with 5 it doesn't work.
Isn't it? Wasn't it? Marvellous!
