This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Executing a function with params...


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-15-2006 , 15:43   Executing a function with params...
Reply With Quote #1

Okay, I know the function MF_AmxExec(), that executes a function, but it doesn't allow paramters. How would I execute a function but with parameters.

Thanks...
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
BAILOPAN
Join Date: Jan 2004
Old 05-15-2006 , 18:01  
Reply With Quote #2

You shouldn't use MF_AmxExec(). You should use MF_RegisterForward/MF_ExecuteForward.

MF_RegisterSPForwardByName is for registering a forward in a single plugin, MF_RegisterForward is for registering a forward in all plugins.
__________________
egg
BAILOPAN is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-16-2006 , 14:50  
Reply With Quote #3

Well, i was going to do that but, I only want to execute the function on certain plugins...

p.s. love your avatar/sig pics and that "Searching...for the perfect program"
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
BAILOPAN
Join Date: Jan 2004
Old 05-16-2006 , 17:01  
Reply With Quote #4

Quote:
Originally Posted by Zenith77
Well, i was going to do that but, I only want to execute the function on certain plugins...
You can do this if you make a native like register_myforward(), and then use MF_RegisterSPForwardByName(). Using the forward system is highly recommended over MF_AmxExec() because it automates the debugger and copying of arrays/strings. If you use MF_AmxExec() and the plugin is in debug mode, it'll crash, and you have to know VM details to use it properly anyway (such as how to pass parameters).

MF_AmxExec() is only intended for old modules like CSX, which load mini-plugins that aren't registered.

Quote:
Originally Posted by Zenith77
p.s. love your avatar/sig pics and that "Searching...for the perfect program"
Thanks ;)
__________________
egg
BAILOPAN is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-17-2006 , 15:02  
Reply With Quote #5

Yes, but won't that execute that forward on all plugins that registered the native? Anyway, I think this should clear things up.


I'm creating a mod that has classes. I want to make it to where the class has special forwads such as when a person of the class spawns.
For example, when the create the class the author must use the SetForwards() native to define what forwards they want to use. Now in the module for the mod, when dispatch spawn is called, it gets the players id, checks if they have a class, gets the class, checks if the class has registered the forward (FW_SPAWN in this class, a binary bit), reterives the base amx structure, then executes the forward, which then I run into my problem, passing parameters. Here is an example.


Code:
#include<amxmodx> #include<military> new const PLUGIN = "Sample Class" new const VERSION = "1.0" new const AUTHOR = "Zenith77" public plugin_init() {      register_plugin(PLUGIN, VERSION, AUTHOR)      //Don't worry about params      CreateClass(BR_ARMY, "Sample", "", TYPE_HUMAN, 5)      //What Forward to use      SetForwards(FW_ADD|FW_SPAWN) //FW_ADD will not be used in this sample... } public ClassSpawn(id) { //See I can't use the forward system or else this will be called on every plugin :/ //andfjknkajsnfdknakfdna }

If you you can target and execute this on specific plugins with the forward system, please let me know. (The closest thing I saw was MF_RegisterSPForward() )
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Twilight Suzuka
bad
Join Date: Jul 2004
Location: CS lab
Old 05-17-2006 , 15:46  
Reply With Quote #6

BAILOPAN just said that. Use SP forwards. SP = single plugin.
__________________
Twilight Suzuka is offline
Send a message via AIM to Twilight Suzuka Send a message via MSN to Twilight Suzuka
Zenith77
Veteran Member
Join Date: Aug 2005
Old 05-17-2006 , 16:17  
Reply With Quote #7

Ok, misunderstood his post...
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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