How to use AttachObjectToVehicle and keep the vehicle always spawned
#1

- Well , I want to use AttachObjectTovehicle..


I Have like 10 Spawned And i have their Co-ordinates , etc..


I've named them Cop[1] = bla bla
Cop[2] = bla bla

and so on


Now.. How to attach an objects to ALL those 10 cars ? hope someone help me xD
Reply
#2

pawn Код:
for(new i=0; i<sizeof(Cop); i++)
{
    AttachObjectToVehicle(Cop[i], blah blah blah);
}
Reply
#3

And , Do i need to add at the top "new Cop[10];" ? Sorry but i am still learning

And , Where do i add that code ?
Reply
#4

I assume Cop[] is holding the vehicle IDs? You should name stuff better so you know what it does, for example 'CopVehicle'.

If you want to create 10 cop cars, then you need to declare an array with 10 cells in outside all callbacks/functions, as you said. The first ID is 0 and last is 9, so you want to do:

pawn Код:
CopVehicle[0] = CreateVehicle();
CopVehicle[1] = CreateVehicle();
CopVehicle[2] = CreateVehicle();
CopVehicle[3] = CreateVehicle();
CopVehicle[4] = CreateVehicle();
CopVehicle[5] = CreateVehicle();
CopVehicle[6] = CreateVehicle();
CopVehicle[7] = CreateVehicle();
CopVehicle[8] = CreateVehicle();
CopVehicle[9] = CreateVehicle();
in OnGameModeInit.
Reply
#5

Aight , Thanks - What about this code :

PHP код:
for(new i=0i<sizeof(Copvehicle); i++)
{
    
AttachObjectToVehicle(Copvehicle[i], blah blah blah);

- Where should i add it ?
Reply
#6

After you create them.
Reply
#7

Well ,thats what i did :


PHP код:
    CopVehicle[0] = AddStaticVehicle(477,1566.2892,-1615.8591,13.1186,270.1325,1,1); // cop car 1
    
CopVehicle[1] = AddStaticVehicle(477,1557.3464,-1615.8545,13.1397,270.2108,1,1); // cop car 2
    
CopVehicle[2] = AddStaticVehicle(477,1591.6287,-1606.2499,13.1367,180.9415,1,1); // cop car 3
    
CopVehicle[3] = AddStaticVehicle(477,1597.4304,-1606.0475,13.1902,181.4439,1,1); // cop car 4
    
CopVehicle[4] = AddStaticVehicle(477,1601.6312,-1630.6210,13.2421,91.8427,1,1); // cop car 5
    
CopVehicle[5] = AddStaticVehicle(477,1564.4960,-1631.6226,13.1129,88.9426,1,1); // cop car 6
    
    
for(new i=0i<sizeof(CopVehicle); i++)
    {
    
AttachObjectToVehicle(CopVehicle[i], 477,-0.039999, -0.4699990.6699990.0000000.0000000.000000);
    } 
But eh.. Nothing was attached to the vehicles -

What should i add here ?


PHP код:
  AttachObjectToVehicle(CopVehicle[i], 477 
Instead of the "477"
Reply
#8

Bump - Second Page..

Really need help to know what to add in the second slot.
Reply
#9

People please i need urgent help........
Reply
#10

Код:
AttachObjectToVehicle(objectid, vehicleid, Float:OffsetX, Float:OffsetY, Float:OffsetZ, Float:RotX, Float:RotY, Float:RotZ)
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)