What's the difference?
#1

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
Reply
#2

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

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

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.
Reply
#5

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

They both do the same, just in different ways.
Reply
#7

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)
Reply
#8

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)
Reply
#9

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

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


Forum Jump:


Users browsing this thread: 1 Guest(s)