24.02.2012, 08:01
Everything compiles correctly, but when in-game this command is not detecting the params and just displays USAGE: /addv [dealerid] [model] [color1] [color2] [price] to the people who type the command.
How can i fix this?
Thanks
Here is the code:
How can i fix this?
Thanks
Here is the code:
pawn Код:
if(strcmp(cmdtext, "/addv", true) == 0)
{
new params[128];
if(!IsAdmin(playerid, 1)) SendClientMessage(playerid, COLOR_RED, "You are not admin!");
if(!IsPlayerSpawned(playerid)) return SendClientMessage(playerid, COLOR_RED, "You can't use this command now!");
new model[32], modelid, dealerid, color1, color2, price;
if(sscanf(params, "dsddd", dealerid, model, color1, color2, price))
return SendClientMessage(playerid, COLOR_GREY, "USAGE: /addv [dealerid] [model] [color1] [color2] [price]");
if(!IsValidDealership(dealerid)) return SendClientMessage(playerid, COLOR_RED, "Invalid dealerid!");
if(IsNumeric(model)) modelid = strval(model);
else modelid = GetVehicleModelIDFromName(model);
if(modelid < 400 || modelid > 611) return SendClientMessage(playerid, COLOR_RED, "Invalid model ID!");
if(color1 < 0 || color2 < 0) return SendClientMessage(playerid, COLOR_RED, "Invalid color!");
if(price < 0) return SendClientMessage(playerid, COLOR_RED, "Invalid price!");
new Float:X, Float:Y, Float:Z, Float:angle;
GetPlayerPos(playerid, X, Y, Z);
GetPlayerFacingAngle(playerid, angle);
X += floatmul(floatsin(-angle, degrees), 4.0);
Y += floatmul(floatcos(-angle, degrees), 4.0);
for(new i=1; i < MAX_DVEHICLES; i++)
{
if(!VehicleCreated[i])
{
new msg[128];
VehicleCreated[i] = VEHICLE_DEALERSHIP;
VehicleModel[i] = modelid;
VehiclePos[i][0] = X;
VehiclePos[i][1] = Y;
VehiclePos[i][2] = Z;
VehiclePos[i][3] = angle+90.0;
VehicleColor[i][0] = color1;
VehicleColor[i][1] = color2;
VehicleInterior[i] = GetPlayerInterior(playerid);
VehicleWorld[i] = GetPlayerVirtualWorld(playerid);
VehicleValue[i] = price;
valstr(VehicleOwner[i], dealerid);
VehicleNumberPlate[i] = DEFAULT_NUMBER_PLATE;
for(new d=0; d < sizeof(VehicleTrunk[]); d++)
{
VehicleTrunk[i][d][0] = 0;
VehicleTrunk[i][d][1] = 0;
}
for(new d=0; d < sizeof(VehicleMods[]); d++)
{
VehicleMods[i][d] = 0;
}
VehiclePaintjob[i] = 255;
UpdateVehicle(i, 0);
SaveVehicle(i);
format(msg, sizeof(msg), "Added vehicle id %d to dealerid %d", i, dealerid);
SendClientMessage(playerid, COLOR_WHITE, msg);
return 1;
}
}
SendClientMessage(playerid, COLOR_RED, "Can't add any more vehicles!");
return 1;
}