SA-MP Forums Archive
Small Questions - 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: Small Questions (/showthread.php?tid=334461)



Small Questions - CoDeZ - 14.04.2012

Hello.. i am new to scripting here and i am asking some questions
I've read lots of tutorials here but i got some questions

Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)
    {
        // Do something here
        return 1;
    }
    return 0;
}
I know that strcmp means string compare but at different tutorials i find "!" before the strcmp and sometimes the "!" is not there so does it make any difference?
Also what does that " == 0 )" thingy means? and what does the return do? i read @ samp wiki but i really couldn't get what does the return do.

Any help would be appreciated
Thanks


Re: Small Questions - ReneG - 14.04.2012

Both ! and 0 are the same thing.
So
pawn Код:
if(!strcmp(string1,string2,true))
and
pawn Код:
if(strcmp(string1,string2,true) == 0)
are the same thing.

Strcmp gets the two strings, and subtracts their character values. If that difference is 0, then the strings match. So doing == 0 and ! are both the same.


Re: Small Questions - CoDeZ - 14.04.2012

Now i get it
Thanks Vincent