25.11.2011, 20:28
Hello,
I've made a command, a chat one.
cmd assigned to strtok(cmdtext, idx);
result assigned to sttrest(cmdtext, idx);
When I'm writing, it will send me that I'm not writing(!strlen(result)).
It doesn't recognize the result..
Strrest:
Strtok:
Thanks advance.
I've made a command, a chat one.
PHP код:
if(strcmp(cmd, "/s", true) == 0 || strcmp(cmd, "/shout", true) == 0)
{
if(!strlen(result))
return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /s(hout) [text]");
format(string, sizeof(string), "%s shouts: %s!", Name(playerid), result);
ProxDetector(15.0,playerid,string,COLOR_FADE1,COLOR_FADE2,COLOR_FADE3,COLOR_FADE4,COLOR_FADE5);
return 1;
}
result assigned to sttrest(cmdtext, idx);
When I'm writing, it will send me that I'm not writing(!strlen(result)).
It doesn't recognize the result..
Strrest:
PHP код:
stock strrest(const string[],index)
{
new length = strlen(string),offset = index,result[256];
while((index < length) && ((index - offset) < (sizeof(result) - 1)) && (string[index] > '\r')) result[index - offset] = string[index],index++;
result[index - offset] = EOS;
if(result[0] == ' ' && string[0] != ' ') strdel(result,0,1);
return result;
}
PHP код:
strtok(const string[], &index)
{
new length = strlen(string);
while ((index < length) && (string[index] <= ' '))
{
index++;
}
new offset = index;
new result[20];
while ((index < length) && (string[index] > ' ') && ((index - offset) < (sizeof(result) - 1)))
{
result[index - offset] = string[index];
index++;
}
result[index - offset] = EOS;
return result;
}