Thread: [Solved] Copying 2D arrays by natives
View Single Post
klippy
AlliedModders Donor
Join Date: May 2013
Location: Serbia
Old 09-10-2016 , 14:23   Re: Copying 2D arrays by natives
Reply With Quote #4

It may be possible to hack around that. Try with this:
PHP Code:
native int GetNativeArray2D(int paramany[][] localint sizecells) = GetNativeArray;

public 
int Native_PassMy2DArray(Handle pluginint numParams)
{
    
int my2DArray[3][6];
    
GetNativeArray2D(1view_as<any>(my2DArray), 6);
    
    for(
int i 03i++) {
        for(
int j 06j++) {
            
PrintToServer("my2DArray[%d][%d] = %d"ijmy2DArray[i][j]);
        }
    }
}

public 
APLRes AskPluginLoad2(Handle myselfbool latechar[] errorint err_max)
{
    
CreateNative("PassMy2DArray"Native_PassMy2DArray);
    
    return 
APLRes_Success;

And in your sub-plugin:
PHP Code:
native void PassMy2DArray(int[][] arr);

public 
void OnPluginStart()
{
    
int myArray[3][6] = {
        {
123456},
        {
789101112},
        {
131415161718}
    };
    
    
PassMy2DArray(myArray);

I'm really interested if that would work, because I have just tested a similar hack on AMXX and it worked.

(please don't kill me for proposing this)

Last edited by klippy; 09-10-2016 at 14:26.
klippy is offline