-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #923 from bitpredator/dev
feat: new weapon repair system + armory map
- Loading branch information
Showing
38 changed files
with
1,723 additions
and
0 deletions.
There are no files selected for viewing
674 changes: 674 additions & 0 deletions
674
server-data/resources/[esx_addons]/alv_repairtable/LICENSE
Large diffs are not rendered by default.
Oops, something went wrong.
46 changes: 46 additions & 0 deletions
46
server-data/resources/[esx_addons]/alv_repairtable/README.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
<h1 align='center'>Alv Repair Table</h1> | ||
|
||
<p align='center'>This is a FiveM script that uses <a href='https://github.com/esx-framework/esx_core'>ESX</a>/<a href='https://github.com/qbcore-framework/qb-core'>QBCore</a>/<a href='https://github.com/overextended/ox_core'>OXCore</a> and <a href='https://github.com/overextended/ox_inventory'>OX Inventory</a> to allow players to fix guns by restoring their durability at a crafting bench in exchange for metal.</p> | ||
|
||
<p align='center'>The script is heavily configurable and has features such as progress bars, animations & props, etc.</p> | ||
|
||
<p align='center'>Script Preview: <a href='https://www.youtube.com/watch?v=GInIUvLqdZM'>Alv.gg YouTube</a></p> | ||
|
||
<h1 align='center'> Installing this to your server.</h1> | ||
|
||
<p align='center'> | ||
<strong> Please ensure you install a release version as if it is not, you may get a version that is actively being worked on and may error.</strong><br><br> | ||
<strong>1.</strong> Download this repository and add the script to your resources folder.<br> | ||
<strong>2.</strong> Make sure the resource is started in the <code>server.cfg</code>, you can add <code>ensure alv_repairtable</code> if it isn't.<br> | ||
<strong>3.</strong> Make sure you add the item in the <code>config.lua</code> file to <code>ox_inventory</code>, if you need help with this see below...<br> | ||
<strong>4.</strong> Once you have completed those steps, the script is ready to be used simply restart your server and you are good to go!<br> | ||
</p> | ||
|
||
<h1 align='center'> Adding the item to OX Inventory.</h1> | ||
|
||
<p align='center'> | ||
<strong>1.</strong> Navigate to your ox_inventory folder and open it, then open the data folder and finally open <code>items.lua</code>.<br> | ||
<strong>2. </strong>Within the items table, add the following code: <code>['scrapmetal'] = { label = 'Scrap Metal', weight = 80, },</code> <br> | ||
<strong>3.</strong> Save the file and restart your server, the item is now added to your server.<br> | ||
</p> | ||
|
||
<h1 align='center'> Have a suggestion?.</h1> | ||
|
||
<p align='center'> | ||
Whether it be as simple as adding a new language to the locales or updating an actual feature within the script, we appreciate all feedback and try to accomodate to all server owners' needs. <br> | ||
Therefore, if you have a suggestion please join the Discord linked below at the bottom of this README file and leave your comment in the suggestions channel. | ||
</p> | ||
|
||
<h1 align='center'> Experienced Developer? Try this!.</h1> | ||
|
||
<p align='center'> | ||
<strong> If you want to have the best performance possible and you understand at least the basics of developing, you could also head to the <code>framework.lua</code> on both the client side and server side, remove all of the code there and add a shared script to the <code>fxmanifest.lua</code> with your frameworks import file, if it supports one. The frameworks in here by default all support imports.</strong><br><br> | ||
</p> | ||
|
||
<h1 align='center'> Need Support?</h1> | ||
|
||
<p align='center'> | ||
I will offer support in my Community Discord, which can be found below as previously mentioned, if you need help with the script you can type in my general chat or makea ticket. Keep in mind that I am not available 24/7 so your response time may vary. You are welcome to ping me with your request to get a better chance of me seeing your message sooner!<br><br> | ||
</p> | ||
|
||
<strong><p align='center'>If you are looking for a Developer with over 3 years of experience on FiveM, feel free to join my <a href='https://discord.gg/alv'>Discord Server</a> or visit my <a href='https://alv.gg'>Website</a>!</p></strong> |
189 changes: 189 additions & 0 deletions
189
server-data/resources/[esx_addons]/alv_repairtable/client/client.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,189 @@ | ||
lib.locale() | ||
|
||
for k, v in pairs(Config.RepairLocations) do | ||
local point = lib.points.new({ | ||
coords = v.Location, | ||
distance = 2.0, | ||
dunak = v.Label, | ||
}) | ||
|
||
if Config.DrawMarker then | ||
function point:nearby() | ||
DrawMarker(2, v.Location, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.3, 0.25, 0.15, 200, 30, 30, 200, false, true, 2, nil, nil, false) | ||
end | ||
end | ||
|
||
if Config.Framework.Target then | ||
function point:onEnter() | ||
repair_bench_target = exports.ox_target:addSphereZone({ | ||
coords = v.Location, | ||
radius = Config.Framework.Radius, | ||
debug = Config.Debug, | ||
options = { | ||
{ | ||
name = "alv_repairbench", | ||
icon = Config.Framework.Icon, | ||
label = v.Label, | ||
onSelect = function() | ||
repairBench() | ||
end, | ||
}, | ||
}, | ||
}) | ||
end | ||
end | ||
|
||
function point:onExit() | ||
if lib.getOpenMenu() == "repair_bench" then | ||
lib.hideMenu() | ||
end | ||
|
||
if Config.Framework.Target then | ||
exports.ox_target:removeZone(repair_bench_target) | ||
end | ||
end | ||
end | ||
|
||
function repairBench(portable) | ||
local failAttempts = 0 | ||
local Weapons = {} | ||
local location = nil | ||
|
||
if not portable then | ||
for k, v in pairs(Config.RepairLocations) do | ||
if #(GetEntityCoords(cache.ped) - v.Location) > 3.0 then | ||
failAttempts = failAttempts + 1 | ||
location = v.Label | ||
|
||
if failAttempts >= #Config.RepairLocations then | ||
return | ||
end | ||
end | ||
end | ||
end | ||
|
||
local allowed = portable or lib.callback.await("alv_repairtable:canUse", false) | ||
|
||
if allowed then | ||
local loadout = lib.callback.await("alv_repairtable:getLoadout", false) | ||
|
||
for k, v in pairs(loadout) do | ||
if string.find(v.name, "WEAPON_") then | ||
if Config.RestrictedTo and Config.RestrictedTo[v.name] then | ||
Weapons[#Weapons + 1] = { label = v.label, description = locale("menu_description", v.label, v.metadata.durability), args = { name = v.name, durability = v.metadata.durability, slot = v.slot } } | ||
elseif Config.RestrictedTo == false then | ||
Weapons[#Weapons + 1] = { label = v.label, description = locale("menu_description", v.label, v.metadata.durability), args = { name = v.name, durability = v.metadata.durability, slot = v.slot } } | ||
end | ||
end | ||
end | ||
|
||
if #Weapons > 0 then | ||
DebugPrint(json.encode(Weapons, { indent = true })) | ||
|
||
BeginMenu(Weapons, location) | ||
else | ||
Config.Notify(locale("no_weapons")) | ||
end | ||
else | ||
Config.Notify(locale("no_job")) | ||
end | ||
end | ||
|
||
if Config.Command and Config.KeyMapping.Enabled then | ||
RegisterCommand("repair_bench", function() | ||
repairBench() | ||
end) | ||
end | ||
|
||
if Config.KeyMapping.Enabled then | ||
RegisterKeyMapping("repair_bench", Config.KeyMapping.Description, "keyboard", Config.Keymapping.Keybind) | ||
end | ||
|
||
RegisterNetEvent("alv_repairtable:placeTable", function() | ||
if Config.TableItem.RequireMetalToPlace then | ||
local hasMetal = lib.callback.await("alv_repairtable:getMetal", false) | ||
|
||
if hasMetal == 0 then | ||
return Config.Notify(locale("no_metal_placing")) | ||
end | ||
end | ||
|
||
if Config.TableItem.Job then | ||
local allowed = lib.callback.await("alv_repairtable:canPlace", false) | ||
|
||
if not allowed then | ||
return Config.Notify(locale("no_job_placing")) | ||
end | ||
end | ||
|
||
if Config.TableItem.TakeOnUse then | ||
lib.callback.await("alv_repairtable:takeTable", false, "place") | ||
end | ||
|
||
local tableHash = GetHashKey(Config.TableItem.Prop) | ||
RequestModel(tableHash) | ||
|
||
while not HasModelLoaded(tableHash) do | ||
Wait(0) | ||
end | ||
|
||
local x, y, z = table.unpack(GetEntityCoords(cache.ped)) | ||
local table = CreateObject(tableHash, x + 2.0, y, z, true, true, true) | ||
PlaceObjectOnGroundProperly(table) | ||
|
||
function DeleteTable() | ||
SetEntityAsMissionEntity(table) | ||
DeleteObject(table) | ||
end | ||
|
||
local table_point = lib.points.new({ | ||
coords = GetEntityCoords(table), | ||
distance = 2.0, | ||
dunake = "nerd", | ||
}) | ||
|
||
function table_point:onEnter() | ||
portable_table = exports.ox_target:addSphereZone({ | ||
coords = GetEntityCoords(table), | ||
radius = Config.Framework.Radius, | ||
debug = Config.Debug, | ||
options = { | ||
{ | ||
name = "alv_useBench", | ||
label = locale("use_repair_bench"), | ||
icon = Config.Framework.Icon, | ||
onSelect = function() | ||
repairBench(true) | ||
end, | ||
}, | ||
{ | ||
name = "alv_takeBench", | ||
label = locale("pick_bench_up"), | ||
icon = Config.Framework.Icon, | ||
onSelect = function() | ||
DeleteTable() | ||
|
||
if Config.TableItem.TakeOnUse then | ||
lib.callback.await("alv_repairtable:takeTable", false, "pickup") | ||
|
||
exports.ox_target:removeZone(portable_table) | ||
table_point = nil | ||
end | ||
end, | ||
}, | ||
}, | ||
}) | ||
end | ||
|
||
function table_point:onExit() | ||
exports.ox_target:removeZone(portable_table) | ||
end | ||
end) | ||
|
||
AddEventHandler("onResourceStop", function(name) | ||
if name == GetCurrentResourceName() then | ||
if lib.getOpenMenu() == "repair_bench" then | ||
lib.hideMenu() | ||
end | ||
end | ||
end) |
14 changes: 14 additions & 0 deletions
14
server-data/resources/[esx_addons]/alv_repairtable/client/framework.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
CreateThread(function() | ||
if Config.Framework.Type == "auto" then | ||
if GetResourceState("es_extended") ~= "missing" then | ||
ESX = exports["es_extended"]:getSharedObject() | ||
elseif GetResourceState("qb-core") ~= "missing" then | ||
QBCore = exports["qb-core"]:GetCoreObject() | ||
elseif GetResourceState("ox_core") ~= "missing" then | ||
local file = ("imports/%s.lua"):format(IsDuplicityVersion() and "server" or "client") | ||
local import = LoadResourceFile("ox_core", file) | ||
local chunk = assert(load(import, ("@@ox_core/%s"):format(file))) | ||
chunk() | ||
end | ||
end | ||
end) |
Oops, something went wrong.