AttachObject - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (
https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: AttachObject (
/showthread.php?tid=271421)
AttachObject -
Yako - 24.07.2011
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?
Re: AttachObject -
MadeMan - 24.07.2011
What button do you press?
Re: AttachObject -
Yako - 24.07.2011
Код:
if((newkeys & KEY_SUBMISSION) && !(oldkeys & KEY_SUBMISSION))
Re: AttachObject -
MoroDan - 24.07.2011
From keyboard, what button do you press ?
Re: AttachObject -
Yako - 24.07.2011
I press 2
Respuesta: AttachObject -
FranciscoSmitch - 05.08.2011
This is the 2 up the Q and the W