Small Questions
#1

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

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

Now i get it
Thanks Vincent
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)