PDA

View Full Version : AttachDynamicObjectToVehicle


TwinkiDaBoss
05/12/2015, 01:02 PM
Alright so the problem is quite simple. Im able to attach these lights on my truck but unable to detach them. It entirely ignores the check before the last one ie: vAttachedSiren[vid]
Maybe Im making some really small mistake and I cant see it (havent slept for a while now) so yeah if you find anything thats bugged let me know
if(PRESSED(KEY_FIRE)) {
if(IsPlayerInAnyVehicle(playerid)) {
new vid = GetPlayerVehicleID(playerid);
if(AccInfo[playerid][PlayerFaction] == 1) {
if(VehInfo[vid][VehFaction] == 1) {
if(vAttachedSiren[vid] == 0) { //ignores this part, continues going forward
if(GetVehicleModel(vid) == 554) {
VehicleSiren[vid] = CreateDynamicObject(19419,0,0,0,0,0,0,0,0);
VehicleSiren[vid] = AttachDynamicObjectToVehicle(VehicleSiren[vid],vid,-0.00282, -0.13681, 0.83630, 0.00000, 0.00000, 0.00000);
vAttachedSiren[vid] = 1;
}
else if(GetVehicleModel(vid) == 515) {
VehicleSiren[vid] = CreateDynamicObject(19419, 0.00461, 1.29206, 1.23484, 0.00000, 0.00000, 0.00000);
VehicleSiren[vid] = AttachDynamicObjectToVehicle(VehicleSiren[vid],vid,0.00461, 1.29206, 1.23484, 0.00000, 0.00000, 0.00000);
vAttachedSiren[vid] = 1;
}
}
else {
DestroyDynamicObject(VehicleSiren[vid]);
vAttachedSiren[vid] = 0;
}
}
}
}
}


So basically if(vAttachedSiren[vid] == 0) { doesnt work

SilverStand
05/12/2015, 01:15 PM
try this


if(PRESSED(KEY_FIRE)) {
if(IsPlayerInAnyVehicle(playerid)) {
new vid = GetPlayerVehicleID(playerid);
if(AccInfo[playerid][PlayerFaction] == 1) {
if(VehInfo[vid][VehFaction] == 1) {
if(vAttachedSiren[vid] == 0) { //ignores this part, continues going forward
if(GetVehicleModel(vid) == 554) {
VehicleSiren[vid] = CreateDynamicObject(19419,0,0,0,0,0,0,0,0);
AttachDynamicObjectToVehicle(VehicleSiren[vid],vid,-0.00282, -0.13681, 0.83630, 0.00000, 0.00000, 0.00000);
vAttachedSiren[vid] = 1;
}
else if(GetVehicleModel(vid) == 515) {
VehicleSiren[vid] = CreateDynamicObject(19419, 0.00461, 1.29206, 1.23484, 0.00000, 0.00000, 0.00000);
AttachDynamicObjectToVehicle(VehicleSiren[vid],vid,0.00461, 1.29206, 1.23484, 0.00000, 0.00000, 0.00000);
vAttachedSiren[vid] = 1;
}
}
else {
if(GetVehicleModel(vid) == 554 || 515) {
DestroyDynamicObject(VehicleSiren[vid]);
vAttachedSiren[vid] = 0;
}
}
}
}
}
}

TwinkiDaBoss
05/12/2015, 01:19 PM
Nopeee, the problem remains, you can attach them but not detach

SilverStand
05/12/2015, 01:21 PM
Try it , edited

TwinkiDaBoss
05/12/2015, 01:28 PM
Try it , edited

Aha I see where you coming from with the code, I thought it should detect automaticly based on Vehicle ID, I guess I was wrong, thanks for the help mate, it works like a charm now, +rep

SilverStand
05/12/2015, 01:31 PM
Aha I see where you coming from with the code, I thought it should detect automaticly based on Vehicle ID, I guess I was wrong, thanks for the help mate, it works like a charm now, +rep

You are welcome xD