02.02.2013, 12:41
You just did something very long, you should make something more simple like this
Код:
if (strcmp("/lock", cmdtext, true, 10) == 0)//your command.
{
new engine, lights, alarm, doors, bonnet, boot, objective;
new vehicleid = GetPlayerVehicleID(playerid);//defining vehicleid is = to GetPlayerVehicleID.
if(IsPlayerInAnyVehicle(playerid))//Thsi will check that is a player In a vehcile or not.
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);//will check that what is the state of the vehicle lock.
if(doors == 1)//will check if the doors are already loocked it not.
{
GetVehicleParamsEx(vehicleid,engine,lights,alarm,doors,bonnet,boot,objective);
SetVehicleParamsEx(vehicleid,engine,lights,alarm,false,bonnet,boot,objective);//same as the engine one.
GameTextForPlayer(playerid,"Vehicle Unlocked!",2000,6);//for a text to appar on the screen for only 2 seconds.
return 1;
}
else
SetVehicleParamsEx(vehicleid,engine,lights,alarm,true,bonnet,boot,objective);
GameTextForPlayer(playerid,"Vehicle Locked!",2000,6);//for a text to appar on the screen for only 2 seconds.
}
else
SendClientMessage(playerid,-1,"Error: You are not in a vehicle!");//the error message.
}
return 0;
}

