Skip to content

Commit

Permalink
more fix things
Browse files Browse the repository at this point in the history
  • Loading branch information
Agimir committed Sep 20, 2024
1 parent a8e5035 commit ff0eb50
Show file tree
Hide file tree
Showing 12 changed files with 133 additions and 151 deletions.
9 changes: 6 additions & 3 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
Expand Up @@ -20,21 +20,24 @@ dependencies {
shared_scripts {
'@ox_lib/init.lua',
'source/shared/*.lua',
'source/util/interface.lua',
'data/*.lua', 'config.lua'
}

-- client files
client_scripts {
'source/client/**/*.lua'
'source/client/**/*.lua',
'source/util/client.lua',
}

-- server files
server_scripts {
'@oxmysql/lib/MySQL.lua',
'source/server/**/*.lua'
'source/server/**/*.lua',
'source/util/server.lua',
}

-- resource files
files {
'data/locale/*.json'
'locales/*.json'
}
2 changes: 1 addition & 1 deletion source/client/leisure/cooler.lua
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ exports('cooler', function()
},
}) then
cooler.obj = CreateObject(cooler.model, offset.x, offset.y, offset.z, true, false, false)
Cnt.SetObject(cooler.obj, heading)
Util.SetObject(cooler.obj, heading)
exports.ox_target:addLocalEntity(cooler.obj, tableoptions_start)
end
end)
4 changes: 2 additions & 2 deletions source/client/leisure/fireworks.lua
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports('firework_s1', function()
local box = lib.callback('miut:s:spawn', false, function()
end, crds, 'ind_prop_firework_03')
-- set heading
Cnt.SetObject(box, head)
Util.SetObject(box, head)
-- progress bar
if lib.progressBar({
duration = 5000,
Expand Down Expand Up @@ -71,7 +71,7 @@ exports('firework_s2', function()
local box = lib.callback('miut:s:spawn', false, function()
end, crds, 'ind_prop_firework_04')
-- set heading
Cnt.SetObject(box, head)
Util.SetObject(box, head)
-- progress bar
if lib.progressBar({
duration = 5000,
Expand Down
10 changes: 5 additions & 5 deletions source/client/vehicle/clean.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ local cleanvehicle = function(vehicle, player)
local response = fixes[math.random(1, #fixes)]
local tx2 = { id = 'clean_complete', title = "Vehicle Cleaned",
description = response }
Ifc.DoNotif(tx2, Cor)
Util.Notify(tx2, Cor)
SetVehicleDirtLevel(vehicle, 0.0)
RemoveDecalsFromVehicle(vehicle)
else
local tx3 = { id = 'clean_stopped', title = "Cleaning Stopped",
description = 'You stopped cleaning' }
Ifc.DoNotif(tx3, War) ClearPedTasks(player)
Util.Notify(tx3, War) ClearPedTasks(player)
end
end

Expand All @@ -52,7 +52,7 @@ AddEventHandler('mi_items:c:vehicle:clean', function(vehicle)
if dirt == 0.0 then
local data = { id = 'fix_unneeded', title = "No Dirt Found",
description = 'As sparkly as they come' }
Ifc.DoNotif(data, Cor)
Util.Notify(data, Cor)
elseif dirt >= 0.0 then
cleanvehicle(vehicle, player)
end
Expand All @@ -66,7 +66,7 @@ exports('cleankit', function()
if not vehicle then
local txt = { id = 'veh_notclose', title = 'Unable to Deploy Tool Kit',
description = 'You need to be close to a vehicle to use this tool' }
Ifc.DoNotif(txt, Err)
Util.Notify(txt, Err)
else
TaskTurnPedToFaceEntity(cache.ped, vehicle, 1000)
TriggerServerEvent('mi_items:s:vehicle:clean', vehicle)
Expand All @@ -81,7 +81,7 @@ local vehicle = lib.getClosestVehicle(coords, 4.0, true)
if not vehicle then
local txt = { id = 'veh_notclose', title = 'Unable to Deploy Tool Kit',
description = 'You need to be close to a vehicle to use this tool' }
Ifc.DoNotif(txt, Err)
Util.Notify(txt, Err)
else
--prog_setup(toolbox.obj)
--TaskTurnPedToFaceEntity(cache.ped, vehicle, 2000)
Expand Down
8 changes: 4 additions & 4 deletions source/client/vehicle/engine.lua
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ local vehiclerepairs = function(vehicle)
local response = fixes[math.random(1, #fixes)]
local tx2 = { id = 'fix_complete', title = "Engine Repaired",
description = response }
Ifc.DoNotif(tx2, Cor) ClearPedTasks(cache.ped)
Util.Notify(tx2, Cor) ClearPedTasks(cache.ped)
SetVehicleEngineHealth(vehicle, 1000)
SetVehicleOilLevel(vehicle, 1000)
SetVehicleDoorShut(vehicle, 4, false)
else
local tx3 = { id = 'fix_stopped', title = "Engine Repair Stopped",
description = 'You stopped working on the engine' }
Ifc.DoNotif(tx3, War) ClearPedTasks(cache.ped)
Util.Notify(tx3, War) ClearPedTasks(cache.ped)
end
end

Expand All @@ -49,7 +49,7 @@ AddEventHandler('mi_items:c:vehicle:repair', function(vehicle)
if health == 1000.0 then
local data = { id = 'fix_unneeded', title = "No Engine Damage Noted",
description = 'This vehicle\'s engine has no need for repairs' }
Ifc.DoNotif(data, Cor)
Util.Notify(data, Cor)
elseif health <= 999.99 then
vehiclerepairs(vehicle)
end
Expand All @@ -63,7 +63,7 @@ exports('enginekit', function()
if not vehicle then
local txt = { id = 'veh_notclose', title = 'Unable to Deploy Tool Kit',
description = 'You need to be close to a vehicle to use this tool' }
Ifc.DoNotif(txt, Err)
Util.Notify(txt, Err)
else
--prog_setup(toolbox.obj)
--TaskTurnPedToFaceEntity(cache.ped, vehicle, 2000)
Expand Down
24 changes: 3 additions & 21 deletions source/client/vehicle/recolor.lua
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ local colorvehicle = function(vehicle, color)
local response = fixes[math.random(1, #fixes)]
local tx2 = { id = 'color_complete', title = "Vehicle Painted",
description = response }
Ifc.DoNotif(tx2, Cor)
Util.Notify(tx2, Cor)
lib.setVehicleProperties(vehicle, { color1 = color })
lib.setVehicleProperties(vehicle, { color2 = color })
else
local tx3 = { id = 'color_stopped', title = "Painting Stopped",
description = 'You stopped cleaning' }
Ifc.DoNotif(tx3, War)
Util.Notify(tx3, War)
end
end

Expand Down Expand Up @@ -179,22 +179,4 @@ exports('spraykit', function()
--TaskTurnPedToFaceEntity(cache.ped, vehicle, 2000)
TriggerServerEvent('mi_items:s:vehicle:color', vehicle)
end
end)

--[[
RegisterCommand('color', function()
-- get vehicle details
local coords = GetEntityCoords(cache.ped)
local vehicle = lib.getClosestVehicle(coords, 4.0, true)
if not vehicle then
local txt = { id = 'veh_notclose', title = 'Unable to Deploy Tool Kit',
description = 'You need to be close to a vehicle to use this tool' }
DoNotif(txt, Err)
else
--prog_setup(toolbox.obj)
--TaskTurnPedToFaceEntity(cache.ped, vehicle, 2000)
TriggerServerEvent('mi_items:s:vehicle:color', vehicle)
end
end, false)
]]
end)
28 changes: 5 additions & 23 deletions source/client/vehicle/tires.lua
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ local repairtire = function(vehicle, player)
local response = fixes[math.random(1, #fixes)]
local tx2 = { id = 'tire_complete', title = "Tires Repaired",
description = response }
Ifc.DoNotif(tx2, Cor)
Util.Notify(tx2, Cor)
local tire = nearbytire(vehicle)
SetVehicleTyreFixed(vehicle, tire)
else
local tx3 = { id = 'tire_stopped', title = "Repair Stopped",
description = 'You stopped repairing the tire' }
Ifc.DoNotif(tx3, War) ClearPedTasks(player)
Util.Notify(tx3, War) ClearPedTasks(player)
end
end

Expand All @@ -77,7 +77,7 @@ AddEventHandler('mi_items:c:vehicle:tires', function(vehicle)
if not fix then
local tx1 = { id = 'tire_notneeded', title = "Repair Not Needed",
description = 'Your tires are in good health' }
Ifc.DoNotif(tx1, Cor)
Util.Notify(tx1, Cor)
elseif fix then
repairtire(vehicle, player)
end
Expand All @@ -91,28 +91,10 @@ exports('tirekit', function()
if not vehicle then
local txt = { id = 'veh_notclose', title = 'Unable to Deploy Tool Kit',
description = 'You need to be close to a vehicle to use this tool' }
Ifc.DoNotif(txt, Err)
Util.Notify(txt, Err)
else
--prog_setup(toolbox.obj)
--TaskTurnPedToFaceEntity(cache.ped, vehicle, 2000)
TriggerServerEvent('mi_items:s:vehicle:tires', vehicle)
end
end)

--[[
RegisterCommand('tirefix', function()
-- get vehicle details
local coords = GetEntityCoords(cache.ped)
local vehicle = lib.getClosestVehicle(coords, 4.0, true)
if not vehicle then
local txt = { id = 'veh_notclose', title = 'Unable to Deploy Tool Kit',
description = 'You need to be close to a vehicle to use this tool' }
DoNotif(txt, Err)
else
--prog_setup(toolbox.obj)
--TaskTurnPedToFaceEntity(cache.ped, vehicle, 2000)
TriggerServerEvent('mi_items:s:vehicle:tires', vehicle)
end
end, false)
]]
end)
2 changes: 2 additions & 0 deletions source/data/items.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@

-- will need for later
20 changes: 4 additions & 16 deletions source/shared/shared.lua
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
-- shared data variables
Shared, Data = {}, {}

-- utility resource variables
Ifc, Cnt, Svr = {}, {}, {}

-- ox variables
Target, Inventory = exports.ox_target, exports.ox_inventory
Lib, Sql = exports.ox_lib, exports.oxmysql

-- debug option
Shared, Data, Util = {}, {}, {}
Debug = true
lib.locale()

-- locale option | 'en', 'es', 'fr'
Locale = 'en'

-- load locale
lib.locale()
Target = exports.ox_target
Inventory = exports.ox_inventory
102 changes: 48 additions & 54 deletions source/util/client.lua
Original file line number Diff line number Diff line change
@@ -1,71 +1,65 @@

-- get time
-- returns in world time details
Cnt.GetWorldTime = function()
local tm = {
hour = GetClockHours(),
mint = GetClockMinutes(),
secd = GetClockSeconds()
}
return tm
lib.locale()

Util.IGTime = function()
local i = {
s = GetClockSeconds(),
m = GetClockMinutes(),
h = GetClockHours()
} return i
end

-- get date
-- returns in world date details
Cnt.GetWorldDate = function()
local dt = {
days = GetClockDayOfMonth(),
week = GetClockDayOfWeek(),
mnth = GetClockMonth()
}
return dt
Util.IGDate = function()
local i = {
d = GetClockDayOfMonth(),
w = GetClockDayOfWeek(),
m = GetClockMonth()
} return i
end

Util.VehicleInfo = function(v)
local m = GetEntityModel(v)
local d = GetDisplayNameFromVehicleModel(m)
local n = GetLabelText(d)
return n
end

-- get vehicle data
-- returns vehicle model name (i.e. jester4 = Jester RR)
Cnt.GetVehInfo = function(vehicle)
local model = GetEntityModel(vehicle)
local display = GetDisplayNameFromVehicleModel(model)
local name = GetLabelText(display)
return name
Util.Delete = function(e)
if not e then
return end
DeleteEntity(e)
e = nil
end

-- set object orientation & physics
-- for placing props that will be stationary
Cnt.SetObject = function(obj, head)
SetEntityHeading(obj, head)
PlaceObjectOnGroundProperly(obj)
FreezeEntityPosition(obj, true)
SetEntityCollision(obj, true, true)
Util.SetObject = function(o,h)
SetEntityHeading(o, h)
PlaceObjectOnGroundProperly(o)
FreezeEntityPosition(o, true)
SetEntityCollision(o, true, true)
end

-- teleport function
-- fades screen to ease player transport
Cnt.Teleport = function(ped, x, y, z, w)
DoScreenFadeOut(100)
Citizen.Wait(1000)
SetEntityCoords(ped, x, y, z, false, false, false, false)
SetEntityHeading(ped, w)
DoScreenFadeIn(750)
Util.Teleport = function(p, x, y, z, w)
DoScreenFadeOut(150)
Wait(500)
SetEntityCoords(p, x, y, z, false, false, false, false)
SetEntityHeading(p, w)
DoScreenFadeIn(150)
end

-- convert current value and max value to percentage
Cnt.GetPercentage = function(percent, maxvalue)
if tonumber(percent) and tonumber(maxvalue) then
return (maxvalue*percent)/100
Util.GetPercentage = function(p, m)
if tonumber(p) and tonumber(m) then
return (m*p)/100
end
end

-- set color for progress bar in context menu
Cnt.GetProgressColor = function(percent)
if percent >= 80 and percent <= 100 then
return '#40C057'
elseif percent <= 80 and percent >= 50 then
return '#FFD43B'
elseif percent <= 50 and percent >= 25 then
return '#F76707'
elseif percent <= 25 and percent >= 0 then
return '#E03131'
Util.GetProgressColor = function(p)
if p >= 80 and p <= 100 then
return '#40C057' -- green
elseif p <= 80 and p >= 50 then
return '#FFD43B' -- yellow
elseif p <= 50 and p >= 25 then
return '#F76707' -- orange
elseif p <= 25 and p >= 0 then
return '#E03131' -- red
end
end
Loading

0 comments on commit ff0eb50

Please sign in to comment.