LibRPC: Difference between revisions
No edit summary |
|||
Line 1: | Line 1: | ||
Library used to execute functions or script send from server. Available with npc v1.6 beta onwards. For squirrel gamemode, see [[RFC]]. | Library used to execute functions or script send from server. Available with npc v1.6 beta onwards. For squirrel gamemode, see [[RFC]]. | ||
==Functions == | ==Functions == | ||
From v1.6 beta 4 and rpclib(plugin version 0x1100) onwards, npc can remotely execute functions of server, provided the server runs squirrel gamemode and player.IsAdmin=true for npc. The following functions are added to npcscripts: | From v1.6 beta 4 and rpclib(plugin version 0x1100) onwards, npc can remotely execute functions of server, provided the server runs squirrel gamemode and <source lang="lua" inline>player.IsAdmin=true</source> for npc. The following functions are added to npcscripts: | ||
*[[LibRPC_F|F]] | *[[LibRPC_F|F]] | ||
*[[LibRPC_RFC|RFC]] | *[[LibRPC_RFC|RFC]] | ||
==ServerData Identifier== | ==ServerData Identifier== | ||
LibRPC when loaded works on server data whose first four bytes is the following: | LibRPC when loaded works on server data whose first four bytes is the following: |
Revision as of 09:51, 3 May 2023
Library used to execute functions or script send from server. Available with npc v1.6 beta onwards. For squirrel gamemode, see RFC.
Functions
From v1.6 beta 4 and rpclib(plugin version 0x1100) onwards, npc can remotely execute functions of server, provided the server runs squirrel gamemode and player.IsAdmin=true
for npc. The following functions are added to npcscripts:
ServerData Identifier
LibRPC when loaded works on server data whose first four bytes is the following:
Offset | Type | Value |
---|---|---|
0 | Integer | 0x40000000 |
ServerData structure
Offset | Type | Value | |
---|---|---|---|
4 | Character | 'F' or 'G' | Function |
Function structure
'F' type function
F type functions are those functions to be called through a name, ( unlike to be called through other methods see 'G' type functions ). The function name is encoded from offset 7.
Offset^ | Type | Value |
---|---|---|
0 | Character | 'F' |
1-4 | Unsigned Integer | size of the function buffer |
5-6 | unsigned short | length of the function name |
7 - 7+len(funcname)-1 | characters | Function Name |
7+len - ... | ... | ... |
^Offset relative to this buffer and not relative to ServerData ( complete buffer. )
'G' type function
G type functions (The name G because character F already taken ). They are functions returned by another function. So the buffer of the G type function contain another function which is first called and its return value, if it is a function, is then called. They can be said to be second order functions.
Offset^ | Type | Value |
---|---|---|
0 | Character | 'G' |
1-4 | Unsigned Integer | size of the buffer |
5 | Character | 'G' or 'F' |
... | ... | ... |
^Offset relative to 'G' function buffer and not relative to complete buffer of ServerData. Functions of higher order can be called through this method.
Example
Offset | Value | Explanation |
---|---|---|
0-3 | 00 00 00 40 |
0x40000000 |
4 | 46 | F |
5-8 | 00 00 00 0f | len of func buffer |
9-10 | 00 05 | len of func name (11-15) |
11-15 | 70 72 69 6e 74 | p r i n t |
16 | 73 | s (for string) |
17 | 00 05 | len of string (19-23) |
19-23 | 48 65 6c 6c 6f | H e l l o |
Other structures
String
Offset^ | Type | Value |
---|---|---|
0 | char | 's' |
1-2 | unsigned short | len of string |
3 - 3+len of string-1 | char sequence | the string |
Integers
Offset^ | Type | Value |
---|---|---|
0 | char | 'i' |
1-4 | int | integer |
Float
Offset^ | Type | Value |
---|---|---|
0 | char | 'f' |
1-4 | float | floating point number |
null
Offset^ | Type | Value |
---|---|---|
0 | char | 'o' |
bool
Offset^ | Type | Value |
---|---|---|
0 | char | 'b' |
1 | unsigned char | 0 or 1 |
Vector
Offset^ | Type | Value |
---|---|---|
0 | char | 'v' |
1-4 | float | Vector.x |
5-8 | float | Vector.y |
9-12 | float | Vector.z |
Quaternion
Offset^ | Type | Value |
---|---|---|
0 | char | 'q' |
1-4 | float | Quaternion.x |
5-8 | float | Quaternion.y |
9-12 | float | Quaternion.z |
13-16 | float | Quaternion.w |
Arrays
Offset^ | Type | Value |
---|---|---|
0 | char | 'a' |
1-4 | unsigned int | length of the array stream |
5 | char | ... |
^All Offsets relative to respective type buffers.