SA-MP Forums Archive
What's the difference? - 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)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: What's the difference? (/showthread.php?tid=114947)



What's the difference? - Galcio - 21.12.2009

Hi, I'm quite new to coding in SAMP, I don't know if this sounds silly or not, whatever. I just wonder what the difference is between:
pawn Код:
if (!strcmp(cmdtext, "/example1", true))
and
pawn Код:
if (strcmp("/objective", cmdtext, true, 10) == 0)
Basically, what's the difference between "!strcmp" and "strcmp"?

Galcio



Re: What's the difference? - Martin_M - 21.12.2009

Actually i don't know, because i never had used strcmp.
Better use dcmd or zcmd. It's faster and better.


Re: What's the difference? - Galcio - 21.12.2009

Thanks.. but that didn't answer my question at all. If somebody knows, please reply as I'm interested in knowing it.


Re: What's the difference? - Finn - 21.12.2009

It's for checking if function returns false.

pawn Код:
if(IsPlayerConnected(playerid))
{
  // Player is connected
}
pawn Код:
if(!IsPlayerConnected(playerid))
{
  // Player is not connected
}
In your case "strcmp() == 0" is the same as "!strcmp()", because false is 0.


Re: What's the difference? - Galcio - 21.12.2009

Thanks.. but if I want to make a teleport command, which one would you use? !strcmp or strcmp?


Re: What's the difference? - Marcel - 21.12.2009

They both do the same, just in different ways.


Re: What's the difference? - Correlli - 21.12.2009

Quote:
Originally Posted by Galcio
Thanks.. but if I want to make a teleport command, which one would you use? !strcmp or strcmp?
It's the same if you use your first or second example.

Use zcmd command processor for commands - http://forum.sa-mp.com/index.php?topic=116240.0 - (it's simple and faster than strcmp)


Re: What's the difference? - Babul - 21.12.2009

simple, the ! char represents the "not".
(1 < 2), true. (1 is smaller)
(1 == 2), not true. (1 equals 2 ?)
!(1 == 2), true. (1 is NOT equal 2)
(1 > 2), not true. (1 greater 2 ?)
!(1 > 2), true. (1 NOT greater 2)



Re: What's the difference? - Niixie - 21.12.2009

If theres and "!" infront of anything its the oppersit than without?
you get it?


Re: What's the difference? - MPKaboose - 21.12.2009

! means is not equal whit like 2 != 3 in you're case ! in front of the function means 0