SA-MP Forums Archive
strcmp() and !strcmp() - 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: strcmp() and !strcmp() (/showthread.php?tid=81427)



strcmp() and !strcmp() - Dreftas - 10.06.2009

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


Re: strcmp() and !strcmp() - DracoBlue - 10.06.2009

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


Re: strcmp() and !strcmp() - Dreftas - 10.06.2009

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 =]


Re: strcmp() and !strcmp() - DracoBlue - 10.06.2009

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

Happy coding,
Draco


Re: strcmp() and !strcmp() - Dreftas - 10.06.2009

Offtopic >

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

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


Re: strcmp() and !strcmp() - DracoBlue - 10.06.2009

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