AttachObjectToVehicle teleports object to blueberry
#1

Hi. I'm trying to attach an object to a vehicle, but everytime I do that, the object just gets teleported to Blueberry.
pawn Код:
AttachObjectToVehicle(LoadBox[vehicleid][ForkliftObject], vehicleid, 0, 0.9, -0.2, 0, 0, 0);
Reply
#2

bump
Reply
#3

1. the LoadBox[vehicleid][ForkliftObject] must be valid object
2. the position of LoadBox[vehicleid][ForkliftObject] must be: 0.0,0.0,0.0
also see here: https://sampwiki.blast.hk/wiki/AttachObjectToVehicle
Reply
#4

Quote:
Originally Posted by Aliassassin123456
Посмотреть сообщение
2. the position of LoadBox[vehicleid][ForkliftObject] must be: 0.0,0.0,0.0
Nope. You can change the offset and the rotation of it.

And yes, LoadBox[vehicleid][ForkliftObject] must be valid (create the object and assign the objectid to that).
Reply
#5

I've added the missing .0 to the position & rotation, and I've made sure that the forklift object is valid, and yet it doesn't appear.
Reply
#6

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
Nope. You can change the offset and the rotation of it.
AttachObjectToVehicle never reset the position of object, example if you need to attach object to this offset of vehicle: 1.0,1.0,1.0 if we set offset of Object to 1.0,1.0,1.0 we can't use 1.0,1.0,1.0 in AttachObjectToVehicle if we do it Object doesn't go to your intentional position
Reply
#7

The position of the object that is to be attached to the vehicle isn't 1.0,1.0,1.0
Reply
#8

You need to do something like this:
pawn Код:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
    if(newstate == PLAYER_STATE_DRIVING)
    {
         LoadBox[GetPlayerVehicleID(playerid)][ForkliftObject] = CreateObject(2000, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
         AttachObjectToVehicle(LoadBox[GetPlayerVehicleID(playerid)][ForkliftObject], GetPlayerVehicleID(playerid), 0, 0.9, -0.2, 0, 0, 0);
    }
    return 1;
}
Reply
#9

This is the code where it creates the object & attaches it to the vehicle
pawn Код:
LoadBox[vehicleid][ForkliftObject] = CreateObject(964,-1077.59997559,4274.39990234,3.40000010,0.00000000,0.00000000,0.00000000);
AttachObjectToVehicle(LoadBox[vehicleid][ForkliftObject], vehicleid, 0.0, 0.9, -0.2, 0.0, 0.0, 0.0);
It's under a command, so it doesn't really fit under OnPlayerStateChange in this case :P
Reply
#10

i told you use 0.0,0.0,0.0 for offset of CreateObject !
Try this:
pawn Код:
LoadBox[vehicleid][ForkliftObject] = CreateObject(964,0.0, 0.0, 0.0, 0.00000000, 0.00000000, 0.00000000);
AttachObjectToVehicle(LoadBox[vehicleid][ForkliftObject], vehicleid, 0.0, 0.9, -0.2, 0.0, 0.0, 0.0);
Reply


Forum Jump:


Users browsing this thread: 3 Guest(s)