Module core.plugins.zz_networking.sh_init
Shared Networking Module
Module Overview
Functions
| PLUGIN:isPositive(value) | Checks if a value is positive. |
| PLUGIN:isFloat(value) | Checks if the value is a float. |
| PLUGIN:getIntegerBits(value) | Gets the amount of bits required to network an integer value. |
| PLUGIN:isNormalVector(vec) | Checks if a vector can be transfered as a normalised vector (all values < 1) |
| PLUGIN:getValueType(value) | Function to get the networking type of a value. |
| PLUGIN:writeType(val) | Function to automatically detect type of value, and add to the network stack. |
| PLUGIN:readType() | Function to automatically read a random variable from the stack, dependent upon its type prefix. |
| PLUGIN:sendType(val) | Duplicate of writeType. |
| PLUGIN:readRawType(type) | Function to read a raw value from the stack, with a given type. |
| PLUGIN:registerNSVar(name) | Function to register a NSVariable. |
| PLUGIN:registerLocalPlyVar(name, type) | Function to register a LPlyVar of given type. |
Tables
| PLUGIN.registered | List of registered Net Shared Variables / Local Player Variables. |
| PLUGIN.varLookup | List of registered vars, indexed in reverse to allow lookup. |
Fields
| PLUGIN.keyBitsNSVar | The number of bits required to transfer our key ID. |
| PLUGIN.typeBits | The number of bits required to transfer our network type. |
- PLUGIN:isPositive(value)
-
Checks if a value is positive.
Parameters:
- value to check.
Returns:
-
boolean | True if positive.
- PLUGIN:isFloat(value)
-
Checks if the value is a float.
NOTE: For values which are floats, but for which conversion to int would not lose precision, this returns FALSE.
EX. isFloat(1.00000) = false
Parameters:
- value Value to check.
Returns:
-
bool If the value is a float.
- PLUGIN:getIntegerBits(value)
-
Gets the amount of bits required to network an integer value.
Parameters:
- value The number to check.
Returns:
-
integer The number of bits required.
- PLUGIN:isNormalVector(vec)
-
Checks if a vector can be transfered as a normalised vector (all values < 1)
Parameters:
- vec Vector to check.
Returns:
-
boolean | If the vector vec is normalized.
- PLUGIN:getValueType(value)
-
Function to get the networking type of a value.
Parameters:
- value The value to check against.
Returns:
-
integer NETTYPE_ enum, representing the value.
- PLUGIN:writeType(val)
-
Function to automatically detect type of value, and add to the network stack.
Parameters:
- val The value to send.
- PLUGIN:readType()
-
Function to automatically read a random variable from the stack, dependent upon its type prefix.
Returns:
-
mixed Data from network stack.
- PLUGIN:sendType(val)
-
Duplicate of writeType.
Parameters:
- val Value to send.
See also:
- PLUGIN:readRawType(type)
-
Function to read a raw value from the stack, with a given type.
Parameters:
- type Type to read.
Returns:
-
mixed Return value from the stack.
- PLUGIN:registerNSVar(name)
-
Function to register a NSVariable.
WARNING: Must be called in the SHARED space, at the same point in script initilisation. Failure to do so WILL break shit.
Parameters:
- name The name of the NSVar to register.
Returns:
-
integer ID of which the NSVar was registered into.
- PLUGIN:registerLocalPlyVar(name, type)
-
Function to register a LPlyVar of given type.
WARNING: Must be called in the SHARED space, at the same point in script initilisation. Failure to do so WILL break shit.
Parameters:
- name The name of the LPlyVar to register.
- type The NETTYPE_ of which the variable will be.
Returns:
-
integer ID of which the NSVar was registered into.