SA-MP Forums Archive
Difference in returns - 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)
+--- Thread: Difference in returns (/showthread.php?tid=406164)



Difference in returns - JavoDiaz - 09.01.2013

Which the difference between


pawn Код:
forward Test(playerid);
public Test(playerid)
{
    SendClientMessage(playerid, ~1, "test");
    return 1;
}
and

pawn Код:
forward Test(playerid);
public Test(playerid)
{
    SendClientMessage(playerid, ~1, "test");
}
?


The same case in plain functions:


pawn Код:
Test(playerid)
{
    SendClientMessage(playerid, ~1, "test");
    return 1;
}
and

pawn Код:
Test(playerid)
{
    SendClientMessage(playerid, ~1, "test");
}

Which is the difference?

I already know that if I need a value I can return it with return but in void functions, in pawn doesn't exist void so, in void functions that executes 1 time and don't need to return any value.

like

Case with callback:

pawn Код:
public OnPlayerConnect(playerid)
{
    SetTimerEx("Test", 1000, false, "d", playerid);
    return 1;
}

Case with plain function:

pawn Код:
public OnPlayerConnect(playerid)
{
    Test(playerid);
    return 1;
}

I need to return a value in the Test function in both cases?


Thanks and respond only people that have understanded my doubt and have experience with this cases to avoid confusions.


Thanks again.


Re: Difference in returns - u3ber - 09.01.2013

pawn is typeless, therefore it doesn't support valueless type void (which you stated but keeps mentioning for some reason..)

return does as says, it returns a value. It's also very handy when passing control back to a block of code.


Re: Difference in returns - JavoDiaz - 09.01.2013

Yes but you don't said me the difference between return a value or not. Thanks for the fast answer.


Re: Difference in returns - JavoDiaz - 09.01.2013

Oh thanks ****** but the function will be slower if I put a return value at the end of it or it's the same thing?

the "void:" tag is in the YSI library?


Thanks.


Re: Difference in returns - JavoDiaz - 09.01.2013

Oh, thanks a lot, I use too much your YSI libraries, they are great, it help me a lot and you too. Thanks for solving another of my doubts ******. I appreciate it a lot.


Re: Difference in returns - u3ber - 09.01.2013

Quote:
Originally Posted by JavoDiaz
Посмотреть сообщение
Oh thanks ****** but the function will be slower if I put a return value at the end of it or it's the same .
all it is, is an extra instruction but this is the LEAST of the your worries. So I'll answer as any sane person would...no.