#Weapon Jam

1 messages · Page 1 of 1 (latest)

winged spear
#

Great job

hybrid stratus
#

Ooh comments 👀

rough turret
hybrid stratus
# rough turret ?? 😅

Good job on the comments, some are in spanish though

Code quality could be improved with those nested ifs tho

#
local currentWeapon = exports.ox_inventory:getCurrentWeapon()
            if currentWeapon then
                local ped = PlayerPedId()
                if IsPedShooting(ped) then
                    local weaponName = currentWeapon.name -- Nombre del arma en ox_inventory (e.g., weapon_combatpistol)
                    local durability = currentWeapon.metadata.durability or 100 -- Deterioro del arma

                    local baseChance = Config.WeaponJamChances[weaponName] or Config.WeaponJamChances['default']
                    local jamChance = CalculateJamChance(baseChance, durability)

                    -- Check if the weapon jams / Verificar si el arma se traba
                    if math.random(1, 100) <= jamChance then
                        isWeaponJammed = true
                        jammedWeapon = weaponName
                        TriggerEvent('qbox-weaponjam:weaponJammed', weaponName)
                    end

                    -- Notify if the weapon is deteriorating / Notificar si el arma se está deteriorando
                    if durability <= 25 then
                        lib.notify({
                            id = 'deterioration_warning',
                            title = Locale['notification_title'],
                            description = Locale['deterioration_warning'],
                            position = 'top-right',
                            style = {
                                backgroundColor = '#ffcc00',
                                color = '#000000',
                                ['.description'] = {
                                    color = '#000000'
                                }
                            },
                            icon = 'wrench',
                            iconColor = '#ffffff'
                        })
                    end
                end
            end

Could be extracted to it's own function

rough turret
#

I put a lot of comments because I forgot sometimes what is what hahahah

hybrid stratus
rough turret
#

Absolutely better than my shit hahahah

wispy shale
#

hello, i can change the proba of any weapong, after 1 shot i all time my weapon jammed :/

rough turret
#

Config.TestMode = true -- Cambiar a false para deshabilitar / Set to false to disable

#

I upload with test mode = true 😅

wispy shale
#

Oh Fuck sorry !

open veldt
rough turret
gray herald
#

will imnprove clarity too

hybrid stratus
gray herald
#

ya ik

#

i was also adding that

hybrid stratus
#

the ping feels very directional in the reply

open veldt
#

I sent him the complete version I made (client/server/config) which has it all in another function, and no IsPedShooting.

rough turret
#

A update is coming if my baby feels better