returns
#1

hi !

I'm trying to learn pawn and I still don't get where should I use return 0 or 1, can someone explain it ?
Reply
#2

u can use return 1;
in last your script
Reply
#3

u can use return 1;
in last your script
Reply
#4

Quote:
Originally Posted by DandyCorleone
Посмотреть сообщение
u can use return 1;
in last your script
But, why return 1 instead of return 0 ?
Reply
#5

https://sampwiki.blast.hk/wiki/Control_Structures#return
Reply
#6

Quote:
Originally Posted by Sunehildeep
Посмотреть сообщение
Ok, I think i understand it a little bit more.

So, what happen if i return 1 value or if I return 0 value ?

For example on this code:

PHP код:
public OnPlayerCommandText(playeridcmdtext[])
{
    if (
strcmp("/lanzacohetes"cmdtexttrue10) == 0)
    {
        
SendClientMessage(playeridCOLOR_WHITE,"[SERVIDOR]: Se te ha sido concedido un lanzacohetes.");
        
GivePlayerWeapon(playerid36500);
        return 
1;
    } 
If you can explain me in a no-programmer language it would be better, what happens line by line and what happens when it reach the return line, with 1 value and 0 value
Reply
#7

A return-statement passes control back to the function that called this function in the first place, i.e. "return to where you were before". In this particular case it's the server process. The server process examines the returned result to decide whether to send the "unknown command" message or not (0/1).

I suggest you read the language guide, specifically the section on operators and expressions (starting page 105): https://dl.dropboxusercontent.com/u/.../pawn-lang.pdf
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)