parameter length (strcmp)
#1

Hello , i'm learning about how using onplayercommandtex so i still can't understand the definition of the parameter "length"

-> When this length is set, the first x chars will be compared - doing "Hello" and "Hell No" with a length of 4 will say it's the same string. <-

I can't understand this and how to apply in a command.

I've read all the wiki about that and i still can't understand >.< thank you.
Reply
#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


Forum Jump:


Users browsing this thread: 1 Guest(s)