Returning more than one thing. - 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: Returning more than one thing. (
/showthread.php?tid=267265)
Returning more than one thing. -
Danny - 07.07.2011
Hi,
I want to create a function that returns more than one integer.
Just like a few SA:MP functions do, like GetPlayerPos. How i can do that?
Greetz.
Danny
Re: Returning more than one thing. -
Daren_Jacobson - 07.07.2011
pass them by reference as arguments, so say I want to return the variables a and b depending on what c is I would do
pawn Код:
RandomFunction(&a, &b, c)
{
a = c - 3;
b = c - 7;
return 1;
}
so
pawn Код:
new alpha, beta, gamma = 25, delta;
delta = RandomeFunction(alpha, beta, gamma);
alpha == 22
beta == 18
gamma == 25
delta = 1
Re: Returning more than one thing. -
Danny - 07.07.2011
Thanks man! I understand it now
Re: Returning more than one thing. -
Shadoww5 - 08.07.2011
Quote:
Originally Posted by Daren_Jacobson
pass them by reference as arguments, so say I want to return the variables a and b depending on what c is I would do
pawn Код:
RandomFunction(&a, &b, c) { a = c - 3; b = c - 7; return 1; }
so
pawn Код:
new alpha, beta, gamma = 25, delta; delta = RandomeFunction(alpha, beta, gamma);
alpha == 22
beta == 18
gamma == 25
delta = 1
|
Why
delta will be 1 ?
Re: Returning more than one thing. -
Donya - 08.07.2011
cus return 1;
Re: Returning more than one thing. - Deskoft - 08.07.2011
pawn Код:
new alpha, beta, gamma = 25, delta;
delta = RandomeFunction(alpha, beta, gamma);
delta is the value of the return.
While the &(variable) points to a variable stored in a external function.