[FREE] Weapon Carry Script

Weapon Carry Script

:star: Check out our other resources on gamzkystore.com or in our Discord

:videocassette: Preview video: Youtube | :computer: Download: Github Repository

There are already quite some ‘weapon-carry’ scripts available, but I often found them to be either, buggy, lacking in features or badly optimized. So I created a version of my own.

Features

  • Tested on the esx-framework, but should also work on qb-core and with ox-inventory.
  • Configure the weapons that should be displayed on a players body, if the player has the weapon in his loadout/inventory.
  • The weapons are attached to a configured position and ped-bone.
  • A debug-mode enables a command which can be used to easily determine the right weapon positions (see the end of the preview video).
  • It is also possible to add clothes-dependend positions, as of now this feature only works with skinchanger.
  • The spawned weapon props are tracked on the server, which deletes the attached props on a player disconnect.
17 Likes

Hey, nice release, but it seems not to work with ox_inventory

Found a fix for it, if you use ox_inventory you have to change something in the code, I think the author accidentally has a spelling error (You used a point instead of a double point in the export) in line 114 (Line 111-123, cl_main.lua):

function DoesPlayerHaveWeapon(itemName)
    -- Handle the case if ox_inventory is used
    if (GetResourceState('ox_inventory') == 'started') then
        return exports.ox_inventory:GetItemCount(itemName) > 0
    end

    -- Handle the case if es_extended or qb-core is used
    if (GetResourceState('es_extended') == 'started' or GetResourceState('qb-core') == 'started') then
        return HasPedGotWeapon(PlayerPedId(), GetHashKey(itemName), false)
    end

    return false
end
1 Like

Hi, thanks for the debugging!

I indeed did not test it for ox-inventory, I will push your fix to the repository later today :smile:

This is fixed now with the latest commit :slight_smile:

1 Like

Does anyone have a snippet for all weapons? :slight_smile:

How can you turn the weapon like that because I’ve already tried it but only have the numpad things that only work against what L-SHIFT + NUMPAD 8 doesn’t work like that

I tested it with illenium-appearance and it works perfectly

So you can move the weapon around but you cannot rotate it?

It is working for me, I have a qwerty keyboard.

I can’t turn it just because when I press the keys you specified in the config it doesn’t work

You can try changing the key you need to hold down for rotating. By default this is L-SHIFT.

This can be found in client/debug.lua, then search for IsControlPressed(0, 21).

You can change the 21 for the key you would like, see Controls - Cfx.re Docs for the keys you can choose.

I already have that open, I’ll try the mouse wheel tomorrow

1 Like

I have to say that with women, no matter whether they are turned or not, nothing is taken over, the weapons always remain straight up on the body

If anyone wants to put it on the mouse wheel, you can use it here

if IsControlPressed(0, 241) then
                yrp = yrp + rotationIncrement
                RespawnProp(propName, propBone)
            elseif IsControlPressed(0, 242) then
                yrp = yrp - rotationIncrement
                RespawnProp(propName, propBone)
            end

            if IsControlPressed(0, 111) then
                -- NUMPAD 8
                yp = yp + positionIncrement
                RespawnProp(propName, propBone)
            end

            if IsControlPressed(0, 110) then
                -- NUMPAD 5
                yp = yp - positionIncrement
                RespawnProp(propName, propBone)
            end

            if IsControlPressed(0, 117) then
                -- NUMPAD 7
                xp = xp - positionIncrement
                RespawnProp(propName, propBone)
            end

            if IsControlPressed(0, 118) then
                -- NUMPAD 9
                xp = xp + positionIncrement
                RespawnProp(propName, propBone)
            end

            if IsControlPressed(0, 108) then
                -- NUMPAD 4
                zp = zp + positionIncrement
                RespawnProp(propName, propBone)
            end

            if IsControlPressed(0, 109) then
                -- NUMPAD 6
                zp = zp - positionIncrement
                RespawnProp(propName, propBone)
            end

Seems like that is an issue related to the ped-bone. The weapons are attached to the specified bone in the configuration, called Bone, where the coordinates you are adding, are coordinates with respect to the position of that bone.

By default, the /weaponprop_spawn command used bone index 24818 (Ped Bones), are you using the same bone in the configuration for the specified weapon?

I only did it with the one weapon specified /weaponprop_spawn w_ar_carbinerifle

You can also print the output of line 149 in cl_main.lua: local bone = GetPedBoneIndex(ped, weaponData.Bone), the variable ‘bone’ should print a value >0 if I am not mistaken. So if it is printing out 0 or -1 the bone is probably not defined correctly and the weapon is just attached to the center of the player.

Hey nice release, what’s the resmon on it?

Hi FurmaZ, see the attached screenshot :slight_smile:

1 Like

I think I found the issue, I just pushed a commit to the Github Repository. Can you check if this update fixes your problem? Make sure to save your changes to the keybinds before updating the resource :smiley:.

I now have it in there from you and now you can also leave it turned female

So it is working? Great :smiley: