HELP PLEASE! "_" - 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)
+--- Thread: HELP PLEASE! "_" (
/showthread.php?tid=361862)
HELP PLEASE! "_" -
bodey3333 - 22.07.2012
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))"
Re: HELP PLEASE! "_" -
Roko_foko - 22.07.2012
Код:
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.
Re: HELP PLEASE! "_" -
[KHK]Khalid - 22.07.2012
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.