SA-MP Forums Archive
Many many arguments in function.. - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: Many many arguments in function.. (/showthread.php?tid=163227)



Many many arguments in function.. - Dreftas - 26.07.2010

Hot to make function like
pawn Код:
SomeFunc(str1[], str2[], ...);
Where "..." there can be, and can be not more function arguments, so I can use
pawn Код:
SomeFunc("Bla", "Bla2", "Bla3", "Bla4");
and so on...

How to make that kind of function ?


Re: Many many arguments in function.. - DJDhan - 26.07.2010

You mean you want to make user defined functions with arguments?

Код:
forward SomeFunction(string1[],string2[]);
public SomeFunction(string1[],string2[])
{
        printf("%s",string1);
        printf("%s",string2);
}
When you call it;
Код:
new stri1[128],stri2[128];
format(stri1,128,"Bla");
format(stri2,128,"Bla2");
SomeFunction(str1,str2);



Re: Many many arguments in function.. - Dreftas - 27.07.2010

Quote:
Originally Posted by DJDhan
Посмотреть сообщение
You mean you want to make user defined functions with arguments?
No, I mean function where i need to use for example first 2 arguments, and then if I want, I can use as many as I need other arguments.


Re: Many many arguments in function.. - RyDeR` - 27.07.2010

Код:
SomeFunc(...)
{
	return 1;
}
Then use arg function to get them.


Re: Many many arguments in function.. - Dreftas - 27.07.2010

Oh, (...), in Lua i've use it like this, doesn't knew that in pawn is same
Thanks.


Re: Many many arguments in function.. - Bardokas - 27.07.2010

Look also here.