need help zcmd and sscanf /veh [ name ] +rep
#7

Yes, you're right, the parameters can be whatever you want ( not numbers ) :
Код:
CMD:hey( p, prm[ ] )
The command Should Be:
pawn Код:
CMD:veh( playerid, params[ ] )
{
    new s_C[ 30 ], i_C[ 2 ];
    if( unformat( params, "s[30]D(-1)D(-1)", s_C, i_C[ 0 ], i_C[ 1 ] ) )        return SendClientMessageEx( playerid, COLOR_WHITE, "USAGE: /veh [model ID] [color 1] [color 2]" );
    if( IsPlayerInAnyVehicle( playerid ) )                                      return SendClientMessageEx( playerid, COLOR_WHITE, "ERROR: You are already in a vehicle." );
       
    new CarModel;
    if( IsNumeric( s_C ) )  CarModel = strval( s_C );
    else                    CarModel = GetVehicleModelIDFromName( s_C );
   
    if( CarModel < 400 || CarModel > 611 )                                      return SendClientMessageEx( playerid, COLOR_WHITE, "ERROR: Invalid vehicle model/name" );
   
    if( i_C[ 0 ] == -1 ) i_C[ 0 ] = random( 250 );
    if( i_C[ 1 ] == -1 ) i_C[ 1 ] = random( 250 );
   
    new Float: Pos[ 4 ];
    GetPlayerPos( playerid, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ] );
    GetPlayerFacingAngle( playerid, Pos[ 3 ] );
    CreatedCars[iIterator] = CreateVehicle( CarModel, Pos[ 0 ], Pos[ 1 ], Pos[ 2 ], Pos[ 3 ], i_C[ 0 ], i_C[ 1 ], -1 );
    VehicleFuel[ CreatedCars[ iIterator ] ] = 100.0;
    LinkVehicleToInterior( CreatedCars[ iIterator ], GetPlayerInterior( playerid ) );
   
    return( 1 );
}
Functions:
pawn Код:
IsNumeric( const string[ ] )
{
    for( new i = 0, j = strlen( string ); i != j; i ++ )
    {
        if( string[ i ] > '9' || string[ i ] < '0' ) return ( 0 );
    }
    return ( 1 );
}
EDIT: Modified the command...
Reply


Messages In This Thread
need help zcmd and sscanf /veh [ name ] +rep - by RicaNiel - 17.04.2012, 00:45
Re: need help zcmd and sscanf /veh [ name ] +rep - by sampmark05 - 17.04.2012, 00:51
Re: need help zcmd and sscanf /veh [ name ] +rep - by ViniBorn - 17.04.2012, 01:30
Re: need help zcmd and sscanf /veh [ name ] +rep - by RicaNiel - 17.04.2012, 04:31
Re: need help zcmd and sscanf /veh [ name ] +rep - by RollTi - 17.04.2012, 05:54
Re: need help zcmd and sscanf /veh [ name ] +rep - by RicaNiel - 17.04.2012, 05:57
Re: need help zcmd and sscanf /veh [ name ] +rep - by aRoach - 17.04.2012, 07:28

Forum Jump:


Users browsing this thread: 2 Guest(s)