attaching these objects, they all go to the wrong vehicle... -
niels44 - 15.01.2013
hey everybody,
somehow this objects i wanna attach all go to the wrong vehicle...
i use this include btw:
https://sampforum.blast.hk/showthread.php?tid=229111&page=8
ok so a little while ago, i wanted to attach some objects NEAR the cargobob helicopter, so 1 could be a driver of it, 1 passenger, and 2 or 3 ppl on each side, that worked out well, then i wanted to create it for the second cargobob, and it didnt work... idk how or what, but it didnt, they didnt got attached etc.
then now i downloaded that include, and i wanted to attach those missiles to 5 different rustlers, but it doesnt attaches it to ANY of the 5 rustlers, instead of the rustlers, it attaches them to the first cargobob i attached those other side objects to, so ppl could lift with the helicopter, anyways this is my code, can anybody tell me what im doing wrong that it all attaches to 1 vehicle(cargobob)?
pawn Код:
// on top i have:
new CargoBob1, CargoBob2;
new Rustler[5];
// ongamemodeinit
CargoBob1 = CreateVehicleInWorld(548, -1362.5999756, -2320.8999023, 71.1999969, 90.0000000, -1, -1, 7);
CargoBob2 = CreateVehicleInWorld(548, -1669.3000488, -2274.1000977, 40.0999985, 90.0000000, -1, -1, 7);
CB2Tuning1 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CB2Tuning2 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CB2Tuning3 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CB2Tuning4 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CB2Tuning5 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CB2Tuning6 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CargoB1Tuning1 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CargoB1Tuning2 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CargoB1Tuning3 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CargoB1Tuning4 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CargoB1Tuning5 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
CargoB1Tuning6 = CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0);
AttachDynamicObjectToVehicle(CB2Tuning1, CargoBob2, -2.295005, -0.504999, -1.609998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CB2Tuning2, CargoBob2, -2.295005, 0.979999, -1.624998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CB2Tuning3, CargoBob2, -2.295005, 2.465008, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CB2Tuning4, CargoBob2, 2.425007, 2.465008, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CB2Tuning5, CargoBob2, 2.425007, 0.949999, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CB2Tuning6, CargoBob2, 2.425007, -0.534999, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CargoB1Tuning1, CargoBob1, -2.295005, -0.504999, -1.609998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CargoB1Tuning2, CargoBob1, -2.295005, 0.979999, -1.624998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CargoB1Tuning3, CargoBob1, -2.295005, 2.465008, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CargoB1Tuning4, CargoBob1, 2.425007, 2.465008, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CargoB1Tuning5, CargoBob1, 2.425007, 0.949999, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CargoB1Tuning6, CargoBob1, 2.425007, -0.534999, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
Rustler[0] = CreateVehicleInWorld(476, -1353.4000244, -2330.6000977, 62.5999985, 180.0000000, -1, -1, 7);
Rustler[1] = CreateVehicleInWorld(476, -1369.9000244, -2331.0000000, 62.5999985, 180.0000000, -1, -1, 7);
AddVehicleMissiles(Rustler[0],-1.324998, -0.904999);
AddVehicleMissiles(Rustler[1],-1.324998, -0.904999);
Rustler[2] = CreateVehicleInWorld(476, -1685.4000244, -2290.0000000, 42.9000015, 0.0000000, -1, -1, 7);
Rustler[3] = CreateVehicleInWorld(476, -1697.4000244, -2289.0000000, 44.0999985, 354.0000000, -1, -1, 7);
Rustler[4] = CreateVehicleInWorld(476, -1718.8000488, -2310.3000488, 45.5999985, 93.9968262, -1, -1, 7);
AddVehicleMissiles(Rustler[2],-1.324998, -0.904999);
AddVehicleMissiles(Rustler[3],-1.324998, -0.904999);
AddVehicleMissiles(Rustler[4],-1.324998, -0.904999);
my createvehicleinworld(originally made by Ryder):
pawn Код:
CreateVehicleInWorld(modelid, Float: x, Float: y, Float: z, Float: ang, color1, color2, worldid) return \
SetVehicleVirtualWorld(AddStaticVehicle(modelid, x, y, z, ang, color1, color2), worldid);
can anybody tell me what is wrong with this code?
greets niels
Re: attaching these objects, they all go to the wrong vehicle... -
niels44 - 16.01.2013
erm bump? i want to attach those 5 different missiles to 5 different rustlers, but instead of the rustlers, it puts them to a cargobob, which i earlier attached other objects to... so anyways is there a way i can fix this?
Re: attaching these objects, they all go to the wrong vehicle... -
redreaper666 - 16.01.2013
Yes there is a way to make this
do like this:
new rustler1;
new rustler2;
rustler1 = AddStaticVehicle(rustlerid,1434.6855,1299.6062,11. 5435,1.9998,0,0);
rustler2 = AddStaticVehicle(rustlerid,1434.6855,1299.6062,11. 5435,1.9998,0,0);
and then attach the objects to the rustler 1.
attachobjecttovehicle(objid,rustler1,...);//Rocket 1
attachobjecttovehicle(objid,rustler2,...);//Rocket 2
Re: attaching these objects, they all go to the wrong vehicle... -
niels44 - 16.01.2013
eehm aint that how i already did it? i only used the Addmissile function, which is in the include doing exxactly wut you did... so this would give the same result right?
Re: attaching these objects, they all go to the wrong vehicle... -
Threshold - 16.01.2013
Can you show us your AddMissile function, the error is probably in there...
EDIT: Too late :P
Re: attaching these objects, they all go to the wrong vehicle... -
SilverKiller - 16.01.2013
Show The AddMissile Function, the error must be there.
Re: attaching these objects, they all go to the wrong vehicle... -
niels44 - 16.01.2013
i did it else ppl, and it works
, not exactly as i wanted it, but it does works and it works properly, also the cargobob objects work, wut i did is using this filterscript(transfered it into my gm):
https://sampforum.blast.hk/showthread.php?tid=280678
and had a look at it, cuz THAT filterscript DOES creates at every rhino a minigun, so i thought lets have a look at it, and i found out that i can easily add more vehicle ids etc to it, so this is wut i did:
pawn Код:
forward check( );
public check( )
{
for( new i = 0; i < MAX_VEHICLES; ++i )
{
new model = GetVehicleModel( i );
if( model == 432 )
{
if( vehhasminigun[ i ] == 0 )
{
vehhasminigun[ i ] = 1;
mgun[ minigunnum ] = CreateDynamicObject( 2985, 0, 0, 0, 0, 0, 0, 7, -1, -1, 200.0 );
AttachDynamicObjectToVehicle( mgun[ minigunnum ], i, 0.74, 3.37, -0.25, 0.00, 0.00, 89.47 );
minigunnum ++;
}
}
if(model == 476)
{
if(vehhasmissile[i] == 0)
{
vehhasmissile[ i ] = 1;
AddVehicleMissiles(i, 1.364998, 0.904999);
}
}
if(model == 548)
{
if(vehhascargo[i] == 0)
{
vehhascargo[i] = 1;
AttachDynamicObjectToVehicle(CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0), i, -2.295005, -0.504999, -1.609998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0), i, -2.295005, 0.979999, -1.624998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0), i, -2.295005, 2.465008, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0), i, 2.425007, 2.465008, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0), i, 2.425007, 0.949999, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
AttachDynamicObjectToVehicle(CreateDynamicObject(914, 0, 0, 0, 0, 0, 0, 7, -1, -1, 100.0), i, 2.425007, -0.534999, -1.639998, -90.449951, 1.005001, 0.000000); //Object Model: 914 |
}
}
}
return 1;
}
forward loop( );
public loop( )
{
for( new i = 0; i < MAX_PLAYERS; ++i )
{
if( IsPlayerConnected( i ) )
{
new vehicleid = GetPlayerVehicleID( i );
new model = GetVehicleModel( vehicleid );
if( model == 432 )
{
new
keys
,ud
,lr
;
GetPlayerKeys( i, keys, ud, lr );
if( keys & 128 )
{
SetPlayerAttachedObject( i, 0, 18695, 1, 0.379999, 1.799999, -2.700000, 0.000000, 0.000000, 0.000000, 1.000000, 1.000000, 1.000000 );
laser[ i ] = CreateObject( 19084, 0.75, 3.84, 0.86, 0.00, 0.00, 92.61 );
AttachObjectToVehicle( laser[ i ], vehicleid, 0.73, 4.18, 0.86, 0.00, 0.00, 88.03 );
PlayerPlaySound( i, 1135, 0.0, 0.0, 0.0 );
SetTimerEx( "destroy", 250, 0, "i", i );
new
Float:x
,Float:y
,Float:z
,Float:x2
,Float:y2
;
GetPlayerPos( i, x2, y2, z );
#pragma unused x2
#pragma unused y2
GetXYInFrontOfPlayer( i, x, y, 5.0 );
for( new u = 0; u < MAX_PLAYERS; ++u )
{
if( IsPlayerInRangeOfPoint( u, 6.0, x, y, z ) && u != i )
{
new Float:hp;
new Float:armour;
GetPlayerArmour(u, armour);
if(armour != 0)
{
SetPlayerArmour(u, armour-5);
PlayerPlaySound( u, 1135, 0.0, 0.0, 0.0 );
}
else
{
GetPlayerHealth( u, hp );
SetPlayerHealth( u, hp - 5 );
PlayerPlaySound( u, 1135, 0.0, 0.0, 0.0 );
}
if( hp < 1 )
CallLocalFunction( "OnPlayerDeath", "ddd", u, i, 38 );
}
}
}
}
}
}
return 1;
}
forward destroy( i );
public destroy( i )
{
RemovePlayerAttachedObject( i, 0 );
DestroyObject( laser[ i ] );
return 1;
}
for the rest nothing, only included the VM(vehicle missile include)
anyways thanks for the help
@******, which other code did you mean?
Re: attaching these objects, they all go to the wrong vehicle... -
niels44 - 16.01.2013
ah i see