06.07.2014, 12:36
(
Last edited by Nero_3D; 06/07/2014 at 01:07 PM.
)
Well that is the problem, you can't determine what kind of array it is (and how big) because you can't tell the difference between a letter and a pointer (they are both just numbers)
You could use a 1d array with looks like "hello|world|" or something like that or you use a format parameter which tells the function how to parse the argument like sscanf does it
But if your function only takes 2d arrays than you could make it without it, you just need to pass the array
You can determine the size by the first pointer (it jumps over all other pointers and therefor it represents the size of the first dimension)
Well there is another way to extract something like that
You could use a 1d array with looks like "hello|world|" or something like that or you use a format parameter which tells the function how to parse the argument like sscanf does it
But if your function only takes 2d arrays than you could make it without it, you just need to pass the array
You can determine the size by the first pointer (it jumps over all other pointers and therefor it represents the size of the first dimension)
Well there is another way to extract something like that
pawn Code:
funcProcess2D(playerid, ...) {
new
arg,
args,
addr,
size
;
#emit addr.pri 12
#emit stor.s.pri arg
#emit load.s.alt 8
#emit add
#emit stor.s.pri args
while((arg += 4) < args) {
static
tmp[1][1]
;
#emit lref.s.pri arg
#emit stor.s.pri addr
#emit load.i
#emit shr.c.pri 2
#emit stor.s.pri size
funcPhrase2D(playerid, addr, tmp, size);
}
}
funcPhrase2D(playerid, addr, array[][], size) {
#emit load.s.pri addr
#emit stor.s.pri array
// normal code work fine after here
while(--size >= 0) {
print(array[size]);
}
}