AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Function Headers (https://forums.alliedmods.net/showthread.php?t=185302)

Liverwiz 05-15-2012 12:19

Function Headers
 
can anyone explain to me the different function header definitions in a simple way that an idiot such as myself can understand?
i.e. public, stock, none, etc

and how can i make a function private (so only this plugin can use it) and how can i make a function so another plugin on the server can use it?

Exolent[jNr] 05-15-2012 15:16

Re: Function Headers
 
If a function is anything except public, then it is only accessible in the plugin that includes it.

If a function is public, it can be accessed using callfuncs and forwards through other plugins.

Alternatively, you can declare a stock function in an include file, then include the .inc file in multiple plugins.

Liverwiz 05-15-2012 15:27

Re: Function Headers
 
So if i wanted to grab functions from another plugin (powers defined in a seperate amxx from the main class) i'd write them all public and call them regularly?

i.e.
Code:

Class: powers
public pwr_money(id){ cs_set_user_money(id, moneySet()) }

Then call it from......
Code:

Class: base
public plugin_init(){ pwr_money(15) }
public moneySet(){ return get_pcvar_num(money_cvar) }

or should i make that stock and include powers? :grrr:
This is kind of what i'm trying to accomplish, i'm just trying to figure out the best way to have two plugins communicate.

hleV 05-15-2012 17:43

Re: Function Headers
 
Quote:

Originally Posted by Exolent[jNr] (Post 1709554)
If a function is public, it can be accessed using callfuncs and forwards through other plugins.


fysiks 05-16-2012 03:20

Re: Function Headers
 
Quote:

Originally Posted by Liverwiz (Post 1709559)
So if i wanted to grab functions from another plugin (powers defined in a seperate amxx from the main class) i'd write them all public and call them regularly?

i.e.
Code:

Class: powers
public pwr_money(id){ cs_set_user_money(id, moneySet()) }

Then call it from......
Code:

Class: base
public plugin_init(){ pwr_money(15) }
public moneySet(){ return get_pcvar_num(money_cvar) }

or should i make that stock and include powers? :grrr:
This is kind of what i'm trying to accomplish, i'm just trying to figure out the best way to have two plugins communicate.

I would use dynamic natives. See the tutorial.


All times are GMT -4. The time now is 00:19.

Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.