sscanf and multiple parameters
#5

Basically, you need to add the first specifier to the other sscanf line(s). There's a certain thing you can do so you don't waste processing power by storing the string again though. Check this out:

pawn Код:
CMD:editveh(playerid, params[])
{
    new
        type [25],
        vID,
        vModel;
       
    if( sscanf( params, "s[25]I(-1)I(-1)", type, vID, vModel ) )
    {
        SendClientMessage (playerid, COL_SILVER, "USAGE: /editveh <type>");
        return 1;
    }
   
    if( !strcmp( type, "model" ) )
    {
        if( sscanf( params, "{s[25]}ii", vID, vModel ) )
        {
            SendClientMessage (playerid, COL_SILVER, "USAGE: /editveh model <vehicle id> <model id>");
            return 1;
        }
       
        if( fexist( GetVehiclePath(vID) ) )
        {
            print("d");
            new
                INI: Vehicle = INI_Open (GetVehiclePath (vID) ),
                annStr [128],
                Float: vx,
                Float: vy,
                Float: vz,
                Float: va,
                tempVID;
               
            GetVehiclePos (vID, vx, vy, vz);
            GetVehicleZAngle (vID, va);
               
            INI_SetTag (Vehicle, "data");
           
            INI_WriteInt (Vehicle, "model", vModel);
           
            INI_Close (Vehicle);
           
            INI_ParseFile( GetVehiclePath (vID), "LoadVehicle_%s", .bExtra = true, .extra = vID );
           
            DestroyVehicle (vID);
           
            tempVID = CreateVehicle( VehicleInfo [vID] [Model], vx, vy, vz, va, VehicleInfo [vID] [SpawnCol1], VehicleInfo [vID] [SpawnCol2], 360000 );
   
            SetVehicleParamsEx (tempVID, VehicleInfo [vID] [EngineStatus], VehicleInfo [vID] [LightStatus], VehicleInfo [vID] [AlarmStatus], \
                VehicleInfo [vID] [Locked], VehicleInfo [vID] [HoodStatus], VehicleInfo [vID] [TrunkStatus], 0
            );
           
            format (annStr, 128, "[VEHICLE] "#INT_SILVER"Vehicle %d's model has been edited to %d.", vID, vModel);
            SendClientMessage (playerid, COL_LIGHTBLUE, annStr);
        }
        else return SendClientMessage (playerid, COL_SILVER, "This vehicle does not exist!");
    }
    return 1;
}
Reply


Messages In This Thread
sscanf and multiple parameters - by 2KY - 07.08.2013, 01:40
Re: sscanf and multiple parameters - by ThePhenix - 07.08.2013, 01:47
Re: sscanf and multiple parameters - by 2KY - 07.08.2013, 01:49
Re: sscanf and multiple parameters - by Ada32 - 07.08.2013, 02:58
Re: sscanf and multiple parameters - by Scenario - 07.08.2013, 03:06
Re: sscanf and multiple parameters - by Edix - 07.08.2013, 03:06

Forum Jump:


Users browsing this thread: 1 Guest(s)