Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- addEvent("onPlayerRearmWeapon",true)
- addEventHandler("onPlayerRearmWeapon",getRootElement(),function(item,slot)
- local psource = source
- takeAllWeapons(psource)
- local ammo = getElementData(psource,getWeaponAmmo(item))
- if ammo < 1 then
- triggerClientEvent(psource,"drawMessage",psource,"You no have ammo for "..item.."!",{197,197,118})
- return
- end
- setElementData(source,"current_weapon",item)
- local id = getWeaponID(item)
- if ammo > 0 then
- giveWeapon(psource,id,ammo,true)
- end
- local mag_size = getWeaponMagSize(item)
- if ammo > mag_size then
- setWeaponAmmo(psource,id,ammo,mag_size)
- else
- setWeaponAmmo(psource,id,ammo)
- end
- triggerClientEvent(psource,"refreshNewInventory",psource)
- end)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement