[SOLVED \o/]sscanf and multiple optional parameters
#13

Ok, cannot believe I'm still stuck on this crap. Basically, I've written the command .. but now I have no idea how to let the user enter either a partial or full name of the car (Infernus, Inf, etc.) or the model ID, I mean, it was EASY with strtok, but now I'm stuck ..

pawn Код:
CMD:v(playerid, params[])
{
    if(PlayerInfo[playerid][Level] >= 3 || IsPlayerAdmin(playerid))
    {
        new car, vIsName, colour1, colour2, vehicle, Int, Float: Angle, Float: X,Float: Y,Float: Z, world;
        if(sscanf(params, "ddd", car, colour1, colour2)) return SendClientMessage(playerid, Red, "USAGE: /v [ModelID/Name] [Colour 1] [Colour 2] (Colours optional)");
        {
            GetPlayerPos(playerid, X, Y, Z); Int = GetPlayerInterior(playerid); world = GetPlayerVirtualWorld(playerid); GetPlayerFacingAngle(playerid,Angle);
            if(car < 400 || car > 611) return SendClientMessage(playerid, Red, "Invalid Vehicle Model");
      if(!IsNumeric(car)) vIsName = GetVehicleModelIDFromName(car); else vIsName = strval(car); // This bit I'm stuck at :|
            vehicle = CreateVehicle(vIsName, X+3, Y, Z, Angle, colour1, colour2, -1);
        vName = GetVehicleName(vehicle);
        if(world > 0) return SetVehicleVirtualWorld(vehicle,world);
        LinkVehicleToInterior(vehicle,Int);
        DynamicV[vehicle] = 1;
        format(string, sizeof(string), "%s successfully spawned. To destroy it, use /dc", vName);
        return SendClientMessage(playerid,White,string);
        }
        else if(sscanf(params, "d", car))
        {
      GetPlayerPos(playerid, X, Y, Z); Int = GetPlayerInterior(playerid); world = GetPlayerVirtualWorld(playerid); GetPlayerFacingAngle(playerid,Angle);
            if(car < 400 || car > 611) return SendClientMessage(playerid, Red, "Invalid Vehicle Model");
      if(!IsNumeric(car)) vIsName = GetVehicleModelIDFromName(car); else vIsName = strval(car);
            vehicle = CreateVehicle(vIsName, X+3, Y, Z, Angle, -1, -1, -1);
        vName = GetVehicleName(vehicle);
        if(world > 0) return SetVehicleVirtualWorld(vehicle,world);
        LinkVehicleToInterior(vehicle,Int);
        DynamicV[vehicle] = 1;
        format(string, sizeof(string), "%s successfully spawned. To destroy it, use /dc", vName);
        return SendClientMessage(playerid,White,string);
        }
    } else return 0;
    return 1;
}
Any help is appreciated, as usual.
Reply


Messages In This Thread
[SOLVED \o/]sscanf and multiple optional parameters - by dcmd_crash - 22.04.2010, 00:03
Re: sscanf and multiple optional parameters - by cessil - 22.04.2010, 04:34
Re: sscanf and multiple optional parameters - by dcmd_crash - 22.04.2010, 18:09
Re: sscanf and multiple optional parameters - by ¤Adas¤ - 22.04.2010, 18:23
Re: sscanf and multiple optional parameters - by dcmd_crash - 22.04.2010, 18:30
Re: sscanf and multiple optional parameters - by dcmd_crash - 23.04.2010, 14:33
Re: sscanf and multiple optional parameters - by woot - 23.04.2010, 17:04
Re: sscanf and multiple optional parameters - by dcmd_crash - 23.04.2010, 17:10
Re: sscanf and multiple optional parameters - by biltong - 23.04.2010, 17:31
Re: sscanf and multiple optional parameters - by Calgon - 23.04.2010, 17:39
Re: sscanf and multiple optional parameters - by dice7 - 23.04.2010, 17:40
Re: sscanf and multiple optional parameters - by dcmd_crash - 23.04.2010, 17:54
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 21:31
Re: sscanf and multiple optional parameters - by woot - 24.04.2010, 21:41
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 21:48
Re: sscanf and multiple optional parameters - by woot - 24.04.2010, 21:54
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 22:10
Re: sscanf and multiple optional parameters - by biltong - 24.04.2010, 22:16
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 22:25
Re: sscanf and multiple optional parameters - by Virtual1ty - 24.04.2010, 22:32
Re: sscanf and multiple optional parameters - by dcmd_crash - 24.04.2010, 23:20
Re: sscanf and multiple optional parameters - by Dabombber - 25.04.2010, 02:38
Re: sscanf and multiple optional parameters - by woot - 25.04.2010, 09:00
Re: sscanf and multiple optional parameters - by Dabombber - 25.04.2010, 11:32
Re: sscanf and multiple optional parameters - by dcmd_crash - 25.04.2010, 21:06
Re: sscanf and multiple optional parameters - by Dabombber - 25.04.2010, 23:34
Re: sscanf and multiple optional parameters - by dcmd_crash - 25.04.2010, 23:41
Re: sscanf and multiple optional parameters - by dcmd_crash - 25.04.2010, 23:51
Re: sscanf and multiple optional parameters - by Calgon - 26.04.2010, 00:32
Re: sscanf and multiple optional parameters - by dcmd_crash - 26.04.2010, 00:36

Forum Jump:


Users browsing this thread: 2 Guest(s)