SA-MP Forums Archive
[SA-MP plugins] static functions - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: [SA-MP plugins] static functions (/showthread.php?tid=529469)



[SA-MP plugins] static functions - Baltazar - 02.08.2014

Example function copied from Pawn Impementer's Guide
Код:
static cell n_sin(AMX *amx, const cell *params)
{
  float r = sin( amx_ctof(params[1]) );
  return ftoc®;
}
Everyting is quite clear here. Except for the fact, that function is declared static! Not all of them are declared using this keyword however. Can anyone explain, what's the point using it?


Re: [SA-MP plugins] static functions - Stanford - 02.08.2014

This function can be used only in the file that they were declared.

So if you put include after that function for a file it won't work because this function is made for the file that it's in only.

I hope I helped any feedback would be appreciated.


Re: [SA-MP plugins] static functions - Baltazar - 02.08.2014

Let's say I introduce two static functions with the same name in a header file and in a source file. They both do different stuff though. You mean these would not interfere somehow? Code would compile well?


Re: [SA-MP plugins] static functions - Stanford - 02.08.2014

Yes I believe. By the way, if you have big codes that contain complex scripting then use static to not have human errors. For example: I put "static ninja(playerid, whatever) in a file in another file that is already included I can use static ninja in another structure.