24.07.2011, 13:11
Hello, I want that officers could attach the light only in few vehicles. Here is my code:
When I enter the vehicle and press the button nothing happens.
Maybe somebody can help me?
Код:
forward IsASportCar(carid);
Код:
public IsASportCar(carid) { if(carid == 33 || carid == 34 || carid == 35 || carid == 36) { return 1; } return 0; }
Код:
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys) { new vid = GetPlayerVehicleID(playerid); if((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION)) { if(!IsASportCar(vid)) { SendClientMessage(playerid,WHITE,"This is not a police car"); }else{ VehicleLightSwitch(playerid); } } return 1; }
Код:
VehicleLightSwitch(playerid) { new vid = GetPlayerVehicleID(playerid); if(Lamp[vid] == 1) { DestroyObject(light[vid]); Lamp[vid] = 0; return 1; } if(Lamp[vid] == 0) { light[vid] = CreateObject(18646,0.398071289,0.75390625,0.43879509, 0.0, 0.0, 96.0); AttachObjectToVehicle(light[vid], vid, 0.398071289,0.75390625,0.43879509, 0.0, 0.0, 0.0); Lamp[vid] = 1; } return 1; }
Код:
AddStaticVehicleEx(541,1526.4551,-1645.7045,5.5157,179.8724,58,8,7200000);//Car 33 AddStaticVehicleEx(541,1530.6464,-1645.2098,5.5966,179.7011,125,125,7200000);//Car 34 AddStaticVehicleEx(541,1534.8159,-1644.9489,5.6616,180.5380,25,1,7200000);//Car 35 AddStaticVehicleEx(541,1538.8845,-1644.8691,5.7656,180.2300,24,1,7200000);//Car 36
Maybe somebody can help me?