Template:Scripting/Squirrel/Functions/Client DataTypes: Difference between revisions

From Vice City Multiplayer
Jump to navigation Jump to search
Caution icon
This wiki is using an old backup from 2020
Some information may be old/missing
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
=== Vector ===
=== Vector ===
{{Scripting/Squirrel/ClientFunctions/Data Types/Vector}}
* Constructor '''Vector(x, y, z)'''
** ''Parameter types: float, float, float''
 
* Constructor '''Vector(vector)'''
** ''Parameter types: Vector''
** Creates a copy of the specified vector.
 
* Property '''X'''
** ''Type: float''
 
* Property '''Y'''
** ''Type: float''
 
* Property '''Z'''
** ''Type: float''
 
* Operator '''+'''
** ''Return type: Vector''
** Adds the values of two vectors together and returns a new instance.


=== VectorScreen ===
=== VectorScreen ===
{{Scripting/Squirrel/ClientFunctions/Data Types/VectorScreen}}
* Constructor '''VectorScreen(x, y)'''
** ''Parameter types: int, int''
 
* Constructor '''VectorScreen(screenVector)'''
** ''Parameter types: VectorScreen''
** Creates a copy of the specified screen vector.
 
* Property '''X'''
** ''Type: int''
 
* Property '''Y'''
** ''Type: int''


=== Colour ===
=== Colour ===
{{Scripting/Squirrel/ClientFunctions/Data Types/Colour}}
* Constructor '''Colour(r, g, b, a)'''
** ''Parameter types: int, int, int, int''
 
* Constructor '''Colour(r, g, b)'''
** ''Parameter types: int, int, int''
** Alpha is set to 255.
 
* Constructor '''Colour(colour)'''
** ''Parameter types: Colour''
** Creates a copy of the specified colour.
 
* Property '''R'''
** ''Type: int''
 
* Property '''G'''
** ''Type: int''
 
* Property '''B'''
** ''Type: int''
 
* Property '''A'''
** ''Type: int''
 
* Property '''Hex'''
** ''Type: int''


=== KeyBind ===
=== KeyBind ===
{{Scripting/Squirrel/ClientFunctions/Data Types/KeyBind}}
Key values are virtual key codes. When a keybind is created, events about it will start coming, no need to register the keybind anywhere. To make a keybind not send events anymore, all references to it must be removed.
 
You can use '''/recordkey''' in game to get a key code.
 
* Constructor '''KeyBind(keyOne)'''
** ''Parameter types: int''
 
* Constructor '''KeyBind(keyOne, keyTwo)'''
** ''Parameter types: int, int''
 
* Constructor '''KeyBind(keyOne, keyTwo, keyThree)'''
** ''Parameter types: int, int, int''


=== RayTrace ===
=== RayTrace ===
{{Scripting/Squirrel/ClientFunctions/Data Types/RayTrace}}
When ray trace is created, the properties from it will contain the results.
 
* Constructor '''RayTrace(start, end, flags)'''
** ''Parameter types: Vector, Vector, flags''
** Flag values can be or-ed together with the | operator to select which types of entities it should check: RAY_BUILDING, RAY_PED, RAY_VEHICLE, RAY_OBJECT.
 
* Property '''Collided''' (read-only)
** ''Type: bool''
** True when the ray hit something.
 
* Property '''Entity''' (read-only)
** ''Type: entity''
** The entity that was hit, or null if nothing was hit. May also be null if the entity has been destroyed.
 
* Property '''Position'''
** ''Type: Vector''
** The position of the collision, or zero vector if nothing was hit.


=== Stream ===
=== Stream ===
{{Scripting/Squirrel/ClientFunctions/Data Types/Stream}}
Used to construct the packet to send to the server or to read the data sent by the server. Read functions cannot be used on streams that were created by the script. The format of the stream is little-endian, with the exception that strings are written as a big-endian 2-byte length followed by the characters. Check Server::SendData for sending the stream or event Server::ServerData for receiving it.
 
* Constructor '''Stream()'''
** Creates a new stream for writing, which can be sent to the server.
 
* Function '''ReadByte()'''
** ''Return type: int''
** Reads a single byte from the stream.
 
* Function '''ReadInt()'''
** ''Return type: int''
** Reads an integer (4 bytes) from the stream.
 
* Function '''ReadFloat()'''
** ''Return type: float''
** Reads a float (4 bytes) from the stream.
 
* Function '''ReadString()'''
** ''Return type: float''
** Reads a string from the stream.
 
* Function '''WriteByte(value)'''
** ''Parameter types: int. Return type: void''
** Writes a single byte to the stream.
 
* Function '''WriteInt(value)'''
** ''Parameter types: int. Return type: void''
** Writes an integer (4 bytes) to the stream.
 
* Function '''WriteFloat(value)'''
** ''Parameter types: float. Return type: void''
** Writes a float (4 bytes) to the stream.
 
* Function '''WriteString(value)'''
** ''Parameter types: string. Return type: void''
** Writes a string to the stream.
 
* Property '''Error''' (read-only)
** ''Type: bool''
** Whether writing exceeded the maximum stream size, or a read call tried to read past the end of the stream.


=== Player ===
=== Player ===
{{Scripting/Squirrel/ClientFunctions/Data Types/Player}}
* Property '''Type''' (read-only)
** ''Type: int''
** The type of this entity, always OBJ_PLAYER.
 
* Property '''ID''' (read-only)
** ''Type: int''
 
* Property '''Local''' (read-only)
** ''Type: bool''
** Whether this is the local player.
 
* Property '''Name''' (read-only)
** ''Type: string''
 
* Property '''Health''' (read-only)
** ''Type: float''
 
* Property '''Armour''' (read-only)
** ''Type: float''
 
* Property '''Position''' (bound)
** ''Type: Vector''


=== Vehicle ===
=== Vehicle ===
{{Scripting/Squirrel/ClientFunctions/Data Types/Vehicle}}
Vehicle position and speed can only be changed if the vehicle is currently controlled by the current player (either a driver, passenger or the closest player).
 
* Property '''Type''' (read-only)
** ''Type: int''
** The type of this entity, always OBJ_VEHICLE.
 
* Property '''ID''' (read-only)
** ''Type: int''
 
* Property '''ModelIndex''' (read-only)
** ''Type: int''
 
* Property '''Health''' (read-only)
** ''Type: float''
 
* Property '''Position''' (bound)
** ''Type: Vector''
 
* Property '''Speed''' (bound)
** ''Type: Vector''
 
* Function '''GetOccupant(slot)'''
** ''Parameter types: int. Return type: Player''
** The value passed to it is the slot number. 0 for driver, 1-8 for passengers.


=== Building ===
=== Building ===
{{Scripting/Squirrel/ClientFunctions/Data Types/Building}}
* Property '''Type''' (read-only)
** ''Type: int''
** The type of this entity, always OBJ_BUILDING.
 
* Property '''ModelIndex''' (read-only)
** ''Type: int''
 
* Property '''Position''' (read-only)
** ''Type: Vector''

Latest revision as of 06:19, 29 July 2016

Vector

  • Constructor Vector(x, y, z)
    • Parameter types: float, float, float
  • Constructor Vector(vector)
    • Parameter types: Vector
    • Creates a copy of the specified vector.
  • Property X
    • Type: float
  • Property Y
    • Type: float
  • Property Z
    • Type: float
  • Operator +
    • Return type: Vector
    • Adds the values of two vectors together and returns a new instance.

VectorScreen

  • Constructor VectorScreen(x, y)
    • Parameter types: int, int
  • Constructor VectorScreen(screenVector)
    • Parameter types: VectorScreen
    • Creates a copy of the specified screen vector.
  • Property X
    • Type: int
  • Property Y
    • Type: int

Colour

  • Constructor Colour(r, g, b, a)
    • Parameter types: int, int, int, int
  • Constructor Colour(r, g, b)
    • Parameter types: int, int, int
    • Alpha is set to 255.
  • Constructor Colour(colour)
    • Parameter types: Colour
    • Creates a copy of the specified colour.
  • Property R
    • Type: int
  • Property G
    • Type: int
  • Property B
    • Type: int
  • Property A
    • Type: int
  • Property Hex
    • Type: int

KeyBind

Key values are virtual key codes. When a keybind is created, events about it will start coming, no need to register the keybind anywhere. To make a keybind not send events anymore, all references to it must be removed.

You can use /recordkey in game to get a key code.

  • Constructor KeyBind(keyOne)
    • Parameter types: int
  • Constructor KeyBind(keyOne, keyTwo)
    • Parameter types: int, int
  • Constructor KeyBind(keyOne, keyTwo, keyThree)
    • Parameter types: int, int, int

RayTrace

When ray trace is created, the properties from it will contain the results.

  • Constructor RayTrace(start, end, flags)
    • Parameter types: Vector, Vector, flags
    • Flag values can be or-ed together with the | operator to select which types of entities it should check: RAY_BUILDING, RAY_PED, RAY_VEHICLE, RAY_OBJECT.
  • Property Collided (read-only)
    • Type: bool
    • True when the ray hit something.
  • Property Entity (read-only)
    • Type: entity
    • The entity that was hit, or null if nothing was hit. May also be null if the entity has been destroyed.
  • Property Position
    • Type: Vector
    • The position of the collision, or zero vector if nothing was hit.

Stream

Used to construct the packet to send to the server or to read the data sent by the server. Read functions cannot be used on streams that were created by the script. The format of the stream is little-endian, with the exception that strings are written as a big-endian 2-byte length followed by the characters. Check Server::SendData for sending the stream or event Server::ServerData for receiving it.

  • Constructor Stream()
    • Creates a new stream for writing, which can be sent to the server.
  • Function ReadByte()
    • Return type: int
    • Reads a single byte from the stream.
  • Function ReadInt()
    • Return type: int
    • Reads an integer (4 bytes) from the stream.
  • Function ReadFloat()
    • Return type: float
    • Reads a float (4 bytes) from the stream.
  • Function ReadString()
    • Return type: float
    • Reads a string from the stream.
  • Function WriteByte(value)
    • Parameter types: int. Return type: void
    • Writes a single byte to the stream.
  • Function WriteInt(value)
    • Parameter types: int. Return type: void
    • Writes an integer (4 bytes) to the stream.
  • Function WriteFloat(value)
    • Parameter types: float. Return type: void
    • Writes a float (4 bytes) to the stream.
  • Function WriteString(value)
    • Parameter types: string. Return type: void
    • Writes a string to the stream.
  • Property Error (read-only)
    • Type: bool
    • Whether writing exceeded the maximum stream size, or a read call tried to read past the end of the stream.

Player

  • Property Type (read-only)
    • Type: int
    • The type of this entity, always OBJ_PLAYER.
  • Property ID (read-only)
    • Type: int
  • Property Local (read-only)
    • Type: bool
    • Whether this is the local player.
  • Property Name (read-only)
    • Type: string
  • Property Health (read-only)
    • Type: float
  • Property Armour (read-only)
    • Type: float
  • Property Position (bound)
    • Type: Vector

Vehicle

Vehicle position and speed can only be changed if the vehicle is currently controlled by the current player (either a driver, passenger or the closest player).

  • Property Type (read-only)
    • Type: int
    • The type of this entity, always OBJ_VEHICLE.
  • Property ID (read-only)
    • Type: int
  • Property ModelIndex (read-only)
    • Type: int
  • Property Health (read-only)
    • Type: float
  • Property Position (bound)
    • Type: Vector
  • Property Speed (bound)
    • Type: Vector
  • Function GetOccupant(slot)
    • Parameter types: int. Return type: Player
    • The value passed to it is the slot number. 0 for driver, 1-8 for passengers.

Building

  • Property Type (read-only)
    • Type: int
    • The type of this entity, always OBJ_BUILDING.
  • Property ModelIndex (read-only)
    • Type: int
  • Property Position (read-only)
    • Type: Vector