Attach Object To Vehicle ( I can pay for help : PM me )
#4

Well, you can't unfortunately. You have to use these functions sequentially: CreateObject, EditObject (OnPlayerEditObject), AttachObjectToVehicle. You have to edit before it's attached, once you attach it, you cannot move the object with EditObject. That's mean you have to create the object by getting the vehicle position, and track the position change inside OnPlayerEditObject, calculate the distance of object to vehicle, if the object position is being edited too far, you have to cancel the edit and revert its position. After the player is done with editing it, Attach the object on vehicle, this object will attach on the center of vehicle, so the x,y,z value are relative to vehicle position. Read this wiki page: https://sampwiki.blast.hk/wiki/AttachObjectToVehicle

You cannot use AttachedObject function (SetPlayerAttachedObject and EditAttachedObject) as a preview, the position are not same, because attachedobject is relative to player character bone, not player position nor vehicle position.

Please note that, once the vehicle is destroyed, you have to Destroy the Object as it wont be destroyed (and will stay on its last position), also it will get attached to the same vehicle id (e.g. player was having vehicle id 111, then it's destroyed, another vehicle is spawning with id 111, the object will reattach to that id). OnVehicleDeath is one callback that detects it, but not all.

Please note that since it uses CreateObject (Global objects), it will have limits, so try using dynamic object (streamer plugin) in case you allow this for many players. https://sampforum.blast.hk/showthread.php?tid=102865
Reply


Messages In This Thread
Attach Object To Vehicle ( I can pay for help : PM me ) - by Mikeydoo - 11.01.2016, 07:13
Re: Attach Object To Vehicle ( I can pay for help : PM me ) - by RoboN1X - 11.01.2016, 08:36
Re: Attach Object To Vehicle ( I can pay for help : PM me ) - by Mikeydoo - 11.01.2016, 14:32
Re: Attach Object To Vehicle ( I can pay for help : PM me ) - by RoboN1X - 12.01.2016, 02:39
Re: Attach Object To Vehicle ( I can pay for help : PM me ) - by PrO.GameR - 12.01.2016, 08:48

Forum Jump:


Users browsing this thread: 1 Guest(s)