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

Commit

Permalink
Updated Callbacks for msk_core
Browse files Browse the repository at this point in the history
  • Loading branch information
Musiker15 committed Mar 4, 2024
1 parent e2b6687 commit 00c03c2
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 32 deletions.
28 changes: 14 additions & 14 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,20 @@
# MSK WeaponAmmo
Usable Clips, Components & Tints

* Forum: https://forum.cfx.re/t/esx-msk-weaponammo-clips-components-tints/4793783
* Discord Support: https://discord.gg/5hHSBRHvJE

**!!! We do not support inventories that have weapons as items !!!**
**!!! We do not support inventories that have weapons as items like ox_inventory !!!**
**!!! We do not support inventories that have weapons as items like ox_inventory !!!**
**!!! We do not support inventories that have weapons as items like ox_inventory !!!**
**!!! We do not support inventories that have weapons as items like ox_inventory !!!**

## Installation
If you are using ESX Menu and NOT one of the others, go to `fxmanifest.lua` and delete `'@NativeUI/NativeUI.lua',` and `'@ragemenu/ragemenu.lua'`

If you are using ESX Legacy and NOT ESX 1.2 then do this:
If you are using ESX 1.2 then do this:
```lua
Config.SavePlayer = {
enable = true,
version = '1.2' -- Set this to '1.2'
}
```

If you are using ESX Legacy then do this:
```lua
Config.SavePlayer = {
enable = true,
Expand All @@ -33,9 +38,4 @@ end)

It should look like this: https://prnt.sc/-El6-xwHQgOp

**Please restart your Server after the Edits!**

## Requirements
* [ESX](https://github.com/esx-framework/esx_core)
* NativeUI *(optional)*
* [RageMenu](https://github.com/EnteNico/ragemenu) *(optional)*
**Please restart your Server after the Edits!**
10 changes: 4 additions & 6 deletions client/client.lua
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ if Config.Hotkey.enable then
if IsPedArmed(playerPed, 4) then
if hash then
local weapon = ESX.GetWeaponFromHash(hash)
local itemName = MSK.TriggerCallback('msk_weaponammo:getItem', weapon.name)
local itemName = MSK.Trigger('msk_weaponammo:getItem', weapon.name)
logging('debug', ('[HOTKEY] [Add Ammo] Item: ^3%s^0, Weapon: ^3%s^0'):format(itemName, weapon.name))

if itemName then
Expand Down Expand Up @@ -62,7 +62,7 @@ AddEventHandler('msk_weaponammo:checkItem', function(clip)
if not Config.Weapons[clip] then return logging('debug', ('[ITEM] [Add Ammo] Item ^3%s^0 is not configured in config.lua'):format(clip)) end
logging('debug', ('[ITEM] [Add Ammo] Item: ^3%s^0, Weapon: ^3%s^0'):format(clip, weapon.name))

if MSK.Table_Contains(Config.Weapons[clip], weapon.name) then
if MSK.TableContains(Config.Weapons[clip], weapon.name) then
TriggerServerEvent('msk_weaponammo:addWeaponClip', weapon.name, clip)
else
Config.Notification(nil, Translation[Config.Locale]['not_correct_weapon'])
Expand Down Expand Up @@ -114,8 +114,6 @@ AddEventHandler('msk_weaponammo:runAnimation', function()
end)

logging = function(code, ...)
if Config.Debug then
local script = "[^2"..GetCurrentResourceName().."^0]"
MSK.logging(script, code, ...)
end
if not Config.Debug then return end
MSK.Logging(code, ...)
end
24 changes: 17 additions & 7 deletions client/menu.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,20 @@ end
---- NativeUI ----

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

CreateThread(function()
while true do
sleep = 200
if _menuPool:IsAnyMenuOpen() then
sleep = 0
_menuPool:ProcessMenus()
local sleep = 1

if _menuPool then
if _menuPool:IsAnyMenuOpen() then
_menuPool:ProcessMenus()
elseif not _menuPool:IsAnyMenuOpen() then
_menuPool:Remove()
end
end

Wait(sleep)
end
end)
Expand All @@ -84,13 +88,19 @@ if Config.Menu:match('NativeUI') then
}

OpenAttachmentMenuNativeUI = function()
if _menuPool then
_menuPool:Remove()
_menuPool = nil
end
_menuPool = NativeUI.CreatePool()

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

mainMenu = NativeUI.CreateMenu(Translation[Config.Locale]['weapon_components'], '~b~'.. Translation[Config.Locale]['remove_components'])
local mainMenu = NativeUI.CreateMenu(Translation[Config.Locale]['weapon_components'], '~b~'.. Translation[Config.Locale]['remove_components'])
_menuPool:Add(mainMenu)

local Components = _menuPool:AddSubMenu(mainMenu, Translation[Config.Locale]['components'])
Expand Down
2 changes: 1 addition & 1 deletion fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ games { 'gta5' }
author 'Musiker15 - MSK Scripts'
name 'msk_weaponammo'
description 'Ammunition, Components & Tints'
version '8.7.2'
version '8.7.3'

lua54 'yes'

Expand Down
6 changes: 2 additions & 4 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,8 @@ AddEventHandler('msk_weaponammo:removeWeaponTint', function(weaponName)
end)

logging = function(code, ...)
if Config.Debug then
local script = "[^2"..GetCurrentResourceName().."^0]"
MSK.logging(script, code, ...)
end
if not Config.Debug then return end
MSK.Logging(code, ...)
end

function items_contains(items, item)
Expand Down

0 comments on commit 00c03c2

Please sign in to comment.