06.09.2011, 13:01
Well, first of all this is not really a tutorial, but rather some useful information that I discovered recently. It involves using the @ symbol to declare public functions.
For example, suppose you have this public function:
Now, we can declare this function in a different way using the @ symbol;
The difference herein is that the @ symbol is now part of the function name (as seen in the forward declaration), while still declaring that function as public and without the need of the 'public' keyword. To call the function via SetTimer/Ex or CallLocal/RemoteFunction you need to include the @ symbol in there too. Example:
The main advantage of using this method is that the actual function name becomes available again for you to use for other function- or even variable names; for example you can have this setup which won't give an error:
Whereas
WILL give an error (error 021: symbol already defined).
Important Note: This method will not work for the default SA-MP callbacks (ex. OnPlayerConnect) for the reasons stated above!
For example, suppose you have this public function:
pawn Код:
forward CallTimer(playerid);
public CallTimer(playerid)
{
// unimportant stuff
}
pawn Код:
forward @CallTimer(playerid);
@CallTimer(playerid)
{
// unimportant stuff
}
pawn Код:
SetTimerEx("@CallTimer", 10000, false, "d", playerid);
pawn Код:
@CallTimer(playerid)
{
// unimportant stuff
}
stock CallTimer(/* params */)
{
// more stuff
}
pawn Код:
public CallTimer(playerid)
{
// unimportant stuff
}
stock CallTimer(/* params */)
{
// more stuff
}
Important Note: This method will not work for the default SA-MP callbacks (ex. OnPlayerConnect) for the reasons stated above!