Module Wrapper.Net
Wrapper - DCS net functions.
Encapsules multiplayer server environment scripting functions from net
Author: Applevangelist
Last Update Oct 2023
Global(s)
Global NET |
Encapsules multiplayer environment scripting functions from net with some added FSM functions and options to block/unblock players in MP environments. |
Type(s)
Fields and Methods inherited from NET | Description |
---|---|
Block a player. |
|
Block a SET_CLIENT of players |
|
Block a specific coalition side, does NOT automatically kick all players of that side or kick out joined players |
|
Block a specific player slot, does NOT automatically kick a player in that slot or kick out joined players |
|
Block a specific UCID of a player, does NOT automatically kick the player with the UCID if already joined. |
|
Executes a lua string in a given lua environment in the game. |
|
Force the slot for a specific client. |
|
Get some data of pilots who have currently joined |
|
Returns the playerID of the local player. |
|
Return the name of a given client. |
|
Find the PlayerID by name |
|
Find the PlayerID from a CLIENT object. |
|
Return a table of attributes for a given client. |
|
Return a table of players currently connected to the server. |
|
Return a statistic for a given client. |
|
Get player UCID from player CLIENT object or player name. |
|
Returns the playerID of the server. |
|
Returns the SideId and SlotId of a given client. |
|
NET:IsAnyBlocked(UCID, Name, PlayerID, PlayerSide, PlayerSlot) |
[Internal] Check any blockers |
Converts a JSON string to a lua value. |
|
Kicks a player from the server. |
|
Write an "INFO" entry to the DCS log file, with the message Message. |
|
Converts a lua value to a JSON string. |
|
Instantiate a new NET object. |
|
NET:OnAfterPlayerBlocked(From, Event, To, Client, Name, Seconds) |
FSM Function OnAfterPlayerBlocked. |
FSM Function OnAfterPlayerDied. |
|
FSM Function OnAfterPlayerEjected. |
|
FSM Function OnAfterPlayerJoined. |
|
FSM Function OnAfterPlayerLeft. |
|
FSM Function OnAfterPlayerUnblocked. |
|
Force a client back to spectators. |
|
Send chat message. |
|
Send chat message to a specific player using the CLIENT object. |
|
Send chat message to a specific player using the player name |
|
Set block chat message. |
|
Set block time in seconds. |
|
Set unblock chat message. |
|
Unblock a player. |
|
Unblock a SET_CLIENT of players |
|
Unblock a specific coalition side. |
|
Unblock a specific slot. |
|
Unblock a specific UCID of a player |
|
[Internal] Event Handler |
|
Stop the event functions |
|
Status - housekeeping |
|
Stop the event functions |
Fields and Methods inherited from FSM | Description |
---|---|
Adds an End state. |
|
Set the default #FSM_PROCESS template with key ProcessName providing the ProcessClass and the process object when it is assigned to a Wrapper.Controllable by the task. |
|
Adds a score for the FSM to be achieved. |
|
Adds a score for the FSM_PROCESS to be achieved. |
|
Add a new transition rule to the FSM. |
|
Get current state. |
|
Returns the End states. |
|
Returns a table of the SubFSM rules defined within the FSM. |
|
Returns a table with the scores defined. |
|
Returns the start state of the FSM. |
|
Get current state. |
|
Returns a table with the Subs defined. |
|
Returns a table of the transition rules defined within the FSM. |
|
Check if FSM is in state. |
|
Load call backs. |
|
Creates a new FSM object. |
|
Sets the start state of the FSM. |
|
Add to map. |
|
Call handler. |
|
Create transition. |
|
Delayed transition. |
|
Event map. |
|
Go sub. |
|
Handler. |
|
Is end state. |
|
Sub maps. |
|
Check if can do an event. |
|
Check if cannot do an event. |
|
Check if FSM is in state. |
|
Fields and Methods inherited from NET.PlayerData | Description |
---|---|
The NET class
Field(s)
Function(s)
Block a player.
Defined in:
NET
Parameters:
Wrapper.Client#CLIENT Client
CLIENT object.
#string PlayerName
(optional) Name of the player.
#number Seconds
(optional) Number of seconds the player has to wait before rejoining.
#string Message
(optional) Message to be sent via chat.
Return value:
#NET:
self
Block a SET_CLIENT of players
Defined in:
NET
Parameters:
Core.Set#SET_CLIENT PlayerSet
The SET to block.
#number Seconds
Seconds (optional) Number of seconds the player has to wait before rejoining.
#string Message
(optional) Message to be sent via chat.
Return value:
#NET:
self
Block a specific coalition side, does NOT automatically kick all players of that side or kick out joined players
Defined in:
NET
Parameters:
#number Side
The side to block - 1 : Red, 2 : Blue
#number Seconds
Seconds (optional) Number of seconds the player has to wait before rejoining.
Return value:
#NET:
self
Block a specific player slot, does NOT automatically kick a player in that slot or kick out joined players
Defined in:
NET
Parameters:
#string slot
The slot to block
#number Seconds
Seconds (optional) Number of seconds the player has to wait before rejoining.
Slot
Return value:
#NET:
self
Block a specific UCID of a player, does NOT automatically kick the player with the UCID if already joined.
Defined in:
NET
Parameters:
#string ucid
#number Seconds
Seconds (optional) Number of seconds the player has to wait before rejoining.
Return value:
#NET:
self
Executes a lua string in a given lua environment in the game.
Defined in:
NET
Parameters:
#string State
The state in which to execute - see below.
#string DoString
The lua string to be executed.
Return value:
#string:
Output
Usage:
States are:
'config': the state in which $INSTALL_DIR/Config/main.cfg is executed, as well as $WRITE_DIR/Config/autoexec.cfg - used for configuration settings
'mission': holds current mission
'export': runs $WRITE_DIR/Scripts/Export.lua and the relevant export API
Force the slot for a specific client.
If this returns false, it didn't work via net
(which is ALWAYS the case as of Nov 2024)!
Defined in:
NET
Parameters:
Wrapper.Client#CLIENT Client
The client
#number SideID
i.e. 0 : spectators, 1 : Red, 2 : Blue
#number SlotID
Slot number
Return value:
#boolean:
Success
Get some data of pilots who have currently joined
Defined in:
NET
Parameters:
Wrapper.Client#CLIENT Client
Provide either the client object whose data to find or
#string Name
The player name whose data to find
Return value:
#table:
Table of #NET.PlayerData or nil if not found
Returns the playerID of the local player.
Always returns 1 for server.
Defined in:
NET
Return value:
#number:
ID
Return the name of a given client.
Effectively the same as CLIENT:GetPlayerName().
Defined in:
NET
Parameter:
Wrapper.Client#CLIENT Client
The client
Return value:
#string:
Name or nil if not obtainable
Find the PlayerID by name
Defined in:
NET
Parameter:
#string Name
The player name whose ID to find
Return value:
#number:
PlayerID or nil
Find the PlayerID from a CLIENT object.
Defined in:
NET
Parameter:
Wrapper.Client#CLIENT Client
The client
Return value:
#number:
PlayerID or nil
Return a table of attributes for a given client.
If optional attribute is present, only that value is returned.
Defined in:
NET
Parameters:
Wrapper.Client#CLIENT Client
The client.
#string Attribute
(Optional) The attribute to obtain. List see below.
Return value:
#table:
PlayerInfo or nil if it cannot be found
Usage:
Table holds these attributes:
'id' : playerID
'name' : player name
'side' : 0 - spectators, 1 - red, 2 - blue
'slot' : slotID of the player or
'ping' : ping of the player in ms
'ipaddr': IP address of the player, SERVER ONLY
'ucid' : Unique Client Identifier, SERVER ONLY
Return a table of players currently connected to the server.
Defined in:
NET
Return value:
#table:
PlayerList
Return a statistic for a given client.
Defined in:
NET
Parameters:
Wrapper.Client#CLIENT Client
The client
#number StatisticID
The statistic to obtain
Return value:
#number:
Statistic or nil
Usage:
StatisticIDs are:
net.PS_PING (0) - ping (in ms)
net.PS_CRASH (1) - number of crashes
net.PS_CAR (2) - number of destroyed vehicles
net.PS_PLANE (3) - ... planes/helicopters
net.PS_SHIP (4) - ... ships
net.PS_SCORE (5) - total score
net.PS_LAND (6) - number of landings
net.PS_EJECT (7) - of ejects
mynet:GetPlayerStatistic(Client,7) -- return number of ejects
Get player UCID from player CLIENT object or player name.
Provide either one.
Defined in:
NET
Parameters:
Wrapper.Client#CLIENT Client
The client object to be used.
#string Name
Player name to be used.
Return value:
#boolean:
success
Returns the playerID of the server.
Currently always returns 1.
Defined in:
NET
Return value:
#number:
ID
Returns the SideId and SlotId of a given client.
Defined in:
NET
Parameter:
Wrapper.Client#CLIENT Client
The client
Return values:
#number:
SideID i.e. 0 : spectators, 1 : Red, 2 : Blue
#number:
SlotID
[Internal] Check any blockers
Defined in:
NET
Parameters:
#string UCID
#string Name
#number PlayerID
#number PlayerSide
#string PlayerSlot
Return value:
#boolean:
IsBlocked
Converts a JSON string to a lua value.
Defined in:
NET
Parameter:
#string Json
Anything JSON
Return value:
#table:
Lua
Kicks a player from the server.
Can display a message to the user.
Defined in:
NET
Parameters:
Wrapper.Client#CLIENT Client
The client
#string Message
(Optional) The message to send.
Return value:
#boolean:
success
Write an "INFO" entry to the DCS log file, with the message Message.
Converts a lua value to a JSON string.
Defined in:
NET
Parameter:
#string Lua
Anything lua
Return value:
#table:
Json
FSM Function OnAfterPlayerBlocked.
Defined in:
NET
Parameters:
#string From
State.
#string Event
Trigger.
#string To
State.
Wrapper.Client#CLIENT Client
Client Object, might be nil.
#string Name
Name of blocked Pilot.
#number Seconds
Blocked for this number of seconds
Return value:
#NET:
self
FSM Function OnAfterPlayerDied.
Defined in:
NET
Parameters:
#string From
State.
#string Event
Trigger.
#string To
State.
Wrapper.Unit#UNIT Client
Unit Object, might be nil.
#string Name
Name of dead Pilot.
Return value:
#NET:
self
FSM Function OnAfterPlayerEjected.
Defined in:
NET
Parameters:
#string From
State.
#string Event
Trigger.
#string To
State.
Wrapper.Unit#UNIT Client
Unit Object, might be nil.
#string Name
Name of leaving Pilot.
Return value:
#NET:
self
FSM Function OnAfterPlayerJoined.
Defined in:
NET
Parameters:
#string From
State.
#string Event
Trigger.
#string To
State.
Wrapper.Client#CLIENT Client
Object.
#string Name
Name of joining Pilot.
Return value:
#NET:
self
FSM Function OnAfterPlayerLeft.
Defined in:
NET
Parameters:
#string From
State.
#string Event
Trigger.
#string To
State.
Wrapper.Unit#UNIT Client
Unit Object, might be nil.
#string Name
Name of leaving Pilot.
Return value:
#NET:
self
FSM Function OnAfterPlayerUnblocked.
Defined in:
NET
Parameters:
#string From
State.
#string Event
Trigger.
#string To
State.
Wrapper.Client#CLIENT Client
Client Object, might be nil.
#string Name
Name of unblocked Pilot.
Return value:
#NET:
self
Force a client back to spectators.
If this returns false, it didn't work via net
(which is ALWAYS the case as of Nov 2024)!
Send chat message.
Defined in:
NET
Parameters:
#string Message
Message to send
#boolean ToAll
(Optional)
Return value:
#NET:
self
Send chat message to a specific player using the CLIENT object.
Defined in:
NET
Parameters:
#string Message
The text message
Wrapper.Client#CLIENT ToClient
Client receiving the message
Wrapper.Client#CLIENT FromClient
(Optional) Client sending the message
Return value:
#NET:
self
Send chat message to a specific player using the player name
Defined in:
NET
Parameters:
#string Message
The text message
#string ToPlayer
Player receiving the message
#string FromPlayer
Optional) Player sending the message
Return value:
#NET:
self
Set block chat message.
Set block time in seconds.
Defined in:
NET
Parameter:
#number Seconds
Numnber of seconds this block will last. Defaults to 600.
Return value:
#NET:
self
Set unblock chat message.
Unblock a player.
Defined in:
NET
Parameters:
Wrapper.Client#CLIENT Client
CLIENT object
#string PlayerName
(optional) Name of the player.
#string Message
(optional) Message to be sent via chat.
Return value:
#NET:
self
Unblock a SET_CLIENT of players
Defined in:
NET
Parameters:
Core.Set#SET_CLIENT PlayerSet
The SET to unblock.
#string Message
(optional) Message to be sent via chat.
Return value:
#NET:
self
Unblock a specific coalition side.
Does NOT unblock specifically blocked playernames or UCIDs.
Defined in:
NET
Parameters:
#number side
The side to block - 1 : Red, 2 : Blue
#number Seconds
Seconds (optional) Number of seconds the player has to wait before rejoining.
self
Side
Return value:
#NET:
self
Unblock a specific slot.
Unblock a specific UCID of a player
[Internal] Event Handler
Stop the event functions
Status - housekeeping
Stop the event functions
Field(s)
Function(s)
Adds an End state.
Set the default #FSM_PROCESS template with key ProcessName providing the ProcessClass and the process object when it is assigned to a Wrapper.Controllable by the task.
Defined in:
Parameters:
#table From
Can contain a string indicating the From state or a table of strings containing multiple From states.
#string Event
The Event name.
Core.Fsm#FSM_PROCESS Process
An sub-process FSM.
#table ReturnEvents
A table indicating for which returned events of the SubFSM which Event must be triggered in the FSM.
Return value:
The SubFSM.
Adds a score for the FSM to be achieved.
Defined in:
Parameters:
#string State
is the state of the process when the score needs to be given. (See the relevant state descriptions of the process).
#string ScoreText
is a text describing the score that is given according the status.
#number Score
is a number providing the score of the status.
Return value:
#FSM:
self
Adds a score for the FSM_PROCESS to be achieved.
Defined in:
Parameters:
#string From
is the From State of the main process.
#string Event
is the Event of the main process.
#string State
is the state of the process when the score needs to be given. (See the relevant state descriptions of the process).
#string ScoreText
is a text describing the score that is given according the status.
#number Score
is a number providing the score of the status.
Return value:
#FSM:
self
Add a new transition rule to the FSM.
A transition rule defines when and if the FSM can transition from a state towards another state upon a triggered event.
Defined in:
Parameters:
#table From
Can contain a string indicating the From state or a table of strings containing multiple From states.
#string Event
The Event name.
#string To
The To state.
Get current state.
Returns the End states.
Returns a table of the SubFSM rules defined within the FSM.
Returns a table with the scores defined.
Returns the start state of the FSM.
Get current state.
Returns a table with the Subs defined.
Returns a table of the transition rules defined within the FSM.
Check if FSM is in state.
Defined in:
Parameter:
#string State
State name.
Return value:
#boolean:
If true, FSM is in this state.
Load call backs.
Sets the start state of the FSM.
Add to map.
Call handler.
Defined in:
Parameters:
#string step
Step "onafter", "onbefore", "onenter", "onleave".
#string trigger
Trigger.
#table params
Parameters.
#string EventName
Event name.
Return value:
Value.
Create transition.
Defined in:
Parameter:
#string EventName
Event name.
Return value:
#function:
Function.
Delayed transition.
Defined in:
Parameter:
#string EventName
Event name.
Return value:
#function:
Function.
Event map.
Go sub.
Defined in:
Parameters:
#string ParentFrom
Parent from state.
#string ParentEvent
Parent event name.
Return value:
#table:
Subs.
Handler.
Is end state.
Defined in:
Parameter:
#string Current
Current state name.
Return values:
#table:
FSM parent.
#string:
Event name.
Sub maps.
Check if can do an event.
Defined in:
Parameter:
#string e
Event name.
Return values:
#boolean:
If true, FSM can do the event.
#string:
To state.
Check if cannot do an event.
Defined in:
Parameter:
#string e
Event name.
Return value:
#boolean:
If true, FSM cannot do the event.
Check if FSM is in state.
Defined in:
Parameters:
#string State
State name.
state
Return value:
#boolean:
If true, FSM is in this state.