return
#1

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

The 'return' statement terminates a function. It is also used when creating custom functions to return numbers/ids into given valuables
Reply
#3

can you give me exmple when i use return 0 and return 1?
Reply
#4

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

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

ok tnx i understand it
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)