HELP PLEASE! "_"
#1

What is that " == 0) " stands for? And what is its advantages? And why does it exists in the first example but not in the second one?
Код:
"if (strcmp(cmdtext, "/msgall", true) == 0)"
Код:
"if (strcmp(cmdtext, "/msgall", true))"
Reply
#2

Код:
if(VariableOne == VariableTwo)
checks if the VariableOne equals VariableTwo.
Notice that this isn't good:
Код:
if(VariableOne = VariableTwo)
Код:
VariableOne = VariableTwo;
changes VariableOne's value to VariableTwo's value.

Why checking if it equals null(==0)? Check how strcmp works.

"if (strcmp(cmdtext, "/msgall", true))" I guess you think
Код:
if (!strcmp(cmdtext, "/msgall", true))
If so, it's the alternative way of doing the first tihing.
Reply
#3

In the first code it's checking if Strcmp returns 0 and in the second code it's checking if it returns 1.

Strcmp returns:

Quote:
Originally Posted by Wiki
-1 if string1 comes before string2
1 if string1 comes after string2
0 if the strings are the same (for the matched length).
More examples with other functions like IsPlayerAdmin

pawn Код:
if(IsPlayerAdmin(playerid) == 1) // checks if IsPlayerAdmin returns 1 (Logged into rcon)
if(IsPlayerAdmin(playerid)) // checks if IsPlayerAdmin returns 1 too (Logged into rcon)
//                     //                                      //               //
if(!IsPlayerAdmin(playerid)) // checks if IsPlayerAdmin returns 0 (Not logged)
if(IsPlayerAdmin(playerid) == 0) // checks if IsPlayerAdmin returns 0 too (Not logged)
You can find more info in the wiki article about Control Structures.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)