parameter length (strcmp)
#2

I do not speak English very well but I will try to explain it

pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])    
{
    if (strcmp("/mycommand", cmdtext, true, 10) == 0)  
    {
        // Do something here
        return 1;
    }
    return 0;
}
Strcmp compare string "mycommand" with string "cmdtext", "true" is "ignorecase", then "mycommand" is the same "MyCoMmaNd", "10" is the lenght of the command, you can also leave it because it is a optional parameter... "== 0" because if the the strings are the same strcmp return 0, then we proceed to the instruction inside the brackets, that return 1 that the command was executed successfully. If the strings don't are the same, return 0 that the command wasn't executed successfully.
Reply


Messages In This Thread
parameter length (strcmp) - by xeon_inside - 31.12.2014, 04:04
Re: parameter length (strcmp) - by VincenzoDrift - 31.12.2014, 08:41

Forum Jump:


Users browsing this thread: 1 Guest(s)