10.01.2011, 10:17
hello guys. im trying to make vehicle commands with zcmd. i want them to work like when you enter engine it turns it on and when you do it again it turns off. but somethings wrong with my code. there are no errors or warnings. please tell me whats wrong.
Код:
COMMAND:engine(playerid,params[]) { if(IsPlayerConnected(playerid)) { new vid = GetPlayerVehicleID(playerid); if (engine == 1) // check if engine ON { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,VEHICLE_PARAMS_OFF,lights,alarm,doors,bonnet,boot,objective); } } else if (engine == 0) // check if engine off { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,VEHICLE_PARAMS_ON,lights,alarm,doors,bonnet,boot,objective); } } } return 1; } COMMAND:lights(playerid,params[]) { if(IsPlayerConnected(playerid)) { new vid = GetPlayerVehicleID(playerid); if (lights == 1) { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,0,alarm,doors,bonnet,boot,objective); } } else if (lights == 0) { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,1,alarm,doors,bonnet,boot,objective); } } } return 1; } COMMAND:alarm(playerid,params[]) { if(IsPlayerConnected(playerid)) { new vid = GetPlayerVehicleID(playerid); if (alarm == 1) // check if engine ON { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,lights,VEHICLE_PARAMS_OFF,doors,bonnet,boot,objective); alarm = 0; } } else if (alarm == 0) // check if engine off { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,lights,VEHICLE_PARAMS_ON,doors,bonnet,boot,objective); alarm = 1; } } } return 1; } COMMAND:hood(playerid,params[]) { if(IsPlayerConnected(playerid)) { new vid = GetPlayerVehicleID(playerid); if (bonnet == 1) // check if engine ON { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,lights,alarm,doors,VEHICLE_PARAMS_OFF,boot,objective); bonnet = 0; } } else if (bonnet == 0) // check if engine off { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,lights,alarm,doors,VEHICLE_PARAMS_ON,boot,objective); bonnet = 1; } } } return 1; } COMMAND:boot(playerid,params[]) { if(IsPlayerConnected(playerid)) { new vid = GetPlayerVehicleID(playerid); if (boot == 1) // check if engine ON { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_OFF,objective); boot = 0; } } else if (boot == 0) // check if engine off { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,VEHICLE_PARAMS_ON,objective); boot = 1; } } } return 1; } COMMAND:highlight(playerid,params[]) { if(IsPlayerConnected(playerid)) { new vid = GetPlayerVehicleID(playerid); if (objective == 1) // check if engine ON { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,VEHICLE_PARAMS_OFF); objective = 0; } } else if (objective == 0) // check if engine off { if(vid != INVALID_VEHICLE_ID) { GetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,objective); SetVehicleParamsEx(vid,engine,lights,alarm,doors,bonnet,boot,VEHICLE_PARAMS_ON); objective = 1; } } } return 1; }