2021-04-18: Keywords
Most people know that YSI adds foreach to the PAWN language, but here is a list of other keywords added by it:
remote functions are called in ALL other scripts, global functions are called in just one.
Most people know that YSI adds foreach to the PAWN language, but here is a list of other keywords added by it:
- foreach - Efficiently looping over sparse arrays and iterators.
Quote:
foreach (new i : Player) printf("Player %d", i);
- task - Timer function that is always running as long as the server is up.
Quote:
task Ping[1000]()
{
____printf("Ping");
}
- ptask - Similar to ?task?, but has a ?playerid? parameter.
Quote:
ptask PlayerPing[1000](playerid)
{
____printf("Ping %d", playerid);
}
- loadtext - Load localised string data for displaying text.
Quote:
loadtext core[ysi_properties];
- remote - A public function that can be called from other scripts with compile-time parameter checking.
Quote:
remote MyFunc(a, b[])
{
}
- broadcastfunc - Call a remote function in all other scripts.
Quote:
broadcastfunc MyFunc(42, "Hello World.");
- inline - Declare a function inside another function, and get access to the enclosing function?s variables.
Quote:
stock Outer(a)
{
____inline Inner(b)
____{
________printf("%d %d", a, b);
____}
}
- using - Pass an inline function to another function as a callback.
Quote:
INI_Parse(file, using inline Local_Parse);
- hook - Use a callback multiple times in multiple files without conflict.
Quote:
hook OnPlayerConnect(playerid)
{
}
- global - When running multiple scripts, only one should be in charge of, say, the anti-cheat. This declares a function as ?global?, such that all scripts can use it but only one script will be in charge.
Quote:
global AC_GiveWeapon(playerid, weaponid, ammo)
{
}
remote functions are called in ALL other scripts, global functions are called in just one.
- foreign - Goes with global to inform a script that this function is in a different script.
Quote:
foreign AC_GiveWeapon(playerid, weaponid, ammo);