Raised This Month: $7 Target: $400
 1% 

how to use MF_CopyAmxMemory?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
OrangePeel
Junior Member
Join Date: Aug 2019
Old 09-27-2020 , 08:39   how to use MF_CopyAmxMemory?
Reply With Quote #1

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;
}
OrangePeel 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 06:41.


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