- Functions in PawnScript are called forms; to use certain native forms, you need to import standard built-in components into your code. For example - to use
cout
, you need to have aconsole
interpreter component imported. Below, you can find the full list of available components.
- Provides console-related forms.
Import the component using:
using console
- Character output.
console.cout('c')
- Character input. Code execution will not be stopped, only a destination variable in which the RCON input will be stored is set.
console.cin(destvar)
- Text line output.
console.println("Hello World!")
- Text line input. Code execution will not be stopped, only a destination variable in which the RCON input will be stored is set.
console.inputln(destvar)
- Raw text output.
console.rawout(RandomTextIg??)
- Provides random, usually internal, forms.
Import the component using:
using system
- Comments.
system.rem("SOME TEXT")
- Used to initialize the arguments.
int arginit_test(num,string) public
{
return 1
}
system.arginit(arginit_test,1,"Hello!")
- Prints out the system version information.
system.ver()
Output:
PawnScript 1.0.8-R2 Brace Inc.
Pawn 3.10.11 ITB CompuPhase
- Sets the current working directory. Example:
// Create a directory named 'MyNewDir' in scriptfiles
files.createdir("MyNewDir")
// Set that as a working directory
system.cd("MyNewDir/")
// Create 'SubMyNewDir' inside
files.createdir("SubMyNewDir")
// Set MyNewDir/SubMyNewDir/ as working dir
system.cd("SubMyNewDir/")
// Create a file inside 'MyNewDir/SubMyNewDir/'
files.open_for_write("test.txt")
files.write("wrote this.")
files.close
system.cd(".."); // Reset back to scriptfiles
// Create a new folder in scriptfiles named 'MyNewDirAgain'
files.createdir("MyNewDirAgain")
NOTE: Always put /
after the directory name when using system.cd
; or /
before a file name when using files.open_...
- either one of those, never both or noone.
- Called when the code gets executed.
@extern
this->struct=default
int main() public
{
console.println("Hello World from main");
return int 1
}
- Provides file-related forms.
Import the component using:
using files
- Opens a file with an intention to write data into it. File is created if it does not exist.
files.open_for_write("file_name.txt")
- Opens a file with an intention to read data from it. File is created if it does not exist.
files.open_for_read("file_name.txt")
- Opens a file with an intention to append data into it. File is created if it does not exist.
files.open_for_append("file_name.txt")
- Reads data from the opened file and stores it into a variable.
new.str,dest_string="something that should change"
files.read(dest_string)
- Writes data into the opened file.
files.write("wrote this into file_name.txt")
- Closes the opened file.
files.close
- Deletes a certain file.
files.delete("newfile.omg")
- Creates a directory.
files.createdir("mydir")
- Provides miscellaneous forms.
Import the component using:
using misc
- Swaps two's variable values.
misc.swap(var1,var2)
NOTE: Now variable var1
will have the value var2
had, and var2
will have the value var1
had.
- Provides forms for data management.
Import the component using:
using data
- Parses and splits a string.
using data
new.str,scanftest1="ok"
new.str,scanftest2="ok"
new.str,scanftest3="ok"
new.str,scanftest4="ok"
new.int,scanftest5=2453
new.int,scanftest6=2453
new.str,scanftest="sscanf-is-so-cool-1-2"
data.sscanf(scanftest,scanftest1,scanftest2,scanftest3,scanftest4,scanftest5,scanftest6)
console.println.log(scanftest1)
console.println.log(scanftest2)
console.println.log(scanftest3)
console.println.log(scanftest4)
console.cout(scanftest5)
console.cout(scanftest6)
Output:
sscanf
is
so
cool
1
2
WARNING: Current sscanf
delimiter is -
because of some limitations we're facing, it may be changed in the future.
- Returns a distance between 2 strings.
data.strdist("hi", "hi") myretref
console.println.log("myretref is {myretref}")
Output:
myretref is 0
Unlike most of the functions, whose return 0 for failed operation and 1 for successful operation, this one returns 65535 for failed operation and integer distance (difference) between 2 strings. In example above, myretref
is 0 because the 2 strings are the same.
- Exports or imports a variable depending on lastly used persistent data management decorator.
@export
this->typename=int
this->from=var
this->to=newvar
data.persistent
Just returns 1.
- Provides forms for interaction with the Pawn language.
Import the component using:
using pawn
- Calls a public function declared in the running Pawn code.
pawn.callfunction("public_name")
- Mathematical operations and functions.
Import the component using:
using math
- Calculates the distance between two 3-dimensional points.
math.vectorsize(234.1,4211.3,43.3,-43.33,-0.1,-823) myretref; // Pretty random coordinates.
console.rawout.log(myretref)
Output:
4308.519042
This function is also one of those which have a specific return value, 0.0 is returned if the operation has failed or if the distance is REALLY just zero, and a specific double
number will be returned if the operation is executed successfully.
- Iterator-related functions.
For further information, check the data structure and foreach
documentation.
- Vector-related functions.
For further information, check the data structure and foreach
documentation.
- Graphics-related functions.
Import the component using:
using graphics
- Clean up the graphics grid.
graphics.cls
- Show the graphics grid in your console.
graphics.show
- "Activate" a specific pixel on the graphics grid.
graphics.showpixel(row, column)
Example:
graphics.showpixel(9,50)
Output:
[Info] PawnScript: Graphics Mode Version: [Gs2]
[Info] [Rows: 20 Columns: 100]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info]
[Info] Powered by: Pawn Release: 3.10.11
- Stack-related functions.
For further information, check the data structure and foreach
documentation.
- Bit array-related functions.
For further information, check the data structure and foreach
documentation.