Can someone explain me the right way of using forward/stock/public...
#6

Forward is used when you create a new function.
You can use it if you want to create one like "SaveStats", so you should use:
pawn Код:
forward SaveStats(playerid);
public SaveStats(playerid)
{
     // Stuff here...
     return 1;
}
On the other hand, stocks don't need forwards, so you can just use:
pawn Код:
stock SaveStats(playerid)
{
     // Some other stuff...
     return 1; // Not necessary...
}
You can also use stock if you want to return some variable/string, cause forward and public won't allow you to do that:
pawn Код:
stock CreateString(playerid)
{
     new string[256];
     format(string, sizeof(string), "My ID is %d", playerid);
     return string;
}
Reply


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)