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

Passing a forward function 2 or more arguments!


Post New Thread Reply   
 
Thread Tools Display Modes
Obbin
Senior Member
Join Date: Mar 2005
Location: 192.168.1.3
Old 09-02-2006 , 16:55   Re: Passing a forward function 2 or more arguments!
Reply With Quote #11

Okay!

include file:
Code:
new g_iForward = CreateMultiForward("entity_touch", ET_STOP, FP_CELL, FP_CELL) new g_iReturn = 163 public pfn_touch( ptr, ptd ) {     if( !ExecuteForward( g_iForward, g_iReturn, ptr, ptd ) )     {         log_amx( "Could not execute forward." )     }     if( !g_iReturn )         return PLUGIN_CONTINUE     return g_iReturn }

sma file:
Code:
#include <incfile> public plugin_init() {     register_plugin("entity_touch forward recreation test", "0.1", "Test") } public entity_touch(entity1, entity2) {     new ptr = entity1     new ptd = entity2     log_amx("[amx] %s touched %s", ptr, ptd)     return PLUGIN_CONTINUE }

What I'm trying to do is:
Making amx mod scripts that use the entity_touch forward compile without modifiaction

Note:
simply calling entity_touch in pfn_touch will not work since that function may not exist.

Thanks for all your help btw!
__________________
Sig(h)!
Obbin is offline
teame06
i have a hat
Join Date: Feb 2005
Location: Hat City
Old 09-02-2006 , 17:45   Re: Passing a forward function 2 or more arguments!
Reply With Quote #12

Well there two ways you can do this ..

#include <backward>

Code:
#if defined _backward_included   #endinput #endif #define _backward_included #include <engine> public pfn_touch(ptr, ptd) {     entity_touch(ptr, ptd)}

The other way would just run it as another plugin instead of an include.

Code:
#include <amxmodx> #include <engine> new g_iForward; new g_iReturn; public plugin_init() {     g_iForward = CreateMultiForward("entity_touch", ET_STOP, FP_CELL, FP_CELL) } public pfn_touch( ptr, ptd ) {     if( !ExecuteForward( g_iForward, g_iReturn, ptr, ptd ) )     {         log_amx( "Could not execute forward." )     }     if( !g_iReturn )         return PLUGIN_CONTINUE     return g_iReturn }

Because the way your doing it now still need modification to the plugin in plugin_init to add a line to plugin_init of the AMX Mod Script.
__________________
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-03-2006 , 04:31   Re: Passing a forward function 2 or more arguments!
Reply With Quote #13

Thanks, I think I'll go for the plugin way!

EDIT:
I got it working using callfunc!

Code:
public pfn_touch(ptr,ptd) {     new cfBegin, cfEnd     cfBegin = callfunc_begin("entity_touch", "")         if(cfBegin > 1)         return PLUGIN_CONTINUE     callfunc_push_int( ptr )     callfunc_push_int( ptd )     cfEnd = callfunc_end( )         return cfEnd;    }
__________________
Sig(h)!

Last edited by Obbin; 09-03-2006 at 04:49.
Obbin 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 15:20.


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