17.03.2011, 04:12
I have a custom police light system. When you are in a certain vehicle and press H or Caps Lock, a light is attached to your vehicle. The thing is, I can't get it to destroy when the key is pressed again. Here is the code:
PS: Is there any way to define a new key?
pawn Код:
new pdlight;
if(newkeys & KEY_CROUCH)
{
if(light == 0)
{
if(IsPlayerInVehicle(playerid, Cars[PD09]) || IsPlayerInVehicle(playerid, Cars[PD10]))
{
pdlight = CreateObject(18646, 0, 0, -500,0, 0, 0, 5000);
AttachObjectToVehicle(pdlight, GetPlayerVehicleID(playerid), 0.4, 0.6, 0.41, 0 ,0 ,0);
light = 1;
}
}else {
if(IsPlayerInVehicle(playerid, Cars[PD09]) || IsPlayerInVehicle(playerid, Cars[PD10])) {
DestroyObject(pdlight);
light = 0;
}
}
}