Introduction

I made this tutorial to show people what the different function types are, when to use them, and what each of them do. I made this tutorial because everybody seemed to be using function types without actually knowing what they do.


Stock Functions

Explanation:

Stocks hide all warnings caused by that function from showing when compiling your script.

Usage:

Stocks shouldn't be used a lot unless you're making functions inside of an include.

Example:

Code:
stock includeName_DoAction(playerid)
{
// do stuff
}


Public Functions

Explanation:

Public functions can be called via CallLocalFunction, CallRemoteFunction, SetTimer, and SetTimerEx. Public functions cannot return strings. You are required to forward a public function ( forward functionName(params or blank) ) or you will receive a warning in the compiler.

Usage:

When creating a timer or a callback in an include, you should use a public function.

Example:

Code:
forward timer1();
public timer1()
{
// do stuff
}

Code:
forward includeName_OnAction(playerid);

if( ... )
{
CallRemoteFunction("includeName_OnAction", "d", playerid);
}


Plain Functions

Explanation:

Plain functions are just normal functions that do everything inside of the function.

Usage:

Plain functions should be used when you don't need to use a stock or a public for what you're trying to do.

Example:

Code:
IsPlayerEnemy(playerid, forplayerid)
{
// do stuff
}


Conclusion

Publics and stocks aren't needed most of the time and you can just use a plain function.