Character
A character object in Ratchet represents an online player.
Members
Characters have only one variable member, which is ID
- this is the same number as Character Unique ID in the DevKit (see the image below) and also as the database ID.
It is also used in Tot scripts as a backend variable to represent players. Therefore you can freely convert this number to a player and a player to this ID in Tot scripts.
And in Ratchet plugins you can also use getPlayerFromID to create a character object from this ID, which is the only way to construct a character object without retrieving it from events or from functions like getPlayersInRadius.
getPlayerFromID
function
Create a character object from the player's database ID.
Syntax:
Character|nil getPlayerFromID( int id )
Example:
local player = getPlayerFromID(301)
print(type(player))
getPlayerFromName
function
Find a player by their character's real name (this will ignore /act
names and similar).
Syntax:
Character|nil getPlayerFromName( string name )
Example:
local player = getPlayerFromName("Bob")
print(type(player))
getPlayersInRadius
function
Returns a table with all players in radius of specified number of tiles from a vector position.
Syntax:
table<Character> getPlayersInRadius( Vector position, float radius )
Example:
-- all players in radius of 10 tiles from the caster
local players = getPlayersInRadius(caster:GetPosition(), 10)
getAllPlayers
function
Returns a table of all players online on the server.
Syntax:
table<Character> getAllPlayers()
getPlayerCount
function
Returns a number of online players on the server.
Syntax:
int getPlayerCount()
GetName
function
Returns a display name of a character. This will use /act
name if applicable.
Syntax:
string Character:GetName()
Example:
local name = player:GetName()
print(name)
GetRealName
function
Returns the actual character name as it exists in the database (ignoring /act
and similar).
Syntax:
string Character:GetRealName()
Example:
local name = player:GetRealName()
print(name)
GetSteamID
function
Returns SteamID64 (decimal), it is just a long number, but it is saved as a string.
Syntax:
string Character:GetSteamID()
Example:
local steamId = player:GetSteamID()
print(steamId)
GetGuildID
function
Returns the database ID of a clan the player is a member of.
Syntax:
int Character:GetGuildID()
Example:
local guildId = player:GetGuildID()
print(guildId)
GetPosition
function
Returns a vector of the current coordinates of player's position in the game world.
Syntax:
Vector Character:GetPosition()
GetFeetPosition
function
Syntax:
Vector Character:GetFeetPosition()
Example:
local position = player:GetPosition()
print(position.x, position.y, position.z)
GiveItem
function
Syntax:
bool Character:GiveItem( int itemId [, int quantity = 1 ] )
Notify
function
Shows a HUD notification to a player.
Syntax:
void Character:Notify( string icon, string text [, Color iconColor ] )
Available icons:
These beautiful icons come from Phosphor Icons, permitted under MIT License.
ExecuteConsoleCommand
function
Syntax:
void Character:ExecuteConsoleCommand( string command )