Posts: 120
Threads: 30
Joined: Feb 2014
Reputation:
0
Hey guys, i want to ask to you, what make forward BlaBla(); public BlaBla() and BlaBla() (( Without public tag )) different?
Posts: 10,066
Threads: 38
Joined: Sep 2007
Reputation:
0
A public function is "visible" to the server. Its name is stored as a literal string in the compiled gamemode so the server can find it by name, whereas regular functions are converted to addresses. The server knows it needs to execute thing X at address Y, but names aren't important. A function need only be public if the server itself needs to find it. This includes the callbacks and timers.
stock is a modifier that hides a variable or function from the compiler if it's not used. There is zero need to use stock in a normal gamemode. It is only useful in included files because the person using those files may or may not use all the features.
Posts: 1,733
Threads: 20
Joined: Nov 2010
Reputation:
0
Also CallRemoteFunction is used with public functions.
That way you can execute a function in a filterscript with code inside your gamemode for example.
This makes it possible to allow 2 separate scripts to exchange data between them.
You may have a filterscript which controls fuel for your vehicles.
Your gamemode could also create vehicles, but will require a function call to your filterscript to set/get fuel values for that vehicle.
If you don't use publics, you can't do this, as the function isn't "public" to the server and/or other scripts.