GabrielMendes999 Posted September 8, 2019 Share Posted September 8, 2019 How do you put an object in the trunk? I wanted to put some boxes in this truck but I don't know how to do it, please help me Link to comment
AlvarO Posted September 9, 2019 Share Posted September 9, 2019 Try to use attachElements function Link to comment
Furzy Posted September 12, 2019 Share Posted September 12, 2019 attachElements setElementPosition you can use bone_attach resource too Link to comment
Casti Posted September 12, 2019 Share Posted September 12, 2019 addCommandHandler("create", function(sourcePlayer) if (sourcePlayer) then local x, y, z = getElementPosition ( sourcePlayer ) -- get the player's position local rotZ = getElementRotation ( sourcePlayer ) -- get the player's rotation around the Z axis in degrees Vehicle = createVehicle ( 411, x+2, y, z, 0, 0, rotZ) Object = createObject ( objectid, 0, 0, 0) attachElements (Vehicle, Object, 0, 0, 5 ) end end) Link to comment
Dzsozi (h03) Posted September 12, 2019 Share Posted September 12, 2019 https://community.multitheftauto.com/index.php?p=resources&s=details&id=15679 With this resource you are able to get/modify the position of a vehicle's cargo space. The position you get is the middle of for example a Bobcat's bed, so if you want to add lots of objects you will have to use some loops for positioning. Look at the exampleS.Lua in the resource. local function testFunction2() local vehicleObject if not isElement(vehicleObject) then local cargoPos = exports["vehiclecargo"]:getVehicleCargoPlacementPosition(source) if cargoPos then local x, y, z = getPositionFromElementOffset(source,cargoPos.x, cargoPos.y, cargoPos.z+0.285) local vehicleObject = createObject(1271, x, y, z, 0, 0, 0) setElementCollisionsEnabled(vehicleObject, false) setObjectScale(vehicleObject, 1.5) attachElements(vehicleObject, source, cargoPos.x, cargoPos.y, cargoPos.z+0.285) -- +value on Z because of the object scaling so the object doesn't collide with the vehicle addEventHandler("onVehicleExit", source, function() if isElement(vehicleObject) then destroyElement(vehicleObject) vehicleObject = nil end end ) end end end addEventHandler("onVehicleEnter", root, testFunction2) Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now