AttachObjectToVehicle and delete attached object. - 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)
+--- Thread: AttachObjectToVehicle and delete attached object. (
/showthread.php?tid=379609)
AttachObjectToVehicle and delete attached object. -
[TLCL]_ECM_PPP - 22.09.2012
Hello everybody! I Attached a red light to maverick and it's attaching but is isn't detaching. Where is my mistake?
Код:
Definicje:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
OnPlayerKeyStateChange:
new helilight = CreateObject(18657,0,0,0,0,0,0,100.0);
if (PRESSED( KEY_CROUCH ))
{
new heliid = GetPlayerVehicleID(playerid);
switch(GetVehicleModel(heliid))
{
case 487:
{
AttachObjectToVehicle(helilight, GetPlayerVehicleID(playerid), 0.004999, 2.019998, 0.599999, -80.025001, 0.000000, 0.000000); //Object Model: 18657 | 0
return 1;
}
}
}
if (RELEASED( KEY_CROUCH ))
{
switch(GetVehicleModel(GetPlayerVehicleID(playerid)))
{
case 487:
{
DestroyObject(helilight);
return 1;
}
}
}
Re: AttachObjectToVehicle and delete attached object. -
clarencecuzz - 22.09.2012
Try this:
pawn Код:
#define PRESSED(%0) \
(((newkeys & (%0)) == (%0)) && ((oldkeys & (%0)) != (%0)))
#define RELEASED(%0) \
(((newkeys & (%0)) != (%0)) && ((oldkeys & (%0)) == (%0)))
new helilight[MAX_PLAYERS];
public OnPlayerConnect(playerid)
{
helilight[playerid] = -1;
return 1;
}
public OnPlayerKeyStateChange(playerid, newkeys, oldkeys)
{
if(PRESSED( KEY_CROUCH ))
{
new heliid = GetPlayerVehicleID(playerid);
if(GetVehicleModel(heliid) == 487)
{
if(helilight[playerid] == -1)
{
helilight[playerid] = CreateObject(18657,0,0,0,0,0,0,100.0);
}
AttachObjectToVehicle(helilight[playerid], heliid, 0.004999, 2.019998, 0.599999, -80.025001, 0.000000, 0.000000); //Object Model: 18657 | 0
}
}
else
{
if(helilight[playerid] != -1)
{
DestroyObject(helilight[playerid]);
helilight[playerid] = -1;
}
}
return 1;
}
Re: AttachObjectToVehicle and delete attached object. -
[TLCL]_ECM_PPP - 22.09.2012
Works. Thx