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: return (
/showthread.php?tid=99090)
return -
_ReloadeD_ - 25.09.2009
why in some commands we have return 1 or return 0??
and how i can know when i need use them?>
tmx for anybody help
Re: return -
dice7 - 25.09.2009
The 'return' statement terminates a function. It is also used when creating custom functions to return numbers/ids into given valuables
Re: return -
_ReloadeD_ - 25.09.2009
can you give me exmple when i use return 0 and return 1?
Re: return -
MadeMan - 25.09.2009
Example:
pawn Код:
MyFunc(playerid)
{
//Code here
return 1;
}
public OnPlayerConnect(playerid)
{
if(MyFunc(playerid) == 1) //This is now 1 so statement is true
}
pawn Код:
MyFunc(playerid)
{
//Code here
return 0;
}
public OnPlayerConnect(playerid)
{
if(MyFunc(playerid) == 1) //This is now 0 so statement is false
}
Re: return -
Desert - 25.09.2009
Also
Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
if (strcmp("/teleport", cmdtext, true, 9) == 0)
{
if(IsPlayerAdmin(playerid))
{
SetPlayerPos(playerid,0,0,0);
return 1;
}
else
return 0;
}
return 0;
}
This code might give you an idea when to use return
Re: return -
_ReloadeD_ - 25.09.2009
ok tnx i understand it