StopNetGame
Parameters
| None. |
Description
|
Leaves the current network game. The session (started with StartNetGame, HostNetGame or JoinNetGame) is shut down for this machine and all its players are removed - other machines see leave messages (type 101) for them. It is safe to call even when no game is running. If the machine leaving was the host, the session tries to carry on: hosting migrates to one of the remaining machines, which receives a message of type 102 from RecvNetMsg to say "you are the host now". After stopping you can start or join a fresh game - which is also the only way to switch sessions, since only one can be active at a time. See also: StartNetGame, HostNetGame, JoinNetGame, NetMsgType. |
Example
; StopNetGame Example ; ------------------- ; Host a game directly (2 = success) status=HostNetGame("demo game") If status=2 Then Print "Hosting 'demo game'" player=CreateNetPlayer("Host") Print "Player '"+NetPlayerName$(player)+"' is in the game" ; StopNetGame ends the network session; if other machines are ; connected, hosting is handed over to one of them StopNetGame Print "" Print "StopNetGame called - the session is over." Print "It is now safe to host or join a fresh game." Else Print "HostNetGame returned "+status+" - could not host a game" Print "(network play may be unavailable on this machine)" EndIf Print "" Print "Press any key to close the example" WaitKey End
Index