#Weapon Jam
1 messages · Page 1 of 1 (latest)
Ooh comments 👀
?? 😅
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
Thanks Fluxed I will check this during the rest of the day 🙌
I put a lot of comments because I forgot sometimes what is what hahahah
Good
Aim for something like #✍〡general message if you can, although that's a library more than a mod
Absolutely better than my shit hahahah
updated! thanks
hello, i can change the proba of any weapong, after 1 shot i all time my weapon jammed :/
Check config
Config.TestMode = true -- Cambiar a false para deshabilitar / Set to false to disable
I upload with test mode = true 😅
Oh Fuck sorry !
So I liked the idea, I didn't like the code 🙂 (no fault to you, I know your learning). The infinite loops you have running every 0 seconds, is painful.
https://gist.github.com/mikepauer/3b6dbfca1b923c67d26ca14a5be2fb6c is an example using CEventGunShot and lib.onCache (you can ignore the server callback line, I made mine perm so you can't just put the weapon away to clear the jam)
Thx Diablo was very hard to find a way to work “good” hehe , thx again
if not currentWeapon then return end
if not IsPedShooting(ped) then return end
You dont need to nest that deep
will imnprove clarity too
I was saying for him to move that into it's own function not for him to use it
the ping feels very directional in the reply
I sent him the complete version I made (client/server/config) which has it all in another function, and no IsPedShooting.
good
A update is coming if my baby feels better