Blitz3D+ Command Reference

DeleteNetPlayer player

Parameters

player - id of a local player, as returned by CreateNetPlayer

Description

Removes one of your local players from the network game.

The player leaves the session and every other machine receives a leave message (type 101) with the departing player's id in NetMsgFrom - their cue to drop that player's ship, name-tag and score from the game.

Only players created on this machine can be deleted here; remote players leave when their own machine deletes them or quits. StopNetGame removes all your players in one go.

See also: CreateNetPlayer, StopNetGame, NetMsgType, NetMsgFrom.

Example

; DeleteNetPlayer Example
; -----------------------

; Host a game directly (2 = success)
status=HostNetGame("demo game")

If status=2 Then
    Print "Hosting 'demo game'"

    player=CreateNetPlayer("Alice")
    Print "Created '"+NetPlayerName$(player)+"' with id "+player

    ; DeleteNetPlayer removes the player from the game and tells
    ; every other machine (they receive a type 101 message)
    DeleteNetPlayer player
    Print ""
    Print "After DeleteNetPlayer, id "+player+"'s name reads '"+NetPlayerName$(player)+"'"

    StopNetGame
    Print ""
    Print "Game stopped"
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