AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Module Coding (https://forums.alliedmods.net/forumdisplay.php?f=9)
-   -   how to use MF_CopyAmxMemory? (https://forums.alliedmods.net/showthread.php?t=327578)

OrangePeel 09-27-2020 09:39

how to use MF_CopyAmxMemory?
 
i want to make a native like this
Code:

native get_move_path(Float:origin1[3], Float:origin2[3], Float:originArray[][3], &size)

public test(id, target)
{
    new Float:origin1[3], Float:origin2[3], originArray[32][3], size
    pev(id, pev_origin, origin1)
    pev(target, pev_origin, origin2)
        get_move_path(origin1, origin2, originArray, size)

    for(new i = 0; i < size; i++)
    {
        server_print("%.2f %.2f %.2f", originArray[i][0], originArray[i][1], originArray[i][2])
    }
}

Code:

static cell AMX_NATIVE_CALL get_move_path(AMX *amx, cell *params)
{
        cell *vAmx1 = MF_GetAmxAddr(amx, params[1]);
        cell *vAmx2 = MF_GetAmxAddr(amx, params[2]);

        REAL fX = amx_ctof(vAmx1[0]);
        REAL fY = amx_ctof(vAmx1[1]);
        REAL fZ = amx_ctof(vAmx1[2]);
        Vector origin1 = Vector(fX, fY, fZ);

        fX = amx_ctof(vAmx2[0]);
        fY = amx_ctof(vAmx2[1]);
        fZ = amx_ctof(vAmx2[2]);
        Vector origin2 = Vector(fX, fY, fZ);


        cell *array = MF_GetAmxAddr(amx, params[3]);
        cell *array_size = MF_GetAmxAddr(amx, params[4]);
        *array_size = size;

   
    /*
   
    i want to copy some vector array to params[3]
    something like this, i dont know how to make it right.
    vecArray[0][0] = 1.0f;
    vecArray[0][1] = 1.0f;
    vecArray[0][2] = 1.0f;
   
    vecArray[1][0] = 1.0f;
    vecArray[1][1] = 1.0f;
    vecArray[1][2] = 1.0f;

    vecArray[2][0] = 1.0f;
    vecArray[2][1] = 1.0f;
    vecArray[2][2] = 1.0f;
    ...

        MF_CopyAmxMemory(array, vecArray, size);
    */
        return 1;
}



All times are GMT -4. The time now is 11:08.

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