strcmp() and !strcmp()
#1

pawn Код:
strcmp("blabla","blabla",true)
This check if blabla = blabla and ignore letter case.


pawn Код:
!strcmp("blabla","blabla",true)
This check if blabla != blabla (unequal)

So wtf is this in my mode:
pawn Код:
if (!strcmp(cmdtext, "/stop", true))
    {
        if(GetPlayerState(playerid) != PLAYER_STATE_ONFOOT) return 0;
        ClearAnimations(playerid);
        return 1;
    }
    if(!strcmp(cmdtext, "/$$", true))
    {
        pInfo[playerid][Money] += 50000;
        return 1;
    }
I dont understand this.. With ! script must do commands if those two strings aren't same, for example /$$ string it must do when cmdtext unequal /$$, but this work... If I remove ! every command make one action. What the fuck is this ? Because now with strcmp() I dont understand what ! do o_O
Reply
#2

Hello!

This is because strcmp does something more then just checking for equality!

Код:
strcmp will test two strings for equallity.

	Returns :
		< 0 if s1 is less than s2
		 0 if s1 == s2
		> 0 if s1 is greater than s2

The net result means that the strcmp return code is logically incorrect because it returns a FALSE value when the strings match.
See strcmp-manual for details.

- Draco
Reply
#3

Quote:
Originally Posted by DracoBlue
Hello!

This is because strcmp does something more then just checking for equality!

Код:
strcmp will test two strings for equallity.

	Returns :
		< 0 if s1 is less than s2
		 0 if s1 == s2
		> 0 if s1 is greater than s2

The net result means that the strcmp return code is logically incorrect because it returns a FALSE value when the strings match.
See strcmp-manual for details.

- Draco
Oh, thats how it does Thanks =]
Reply
#4

Quote:
Originally Posted by Dreftas
Oh, thats how it does Thanks =]
I was wondering if somebody ever asks whyyyyy!

Happy coding,
Draco
Reply
#5

Offtopic >

SetPlayerTeam(1,-1);
SetPlayerTeam(2,-1);
SetPlayerTeam(3,-1);

Now players id 1,2 and 3 team is same ?
Reply
#6

Quote:
Originally Posted by Dreftas
Offtopic >

SetPlayerTeam(1,-1);
SetPlayerTeam(2,-1);
SetPlayerTeam(3,-1);

Now players id 1,2 and 3 team is same ?
better try this thread for such questions: http://forum.sa-mp.com/index.php?topic=48279.0

You will need to use SetTeamCount, too.

- Draco
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)