Unlimited function arguments: Fetching and passing the unchanged {Float,_}:... ?
#1

Hello there,

I'm willing to build dynamic, re-usable countdown functionality for my soon-to-come gamemode.

My first assumption were using the "unlimited arguments" function and passing the direct raw data into SetTimerEx(), after setting some local data. To make the long story short, and the overall algorithm much simplified, let's think of somehting like that:

Код:
Countdown_forPlayer(playerid, seconds, callback[], fmt[], {Float,_}:...) {

	new miliseconds = seconds * 1000;
	SetTimerEx(callback, miliseconds, false, fmt, {Float,_}:...); // this {Float,_}:... here is guesed and doesn't work
}
I figured out (with a little help from my friends; cheers TheAlpha ) that {Float,_}:... in function declaration actually allows me for the unlimited args, but then... how do i get the _raw_ data and pass anywhere further?

All i've seen around are numargs(), getarg() and setarg(), which obviously are not the case here. (unless i can grab those args with a loop, combine back together and put in the SetTimerEx() thingy; still not certain how would that be even possible)

I'd be really thankfull for any tips.

Cheers!
Reply
#2

There is a way to do this, but it is very strange and hard. Better just use simple SetTimerEx...
Reply
#3

Well, using 'just SetTimerEx' is deffinitely not the case; the lines i pasted are just an example; i'm going for much more advanced functionality inside the function.
Reply
#4

The functions are called numarg, getarg and setarg.
Here's a tut
http://forum.sa-mp.com/index.php?topic=101773.0
Reply
#5

I know (and mentioned it myself), but still i'm asking how to get all the arguments in one "variable" (or any other form) to be able to pass it raw into the inner SetTimerEx() function?
Reply
#6

Something like this then ?
pawn Код:
#define Countdown_forPlayer(%1,%2,%3,%4,%5) new FALSE = 0; do {new miliseconds=%2*1000; SetTimerEx((%3),miliseconds,0,(%4),%5); printf("%d",miliseconds);} while(FALSE)
Note that I don't quite understand why you need to declare a new variable FALSE (or whatever name) and set it to 0, because if using only 0 in the do-while, the code will error on compile
Reply
#7

Hi,

Thanks again for Your effort, it looks pretty nice.

But still not much of a clue how do i insert other functionalities inside? :>
Your example looks like just SetTimerEx() replacement, and thus i want to pluck some functionality in AND THEN call SetTimerEx() at the end
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)