[help] /bonnet not working on my cmd -
tony_fitto - 07.08.2011
Hey guys,
I just made this command "/bonnet" and it's not working some how.
If anyone find the problem please help me, cause I get no error or warnings on the command, and the onlything I see is when I do only type "/bonnet" and not "/bonnet open"
pawn Код:
if(strcmp(cmdtext, "/bonnet", true) == 0)
{
new tmpcar;
new Message[256];
new strGatePosition[256];
strGatePosition = strtok(cmdtext, idx);
if(!strlen(strGatePosition))
{
SendClientMessage(playerid, COLOR_GREY, "USAGE: /bonnet [open, close]");
return 1;
}
if(strcmp(strGatePosition,"open",true) == 0)
{
if(GetPlayerState(playerid) == 1)
{
tmpcar = GetClosestCar(playerid);
}
if(GetDistanceToCar(playerid,tmpcar) <= 4)
{
new engine,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);
format(Message, sizeof(Message), "* %s open the hood.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, Message, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
else if(strcmp(strGatePosition,"close",true) == 0)
{
if(GetPlayerState(playerid) == 1)
{
tmpcar = GetClosestCar(playerid);
}
if(GetDistanceToCar(playerid,tmpcar) <= 4)
{
new engine,lights,alarm,doors,bonnet,boot,objective;
GetVehicleParamsEx(tmpcar,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(tmpcar,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective);
format(Message, sizeof(Message), "* %s close the hood.", GetPlayerNameEx(playerid));
ProxDetector(30.0, playerid, Message, COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE,COLOR_PURPLE);
}
}
return 1;
}
Re: [help] /bonnet not working on my cmd -
Grim_ - 07.08.2011
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)
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;
}
If you're going to be using more than one parameter, look into the use of sscanf.
Re: [help] /bonnet not working on my cmd -
tony_fitto - 07.08.2011
Cause I hate ZCMD, and my question was why it wasn't working.