23.08.2013, 15:59
Can someone explain me, when should i use forward,stock,public...?
Explain by examples with explanation please.
Explain by examples with explanation please.
forward SaveStats(playerid);
public SaveStats(playerid)
{
// Stuff here...
return 1;
}
stock SaveStats(playerid)
{
// Some other stuff...
return 1; // Not necessary...
}
stock CreateString(playerid)
{
new string[256];
format(string, sizeof(string), "My ID is %d", playerid);
return string;
}
In general, functions do not need the public keyword. Don't add public to a function just because it looks nice. If you are an experienced scripter, it's quite easy to understand when a function should be public: A function should be public whenever "the server" must be able to call the function at run time. Always add public to your function when it is called by - a timer, (see also SetTimer and SetTimerEx), - CallLocalFunction, - CallRemoteFunction. |