Types & Variables
Primitive types, handles, null and type rules.
Primitive types
| Type | Description |
|---|---|
int | 64-bit signed integer (decimal or 0x hex) |
float | 64-bit floating point |
string | UTF-8 text |
bool | true / false |
array | Ordered list |
map | String-keyed dictionary |
null | Absence of a value |
Handle types
Callback parameters can be typed as engine handles. Natives still take plain integer ids.
knight
player::death(int playerid, Player killer, int reason) {
if (killer != null) {
SendClientMessage(playerid, "You were killed by {PlayerName(killer)}.");
}
};
Optional annotations
knight
let score: int = 0;
let speed: float = 1.5;
Checking types at runtime
knight
let v = GetPlayerMoney(playerid);
if (is_number(v)) {
Log("money is a number: " + str(v));
}
Log("type is " + typeof(v));