Platform SDK: DirectX

DirectPlay4.SetPlayerData

The DirectPlay4.SetPlayerData method associates an application-specific data block with a player ID.

object.SetPlayerData(playerId As Long, _
    data As String, _
    flags As CONST_DPSETFLAGS) 

Parameters

object
Object expression that resolves to a DirectPlay4 object.
playerId
ID of the player for which data is being set.
data
Data to be set. Set this parameter to "" in order to clear any existing player data.
flags
Flag from the CONST_DPSETFLAGS enumeration that sets the data-propagation options. If this parameter is set to 0 (DPGET_REMOTE), the remote player data will be set and propagated by using nonguaranteed messaging.

Error Codes

If the method fails, an error is raised and Err.Number may be set to one of the following values:

DPERR_ACCESSDENIED
DPERR_CONNECTIONLOST
DPERR_INVALIDFLAGS
DPERR_INVALIDOBJECT
DPERR_INVALIDPARAMS
DPERR_INVALIDPLAYER

Remarks

This method should not be used for updating real-time information (such as position updates), because of the overhead introduced. It is much more efficient to use DirectPlay4.Send for this. SetPlayerData is more appropriate for shared state information that doesn't change very often and is not time-critical (such as a player's name).

DirectPlay can maintain two types of player data: local and remote. Local data is available only to the application on the local computer. Remote data is propagated to all the other applications in the session. This method returns DPERR_ACCESSDENIED if you try to set player data for a remote player. A DPSYS_SETPLAYERORGROUPDATA system message will be sent to all players (including the sender) notifying them of the change unless DPSESSION_NODATAMESSAGES is set in the session description. It is safe to store resources in the local data; the local data block is available (in the DPSYS_DESTROYPLAYERORGROUP system message) when the player is being destroyed, so the application can free those resources.

See Also

DirectPlay4.GetPlayerData