01.06.2012, 15:10
The issue would appear to be that you're splitting the string by spaces, but if there are no spaces then nothing is going to be sent to the 2 dimensional array you've named "cmd". Which means it's just going to be blank and therefore the if statement won't be true.
You can confirm this by typing "/test test", without the quotes.
To fix it, you could simply do this:
Then the first cell in the array will contain the command regardless. The size of that array is quite large too, are you really ever going to need 100 parameters? Might want to rethink that.
You should also consider moving onto a command processing system like ZCMD with sscanf to split the commands parameters up, it's a lot easier and there is less stuff you have to deal with, not to mention more efficient.
You can confirm this by typing "/test test", without the quotes.
To fix it, you could simply do this:
pawn Код:
new cmd[100][128];
strcat(cmd[0], cmdtext);
split(cmdtext, cmd, ' ');
You should also consider moving onto a command processing system like ZCMD with sscanf to split the commands parameters up, it's a lot easier and there is less stuff you have to deal with, not to mention more efficient.