AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   (OLD) Bug Reports (https://forums.alliedmods.net/forumdisplay.php?f=24)
-   -   [REQ] Function request - callfunc_push_array() (https://forums.alliedmods.net/showthread.php?t=42810)

Zenith77 08-07-2006 21:58

[REQ] Function request - callfunc_push_array()
 
Basicly, it would be nice to have callfunc_push_array().
Yes I know, that this is out-dated with ExecuteForward and CreateForward and they exist now, but those won't work with the way my plugin works.
Thank you.

--Zenith

Twilight Suzuka 08-07-2006 23:32

Re: [REQ] Function request - callfunc_push_array()
 
I never really got why that wasn't in there...

Zenith77 08-08-2006 00:05

Re: [REQ] Function request - callfunc_push_array()
 
Me to. Why have a callfunc_push_str() function but not a callfunc_push_array() :/.

BAILOPAN 08-08-2006 01:40

Re: [REQ] Function request - callfunc_push_array()
 
I don't know whether I want to add this or not as I view the callfunc set of natives to be deprecated (as they can be nicely replaced by register_native and CreateOneForward).

I'm marking it for unsupported addition for now, I'll reply to this thread when there's a commit to the source tree.

Zenith77 08-08-2006 11:01

Re: [REQ] Function request - callfunc_push_array()
 
Quote:

Yes I know, that this is out-dated with ExecuteForward and CreateForward and they exist now, but those won't work with the way my plugin works.
:/

My plugin needs needs to be able to dynamically pass parameters to a function. Ok this is how it works (I won't past code since its a private plugin)....

My plugin is using the sockets. Ok when data is received, it is sorted out into arguments, then, the plugin will look at how some other plugin wants this data to be called to its function and then convert the parameters from a string to what the data type needs to be.

Summary:

Plugin receives a "message".
Looks through it's message table and finds the base plugin that registered the message.
Sorts out the arguments.
Loops through all the arguments and checks from the forward data type table what data type each argument should be, and converts it (str_to_num, str_to_float, etc).

The last step when the plugin loops through all the arguments is why I need the callfunc_push_array(), because of the plugin's protocal. If any of the DEV's need to look at the code, I'll PM it to them.

Greenberet 08-08-2006 11:50

Re: [REQ] Function request - callfunc_push_array()
 
Quote:

Originally Posted by Zenith77
:/

My plugin needs needs to be able to dynamically pass parameters to a function. Ok this is how it works (I won't past code since its a private plugin)....

My plugin is using the sockets. Ok when data is received, it is sorted out into arguments, then, the plugin will look at how some other plugin wants this data to be called to its function and then convert the parameters from a string to what the data type needs to be.

Summary:

Plugin receives a "message".
Looks through it's message table and finds the base plugin that registered the message.
Sorts out the arguments.
Loops through all the arguments and checks from the forward data type table what data type each argument should be, and converts it (str_to_num, str_to_float, etc).

The last step when the plugin loops through all the arguments is why I need the callfunc_push_array(), because of the plugin's protocal. If any of the DEV's need to look at the code, I'll PM it to them.

I wrote a plugin that could be very similar to yours.
It lets you execute public functions from any plugin
Callfunc implementation

Zenith77 08-08-2006 12:31

Re: [REQ] Function request - callfunc_push_array()
 
Your's is actually very close to how mine works, but it still doesn't solve my problem :/.

Greenberet 08-08-2006 15:14

Re: [REQ] Function request - callfunc_push_array()
 
And i have a solution with dynamic natives for you
Code:
#include <amxmodx> native callfunc_push_array( arr[] ); public plugin_natives() {     register_native( "callfunc_push_array", "__callfunc_push_array" ); } public __callfunc_push_array( ) {     return callfunc_push_int( get_param( 1 ) ); } public plugin_init () {     register_plugin( "Push Array", "1.0", "Greenberet" );     register_clcmd( "push_array", "cmdPushArray" ); } public arrayprint( arr[], len ) {     static string[512]     formatex( string, 512, "%i", arr[0] );     for( new i = 1; i < len; i++ )         format( string,512, "%s %i", string,arr[i] );             client_print(0, print_chat, "Array: %s | Len: %i", string, len ); } public cmdPushArray( Client ) {     new bla[6];         for( new i = 0; i < 6; i++ )         bla[i] = 5 - i;         client_print( 0, print_chat, "direct call" );     arrayprint( bla, 6 );         client_print( 0, print_chat, "callfunc call" );         callfunc_begin_i( get_func_id("arrayprint") );     callfunc_push_array( bla );     callfunc_push_int( 6 );     callfunc_end(); }

output:
Code:

direct call
5 4 3 2 1 0
callfunc call
5 4 3 2 1 0


Zenith77 08-08-2006 15:56

Re: [REQ] Function request - callfunc_push_array()
 
Wow, thanks.

I actually though about doing that, since aww nm screw it. Thanks again. +karama

-Zenith

Greenberet 08-08-2006 16:38

Re: [REQ] Function request - callfunc_push_array()
 
1 Attachment(s)
Here is a patch file for the current svn revision to add this native


All times are GMT -4. The time now is 17:33.

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