Cyandie Posted June 5, 2012 Share Posted June 5, 2012 Hey there I was wondering how would it be able to attach a suitcase to a 'thePlayer' or 'source' s Arm? ( If so could you give a example code it would be great if you could ). Link to comment
micheal1230 Posted June 5, 2012 Share Posted June 5, 2012 (edited) https://community.multitheftauto.com/index.php?p= ... ls&id=2540 https://wiki.multitheftauto.com/wiki/AttachElements 1:38 for suitcase Tank Hat From Wiki function tankHat ( source, commandName ) local x, y, z = getElementPosition ( source ) --Get the players position local tank = createVehicle ( 432, x, y, z + 5 ) --Create a tank attachElements ( tank, source, 0, 0, 5 ) --Attach the tank to the player. end addCommandHandler ( "hat", tankHat ) Edit: Might Use This Resource For Myself Edit 2: Cant Get The Resource To Work For Me Edit 3: The Resource Does Work I Just Fail Edited June 6, 2012 by Guest Link to comment
micheal1230 Posted June 6, 2012 Share Posted June 6, 2012 Hey there I was wondering how would it be able to attach a suitcase to a 'thePlayer' or 'source' s Arm? ( If so could you give a example code it would be great if you could ). Here is my script i doesnt work too well, i cant get the rotation to set and it doesnt lock the the hand bone so when you walk it floats next to you but its still a start function suitcase(source, commandName) local x, y, z = getElementPosition ( source ) local attachedElements = getAttachedElements local case = createObject(1210, x + 0.2, y, z , 0, 0, 0) if exports.global:hasItem(source, 157) then attachElements ( case, source, 0.2, 0, 0, 0, 0, 0) exports.global:sendLocalMeAction(source, "out a briefcase and start's to carry it.") end end addCommandHandler("suitcase", suitcase) Link to comment
myonlake Posted June 6, 2012 Share Posted June 6, 2012 (edited) addCommandHandler("suitcase", function(player, cmd) local x, y, z = getElementPosition(player) local case = createObject(1210, x, y, z, 0, 0, 0) attachElements(case, player, 0.2, 0, 0, 0, 0, 0) end ) Edited June 6, 2012 by Guest Link to comment
Cyandie Posted June 6, 2012 Author Share Posted June 6, 2012 addCommandHandler("suitcase", function(player, cmd) local x, y, z = getElementPosition(player) local case = createObject(1210, x, y, z, 0, 0, 0) if exports.global:hasItem(player, 157) then attachElements(case, player, 0.2, 0, 0, 0, 0, 0) exports.global:sendLocalMeAction(player, "out a briefcase and start's to carry it.") end end ) I don't use vG Code I just use Freeroam to script in but cheers Link to comment
myonlake Posted June 6, 2012 Share Posted June 6, 2012 Oh I thought it was your script earlier there, nevermind about that. Link to comment
50p Posted June 6, 2012 Share Posted June 6, 2012 The thing is attachElements always attaches an element to another element at specified offset position and rotation. Once you attach it, it will stay at that position all the time like micheal1230 said. ...Here is my script i doesnt work too well, i cant get the rotation to set and it doesnt lock the the hand bone so when you walk it floats next to you but its still a start ... This is the correct behaviour of attachElements function. If you want the object to be attached to a bone you need to set elements position to the bone position and rotation on every frame (onClientRender or I'd advice to use onClientPreRender since this event is triggered before all positions are updated so it doesn't look like a lag). You can try to do it yourself if you're not afraid of challenges or you can download a resource which does that. I don't know its name but I'm pretty sure you will find it on community site (just search for "bone"). Or search forum, I'm sure this question has been asked before. Good luck. Link to comment
DarkLink Posted June 6, 2012 Share Posted June 6, 2012 The thing is attachElements always attaches an element to another element at specified offset position and rotation. Once you attach it, it will stay at that position all the time like micheal1230 said....Here is my script i doesnt work too well, i cant get the rotation to set and it doesnt lock the the hand bone so when you walk it floats next to you but its still a start ... This is the correct behaviour of attachElements function. If you want the object to be attached to a bone you need to set elements position to the bone position and rotation on every frame (onClientRender or I'd advice to use onClientPreRender since this event is triggered before all positions are updated so it doesn't look like a lag). You can try to do it yourself if you're not afraid of challenges or you can download a resource which does that. I don't know its name but I'm pretty sure you will find it on community site (just search for "bone"). Or search forum, I'm sure this question has been asked before. Good luck. Thats nice, thanks for your explation 50p, i did not start this thread, but can I ask u something about it ? How do I know the exactly coords to attach the element ? I mean the exactly position to be on hand... on torso... on leg... just by doing alot of tests ? and trys ? using coords near player position ? Thanks alot in advance Link to comment
50p Posted June 6, 2012 Share Posted June 6, 2012 @DarkLink, Does this answers your question? https://wiki.multitheftauto.com/wiki/GetPedBonePosition Link to comment
DarkLink Posted June 6, 2012 Share Posted June 6, 2012 @DarkLink,Does this answers your question? https://wiki.multitheftauto.com/wiki/GetPedBonePosition ofc it answers ! thanks alot mate ! Link to comment
Cyandie Posted June 6, 2012 Author Share Posted June 6, 2012 I got it woking to look like he's holding was awesome ;D Link to comment
micheal1230 Posted June 6, 2012 Share Posted June 6, 2012 I got it woking to look like he's holding was awesome ;D Did you get the resource working? or did you script frames ? if you didnt script frames could you maybe tell me how to get the resource to work? 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