SA-MP Forums Archive
AddNums(...) <- Explain elipsis operator please - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: AddNums(...) <- Explain elipsis operator please (/showthread.php?tid=547999)



AddNums(...) <- Explain elipsis operator please - sammp - 26.11.2014

I'd like to know the most efficient method of receiving the arguments of an unknown amount of args, example:

pawn Код:
Add(3, 40, 302);
Add(4,4,4,4,4,4,4);
I know you use getarg(); and numargs(); I can;t remember how to do it, lol.


Re: AddNums(...) <- Explain elipsis operator please - Vince - 27.11.2014

pawn Код:
for(new i, j = numargs(); i < j; i++)
{
    sum += getarg(i);
}
return sum;