08.01.2014, 22:28
pawn Код:
public OnPlayerCommandText(playerid, cmdtext[]) {
new cmd[128], idx;
new tmp[128];
cmd = strtok(cmdtext, idx);
if (!strcmp(cmd, "/pintarcarro") ) {
if ( !IsPlayerInAnyVehicle(playerid))
return SendClientMessage(playerid, -1, "Vocк nгo esta em nenhum veнculo!");
tmp = strtok(cmdtext, idx);
if ( !strlen(tmp) )
return SendClientMessage(playerid, -1, "Use /pintarcarro [cor 1] [cor 2]");
new cor1 = strval(tmp);
tmp = strtok(cmdtext, idx);
if ( !strlen(tmp) )
return SendClientMessage(playerid, -1, "Use /pintarcarro [cor 1] [cor 2]");
new cor2 = strval(tmp);
if ( cor1 > 241 || cor1 < 0 || cor2 > 241 || cor2 < 0)
return SendClientMessage(playerid, -1, "Cor invбlida! Use valores entre 0 e 241!");
ChangeVehicleColor(GetPlayerVehicleID (playerid), cor1 , cor2 );
format (tmp, sizeof tmp, "Cores do veнculo alteradas! Cor 1 agora й %d e cor 2 й %d", cor1, cor2);
SendClientMessage(playerid, -1, tmp);
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;
}