Quote: "does that mean the command does it automatically?"
The NET PLAYER CREATED and NET PLAYER DELETED functions will return each connected/disconnected player number only once - the next time you call these functions, DBPro will either return 0, or the number of the next player that connected/disconnected.
As for the variable being reset... well, no it's ALWAYS set to the value that the function returns. You don't need to clear it or pre-prepare it.
Here's another example I've dug up:
sync off
sync rate 30
perform checklist for net connections
Connected = 0
for i = 1 to checklist quantity()
if instr(checklist string$(i), "TCP/IP") > 0
Connected = 1
set net connection i, "127.0.0.1"
exit
endif
next
if Connected = 0 then report error "Unable to locate the TCP/IP connection"
PlayerNo = default net game("MultiplayerMouse", str$(timer()), 2, 1)
LastMouseClick = 0
do
` Determine if a message needs to be send (mouse movement)
if mousemovex() <> 0 or mousemovey() <> 0 or mouseclick() <> LastMouseClick
if mouseclick() = LastMouseClick
` No click, so send a straight mouse movement messages
make memblock 1, 12
write memblock dword 1, 0, 0
write memblock dword 1, 4, mousex()
write memblock dword 1, 8, mousey()
send net message memblock 0, 1, 1
delete memblock 1
else
` Click change, so send a full mouse refresh
make memblock 1, 16
write memblock dword 1, 0, 1
write memblock dword 1, 4, mousex()
write memblock dword 1, 8, mousey()
write memblock dword 1, 12, mouseclick()
send net message memblock 0, 1, 1
delete memblock 1
LastMouseClick = mouseclick()
endif
endif
get net message
while net message exists() <> 0
` Only take action on memblock messages
if net message type() = 4
net message memblock 1
select memblock dword(1, 0)
case 0
` Received a mousemove event
OtherMouseX = memblock dword(1, 4)
OtherMouseY = memblock dword(1, 8)
endcase
case 1
` Received a full mouse refresh
OtherMouseX = memblock dword(1, 4)
OtherMouseY = memblock dword(1, 8)
OtherMouseClick = memblock dword(1, 12)
endcase
endselect
delete memblock 1
endif
get net message
endwhile
cls
text 0, 0, str$(OtherMouseX)
text 0, 15, str$(OtherMouseY)
text 0, 30, str$(OtherMouseClick)
sync
loop
Run two sessions. The active application will send the mouse coordinates to the other. As it's a very simple example, there are only two message types. The first is the x/y of the mouse. The last is the x/y of the mouse, plus the mouse button state.
The format of these is as follows...
Offset Data type Data
0 DWORD Message type = 0 (mouse position)
4 DWORD Mouse X
8 DWORD Mouse Y
0 DWORD Message type = 1 (mouse position + button)
4 DWORD Mouse X
8 DWORD Mouse Y
12 DWORD Mouse button state
As I said, it's not a very complex system (and wasn't meant to be - I was learning the multiplayer commands myself at the time), so the message types aren't very complex.