Nu te inregistra daca esti idiot sau agramat!
AlphaCS.RO[ORIGINAL GAMING]
Thanks:
0
Likes:
0
-
[Tutorial] Function Type Explanation (stock, public, plain)
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.
Similar Threads
-
By SergiuOfficial in forum Tutoriale
Replies: 0
Last Post: 09-07-17, 18:28
-
By SergiuOfficial in forum Tutoriale
Replies: 0
Last Post: 19-06-17, 11:23
-
By SiNiSTER in forum Tutoriale
Replies: 0
Last Post: 23-11-16, 20:11
-
By SiNiSTER in forum Plugins
Replies: 0
Last Post: 30-07-16, 11:07
-
By SiNiSTER in forum Plugins
Replies: 0
Last Post: 04-07-16, 20:51
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules