05.04.2016, 19:16
You can merge a few things together:
PHP код:
command(veh, playerid, params[]) {
new
vehicleid[30];
if(sscanf(params, "s[30]", vehicleid)) {
return SendClientMessage(playerid, -1, "usage: /veh <name/modelid>");
}
if((vehicleid[0] = GetVehicleModelByName(model)) == 0) {
return SendClientMessage(playerid, -1, "error: invalid model id.");
}
CreateVehicleEx(playerid, vehicleid);
return true;
}
GetVehicleModelByName(const name[])
{
if (IsNumeric(name) && (strval(name) >= 400 && strval(name) <= 611))
return strval(name);
for (new i = 0; i < sizeof(NameVehicles); i ++)
{
if (strfind(NameVehicles[i], name, true) != -1)
{
return i + 400;
}
}
return 0;
}