Jump to content

Attaching a Suitcase


Cyandie

Recommended Posts

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 by Guest
Link to comment
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
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 by Guest
Link to comment
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

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
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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...