[DevTool] Attach Object to Ped with preview

Hey, today I am here to release a simple dev tool I had to make to help me visualize attaching objects to a ped.

Commands:

  • /co [OBJECT_NAME] [BONE] - Creates the object
  • /cd - Deletes object
  • /cout - Outputs to console the positions, bone, rotation etc
  • /cst [number] - Sets the tolerance everytime you move something
  • /cb [bone] - Changes the bone. The bone should be the name and not the id

Controls:

  • Numpad 8 - Increases Z
  • Numpad 5 - Decreases Z
  • Arrow up - Moves Y
  • Arrow down - Moves Y
  • Arrow left - Moves X
  • Arrow right - Moves X
  • Numpad 7 - Rotates Z
  • Numpad 9 - Rotates Z
  • Numpad 4 - Rotates Y
  • Numpad 6 - Rotates Y
  • Numpad + - Rotates X
  • Numpad - - Rotates X
bones = {
    ["SKEL_ROOT"] = 0,
    ["FB_R_Brow_Out_000"] = 1356,
    ["SKEL_L_Toe0"] = 2108,
    ["MH_R_Elbow"] = 2992,
    ["SKEL_L_Finger01"] = 4089,
    ["SKEL_L_Finger02"] = 4090,
    ["SKEL_L_Finger31"] = 4137,
    ["SKEL_L_Finger32"] = 4138,
    ["SKEL_L_Finger41"] = 4153,
    ["SKEL_L_Finger42"] = 4154,
    ["SKEL_L_Finger11"] = 4169,
    ["SKEL_L_Finger12"] = 4170,
    ["SKEL_L_Finger21"] = 4185,
    ["SKEL_L_Finger22"] = 4186,
    ["RB_L_ArmRoll"] = 5232,
    ["IK_R_Hand"] = 6286,
    ["RB_R_ThighRoll"] = 6442,
    ["SKEL_R_Clavicle"] = 10706,
    ["FB_R_Lip_Corner_000"] = 11174,
    ["SKEL_Pelvis"] = 11816,
    ["IK_Head"] = 12844,
    ["SKEL_L_Foot"] = 14201,
    ["MH_R_Knee"] = 16335,
    ["FB_LowerLipRoot_000"] = 17188,
    ["FB_R_Lip_Top_000"] = 17719,
    ["SKEL_L_Hand"] = 18905,
    ["FB_R_CheekBone_000"] = 19336,
    ["FB_UpperLipRoot_000"] = 20178,
    ["FB_L_Lip_Top_000"] = 20279,
    ["FB_LowerLip_000"] = 20623,
    ["SKEL_R_Toe0"] = 20781,
    ["FB_L_CheekBone_000"] = 21550,
    ["MH_L_Elbow"] = 22711,
    ["SKEL_Spine0"] = 23553,
    ["RB_L_ThighRoll"] = 23639,
    ["PH_R_Foot"] = 24806,
    ["SKEL_Spine1"] = 24816,
    ["SKEL_Spine2"] = 24817,
    ["SKEL_Spine3"] = 24818,
    ["FB_L_Eye_000"] = 25260,
    ["SKEL_L_Finger00"] = 26610,
    ["SKEL_L_Finger10"] = 26611,
    ["SKEL_L_Finger20"] = 26612,
    ["SKEL_L_Finger30"] = 26613,
    ["SKEL_L_Finger40"] = 26614,
    ["FB_R_Eye_000"] = 27474,
    ["SKEL_R_Forearm"] = 28252,
    ["PH_R_Hand"] = 28422,
    ["FB_L_Lip_Corner_000"] = 29868,
    ["SKEL_Head"] = 31086,
    ["IK_R_Foot"] = 35502,
    ["RB_Neck_1"] = 35731,
    ["IK_L_Hand"] = 36029,
    ["SKEL_R_Calf"] = 36864,
    ["RB_R_ArmRoll"] = 37119,
    ["FB_Brow_Centre_000"] = 37193,
    ["SKEL_Neck_1"] = 39317,
    ["SKEL_R_UpperArm"] = 40269,
    ["FB_R_Lid_Upper_000"] = 43536,
    ["RB_R_ForeArmRoll"] = 43810,
    ["SKEL_L_UpperArm"] = 45509,
    ["FB_L_Lid_Upper_000"] = 45750,
    ["MH_L_Knee"] = 46078,
    ["FB_Jaw_000"] = 46240,
    ["FB_L_Lip_Bot_000"] = 47419,
    ["FB_Tongue_000"] = 47495,
    ["FB_R_Lip_Bot_000"] = 49979,
    ["SKEL_R_Thigh"] = 51826,
    ["SKEL_R_Foot"] = 52301,
    ["IK_Root"] = 56604,
    ["SKEL_R_Hand"] = 57005,
    ["SKEL_Spine_Root"] = 57597,
    ["PH_L_Foot"] = 57717,
    ["SKEL_L_Thigh"] = 58271,
    ["FB_L_Brow_Out_000"] = 58331,
    ["SKEL_R_Finger00"] = 58866,
    ["SKEL_R_Finger10"] = 58867,
    ["SKEL_R_Finger20"] = 58868,
    ["SKEL_R_Finger30"] = 58869,
    ["SKEL_R_Finger40"] = 58870,
    ["PH_L_Hand"] = 60309,
    ["RB_L_ForeArmRoll"] = 61007,
    ["SKEL_L_Forearm"] = 61163,
    ["FB_UpperLip_000"] = 61839,
    ["SKEL_L_Calf"] = 63931,
    ["SKEL_R_Finger01"] = 64016,
    ["SKEL_R_Finger02"] = 64017,
    ["SKEL_R_Finger31"] = 64064,
    ["SKEL_R_Finger32"] = 64065,
    ["SKEL_R_Finger41"] = 64080,
    ["SKEL_R_Finger42"] = 64081,
    ["SKEL_R_Finger11"] = 64096,
    ["SKEL_R_Finger12"] = 64097,
    ["SKEL_R_Finger21"] = 64112,
    ["SKEL_R_Finger22"] = 64113,
    ["SKEL_L_Clavicle"] = 64729,
    ["FACIAL_facialRoot"] = 65068,
    ["IK_L_Foot"] = 65245
}

object=nil;
editMode=false;

x=0.0;
y=0.0;
z=0.0;
px=0.0;
py=0.0;
pz=0.0;

bone=nil;

tol=0.05;

RegisterCommand("co", function(source, args, rawCommand)

    local objectName=args[1];
    bone=args[2];

    local ped=PlayerPedId();

    local on=GetHashKey(objectName)
    RequestModel(on)
    while not HasModelLoaded(on) do
        Wait(100)
    end

    object=CreateObject(on, 1.0, 1.0, 1.0, true, true, false)

    AttachEntityToEntity(object, ped, GetPedBoneIndex(ped, bones[bone]), x,y,z,px,py,pz,1, 1, 0, 0, 2, 1);

    editMode=true;

end, false)

RegisterCommand("cb", function(source,args, rawCommand)
    bone=args[1];

    DetachEntity(object,true,false);
    AttachEntityToEntity(object, ped, GetPedBoneIndex(ped, bones[bone]), x,y,z,px,py,pz,1, 1, 0, 0, 2, 1);
end)

RegisterCommand("cout", function(source,args,rawCommand)
    print("--------------------------------------------------------");
    print("X: " .. x .. " Y: " .. y .. " Z: " .. z);
    print("PX: " .. px .. " PY: " .. py .. " PZ: " .. pz);
    print("Bone: " .. bone .. " Bone final: " .. bones[bone]);
    print("--------------------------------------------------------");
end)

RegisterCommand("cd", function(source,args,rawCommand)

    x=0.0;
    y=0.0;
    z=0.0;
    px=0.0;
    py=0.0;
    pz=0.0;

    DeleteObject(object)
end)

RegisterCommand("cst", function(source,args,rawCommand)
    tol=tonumber(args[1]);
end)

Citizen.CreateThread(function()
    while not NetworkIsSessionStarted() do
        Citizen.Wait(500)
    end
    while true do
        local sleep = 1500
        if object and editMode then
            sleep  = 1
            local playerPed = PlayerPedId()
            local Waiting = 1500
            local changed=false;

            while editMode and object do
                ---Base code from: https://forum.cfx.re/t/free-object-spawn-standalone/4757038
                Waiting = 1

                --- Numpad 8 > Altitude +
                if IsControlPressed(0, 111) then
                    z=z+tol;
                    changed=true;
                end

                ---Numpa 5 > Altitude -
                if IsControlPressed(0, 110) then
                    z=z-tol;
                    changed=true;
                end
                --- Arrow up - Move Y
                if IsControlPressed(0, 172) then
                    y=y+tol;
                    changed=true;
                end
                --- Arrow down - Move Y
                if IsControlPressed(0, 173) then
                    y=y-tol;
                    changed=true;
                end
                --- Arrow left - Move X
                if IsControlPressed(0, 174) then
                    x=x-tol;
                    changed=true;
                end
                --- Arrow right - Move X
                if IsControlPressed(0, 175) then
                    x=x+tol;
                    changed=true;
                end

                --- Numpad 7 - Z
                if IsControlPressed(0, 117) then
                    pz=pz-tol;
                    changed=true;
                end
                --- Numpad 9 - Z
                if IsControlPressed(0, 118) then
                    pz=pz+tol;
                    changed=true;
                end

                --- Numpad 4 - Y
                if IsControlPressed(0, 124) then
                    py=py-tol;
                    changed=true;
                end
                --- Numpad 6 - Y
                if IsControlPressed(0, 126) then
                    py=py+tol;
                    changed=true;
                end

                --- Numpad - - X
                if IsControlPressed(0, 315) then
                    px=px-tol;
                    changed=true;
                end
                --- Numpad + - X
                if IsControlPressed(0, 314) then
                    px=px+tol;
                    changed=true;
                end

                if(changed) then
                    DetachEntity(object,true,false);
                    AttachEntityToEntity(object, playerPed, GetPedBoneIndex(playerPed, bones[bone]), x,y,z,px,py,pz,1, 1, 0, 0, 2, 1);
                end


                Citizen.Wait(Waiting)
            end
        end
        Citizen.Wait(sleep)
    end
end)

Other Works

Wiretap Script - Listen to other player’s phone calls
Phone Records - Allow jobs to access citizen’s phone records
Crime Scene and Fire Tap, 20 Evidence Markers, Body Silhouete
Most advanced whiteboard system - draw on boards

[Open Source] FiveM Pager System with Discord Integration
[Open Source] Dynamic Settings control interface
[Open Source] PMA-Voice Radio List - See who’s on your frequency

21 Likes

useful thing and its better add that in github :smiley:

1 Like

If you add a zip folder with a folder, fxmanifest and your script, you can upload it here for people to download rather than copy pasting code.

didn’t feel like waiting on the OP to convert it into a resource, so I did it myself! attached are two files (.7z and .zip), as well as a GitHub repo. enjoy!
ObjectAttachPreview.7z (2 KB)
ObjectAttachPreview.zip (2.4 KB)

3 Likes

love the tool… need to find what interfering with my numpad… all rotates dont work for me… but numpad 8 and 5 and arrows does… go figure… thank you for the code.

Im considering switching it to RegisterKeyMapping soon.

1 Like

highly recommend +1

It does work for me without turning off any ressources that was conflicting with my numpad…
for science :slight_smile:

EDIT: now all keys worked but still no rotation… played with AttachEntityToEntity… not working for me for now…


local numpad_1,numpad_2,numpad_3,numpad_4,numpad_5,numpad_6,numpad_7,numpad_8,numpad_9,numpad_0,numpad_plus,numpad_minus,arrow_up,arrow_down,arrow_left,arrow_right = false,false,false,false,false,false,false,false,false,false,false,false,false,false,false,false
CreateThread(function()
    while true do
        Wait(10)

        if numpad_7 then
            print("numpad_7")
        end
        if numpad_8 then
            print("numpad_8")
        end
        if numpad_9 then
            print("numpad_9")
        end
        
        if numpad_4 then
            print("numpad_4")
        end
        if numpad_5 then
            print("numpad_5")
        end
        if numpad_6 then
            print("numpad_6")
        end
        
        if numpad_1 then
            print("numpad_1")
        end
        if numpad_2 then
            print("numpad_2")
        end
        if numpad_3 then
            print("numpad_3")
        end
                        
        if numpad_0 then
            print("numpad_0")
        end
        if numpad_plus then
            print("numpad_+")
        end
        if numpad_minus then
            print("numpad_-")
        end

        if arrow_up then
            print("arrow up")
        end
        if arrow_down then
            print("arrow down")
        end
        if arrow_left then
            print("arrow left")
        end
        if arrow_right then
            print("arrow right")
        end

    end
end)
--------------------------------------------------------------------------->
RegisterCommand('+numpad_7', function() numpad_7 = true end, false)
RegisterCommand('-numpad_7', function() numpad_7 = false end, false)
RegisterKeyMapping('+numpad_7', 'Numpad 7', 'keyboard', 'numpad7')
--------------------------------------------------------------------------->
RegisterCommand('+numpad_8', function() numpad_8 = true end, false)
RegisterCommand('-numpad_8', function() numpad_8 = false end, false)
RegisterKeyMapping('+numpad_8', 'Numpad 8', 'keyboard', 'numpad8')
--------------------------------------------------------------------------->
RegisterCommand('+numpad_9', function() numpad_9 = true end, false)
RegisterCommand('-numpad_9', function() numpad_9 = false end, false)
RegisterKeyMapping('+numpad_9', 'Numpad 9', 'keyboard', 'numpad9')
--------------------------------------------------------------------------->

--------------------------------------------------------------------------->
RegisterCommand('+numpad_4', function() numpad_4 = true end, false)
RegisterCommand('-numpad_4', function() numpad_4 = false end, false)
RegisterKeyMapping('+numpad_4', 'Numpad 4', 'keyboard', 'numpad4')
--------------------------------------------------------------------------->
RegisterCommand('+numpad_5', function() numpad_5 = true end, false)
RegisterCommand('-numpad_5', function() numpad_5 = false end, false)
RegisterKeyMapping('+numpad_5', 'Numpad 5', 'keyboard', 'numpad5')
--------------------------------------------------------------------------->
RegisterCommand('+numpad_6', function() numpad_6 = true end, false)
RegisterCommand('-numpad_6', function() numpad_6 = false end, false)
RegisterKeyMapping('+numpad_6', 'Numpad 6', 'keyboard', 'numpad6')
--------------------------------------------------------------------------->

--------------------------------------------------------------------------->
RegisterCommand('+numpad_1', function() numpad_1 = true end, false)
RegisterCommand('-numpad_1', function() numpad_1 = false end, false)
RegisterKeyMapping('+numpad_1', 'Numpad 1', 'keyboard', 'numpad1')
--------------------------------------------------------------------------->
RegisterCommand('+numpad_2', function() numpad_2 = true end, false)
RegisterCommand('-numpad_2', function() numpad_2 = false end, false)
RegisterKeyMapping('+numpad_2', 'Numpad 2', 'keyboard', 'numpad2')
--------------------------------------------------------------------------->
RegisterCommand('+numpad_3', function() numpad_3 = true end, false)
RegisterCommand('-numpad_3', function() numpad_3 = false end, false)
RegisterKeyMapping('+numpad_3', 'Numpad 3', 'keyboard', 'numpad3')
--------------------------------------------------------------------------->

--------------------------------------------------------------------------->
RegisterCommand('+numpad_0', function() numpad_0 = true end, false)
RegisterCommand('-numpad_0', function() numpad_0 = false end, false)
RegisterKeyMapping('+numpad_0', 'Numpad 0', 'keyboard', 'numpad0')
--------------------------------------------------------------------------->
RegisterCommand('+numpad_plus', function() numpad_plus = true end, false)
RegisterCommand('-numpad_plus', function() numpad_plus = false end, false)
RegisterKeyMapping('+numpad_plus', 'Numpad +', 'keyboard', 'ADD')
--------------------------------------------------------------------------->
RegisterCommand('+numpad_minus', function() numpad_minus = true end, false)
RegisterCommand('-numpad_minus', function() numpad_minus = false end, false)
RegisterKeyMapping('+numpad_minus', 'Numpad -', 'keyboard', 'SUBTRACT')
--------------------------------------------------------------------------->

--------------------------------------------------------------------------->
RegisterCommand('+arrow_up', function() arrow_up = true end, false)
RegisterCommand('-arrow_up', function() arrow_up = false end, false)
RegisterKeyMapping('+arrow_up', 'Arrow Up', 'keyboard', 'UP')
--------------------------------------------------------------------------->
RegisterCommand('+arrow_down', function() arrow_down = true end, false)
RegisterCommand('-arrow_down', function() arrow_down = false end, false)
RegisterKeyMapping('+arrow_down', 'Arrow Down', 'keyboard', 'DOWN')
--------------------------------------------------------------------------->
RegisterCommand('+arrow_left', function() arrow_left = true end, false)
RegisterCommand('-arrow_left', function() arrow_left = false end, false)
RegisterKeyMapping('+arrow_left', 'Arrow Left', 'keyboard', 'LEFT')
--------------------------------------------------------------------------->
RegisterCommand('+arrow_right', function() arrow_right = true end, false)
RegisterCommand('-arrow_right', function() arrow_right = false end, false)
RegisterKeyMapping('+arrow_right', 'Arrow Right', 'keyboard', 'RIGHT')
--------------------------------------------------------------------------->
1 Like

nice release :slight_smile:

2 Likes

So, i made another version using RegisterKeyMapping and which is way easier to control. (You got a hit the button each time you want to rotate, so instead of the original version, this one allows for way more sensitive moves)

  • / - to increase/decrease the tollerance and then all keys are in the fivem keybindings.

It uses tnotify just to tell you about what tollerance you are using now, you can use anything else.
Also, it seems like some rotations to the same, which is probably related to how the Attach works.

bones = {
    ["SKEL_ROOT"] = 0,
    ["FB_R_Brow_Out_000"] = 1356,
    ["SKEL_L_Toe0"] = 2108,
    ["MH_R_Elbow"] = 2992,
    ["SKEL_L_Finger01"] = 4089,
    ["SKEL_L_Finger02"] = 4090,
    ["SKEL_L_Finger31"] = 4137,
    ["SKEL_L_Finger32"] = 4138,
    ["SKEL_L_Finger41"] = 4153,
    ["SKEL_L_Finger42"] = 4154,
    ["SKEL_L_Finger11"] = 4169,
    ["SKEL_L_Finger12"] = 4170,
    ["SKEL_L_Finger21"] = 4185,
    ["SKEL_L_Finger22"] = 4186,
    ["RB_L_ArmRoll"] = 5232,
    ["IK_R_Hand"] = 6286,
    ["RB_R_ThighRoll"] = 6442,
    ["SKEL_R_Clavicle"] = 10706,
    ["FB_R_Lip_Corner_000"] = 11174,
    ["SKEL_Pelvis"] = 11816,
    ["IK_Head"] = 12844,
    ["SKEL_L_Foot"] = 14201,
    ["MH_R_Knee"] = 16335,
    ["FB_LowerLipRoot_000"] = 17188,
    ["FB_R_Lip_Top_000"] = 17719,
    ["SKEL_L_Hand"] = 18905,
    ["FB_R_CheekBone_000"] = 19336,
    ["FB_UpperLipRoot_000"] = 20178,
    ["FB_L_Lip_Top_000"] = 20279,
    ["FB_LowerLip_000"] = 20623,
    ["SKEL_R_Toe0"] = 20781,
    ["FB_L_CheekBone_000"] = 21550,
    ["MH_L_Elbow"] = 22711,
    ["SKEL_Spine0"] = 23553,
    ["RB_L_ThighRoll"] = 23639,
    ["PH_R_Foot"] = 24806,
    ["SKEL_Spine1"] = 24816,
    ["SKEL_Spine2"] = 24817,
    ["SKEL_Spine3"] = 24818,
    ["FB_L_Eye_000"] = 25260,
    ["SKEL_L_Finger00"] = 26610,
    ["SKEL_L_Finger10"] = 26611,
    ["SKEL_L_Finger20"] = 26612,
    ["SKEL_L_Finger30"] = 26613,
    ["SKEL_L_Finger40"] = 26614,
    ["FB_R_Eye_000"] = 27474,
    ["SKEL_R_Forearm"] = 28252,
    ["PH_R_Hand"] = 28422,
    ["FB_L_Lip_Corner_000"] = 29868,
    ["SKEL_Head"] = 31086,
    ["IK_R_Foot"] = 35502,
    ["RB_Neck_1"] = 35731,
    ["IK_L_Hand"] = 36029,
    ["SKEL_R_Calf"] = 36864,
    ["RB_R_ArmRoll"] = 37119,
    ["FB_Brow_Centre_000"] = 37193,
    ["SKEL_Neck_1"] = 39317,
    ["SKEL_R_UpperArm"] = 40269,
    ["FB_R_Lid_Upper_000"] = 43536,
    ["RB_R_ForeArmRoll"] = 43810,
    ["SKEL_L_UpperArm"] = 45509,
    ["FB_L_Lid_Upper_000"] = 45750,
    ["MH_L_Knee"] = 46078,
    ["FB_Jaw_000"] = 46240,
    ["FB_L_Lip_Bot_000"] = 47419,
    ["FB_Tongue_000"] = 47495,
    ["FB_R_Lip_Bot_000"] = 49979,
    ["SKEL_R_Thigh"] = 51826,
    ["SKEL_R_Foot"] = 52301,
    ["IK_Root"] = 56604,
    ["SKEL_R_Hand"] = 57005,
    ["SKEL_Spine_Root"] = 57597,
    ["PH_L_Foot"] = 57717,
    ["SKEL_L_Thigh"] = 58271,
    ["FB_L_Brow_Out_000"] = 58331,
    ["SKEL_R_Finger00"] = 58866,
    ["SKEL_R_Finger10"] = 58867,
    ["SKEL_R_Finger20"] = 58868,
    ["SKEL_R_Finger30"] = 58869,
    ["SKEL_R_Finger40"] = 58870,
    ["PH_L_Hand"] = 60309,
    ["RB_L_ForeArmRoll"] = 61007,
    ["SKEL_L_Forearm"] = 61163,
    ["FB_UpperLip_000"] = 61839,
    ["SKEL_L_Calf"] = 63931,
    ["SKEL_R_Finger01"] = 64016,
    ["SKEL_R_Finger02"] = 64017,
    ["SKEL_R_Finger31"] = 64064,
    ["SKEL_R_Finger32"] = 64065,
    ["SKEL_R_Finger41"] = 64080,
    ["SKEL_R_Finger42"] = 64081,
    ["SKEL_R_Finger11"] = 64096,
    ["SKEL_R_Finger12"] = 64097,
    ["SKEL_R_Finger21"] = 64112,
    ["SKEL_R_Finger22"] = 64113,
    ["SKEL_L_Clavicle"] = 64729,
    ["FACIAL_facialRoot"] = 65068,
    ["IK_L_Foot"] = 65245
}

object=nil;
editMode=false;

x=0.0;
y=0.0;
z=0.0;
px=0.0;
py=0.0;
pz=0.0;

bone=nil;

tol=0.05;

RegisterCommand("co", function(source, args, rawCommand)

    local objectName=args[1];
    bone=args[2];

    local ped=PlayerPedId();

    local on=GetHashKey(objectName)
    RequestModel(on)
    while not HasModelLoaded(on) do
        Wait(100)
    end

    object=CreateObject(on, 1.0, 1.0, 1.0, true, true, false)

    AttachEntityToEntity(object, ped, GetPedBoneIndex(ped, bones[bone]), x,y,z,px,py,pz,1, 1, 0, 0, 2, 1);

    editMode=true;

end, false)

RegisterCommand("cb", function(source,args, rawCommand)
    bone=args[1];

    DetachEntity(object,true,false);
    AttachEntityToEntity(object, ped, GetPedBoneIndex(ped, bones[bone]), x,y,z,px,py,pz,1, 1, 0, 0, 2, 1);
end)

RegisterCommand("cout", function(source,args,rawCommand)
    print("--------------------------------------------------------");
    print("X: " .. x .. " Y: " .. y .. " Z: " .. z);
    print("PX: " .. px .. " PY: " .. py .. " PZ: " .. pz);
    print("Bone: " .. bone .. " Bone final: " .. bones[bone]);
    print("--------------------------------------------------------");
end)

RegisterCommand("cd", function(source,args,rawCommand)

    x=0.0;
    y=0.0;
    z=0.0;
    px=0.0;
    py=0.0;
    pz=0.0;

    DeleteObject(object)
end)

RegisterCommand("cst", function(source,args,rawCommand)
    tol=tonumber(args[1]);
end)


RegisterCommand("plusz", function(source,args,rawCommand)
    z=z+tol;
    changeCoords();
end, false)
RegisterKeyMapping('plusz', '+ Z', 'keyboard', 'numpad8')

RegisterCommand("minusz", function(source,args,rawCommand)
    z=z-tol;
    changeCoords();
end, false)
RegisterKeyMapping('minusz', '- Z', 'keyboard', 'numpad5')

RegisterCommand("plusy", function(source,args,rawCommand)
    y=y+tol;
    changeCoords();
end, false)
RegisterKeyMapping('plusy', '+ Y', 'keyboard', 'up')

RegisterCommand("minusy", function(source,args,rawCommand)
    y=y-tol;
    changeCoords();
end, false)
RegisterKeyMapping('minusy', '- Y', 'keyboard', 'down')

RegisterCommand("plusx", function(source,args,rawCommand)
    x=x+tol;
    changeCoords();
end, false)
RegisterKeyMapping('plusx', '+ X', 'keyboard', 'right')

RegisterCommand("minusx", function(source,args,rawCommand)
    x=x-tol;
    changeCoords();
end, false)
RegisterKeyMapping('minusx', '- X', 'keyboard', 'left')

--- Rotation

RegisterCommand("pluspz", function(source,args,rawCommand)
    pz=pz+tol;
    changeCoords();
end, false)
RegisterKeyMapping('pluspz', '+ PZ', 'keyboard', 'numpad9')

RegisterCommand("minuspz", function(source,args,rawCommand)
    pz=pz-tol;
    changeCoords();
end, false)
RegisterKeyMapping('minuspz', '- PZ', 'keyboard', 'numpad7')

RegisterCommand("pluspy", function(source,args,rawCommand)
    py=py+tol;
    changeCoords();
end, false)
RegisterKeyMapping('pluspy', '+ PY', 'keyboard', 'numpad6')

RegisterCommand("minuspy", function(source,args,rawCommand)
    py=py-tol;
    changeCoords();
end, false)
RegisterKeyMapping('minuspy', '- PY', 'keyboard', 'numpad4')

RegisterCommand("pluspx", function(source,args,rawCommand)
    px=px+tol;
    changeCoords();
end, false)
RegisterKeyMapping('pluspx', '+ PX', 'keyboard', 'numpad3')

RegisterCommand("minuspx", function(source,args,rawCommand)
    px=px-tol;
    changeCoords();
end, false)
RegisterKeyMapping('minuspx', '- PX', 'keyboard', 'numpad1')

RegisterCommand("plustol", function(source,args,rawCommand)
    tol=tol+0.05;
    exports['t-notify']:Alert({
        style = 'error',
        message = "Tol is now: " .. tostring(tol)
    })
end, false)
RegisterKeyMapping('plustol', '+ TOL', 'keyboard', 'add')

RegisterCommand("minustol", function(source,args,rawCommand)
    tol=tol-0.05;
    exports['t-notify']:Alert({
        style = 'error',
        message = "Tol is now: " .. tostring(tol)
    })
end, false)
RegisterKeyMapping('minustol', '- TOL', 'keyboard', 'subtract')

function changeCoords()

    DetachEntity(object,true,false);
    local playerPed=PlayerPedId();
    AttachEntityToEntity(object, playerPed, GetPedBoneIndex(playerPed, bones[bone]), x,y,z,px,py,pz,1, 1, 0, 0, 2, 1);

end

Did you find this out? I’m running into this problem atm :confused:

Has anyone managed to solve the problem of rotation px py pz?

It’s actually working but the increment is so low that you can barely see it moving. I added a new increment of 1 for the rotation options and that helped a lot. So where you see tol=0.05 I added a tolr=1 and changed all the rotate math to use tolr instead of tol.

does this stiff work because I can’t get it to work I get an error thrown ‘attempt to perform arithmetic on a nil value’

It should still work, yes. But there’s a better tool now: [DEV-Tool] TGIANN Attach Prop to Player

1 Like