Raised This Month: $51 Target: $400
 12% 

Passing a forward function 2 or more arguments!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 09-02-2006 , 15:00   Passing a forward function 2 or more arguments!
Reply With Quote #1

Taken from Hawk552's Plugin API tutorial:

Code:
#include <amxmodx> new Float:g_flDelay public plugin_init() {     register_plugin("API Test - Core","1.0","Hawk552")         g_flDelay = random_float(0.1,0.5)     set_task(g_flDelay,"fnDoForward") } public fnDoForward() {     new iForward = CreateMultiForward("plugin_init_delay",ET_IGNORE,FP_FLOAT),iReturn     if(iForward < 0)         return log_amx("Forward could not be created.")         if(!ExecuteForward(iForward,iReturn,g_flDelay))         return log_amx("Could not execute forward.")             return DestroyForward(iForward) }

Code:
#include <amxmodx> public plugin_init()     register_plugin("API Test - Attachment","1.0","Hawk552")     public plugin_init_delay(Float:flDelay)     log_amx("Forward executed %f seconds after plugin_init.",flDelay)

Now I want to pass plugin_init_delay another argument like this:
plugin_init_delay(Float:flDelay, iRand)

How do I do that?
__________________
Sig(h)!
Obbin is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 09-02-2006 , 15:26   Re: Passing a forward function 2 or more arguments!
Reply With Quote #2

Code:
You need to create the arguments in CreateMultiForward. CreateMultiForward("plugin_init_delay",ET_IGNORE,FP_FLOAT, FP_CELL) Then you need to add the extra arugument when executing. I'm not sure what you wanted  the extra argument for but that what you need to do .. if(!ExecuteForward(iForward,iReturn,g_flDelay, iRand))
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 09-02-2006 , 16:11   Re: Passing a forward function 2 or more arguments!
Reply With Quote #3

Thanks!
Now I have another problem:
Code:
//Natives added by Obbin new iForward = CreateMultiForward("entity_touch",ET_STOP,FP_CELL), iReturn /* public pfn_touch( ptr, ptd ) {     if( !ExecuteForward( iForward, iReturn, ptr, ptd ) )     {         log_amx( "Could not execute forward." )     }     if( !iReturn )         return PLUGIN_CONTINUE     return iReturn } */
This dows just throw 2 "symbol is never used" warnings

Code:
//Natives added by Obbin new iForward = CreateMultiForward("entity_touch",ET_STOP,FP_CELL), iReturn //ERROR IS HERE public pfn_touch( ptr, ptd ) {     if( !ExecuteForward( iForward, iReturn, ptr, ptd ) )     {         log_amx( "Could not execute forward." )     }     if( !iReturn )         return PLUGIN_CONTINUE     return iReturn }
However this throws out "error 008: must be a constant expression; assumed zero" (on the line starting with "new iForward")

What is wrong?
__________________
Sig(h)!

Last edited by Obbin; 09-02-2006 at 16:13. Reason: More info
Obbin is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 09-02-2006 , 16:16   Re: Passing a forward function 2 or more arguments!
Reply With Quote #4

If your going to execute a forward with two arguments. You need to make sure CreateMultiForward was setup for two arguments, etc
Code:
// One Argument CreateMultiForward("entity_touch",ET_STOP,FP_CELL) // Two Arguments CreateMultiForward("entity_touch",ET_STOP,FP_CELL, FP_CELL) // Three Arguments CreateMultiForward("entity_touch",ET_STOP,FP_CELL, FP_CELL, FP_CELL)


Also where is new located? iForward = CreateMultiForward("entity_touch",ET_STOP,FP_ CELL), iReturn //ERROR IS HERE
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 09-02-2006 at 16:26.
teame06 is offline
Send a message via AIM to teame06
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 09-02-2006 , 16:29   Re: Passing a forward function 2 or more arguments!
Reply With Quote #5

Isn't it there?
I might have edited it but my short-time memory is like it is xP

EDIT: Hmm, i'm still getting it :S

Code:
new iForward = CreateMultiForward("entity_touch", ET_STOP, FP_CELL, FP_CELL) new iReturn = 163 //Yes, I know this is just stupid, I'll deal with it later public pfn_touch( ptr, ptd ) {     if( !ExecuteForward( iForward, iReturn, ptr, ptd ) )     {         log_amx( "Could not execute forward." )     }     if( !iReturn )         return PLUGIN_CONTINUE     return iReturn }
__________________
Sig(h)!

Last edited by Obbin; 09-02-2006 at 16:36.
Obbin is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 09-02-2006 , 16:35   Re: Passing a forward function 2 or more arguments!
Reply With Quote #6

Code:
new iForward = CreateMultiForward("entity_touch",ET_STOP,FP_CELL), iReturn //ERROR IS HERE ^--- Did you put that into plugin_init() or as a global variable?


If you did that exactly in global then that why your getting that error..
You need to do new iForward as a global.
__________________
No private support via Instant Message
GunGame:SM Released

Last edited by teame06; 09-02-2006 at 16:37.
teame06 is offline
Send a message via AIM to teame06
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 09-02-2006 , 16:37   Re: Passing a forward function 2 or more arguments!
Reply With Quote #7

Global.
__________________
Sig(h)!
Obbin is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 09-02-2006 , 16:38   Re: Passing a forward function 2 or more arguments!
Reply With Quote #8

Code:
new iForward public plugin_init() {      iForward = CreateMultiForward("entity_touch",ET_STOP,FP_CELL) }

That what your suppose to do .. You can't use a native in a global like that.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 09-02-2006 , 16:40   Re: Passing a forward function 2 or more arguments!
Reply With Quote #9

Hmm, but it needs to be called on startup, can I use plugin_init in an include file AND in the sma?
It needs to be called at startup and it needs to be in a inc.
__________________
Sig(h)!
Obbin is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 09-02-2006 , 16:50   Re: Passing a forward function 2 or more arguments!
Reply With Quote #10

Ok, Now i'm really confused on what you are trying to do with Dynamic Forwards. I would attach your source cause you just confused the hell out of me trying to put this into include.
__________________
No private support via Instant Message
GunGame:SM Released
teame06 is offline
Send a message via AIM to teame06
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 22:46.


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