Returning more than one thing.
#1

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
Reply
#2

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
Reply
#3

Thanks man! I understand it now
Reply
#4

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 ?
Reply
#5

cus return 1;
Reply
#6

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.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)