23.02.2010, 21:16
Simplest to use strtok
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[128], idx;
cmd = strtok(cmdtext, idx);
if(strcmp("/say", cmd, true)==0)
{
new tmp[128];
new iText;
tmp = strtok(cmdtext, idx);
iText= strval(tmp);
if(strlen(tmp) == 0) return SendClientMessage(playerid, 0xFFFFFFFF, "Usage: /say [Text]");
SetPlayerChatBubble(playerid, iText, 0xFF0000FF, 100.0, 10000);
return 1;
}
return 0;
}
//Somewhere in your script
stock 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;
}