21.01.2012, 18:50
(
Последний раз редактировалось iggy1; 22.01.2012 в 11:25.
)
This is just a loop for variable argument functions, less typing is the only advantage for using it.
First argument is just an identifier for a new variable that will hold the index of the argument.
Second argument is the amount of function parameters that precede the variable arguments (0 for none).
Example
First argument is just an identifier for a new variable that will hold the index of the argument.
Second argument is the amount of function parameters that precede the variable arguments (0 for none).
pawn Код:
#define va_loop(%0,%1)\
new _n_va_args=numargs();\
for(new %0=%1;%0<_n_va_args;++%0)
pawn Код:
foo(oneplayer, twoplayer, ...)
{
SendClientMessage(oneplayer, 0xff0000AA, "foo");
SendClientMessage(twoplayer, 0xff0000AA, "foo");
va_loop(i, 2)//first arguement is a new var (index of argument) - second is the amount of params that precede the variable args
{
SendClientMessage(getarg(i), 0xff0000AA, "foo");
}
}
//call the function
foo(1, 2, 3, 4, 5, 6, 7);