07.07.2010, 14:06
well, ehm...when i type /carcolor color color , the server say UNKNOWN COMMAND, but the script hasn't errors or warnings. why?
if(strcmp("/carcolor", cmdtext, true)== 0)
if(strcmp("/carcolor", cmdtext, true)== 0)
{
if(!IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, COLOR_BRIGHTRED, "You must be in a vehicle to use this command !");
new tmp[4];
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
new color1 = strval(tmp);
tmp = strtok(cmdtext,idx);
if(!strlen(tmp)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /carcolor [color1] [color2]");
new color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
return 1;
}
if(strcmp(cmdtext,"/bla",true) == 0)
if(!strcmp(cmdtext,"/bla",true))
public OnPlayerCommandText(playerid, cmdtext[])
{
new cmd[256], idx;
cmd = strtok(cmdtext, idx);
if(!strcmp(cmd, "/carcolor", true))
{
if(IsPlayerInAnyVehicle(playerid))
{
new color1, color2;
new tmp[256];
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carcolor (color1) (color2)");
color1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if(!strlen(tmp)) return SendClientMessage(playerid, 0xFF0000FF, "USAGE: /carcolor (color1) (color2)");
color2 = strval(tmp);
ChangeVehicleColor(GetPlayerVehicleID(playerid), color1, color2);
}
else
{
SendClientMessage(playerid, 0xFF0000FF, "Your Not in any Vehicle!");
}
return 1;
}
return 0;
}
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;
}