19.11.2014, 20:08
I noticed the explicit "no c/c++ support here" rule is gone.
To return a string/array you would retrieve the address of the array passed by the script, and then just write into that referenced array. The plugin SDK provides the functions needed for that.
Take a look e.g. at the vector plugin (or any other plugin that can return strings):
To return a string/array you would retrieve the address of the array passed by the script, and then just write into that referenced array. The plugin SDK provides the functions needed for that.
Take a look e.g. at the vector plugin (or any other plugin that can return strings):
pawn Код:
native cvector_get_arr(vector, index, destination[], len=sizeof(string));
cell AMX_NATIVE_CALL CVectorNatives::get_arr(AMX* amx, cell* params){
cell pawnid = params[1];
cell elem = params[2];
if (!sdk_is_vector_exists(amx,pawnid) || !sdk_is_exists(amx,pawnid,elem))
return -1;
if (local_vectors[amx][pawnid].get_type(elem) != 0)
return -2;
// Relevant part starts here
cell* addr = NULL; // Get the address of the destination array
amx_GetAddr(amx,params[3],&addr);
cell size = params[4]; // Get the size of the destination array
// ...
amx_SetString(addr,some_string,0,0,size); // write some_string into the destination array to return it to pawn
return 1;
}