AttachDynamicObjectToVehicle
#1

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
PHP код:
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.136810.83630,   0.000000.000000.00000);
                                    
vAttachedSiren[vid] = 1;
                        }
                        else if(
GetVehicleModel(vid) == 515) {
                                    
VehicleSiren[vid] = CreateDynamicObject(194190.004611.292061.23484,   0.000000.000000.00000);
                                    
VehicleSiren[vid] = AttachDynamicObjectToVehicle(VehicleSiren[vid],vid,0.004611.292061.23484,   0.000000.000000.00000);
                                    
vAttachedSiren[vid] = 1;
                        }
                    }
                    else {
                        
DestroyDynamicObject(VehicleSiren[vid]);
                        
vAttachedSiren[vid] = 0;
                    }
                }
            }
        }
    } 
So basically if(vAttachedSiren[vid] == 0) { doesnt work
Reply
#2

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; 
                        }
                    } 
                } 
            } 
        } 
    }
Reply
#3

Nopeee, the problem remains, you can attach them but not detach
Reply
#4

Try it , edited
Reply
#5

Quote:
Originally Posted by SilverStand
Посмотреть сообщение
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
Reply
#6

Quote:
Originally Posted by TwinkiDaBoss
Посмотреть сообщение
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
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)