Interface IServerPlayer
- Namespace
- Vintagestory.API.Server
- Assembly
- VintagestoryAPI.dll
Represents a player on the server side that joined the server at least once. May not be online at this point in time.
public interface IServerPlayer : IPlayer
- Inherited Members
- Extension Methods
Properties
ConnectionState
Retrieves the current connection state of the client
EnumClientState ConnectionState { get; }
Property Value
CurrentChunkSentRadius
The "radius" of chunks that the player already received. If set to 0, the server will recheck all nearby chunks if they have been sent or not and send them when necessary
int CurrentChunkSentRadius { get; set; }
Property Value
IpAddress
Get the IP for the given player ID. Returns null if not connected, or when called on client side.
string IpAddress { get; }
Property Value
ItemCollectMode
int ItemCollectMode { get; set; }
Property Value
LanguageCode
The language this player is currently using
string LanguageCode { get; }
Property Value
Ping
Returns the players ping time in seconds. Returns NaN if not connected or when on client side.
float Ping { get; }
Property Value
ServerData
The players configuration that is world independent
IServerPlayerData ServerData { get; }
Property Value
Methods
BroadcastPlayerData(bool)
Notifies all clients of given players playerdata. Useful when you modified any of the WorldData. Does nothing if this player is not connected. Also sends the player data to the player himself
void BroadcastPlayerData(bool sendInventory = false)
Parameters
sendInventory
bool
ClearSpawnPosition()
Removes the player specific spawn position, which means it will default to the role or global default spawn position
void ClearSpawnPosition()
Disconnect()
Disconnects (kicks) this player from the server. Does nothing if this player is not connected.
void Disconnect()
Disconnect(string)
Disconnects (kicks) a player from the server with given reason. Does nothing if this player is not connected.
void Disconnect(string message)
Parameters
message
stringMessage displayed to the player
GetModData<T>(string, T)
T GetModData<T>(string key, T defaultValue = default)
Parameters
key
stringdefaultValue
T
Returns
- T
Type Parameters
T
GetModdata(string)
Retrieve arbitrary, permantly stored mod data
byte[] GetModdata(string key)
Parameters
key
string
Returns
- byte[]
GetSpawnPosition(bool)
Returns the default spawn position. This method will return the custom spawnpoint if one has been permanently set. If no custom spawnpoint is present this method will return the global default spawnpoint. Returns null when called on client side.
FuzzyEntityPos GetSpawnPosition(bool consumeSpawnUse)
Parameters
consumeSpawnUse
boolIf true, and this spawn point is use limited, will consume one use of it
Returns
RemoveModdata(string)
Removes the permanently stored mod data
void RemoveModdata(string key)
Parameters
key
string
SendIngameError(string, string, params object[])
Shows a vibrating red text in the players screen. If message is null the client will try to find a language entry using supplied code prefixed with 'ingameerror-' (which is recommended so that the errors are translated to the users local language)
void SendIngameError(string code, string message = null, params object[] langparams)
Parameters
code
stringmessage
stringlangparams
object[]If message is null, these are the arguments passed into the Language translation tool
SendLocalisedMessage(int, string, params object[])
Sends a chat message (notification type) to this player, localised to the player's own language independent from the server language
The message will be string formatted - similar to Lang.Get() - with the specified optional args
void SendLocalisedMessage(int groupId, string message, params object[] args)
Parameters
SendMessage(int, string, EnumChatType, string)
Sends a chat message to this player to given groupId. You can use GlobalConstants.GeneralChatGroup as groupId to send it to the players general chat.
void SendMessage(int groupId, string message, EnumChatType chatType, string data = null)
Parameters
groupId
intmessage
stringchatType
EnumChatTypedata
stringOptional parameter that can be used to pass on unformated data. Just like stdin/stdout/stderr, you could see this as a separate "programming communication channel"
SendPositionToClient()
Tells the server send a position packet to the client
void SendPositionToClient()
SetModData<T>(string, T)
void SetModData<T>(string key, T data)
Parameters
key
stringdata
T
Type Parameters
T
SetModdata(string, byte[])
Allows setting of arbitrary, permanantly stored moddata attached to this player. Not synced to client.
void SetModdata(string key, byte[] data)
Parameters
SetRole(string)
Sets the players privilege role. For a list of roles, read sapi.Config.Roles
void SetRole(string roleCode)
Parameters
roleCode
string
SetSpawnPosition(PlayerSpawnPos)
Sets a player specific spawn position
void SetSpawnPosition(PlayerSpawnPos pos)
Parameters
pos
PlayerSpawnPos
Events
InWorldAction
event OnEntityAction InWorldAction