[Plugin] Char array returnen
#8

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):

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;
}
Reply


Messages In This Thread
Char array returnen - by Olymp2000 - 18.11.2014, 20:28
AW: Char array returnen - by Olymp2000 - 18.11.2014, 20:38
AW: Char array returnen - by Olymp2000 - 19.11.2014, 19:38
Re: Char array returnen - by GWMPT - 19.11.2014, 19:40
AW: Char array returnen - by Olymp2000 - 19.11.2014, 19:44
Re: Char array returnen - by PaulMcCartney - 19.11.2014, 20:02
AW: Char array returnen - by Olymp2000 - 19.11.2014, 20:06
Re: Char array returnen - by Mauzen - 19.11.2014, 20:08
AW: Char array returnen - by Olymp2000 - 19.11.2014, 20:11
Re: Char array returnen - by Mauzen - 19.11.2014, 20:21
AW: Char array returnen - by Olymp2000 - 19.11.2014, 20:27
Re: Char array returnen - by Mauzen - 19.11.2014, 20:32
AW: Char array returnen - by Olymp2000 - 19.11.2014, 20:36
Re: Char array returnen - by Mauzen - 19.11.2014, 20:54
AW: Char array returnen - by BigETI - 21.11.2014, 12:09

Forum Jump:


Users browsing this thread: 3 Guest(s)