22.04.2010, 00:03
Hi, I'm trying to convert my whole gamemode (235 commands -_-) to sscanf and ZCMD .. it's going great, but I have come up against a problem.
The command below is to spawn a vehicle with optional colour params.. basically, if they don't enter a colour .. or two colours then the vehicle colour is set to a random colour. Could someone please explain to me how I would do this? I can't see any way to use !strlen and it doesn't even work with ZCMD anyways.
Any help appreciated, thanks.
The command below is to spawn a vehicle with optional colour params.. basically, if they don't enter a colour .. or two colours then the vehicle colour is set to a random colour. Could someone please explain to me how I would do this? I can't see any way to use !strlen and it doesn't even work with ZCMD anyways.
pawn Код:
CMD:v(playerid, params[])
{
if(PlayerInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid))
{
new car, colour1, colour2, vehicle, Int, Float: Angle, Float: X,Float: Y,Float: Z, world;
GetPlayerPos(playerid, X, Y, Z); Int = GetPlayerInterior(playerid); world = GetPlayerVirtualWorld(playerid); GetPlayerFacingAngle(playerid,Angle);
if(sscanf(params, "dzz", car, colour1, colour2)) return SendClientMessage(playerid, Red,"USAGE: /v [model ID] [colour 1] [colour 2]");
if(!strlen(colour1)) colour1st = random(126); else colour1st = strval(tmp2);
if(!strlen(colour2)) colour2nd = random(126); else colour2nd = strval(tmp3);
if(!strlen(params)) return SendClientMessage(playerid, Red,"USAGE: /v [model ID] [colour 1] [colour 2]");
if(car < 400 || car > 611) return SendClientMessage(playerid, Red, "Invalid Vehicle Model");
vehicle = CreateVehicle(car, X+3, Y, Z, Angle, colour1, colour2, -1);
vName = GetVehicleName(vehicle);
if(world > 0) return SetVehicleVirtualWorld(vehicle,world);
LinkVehicleToInterior(vehicle,Int);
format(string, sizeof(string), "%s successfully spawned. To destroy it, use /dv", vName);
return SendClientMessage(playerid,White,string);
} else return 0;
}
