Return Values Help
#1

Hi

There is a php code and i wanted to know that can i add return 0 or not or whatever to do.

GOOD?
PHP код:
//==============================================================================
// Math Quiz Answer
//==============================================================================
    
if(strval(text) == MathQuizTest && MathQuizTest != -1)
    {
    
CorrectAnswer(playerid);
    return 
0;
    } 
Or This is GOOD?
PHP код:
//==============================================================================
// Math Quiz Answer
//==============================================================================
    
if(strval(text) == MathQuizTest && MathQuizTest != -1)
    {
    
CorrectAnswer(playerid);
    } 
Or This is GOOD?
PHP код:
//==============================================================================
// Math Quiz Answer
//==============================================================================
    
if(strval(text) == MathQuizTest && MathQuizTest != -1CorrectAnswer(playerid); 
Suggest guys which right otherwise tell me how to make right.

Thank You
Reply
#2

return 0 stands for return false
return 1 stands for return true

You should return 1 or return true at the place where you want a function to be called correctly. At each Command or function's true part, you should return 1 and visa versa.

PHP код:
if(strval(text) == MathQuizTest && MathQuizTest != -1
    { 
        
CorrectAnswer(playerid); 
        return 
1
    }  
 else return 
0
or

PHP код:
if(strval(text) == MathQuizTest && MathQuizTest != -1) return  CorrectAnswer(playerid); 
 
 else return 
0
Reply
#3

This is under OnPlayerText So Is there a effect of return 1 on other statements?
Reply
#4

This code
PHP код:
if(strval(text) == MathQuizTest && MathQuizTest != -1
    { 
        
CorrectAnswer(playerid); 
        return 
1
    }  
 else return 
0
show Warning 225: unreachable code

Help me Guys pls
Reply
#5

Dont add else return 0. You are already returning something at the end of the callback.
Reply
#6

Quote:
Originally Posted by TadePoleMG
Посмотреть сообщение
This is under OnPlayerText So Is there a effect of return 1 on other statements?
When you return 1 under OnPlayerText, it allows the text to be sent to the chat. If you return 0, you can use the text and then not send it to the chat.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)