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

Commit

Permalink
Bug fixes and security improvments
Browse files Browse the repository at this point in the history
  • Loading branch information
1OSaft authored Apr 18, 2024
1 parent 4159d6c commit d5c9983
Show file tree
Hide file tree
Showing 9 changed files with 224 additions and 154 deletions.
104 changes: 99 additions & 5 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
Config = {}
Config, Locales = {}, {}

CreateThread(function()
TriggerEvent('unr3al_methlab:client:getConfig')
end)

RegisterNetEvent('unr3al_methlab:client:getConfig', function()
Config = lib.callback.await('unr3al_methlab:server:getConfig', false)
Config, Locales = lib.callback.await('unr3al_methlab:server:getConfig', false)
end)

--------------------------------------------------------------------------------------------------------------
Expand Down Expand Up @@ -177,16 +178,109 @@ lib.callback.register('unr3al_methlab:client:startSlurryAnima', function(netId)
end
end)

-- lib.callback.register('unr3al_methlab:client:startRaidAnima', function(netId, duration, coords)
-- local entity = NetworkGetEntityFromNetworkId(netId)
-- if not DoesEntityExist(entity) then return end
-- TriggerEvent('ox_inventory:disarm', GetPlayerServerId(cache.ped), true)

-- -- ["weld"] = {
-- -- "Scenario",
-- -- "WORLD_HUMAN_WELDING",
-- -- "Weld"
-- -- }
-- -- local anim = 'Scenario'

-- -- lib.requestAnimDict(anim)

-- -- local playerPed = PlayerPedId()

-- -- TaskPlayAnim(playerPed, 'Scenario', 'WORLD_HUMAN_WELDING', 8.0, -8.0, -1, 0, 0, false, false, false)

-- local playerPed = PlayerPedId()
-- --TaskStartScenarioInPlace(playerPed, 'WORLD_HUMAN_WELDING', 5000, false)
-- TaskStartScenarioAtPosition(playerPed, 'WORLD_HUMAN_WELDING', coords.x, coords.y, coords.z, coords.w, duration, false, true)

-- Wait(5000)
-- ClearPedTasksImmediately(playerPed)

-- Wait(2000)
-- if lib.progressBar({
-- duration = duration,
-- label = Locales[Config.Locale]['SlurryRefineryProgress'],
-- useWhileDead = false,
-- allowRagdoll = false,
-- allowCuffed = false,
-- allowFalling = false,
-- canCancel = true,
-- disable = {
-- move = true,
-- car = true,
-- combat = true,
-- mouse = true
-- },
-- anim = {
-- dict = 'missfam4',
-- clip = 'base'
-- },
-- prop = {
-- model = `p_amb_clipboard_01`,
-- bone = 36029,
-- pos = vec3(0.16, 0.08, 0.1),
-- rot = vec3(-130.0, -50.0, 0.0)
-- },
-- }) then
-- local success = lib.skillCheck({'easy','easy','easy','easy'}, {'e'})
-- return success
-- else
-- return false
-- end
-- end)

RegisterNetEvent('unr3al_methlab:client:updateUpgradeMenu', function()
local methStorage = lib.callback.await('unr3al_methlab:server:getStorage', false, NetworkGetNetworkIdFromEntity(cache.ped))
local storageMax
if methStorage == #Config.Upgrades.Storage then
storageMax = true
end
local methSecurity = lib.callback.await('unr3al_methlab:server:getSecurity', false, NetworkGetNetworkIdFromEntity(cache.ped))
local securityMax
if methSecurity == #Config.Upgrades.Security then
securityMax = true
end
lib.registerContext({
id = 'methlab_Menu_Upgrade',
title = Locales[Config.Locale]['UpgradeLab'],
menu = 'methlab_Menu_Leave',
options = {
{
title = Locales[Config.Locale]['UpgradeStorage'],
description = Locales[Config.Locale]['CurrentLevel']..tostring(methStorage)..'/'..tostring(#Config.Upgrades.Storage),
icon = 'box',
disabled = storageMax,
onSelect = function()
TriggerServerEvent('unr3al_methlab:server:upgradeStorage', currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end,
},
{
title = Locales[Config.Locale]['UpgradeSecurity'],
description = Locales[Config.Locale]['CurrentLevel']..tostring(methSecurity)..'/'..tostring(#Config.Upgrades.Security),
icon = 'box',
disabled = securityMax,
onSelect = function()
TriggerServerEvent('unr3al_methlab:server:upgradeSecurity', currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end,
},
}
})
lib.showContext("methlab_Menu_Upgrade")
end)


AddEventHandler('onClientResourceStart', function (resourceName)
if(GetCurrentResourceName() ~= resourceName) then
return
else
Config = lib.callback.await('unr3al_methlab:server:getConfig', false, NetworkGetNetworkIdFromEntity(cache.ped))
Wait(1000)
lib.registerContext({
id = 'methlab_Menu_Enter',
title = Locales[Config.Locale]['EnterContextmarker'],
Expand All @@ -212,7 +306,7 @@ AddEventHandler('onClientResourceStart', function (resourceName)
description = Locales[Config.Locale]['RaidLabelDesc'],
icon = 'screwdriver-wrench',
onSelect = function()
TriggerServerEvent('unr3al_methlab:server:locklab', currentLab, NetworkGetNetworkIdFromEntity(PlayerPedId()))
TriggerServerEvent('unr3al_methlab:server:raidlab', currentLab, NetworkGetNetworkIdFromEntity(PlayerPedId()))
end,
disabled = true
},
Expand Down Expand Up @@ -243,7 +337,7 @@ AddEventHandler('onClientResourceStart', function (resourceName)
title = Locales[Config.Locale]['UpgradeLab'],
description = Locales[Config.Locale]['UpgradeLabDesc'],
icon = 'wrench',
menu = 'methlab_Menu_Upgrade',
event = 'unr3al_methlab:client:updateUpgradeMenu',
arrow = true,
},
}
Expand Down
157 changes: 44 additions & 113 deletions client/marker.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,31 +8,26 @@ Citizen.CreateThread(function()
distance = 20,
interactPoint = nil,
nearby = function()
local marker = Config.Marker
DrawMarker(marker.type, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0 , 0.0, 0.0, 0.0, marker.sizeX, marker.sizeY, marker.sizeZ, marker.r, marker.b, marker.g, marker.a, false, false, 0, marker.rotate, false, false, false)
if not Config.UsePed.Enabled then
local marker = Config.Marker
DrawMarker(marker.type, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0 , 0.0, 0.0, 0.0, marker.sizeX, marker.sizeY, marker.sizeZ, marker.r, marker.b, marker.g, marker.a, false, false, 0, marker.rotate, false, false, false)
end
end,
onEnter = function(self)
if self.interactPoint then return end
if Config.UsePed.Enabled then
lib.requestModel(Config.UsePed.Model)
local ped = CreatePed(CIVMALE, GetHashKey(Config.UsePed.Model), coords.x, coords.y, coords.z - 1, methlabMarker.HeadingPed, false, true)
FreezeEntityPosition(ped, true)
SetEntityInvincible(ped, true)
SetBlockingOfNonTemporaryEvents(ped, true)
end
self.interactPoint = lib.points.new({
coords = coords,
distance = 1,
nearby = function()
if IsControlJustReleased(0, 51) then
currentLab = methlabID
local owned = lib.callback.await('unr3al_methlab:server:isLabOwned', false, currentLab)
if owned == 1 then
lib.showContext("methlab_Menu_Enter")
else
local alert = lib.alertDialog({
header = Locales[Config.Locale]['AlertDialogHeader'],
content = Locales[Config.Locale]['AlertDialogHeaderDesc'],
centered = true,
cancel = true
})
if alert == 'confirm' then
local buyLab = lib.callback.await('unr3al_methlab:server:buyLab', false, currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end
end
TriggerEvent('unr3al_methlab:client:doEnterStuff', methlabID)
end
end,
onEnter = function()
Expand All @@ -45,6 +40,9 @@ Citizen.CreateThread(function()
end,
onExit = function(self)
if not self.interactPoint then return end
if Config.UsePed.Enabled then
DeletePed(ped)
end
self.interactPoint:remove()
self.interactPoint = nil
end,
Expand All @@ -67,42 +65,6 @@ Citizen.CreateThread(function()
distance = 2,
nearby = function()
if IsControlJustReleased(0, 51) then
local methStorage = lib.callback.await('unr3al_methlab:server:getStorage', false, NetworkGetNetworkIdFromEntity(cache.ped))
local storageMax
if methStorage == #Config.Upgrades.Storage then
storageMax = true
end
local methSecurity = lib.callback.await('unr3al_methlab:server:getSecurity', false, NetworkGetNetworkIdFromEntity(cache.ped))
local securityMax
if methSecurity == #Config.Upgrades.Security then
securityMax = true
end
lib.registerContext({
id = 'methlab_Menu_Upgrade',
title = Locales[Config.Locale]['UpgradeLab'],
menu = 'methlab_Menu_Leave',
options = {
{
title = Locales[Config.Locale]['UpgradeStorage'],
description = Locales[Config.Locale]['CurrentLevel']..tostring(methStorage)..'/'..tostring(#Config.Upgrades.Storage),
icon = 'box',
disabled = storageMax,
onSelect = function()
TriggerServerEvent('unr3al_methlab:server:upgradeStorage', currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end,
},
{
title = Locales[Config.Locale]['UpgradeSecurity'],
description = Locales[Config.Locale]['CurrentLevel']..tostring(methSecurity)..'/'..tostring(#Config.Upgrades.Security),
icon = 'box',
--disabled = securityMax,
disabled = true,
onSelect = function()
TriggerServerEvent('unr3al_methlab:server:upgradeSecurity', currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end,
},
}
})
lib.showContext("methlab_Menu_Leave")
end
end,
Expand Down Expand Up @@ -232,30 +194,16 @@ Citizen.CreateThread(function()
for methlabID, methlabMarker in pairs(Config.Methlabs) do
exports.ox_target:addSphereZone({
coords = methlabMarker.Coords,
radius = Config.Target.Radius,
radius = Config.Target.EnterPoint.TargetSize,
debug = Config.Debug,
drawSprite = Config.Debug,
options = {
{
name = 'methLabEnterPoint'..methlabID,
label = Locales[Config.Locale]['NormalMenuTextUI'],

distance = Config.Target.EnterPoint.InteractDistance,
onSelect = function(data)
currentLab = methlabID
local owned = lib.callback.await('unr3al_methlab:server:isLabOwned', false, currentLab)
if owned == 1 then
lib.showContext("methlab_Menu_Enter")
else
local alert = lib.alertDialog({
header = Locales[Config.Locale]['AlertDialogHeader'],
content = Locales[Config.Locale]['AlertDialogHeaderDesc'],
centered = true,
cancel = true
})
if alert == 'confirm' then
local buyLab = lib.callback.await('unr3al_methlab:server:buyLab', false, currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end
end
TriggerEvent('unr3al_methlab:client:doEnterStuff', methlabID)
end,
}
}
Expand All @@ -270,60 +218,23 @@ Citizen.CreateThread(function()
{
name = 'methExitPoint',
label = Locales[Config.Locale]['NormalMenuTextUI'],
distance = 3,

distance = Config.Target.ExitPoint.InteractDistance,
onSelect = function(data)
local methStorage = lib.callback.await('unr3al_methlab:server:getStorage', false, NetworkGetNetworkIdFromEntity(cache.ped))
local storageMax
if methStorage == #Config.Upgrades.Storage then
storageMax = true
end
local methSecurity = lib.callback.await('unr3al_methlab:server:getSecurity', false, NetworkGetNetworkIdFromEntity(cache.ped))
local securityMax
if methSecurity == #Config.Upgrades.Security then
securityMax = true
end
lib.registerContext({
id = 'methlab_Menu_Upgrade',
title = Locales[Config.Locale]['UpgradeLab'],
menu = 'methlab_Menu_Leave',
options = {
{
title = Locales[Config.Locale]['UpgradeStorage'],
description = Locales[Config.Locale]['CurrentLevel']..tostring(methStorage)..'/'..tostring(#Config.Upgrades.Storage),
icon = 'box',
disabled = storageMax,
onSelect = function()
TriggerServerEvent('unr3al_methlab:server:upgradeStorage', currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end,
},
{
title = Locales[Config.Locale]['UpgradeSecurity'],
description = Locales[Config.Locale]['CurrentLevel']..tostring(methSecurity)..'/'..tostring(#Config.Upgrades.Security),
icon = 'box',
--disabled = securityMax,
disabled = true,
onSelect = function()
TriggerServerEvent('unr3al_methlab:server:upgradeSecurity', currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end,
},
}
})
lib.showContext("methlab_Menu_Leave")
end,
}
}
})
exports.ox_target:addSphereZone({
coords = vector3(1005.80, -3201.60, -38.57),
radius = 1.2,
radius = Config.Target.MethPoint.TargetSize,
debug = Config.Debug,
drawSprite = Config.Debug,
options = {
{
name = 'methMakerPoint',
label = Locales[Config.Locale]['PouringTextUI'],
distance = 1.5,
distance = Config.Target.MethPoint.InteractDistance,

onSelect = function(data)
TriggerServerEvent('unr3al_methlab:server:startprod', NetworkGetNetworkIdFromEntity(cache.ped))
Expand All @@ -341,7 +252,7 @@ Citizen.CreateThread(function()
{
name = 'methSlurryPoint',
label = Locales[Config.Locale]['RefineryTextUI'],
distance = 1.5,
distance = Config.Target.SlurryPoint.InteractDistance,

onSelect = function(data)
TriggerServerEvent('unr3al_methlab:server:startSlurryRefinery', NetworkGetNetworkIdFromEntity(cache.ped))
Expand All @@ -358,13 +269,33 @@ Citizen.CreateThread(function()
{
name = 'methStoragePoint',
label = Locales[Config.Locale]['StorageTextUI'],
distance = 3,
distance = Config.Target.StoragePoint.InteractDistance,

onSelect = function(data)
TriggerServerEvent('unr3al_methlab:server:startSlurryRefinery', NetworkGetNetworkIdFromEntity(cache.ped))
TriggerServerEvent('unr3al_methlab:server:openStorage', NetworkGetNetworkIdFromEntity(cache.ped))
end,
}
}
})
end
end)



RegisterNetEvent('unr3al_methlab:client:doEnterStuff', function(methlabID)
currentLab = methlabID
local owned = lib.callback.await('unr3al_methlab:server:isLabOwned', false, currentLab)
if owned == 1 then
lib.showContext("methlab_Menu_Enter")
else
local alert = lib.alertDialog({
header = Locales[Config.Locale]['AlertDialogHeader'],
content = Locales[Config.Locale]['AlertDialogHeaderDesc'],
centered = true,
cancel = true
})
if alert == 'confirm' then
local buyLab = lib.callback.await('unr3al_methlab:server:buyLab', false, currentLab, NetworkGetNetworkIdFromEntity(cache.ped))
end
end
end)
Loading

0 comments on commit d5c9983

Please sign in to comment.