12.04.2015, 18:05
I am unsure what the whole looping construct is for. You should just try to create the vehicle and if that fails because the limit is reached then CreateVehicle will return INVALID_VEHICLE_ID. What you described should be easily achievable with sscanf's optional parameters.
You could even prepare the formatstring by inserting the player's current vehicle model.
pawn Код:
if(sscanf(params, "D(-1)D(-1)D(-1)D(300)", model, col1, col2, delay))
{
if(!(400 <= model <= 611))
{
// model not valid, do something
}
if(col1 == -1)
col1 = random(126);
if(col2 == -1)
col2 = random(126);
if(!(15 <= delay <= 300))
return SendClientMessage ... invalid respawn delay must be between 15 and 300
v[playerid] = CreateVehicle(model, ..., col1, col2, delay);
if(v[playerid] == INVALID_VEHICLE_ID)
return SendClientMessage ... failed, vehicle limit reached
}