17.05.2011, 06:31
hello,
is there any way to pass an array of strings? (as reference)
thanks,
N1trO
is there any way to pass an array of strings? (as reference)
thanks,
N1trO
static String[24];
new array = 5;
format(String,sizeof(String),"Array : %d",array);
Do not quite understand what you mean bad in this case would be;
pawn Код:
|
native GetMatrix(&arr[][],&size1 = sizeof(arr),&size2 = sizeof(arr[]));
Multi-dimensional arrays must be handled differently, though, as the memory lay-out differs between C/C++ and pawn. In comparison with C/C++, two- dimensional arrays in pawn are prefixed with a single-dimensional array that holds memory offsets to the start of each “row” in the two-dimensional array. This extra list allows each row to have a different column length. In C/C++, each column in a two-dimensional array must have the same size. If you are writing a wrapper function for an existing C function, as opposed to writing/adapting a native function specifically to exploit pawn’s features, you will not be concerned with variable column-length arrays —C/C++ does not support them, so your native function will not allow them. All that needs to be done, then, is to skip the prefixed “column offsets” list after getting the address from amx_GetAddr. For an example, I use the OpenGL function glMultMatrixf which multiplies a given 4 Ч 4 matrix with the current matrix. The prototype of the function is: Код:
void glMultMatrixf(const GLfloat *m); four cells to them. Код:
static cell n_glMultMatrixf(AMX *amx, const cell *params) { cell *cptr; assert(sizeof(cell) == sizeof(time_t)); amx_GetAddr(amx, params[1], &cptr); glMultMatrixf( (GLfloat*)(cptr + 4) ); return 0; } |