07.08.2011, 01:11
Why are you using strtok + strcmp method? It's horribly slow! Here's an example of using ZCMD (which will remove the use of strtok all together)
If you're going to be using more than one parameter, look into the use of sscanf.
pawn Код:
COMMAND:bonnet( playerid, params[ ] )
{
if( isnull( params ) ) return SendClientMessage( playerid, COLOR_GREY: "USAGE: /bonnet [open, close]" );
if( !strcmp( params, "open", true ) )
{
if( GetPlayerState( playerid ) == 1 ) tmpcar = GetClosestCar( playerid );
if( GetDistanceToCar( playerid, tmpcar ) <= 4 )
{
new engline, lights, alarm, doors, bonnet, boot, objective;
GetVehicleParamsEx( tmpcar, engine, lights, alarm, doors, bonnet, boot, objective );
SetVehicleParamsEx( tmpcar, engine, lights, alarm, doors, VEHICLE_PARAMS_ON, boot, objective );
// ...
}
}
else if( !strcmp( params, "close", true ) )
{
// .. close the bonnet
}
return 1;
}