How to add arguments to format? -
TheGamer! - 11.03.2012
For example:
pawn Код:
for(new i; i<5; i++)
{
CallLocalFunction(something, something, something[i]);
}
It works but it calls the function 5x. I want to call once...
Is this possible?
Re: How to add arguments to format? -
MP2 - 11.03.2012
What do you mean? Explain clearly.
Re: How to add arguments to format? -
TheGamer! - 11.03.2012
pawn Код:
CallLocalFunction(func, parameters, cmd[0], cmd[1], cmd[2]); // I defined func and parameters before
Like this. But the number of cmd is various.
Re: How to add arguments to format? -
Twisted_Insane - 11.03.2012
Did you copy this from somewhere? This is your code:
pawn Код:
for(new i; i < [B]5[/B]; i++)
It tells the script, that it should call the function AS long, as i is smaller then 5 times. That means:
0, 1, 2, 3, 4 = 5 TIMES
If you want it for one time, it should be like this:
Re: How to add arguments to format? -
TheGamer! - 11.03.2012
I didn't copy it, and your code will add one parameter. I want more...
Re: How to add arguments to format? -
MP2 - 11.03.2012
This may be what you're looking for, I'm not sure:
https://sampforum.blast.hk/showthread.php?tid=77000
Re: How to add arguments to format? -
TheGamer! - 11.03.2012
Yes thanks
Quote:
Originally Posted by MP2
|
But, there's any function to get an other function's arguments?
Re: How to add arguments to format? -
Gh05t_ - 11.03.2012
Quote:
Originally Posted by Twisted_Insane
Did you copy this from somewhere? This is your code:
pawn Код:
for(new i; i < [B]5[/B]; i++)
It tells the script, that it should call the function AS long, as i is smaller then 5 times. That means:
0, 1, 2, 3, 4 = 5 TIMES
If you want it for one time, it should be like this:
|
Err, you know if your calling a function once, there is no need for a loop?
AW: How to add arguments to format? -
Nero_3D - 11.03.2012
Wrote an example, similar to
RyDeR` code
pawn Код:
public OnFilterScriptInit() {
CallLocalFunction("MiscFunc", "ii", 1, 2); // to init CallLocalFunction
CallLocalFunctionEx("MyFunc", "iiiii", 1, 2, 3, 4, 5);
}
pawn Код:
stock CallLocalFunctionEx(const func[], const form[], {Float, _}: ...) {
new
args = ((numargs() - 2) << 2),
addr,
i
;
#emit addr.pri form
#emit stor.s.pri addr
for(i = (addr + args), args += 8; addr != i; i -= 4) {
#emit load.s.pri i
#emit load.i
#emit push.pri
}
#emit push.s form
#emit push.s func
#emit push.s args
#emit sysreq.c CallLocalFunction
}
pawn Код:
forward MyFunc(v1, v2, v3, v4, v5);
public MyFunc(v1, v2, v3, v4, v5) {
printf("%d %d %d %d %d", v1, v2, v3, v4, v5);
}