About return - 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: About return (
/showthread.php?tid=148076)
About return -
UsaBoy91 - 15.05.2010
If i don't return anything in a timer seted from OnGameModeInit , or if I don't return anything from a SA:MP Callback , will this make problems for my server ? Like ... to make ping ... or another bad things ?
Thanks
Re: About return -
juice.j - 15.05.2010
What do you mean with returning anything in a timer?
Re: About return -
Torran - 15.05.2010
He means:
Instead of:
pawn Код:
public Example()
{
return 1;
}
Re: About return -
UsaBoy91 - 15.05.2010
Yes ...
Re: About return -
UsaBoy91 - 15.05.2010
Somebody can help me ?
Re: About return -
¤Adas¤ - 15.05.2010
There must be a return. Else compiler will show an error or what
Re: About return -
UsaBoy91 - 15.05.2010
Nice joke
Re: About return -
Sergei - 15.05.2010
You aren't forced to, but it doesn't hurt if you do
at the end.
Re: About return -
Backwardsman97 - 15.05.2010
I use them because it will end that section of code. I don't know the fancy words for it but it stops the code where it's at. At least that's my understanding of it. Let me show you...
pawn Код:
public Function(blah)
{
if(blah == 1)
{
//Some code
}
if(blah == 2)
{
//Some code
}
return 1;
}
Now if blah equals 1, it's going to go in there and execute that code. After that, if there's no return, it will jump out and check if blah equals 2. Well this is unnecessary because we already saw that it equaled 1. If there's a return in there, it will stop after it sees it's at 1. You could return whatever number you wanted to. It just depends on the code. If you had some more code at the bottom of those if statements, then you wouldn't want to have a return in them.
Re: About return -
MafiaGuy™ - 16.05.2010
1. Stops the code in certain points.
2. You can return a value for some function/public like return Money[playerid];
3. Example for onplayertext, if you put return 0; it wont shot the samp default chat. return 1 will show.