AttachObject
#1

Hello, I want that officers could attach the light only in few vehicles. Here is my code:
Код:
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
When I enter the vehicle and press the button nothing happens.
Maybe somebody can help me?
Reply
#2

What button do you press?
Reply
#3

Код:
if((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
Reply
#4

From keyboard, what button do you press ?
Reply
#5

I press 2
Reply
#6

This is the 2 up the Q and the W
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)