PDA

View Full Version : Calling public function from other plugin?


Ms. Trooper
10-04-2014, 00:03
How would one go about calling a public function from another (different) plugin?

Thanks!

Marcus_Brown001
10-04-2014, 00:12
One way to do this is to use plugin natvies. Look at this (https://wiki.alliedmods.net/Creating_Natives_(SourceMod_Scripting)) for more information.

Impact123
10-04-2014, 01:11
Here (https://github.com/Impact123/CallAdmin/blob/development/gameserver/calladmin.sp#L1119)'s a function which iterates all loaded plugins and calls a function by name on any plugin that has it.
Here (https://github.com/Impact123/CallAdmin/blob/development/gameserver/calladmin_ts3.sp#L219)'s the function that would be called by this.

While this works, you probably want to use real natives, examples can be found in the first file too.
The only reason we did it this way is because we needed to get a return value from from each plugin, you can't do that with forwards.

Official documentation on the subject, in addition to what marcus posted, can be found here (https://wiki.alliedmods.net/Function_Calling_API_%28SourceMod_Scripting%2 9) and here (https://wiki.alliedmods.net/Category:Sourcemod_scripting).

Marcus_Brown001
10-04-2014, 01:21
That's pretty neat. Thanks, Impact! :D