Char array returnen -
Olymp2000 - 18.11.2014
How to return a string (in func it is a char array)
AW: Char array returnen -
Olymp2000 - 18.11.2014
How to return a string (in func it is a char array)
AW: Char array returnen -
Olymp2000 - 19.11.2014
Need help
Re: Char array returnen -
GWMPT - 19.11.2014
Need help heh?
Then, please, write your topic in English, so we can assist you.
AW: Char array returnen -
Olymp2000 - 19.11.2014
How to return a string (in func it is a char array)
Re: Char array returnen -
PaulMcCartney - 19.11.2014
You can only post in english here, update your topic.
AW: Char array returnen -
Olymp2000 - 19.11.2014
Done. Searching for help:How to return a string (in func it is a char array)
Re: Char array returnen -
Mauzen - 19.11.2014
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;
}
AW: Char array returnen -
Olymp2000 - 19.11.2014
Sry i am new but this was my first opinon but then the vector didnt bring anything cauz you hafe a buffer with a defined size but i want a direct return so at the end i can place it for ex in SendClientMessage
Re: Char array returnen -
Mauzen - 19.11.2014
Afaik a plugin native can only return a single pawn cell, I havent seen a plugin native with a true string return. Better just use the reference way, its better style anways. If you really need direct return you could still wrap it in a pawn function, just like people sometimes do for GetPlayerName.
AW: Char array returnen -
Olymp2000 - 19.11.2014
But then a char vector is never possible or ? Because you ever need a buffer which have a defined size
Re: Char array returnen -
Mauzen - 19.11.2014
At least in pawn it isnt possible, because after all youll always end up with a fixed-size array.
You can have a char vector in a plugin, but when returning it to pawn youll also have to write it into an array with fix size.
AW: Char array returnen -
Olymp2000 - 19.11.2014
How to wrap it without an array in pawn ?
Re: Char array returnen -
Mauzen - 19.11.2014
pawn Код:
stock GetDirectArrayReturn() {
new array[ARRAY_SIZE];
Native_GetSomeArray(array);
return array;
}
Something like that. Its pretty pointless to do that, but a many people do it anyways, just to safe that one line of code.
AW: Char array returnen -
BigETI - 21.11.2014
Strings (arrays) in PAWN are basicly references of 32 bit array objects, so you have to allocate that array in your plugin and return its reference.