Skip to content
This repository has been archived by the owner on Sep 22, 2024. It is now read-only.

Commit

Permalink
Update v8.8.0
Browse files Browse the repository at this point in the history
* Added new Items for Weaponcomponents
* Some other changes
  • Loading branch information
Musiker15 committed May 27, 2024
1 parent 00c03c2 commit a150638
Show file tree
Hide file tree
Showing 7 changed files with 198 additions and 232 deletions.
2 changes: 0 additions & 2 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
ESX = exports["es_extended"]:getSharedObject()

if Config.AntiWeaponPunch then
CreateThread(function()
while true do
Expand Down
62 changes: 9 additions & 53 deletions client/menu.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
RegisterNetEvent('msk_weaponammo:openAttachmentMenu')
AddEventHandler('msk_weaponammo:openAttachmentMenu', function()
if Config.Menu:match('ESX') then
if Config.Menu == 'ESX' then
OpenAttachmentMenuESX() -- ESX Menu
elseif Config.Menu:match('NativeUI') then
elseif Config.Menu == 'NativeUI' then
OpenAttachmentMenuNativeUI() -- NativeUI
elseif Config.Menu:match('RageMenu') then
OpenAttachmentMenuRageMenu() -- RageMenu
end
end)

----------------------------------------------------------------
-- ESX Menu
----------------------------------------------------------------
OpenAttachmentMenuESX = function()
local playerPed = PlayerPedId()
local hash = GetSelectedPedWeapon(playerPed)
Expand Down Expand Up @@ -56,9 +57,10 @@ OpenAttachmentMenuESX = function()
end)
end

---- NativeUI ----

if Config.Menu:match('NativeUI') then
----------------------------------------------------------------
-- NativeUI Menu
----------------------------------------------------------------
if Config.Menu == 'NativeUI' then
local _menuPool = nil

CreateThread(function()
Expand Down Expand Up @@ -124,50 +126,4 @@ if Config.Menu:match('NativeUI') then
_menuPool:MouseEdgeEnabled(false)
_menuPool:ControlDisablingEnabled(false)
end
end

-- RageMenu

if Config.Menu:match('RageMenu') then
local mainMenu

OpenAttachmentMenuRageMenu = function()
local playerPed = PlayerPedId()
local hash = GetSelectedPedWeapon(playerPed)
local weapon = ESX.GetWeaponFromHash(hash)

if not weapon then Config.Notification(nil, Translation[Config.Locale]['no_weapon']) return end

local Items = {
{name = Translation[Config.Locale]['scope'], desc = Translation[Config.Locale]['remove_scope'], comtype = 'scope', type = 'component'},
{name = Translation[Config.Locale]['grip'], desc = Translation[Config.Locale]['remove_grip'], comtype = 'grip', type = 'component'},
{name = Translation[Config.Locale]['flashlight'], desc = Translation[Config.Locale]['remove_flashlight'], comtype = 'flashlight', type = 'component'},
{name = Translation[Config.Locale]['clip_extended'], desc = Translation[Config.Locale]['remove_clip_extended'], comtype = 'clip_extended', type = 'component'},
{name = Translation[Config.Locale]['suppressor'], desc = Translation[Config.Locale]['remove_suppressor'], comtype = 'suppressor', type = 'component'},
{name = Translation[Config.Locale]['luxary_finish'], desc = Translation[Config.Locale]['remove_luxary_finish'], comtype = 'luxary_finish', type = 'component'},
{name = Translation[Config.Locale]['tint'], desc = Translation[Config.Locale]['remove_tint'], type = 'tint'},
}

mainMenu = RageMenu:CreateMenu(Translation[Config.Locale]['weapon_components'], '~b~'.. Translation[Config.Locale]['remove_components'])
local components = RageMenu:CreateMenu(Translation[Config.Locale]['components'], Translation[Config.Locale]['components'])
mainMenu:AddSubmenu(components, Translation[Config.Locale]['components'], '')

for k, v in pairs(Items) do
components:AddButton(v.name, '~b~' .. v.desc):On('click', function(item)
if v.type == 'component' then
TriggerServerEvent('msk_weaponammo:removeWeaponComponent', weapon.name, v.comtype)
elseif v.type == 'tint' then
TriggerServerEvent('msk_weaponammo:removeWeaponTint', weapon.name)
end
end)
end

RageMenu:OpenMenu(mainMenu)
end

AddEventHandler('onResourceStop', function(resource)
if GetCurrentResourceName() == resource then
RageMenu:Close(mainMenu)
end
end)
end
24 changes: 14 additions & 10 deletions config.lua
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
Config = {}
----------------------------------------------------------------
Config.Locale = 'de'
Config.VersionChecker = true
Config.Debug = true
Config.VersionChecker = true
----------------------------------------------------------------
Config.Menu = 'RageMenu' -- Set to 'ESX' if you want ESX Menu || Set to 'NativeUI' if you want NativeUI || Set to 'RageMenu' if you want RageMenu
Config.Menu = 'NativeUI' -- Set to 'ESX' if you want ESX Menu || Set to 'NativeUI' if you want NativeUI
Config.AntiWeaponPunch = true -- Set false if you don't want to use this
Config.Animation = true -- Set false if you dont want an animation

Config.SavePlayer = {
enable = true,
version = 'legacy' -- Set to '1.2' or 'legacy' // For ESX 1.2 set to '1.2', for ESX Legacy set 'legacy'
}
Config.SavePlayer = true

Config.enableMaxAmmo = true -- Set false to deactivate this feature
Config.checkMaxAmmo = {
Expand Down Expand Up @@ -55,8 +52,7 @@ Config.WeaponAmmoClips = { -- Will give this many bullets to player
['throwableclip'] = 5,

-- CUSTOM ITEMS // Add them in server_items.lua
['polweaclip'] = 30, -- All Weapontypes
['polweabox'] = 150, -- All Weapontypes
['itemname'] = true,
}
----------------------------------------------------------------
-- Set true if you like to remove item when used
Expand All @@ -74,10 +70,19 @@ Config.Removeables = {

-- Weapon Attachments
['scope'] = true,
['scope_holo'] = true,
['scope_small'] = true,
['scope_medium'] = true,
['scope_large'] = true,
['scope_advanced'] = true,
['grip'] = true,
['flashlight'] = true,
['clip_default'] = true,
['clip_extended'] = true,
['clip_drum'] = true,
['clip_box'] = true,
['suppressor'] = true,
['compensator'] = true,
['luxary_finish'] = true,
['attachment_remover'] = false, -- This item removes Weapon Components and opens the Menu // recommended set to false

Expand All @@ -91,8 +96,7 @@ Config.Removeables = {
['tint_platinum'] = true,

-- CUSTOM ITEMS // Add them in server_items.lua
['polweaclip'] = true,
['polweabox'] = true,
['itemname'] = true,
}
----------------------------------------------------------------
-- Please don't TOUCH if you don't know what you are doing!!
Expand Down
4 changes: 2 additions & 2 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_weaponammo'
description 'Ammunition, Components & Tints'
version '8.7.3'
version '8.8.0'

lua54 'yes'

shared_scripts {
'@es_extended/imports.lua',
'@msk_core/import.lua',
'config.lua',
'translation.lua'
}

client_scripts {
'@NativeUI/NativeUI.lua', -- Remove this if you don't use NativeUI // Go to menu.lua and remove ALL of the NativeUI Code
'@ragemenu/ragemenu.lua', -- Remove this if you don't use RageMenu // Go to menu.lua and remove ALL of the RageMenu Code
'client/*.lua'
}

Expand Down
27 changes: 7 additions & 20 deletions server/server.lua
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
ESX = exports["es_extended"]:getSharedObject()

-- Events
RegisterNetEvent('msk_weaponammo:addWeaponClip')
AddEventHandler('msk_weaponammo:addWeaponClip', function(weaponName, clip)
local src = source
Expand All @@ -19,7 +16,7 @@ AddEventHandler('msk_weaponammo:addWeaponClip', function(weaponName, clip)
logging('debug', ('Ammo in Weapon: %s, Ammo in Clip: %s, Ammo after Relaod: %s, MaxAmmo in Config: %s'):format(v.ammo, ammo, v.ammo + ammo, Config.checkMaxAmmo[clip]))

if (v.ammo + ammo) <= Config.checkMaxAmmo[clip] then
xPlayer.triggerEvent('msk_weaponammo:runAnimation')
TriggerClientEvent('msk_weaponammo:runAnimation', src)
xPlayer.addWeaponAmmo(weaponName, ammo)
TriggerClientEvent('msk_weaponammo:updateAmmo', src, weaponName, ammo)
Config.Notification(src, Translation[Config.Locale]['used_clip']:format(hasItem.label))
Expand All @@ -37,7 +34,7 @@ AddEventHandler('msk_weaponammo:addWeaponClip', function(weaponName, clip)
end
else
logging('debug', ('Weapon: %s, Item: %s, Ammo: %s'):format(weaponName, clip, ammo))
xPlayer.triggerEvent('msk_weaponammo:runAnimation')
TriggerClientEvent('msk_weaponammo:runAnimation', src)
xPlayer.addWeaponAmmo(weaponName, ammo)
TriggerClientEvent('msk_weaponammo:updateAmmo', src, weaponName, ammo)
Config.Notification(src, Translation[Config.Locale]['used_clip']:format(hasItem.label))
Expand Down Expand Up @@ -129,11 +126,7 @@ MSK.Register('msk_weaponammo:getItem', function(source, weaponName)
end
end

if match then
return items[1]
else
return false
end
return match and items[1] or false
end)

-- Add/Remove Weapon Tints
Expand Down Expand Up @@ -235,22 +228,16 @@ function items_contains(items, item)
end

function saveESXPlayer(xPlayer)
if not Config.SavePlayer.enable then return end

if Config.SavePlayer.version:match('1.2') then
ESX.SavePlayer(xPlayer)
elseif Config.SavePlayer.version:match('legacy') then
local Core = exports.es_extended.getCoreObject() -- exports('getCoreObject', function() return Core end)
Core.SavePlayer(xPlayer)
end
if not Config.SavePlayer then return end
MySQL.update("UPDATE users SET loadout = ? WHERE identifier = ?", {json.encode(xPlayer.getLoadout(true)), xPlayer.identifier})
end

GithubUpdater = function()
GetCurrentVersion = function()
local GetCurrentVersion = function()
return GetResourceMetadata(GetCurrentResourceName(), "version")
end

isVersionIncluded = function(Versions, cVersion)
local isVersionIncluded = function(Versions, cVersion)
for k, v in pairs(Versions) do
if v.version == cVersion then
return true
Expand Down
Loading

0 comments on commit a150638

Please sign in to comment.