AttachObjectToVehicle Arrays - 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 Arrays (
/showthread.php?tid=346210)
AttachObjectToVehicle Arrays -
Luis- - 27.05.2012
Hi, I need help with arrays, I have an array of coords for two vehicles which are PD vehicles and I need to use the array coords with AttachObjectToVehicle.
pawn Код:
new Float:PDObjects[2][] = {
{0.009999,3.435001,-0.435000,90.359909,-90.179969,0.000000},
{-0.000000,2.400000,0.075000,89.099983,-89.099983,0.000001}
};
new rand = random(sizeof(PDObjects));
AttachObjectToVehicle(myobject, i, PDObjects[rand][0], PDObjects[rand][1], PDObjects[rand][2], PDObjects[rand][3], PDObjects[rand][4], PDObjects[rand][5]);
Re: AttachObjectToVehicle Arrays -
Luis- - 27.05.2012
Ah, sorry! I want to put some coords in a array which has been posted on the OP and then when I spawn my vehicles it does a check to see if one of the vehicles is a police car, then it should attach the object I created to the police car using the coords in the array.
Re: AttachObjectToVehicle Arrays -
ViniBorn - 27.05.2012
You created the object 'myobject' ?
pawn Код:
public OnVehicleSpawn(vehicleid)
{
if(GetVehicleModel(vehicleid) == 596) // LSPD
{
new rand = random(sizeof(PDObjects));
AttachObjectToVehicle(myobject, vehicleid, PDObjects[rand][0], PDObjects[rand][1], PDObjects[rand][2], PDObjects[rand][3], PDObjects[rand][4], PDObjects[rand][5]);
}
return true;
}
Re: AttachObjectToVehicle Arrays -
Luis- - 27.05.2012
It did work but the coords are set for two vehicles. One if the cruiser and the other is the enforcer.
Re: AttachObjectToVehicle Arrays -
ViniBorn - 27.05.2012
What is the model ID of them?
Adapt.
Ex:
pawn Код:
public OnVehicleSpawn(vehicleid)
{
new rand;
if(GetVehicleModel(vehicleid) == MODEL_ENFORCER) // Enforcer
rand = 0;
else if(GetVehicleModel(vehicleid) == MODEL_CRUISER) // Cruiser
rand = 1;
AttachObjectToVehicle(myobject, vehicleid, PDObjects[rand][0], PDObjects[rand][1], PDObjects[rand][2], PDObjects[rand][3], PDObjects[rand][4], PDObjects[rand][5]);
return true;
}
Re: AttachObjectToVehicle Arrays -
Luis- - 27.05.2012
Thanks, it worked like a charm!