Raised This Month: $27 Target: $400
 6% 

Solved get_array_byref?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 02-10-2020 , 16:44   get_array_byref?
Reply With Quote #1

This is a bit mind-boggling and I cannot find anything related to my issue. Is it even possible to refer arrays in dynamic/fake natives?
__________________
Discord: wEight#6773

Hobbies:
- Map Designing (Any Half-Life 1 Engine Game)
- Pawn (Intermediate / Counter-Strike 1.6 only)
- C#/VB for .Net (Intermediate / Winforms)
- Java (Mostly Android Application Development)

Last edited by redivcram; 02-15-2020 at 13:02.
redivcram is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-10-2020 , 17:56   Re: get_array_byref?
Reply With Quote #2

Can you show an example of what you're trying to accomplish?
__________________
Bugsy is online now
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 02-10-2020 , 19:13   Re: get_array_byref?
Reply With Quote #3

PHP Code:
// Plugin 1
public plugin_natives()
{
    
register_library("fakenatives");
    
    
register_native("FakeNative""_FakeNative");
}

public 
_FakeNative(iPluginiParams) {
    
    
// Do something to the parsed array?

I wanna use the native as such:
PHP Code:
// Plugin 2
new myArray[8];

FakeNative(myArray);

// Do something with the modified array. 
Basically what I said in the first post.
__________________
Discord: wEight#6773

Hobbies:
- Map Designing (Any Half-Life 1 Engine Game)
- Pawn (Intermediate / Counter-Strike 1.6 only)
- C#/VB for .Net (Intermediate / Winforms)
- Java (Mostly Android Application Development)

Last edited by redivcram; 02-10-2020 at 19:14.
redivcram is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-10-2020 , 19:23   Re: get_array_byref?
Reply With Quote #4

Here's an example setting string and an array
PHP Code:

#include <amxmodx>

public plugin_init()
{
    
register_plugin"String/Array in Dynamic Natives" "0.1" "bugsy" );
}

public 
plugin_natives()
{
    
register_library"bugsy_test" );
    
    
register_native"get_steam_id","_get_steam_id" );
    
register_native"get_random_nums","_get_random_nums" );
}

public 
_get_steam_idiPlugin iParams )
{
    new 
szTmpStr34 ];
    
    
get_user_authidget_param(1) , szTmpStr charsmaxszTmpStr ) );
    
set_stringszTmpStr get_param) );
}

public 
_get_random_numsiPlugin iParams )
{
    new 
iCount iNumbers10 ];
    
    
iCount get_param);
    
    if ( 
iCount 10 
        return -
1;
        
    for ( new 
iCount i++ )
    {
        
iNumbers] = random5000 );
    }
    
    
set_arrayiNumbers iCount );
    
    return 
iCount;

PHP Code:
#pragma reqlib "bugsy_test"

native get_steam_idid szDest[] , iMaxChars )
native get_random_numsiCount iDest[] ) 
The plugin
PHP Code:

#include <amxmodx>
#include <bugsytest>

new const VERSION[] = "0.1";

public 
plugin_init() 
{
    
register_plugin"Native test" VERSION "bugsy" );
    
    
register_clcmd"say string" "GetAuthID" );
    
register_clcmd"say array" "RandomNumbers" );
}

public 
GetAuthIDid 
{    
    new 
szSteamID33 ];
    
get_steam_idid szSteamIDcharsmaxszSteamID ) );
    
server_print"String value: %s" szSteamID );


public 
RandomNumbersid 
{    
    new 
iNumbers10 ];
    
get_random_numsiNumbers );
    
server_print"%d %d %d %d %d" iNumbers[0] , iNumbers[1] ,iNumbers[2] ,iNumbers[3] ,iNumbers[4] );

__________________

Last edited by Bugsy; 02-10-2020 at 20:24.
Bugsy is online now
redivcram
Veteran Member
Join Date: Jul 2014
Location: Serbia
Old 02-15-2020 , 13:02   Re: get_array_byref?
Reply With Quote #5

Thanks! All seems to be working well for me.
__________________
Discord: wEight#6773

Hobbies:
- Map Designing (Any Half-Life 1 Engine Game)
- Pawn (Intermediate / Counter-Strike 1.6 only)
- C#/VB for .Net (Intermediate / Winforms)
- Java (Mostly Android Application Development)
redivcram is offline
Reply


Thread Tools
Display Modes

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 23:49.


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