Skip to content

Commit

Permalink
v1.0.1
Browse files Browse the repository at this point in the history
  • Loading branch information
swkeep committed Sep 22, 2022
1 parent bad5e55 commit 91280c6
Show file tree
Hide file tree
Showing 6 changed files with 168 additions and 26 deletions.
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,19 @@

- [qb-core]()
- [keep-menu](https://github.com/swkeep/keep-menu)
- [keep-input](https://github.com/swkeep/keep-input)
- [qb-radialmenu](https://github.com/qbcore-framework/qb-radialmenu)

- [qb-menu] support will be in future updates
- Support for [qb-input] will not be added most likely

## Installation

- Drag and drop resource in your server!
- run the sql.sql on your database.
- setup the config file.
- done!
- now you can use /saveinsidegarage jobname command while you're inside a vehicle
- and save it as shared vehicle inside the garage

## Features
11 changes: 10 additions & 1 deletion client/client.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-- _
-- | |
-- _____ _| | _____ ___ _ __
-- / __\ \ /\ / / |/ / _ \/ _ \ '_ \
-- \__ \\ V V /| < __/ __/ |_) |
-- |___/ \_/\_/ |_|\_\___|\___| .__/
-- | |
-- |_|
-- https://github.com/swkeep
local QBCore = exports['qb-core']:GetCoreObject()

local GarageLocation = {}
Expand Down Expand Up @@ -197,7 +206,7 @@ local function InitGarageZone()
name = 'GarageStation ' .. k,
minZ = v.minz,
maxZ = v.maxz,
debugPoly = true
debugPoly = Config.MagicTouch
})
GarageLocation[k]:onPlayerInOut(function(isPointInside)
if isPointInside then
Expand Down
10 changes: 10 additions & 0 deletions client/menu/functions.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
-- _
-- | |
-- _____ _| | _____ ___ _ __
-- / __\ \ /\ / / |/ / _ \/ _ \ '_ \
-- \__ \\ V V /| < __/ __/ |_) |
-- |___/ \_/\_/ |_|\_\___|\___| .__/
-- | |
-- |_|
-- https://github.com/swkeep

local QBCore = exports['qb-core']:GetCoreObject()

local function Round(num, dp)
Expand Down
92 changes: 78 additions & 14 deletions client/menu/menu.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
-- _
-- | |
-- _____ _| | _____ ___ _ __
-- / __\ \ /\ / / |/ / _ \/ _ \ '_ \
-- \__ \\ V V /| < __/ __/ |_) |
-- |___/ \_/\_/ |_|\_\___|\___| .__/
-- | |
-- |_|
-- https://github.com/swkeep

local QBCore = exports['qb-core']:GetCoreObject()
local keep_menu = {}
local Cachedata = nil
Expand Down Expand Up @@ -248,7 +258,7 @@ function keep_menu:take_out_menu(data, vehicle, veh, per)
icon = 'fa-solid fa-clipboard-question',
args = { { plate = vehicle.plate, data = data, vehicle = vehicle, veh = veh } },
action = function(args)
keep_menu:vehicle_parking_log(args[1])
keep_menu:vehicle_parking_log(args[1], per)
end
},
}
Expand All @@ -264,8 +274,6 @@ function keep_menu:take_out_menu(data, vehicle, veh, per)

Menu[#Menu + 1] = {
header = "Modify Vehicle's Name",
type = 'server',
event = 'keep-jobgarages:server:dupe',
icon = 'fa-solid fa-pen-to-square',
action = function()
local Input = {
Expand All @@ -292,8 +300,6 @@ function keep_menu:take_out_menu(data, vehicle, veh, per)

Menu[#Menu + 1] = {
header = "Modify Vehicle's Plate",
type = 'server',
event = 'keep-jobgarages:server:dupe',
icon = 'fa-solid fa-pen-to-square',
action = function()
local Input = {
Expand All @@ -318,6 +324,65 @@ function keep_menu:take_out_menu(data, vehicle, veh, per)
end
end
}

Menu[#Menu + 1] = {
header = "Modify Vehicle's Customizability",
icon = 'fa-solid fa-pen-to-square',
action = function()
local Input = {
inputs = {
{
isRequired = true,
name = 'customizability',
title = "Modify Vehicle's Customizability",
force_value = vehicle.plate,
type = "radio",
options = {
{ value = true, text = 'Yes' },
{ value = false, text = 'No' },
},
},
}
}

local inputData, reason = exports['keep-input']:ShowInput(Input)
if reason == 'submit' then
if not inputData.customizability then return end
TriggerServerEvent('keep-jobgarages:server:set_is_customizable', inputData.customizability,
vehicle.plate)
end
end
}

Menu[#Menu + 1] = {
header = "Delete Vehicle",
icon = 'fa-solid fa-pen-to-square',
action = function()
local Input = {
inputs = {
{
isRequired = true,
name = 'delete',
title = "Delete Vehicle",
force_value = vehicle.plate,
type = "radio",
options = {
{ value = true, text = 'Yes' },
{ value = false, text = 'No' },
},
},
}
}

local inputData, reason = exports['keep-input']:ShowInput(Input)
if reason == 'submit' then
if not inputData.delete then return end
if inputData.delete == 'true' then
TriggerServerEvent('keep-jobgarages:server:delete', vehicle.plate)
end
end
end
}
end

local op = exports['keep-menu']:createMenu(Menu)
Expand Down Expand Up @@ -402,16 +467,15 @@ function keep_menu:vehicle_actions_menu(data)
end, vehicle.plate)
end

function keep_menu:vehicle_parking_log(data)
function keep_menu:vehicle_parking_log(data, per)
local Menu = {
{
header = "Go Back",
icon = 'fa-solid fa-angle-left',
args = { { data = data.data, vehicle = data.vehicle, veh = data.veh } },
action = function(args)
keep_menu:take_out_menu(args[1].data, args[1].vehicle, args[1].veh)
end
},
-- {
-- header = "Go Back",
-- icon = 'fa-solid fa-angle-left',
-- action = function()
-- keep_menu:take_out_menu(data.data, data.vehicle, data.veh, per)
-- end
-- },
}

TriggerCallback('keep-jobgarages:server:get_vehicle_log', function(LOGS)
Expand Down
2 changes: 2 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ Config.AllowledList = {
'TOA30976'
}

Config.MagicTouch = false

Config.VehicleWhiteList = {
['defaultPolice'] = {
{ label = 'Sheriff', spawncode = 'Sheriff2', icon = 'fa-solid fa-car-side' },
Expand Down
71 changes: 60 additions & 11 deletions server/server.lua
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
-- _
-- | |
-- _____ _| | _____ ___ _ __
-- / __\ \ /\ / / |/ / _ \/ _ \ '_ \
-- \__ \\ V V /| < __/ __/ |_) |
-- |___/ \_/\_/ |_|\_\___|\___| .__/
-- | |
-- |_|
-- https://github.com/swkeep
local QBCore = exports['qb-core']:GetCoreObject()

local out_vehicles = {
Expand Down Expand Up @@ -176,7 +185,6 @@ RegisterNetEvent('keep-jobgarages:server:dupe', function(plate)
end
end)


RegisterNetEvent('keep-jobgarages:server:update_vehicle_name', function(new_name, plate)
local src = source
local player = QBCore.Functions.GetPlayer(src)
Expand All @@ -201,6 +209,39 @@ RegisterNetEvent('keep-jobgarages:server:update_vehicle_plate', function(new_pla
end)
end)

RegisterNetEvent('keep-jobgarages:server:set_is_customizable', function(state, plate)
local src = source
local player = QBCore.Functions.GetPlayer(src)
if not cidWhiteListed(player) then
Notification(src, 'You are not whitelisted', 'error')
return
end
-- state might be no a bool value
if state == 'false' then
MySQL.Async.execute('UPDATE keep_garage SET is_customizable = ? WHERE plate = ?', { 0, plate }, function()
Notification(src, 'success', 'success')
end)
else
MySQL.Async.execute('UPDATE keep_garage SET is_customizable = ? WHERE plate = ?', { 1, plate }, function()
Notification(src, 'success', 'success')
end)
end
end)

RegisterNetEvent('keep-jobgarages:server:delete', function(plate)
local src = source
local player = QBCore.Functions.GetPlayer(src)
if not cidWhiteListed(player) then
Notification(src, 'You are not whitelisted', 'error')
return
end
-- state might be no a bool value
MySQL.Async.execute('DELETE FROM keep_garage WHERE plate = ?', { plate }, function()
Notification(src, 'success', 'success')
end)

end)

RegisterNetEvent("keep-jobgarages:server:update_state", function(plate, properties)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
Expand Down Expand Up @@ -258,16 +299,24 @@ RegisterNetEvent("keep-jobgarages:server:update_state", function(plate, properti
end
end)

QBCore.Commands.Add('saveInsideGarage', 'Save vehicle in shared garage', {}, true,
function(source, args)
local Player = QBCore.Functions.GetPlayer(source)
if not cidWhiteListed(Player) then
Notification(src, 'You are not whitelisted', 'error')
return
end
TriggerClientEvent('keep-jobgarages:client:newVehicleSetup', source, args[1],
QBCore.Shared.Jobs[args[1]].grades)
end, 'user')
QBCore.Commands.Add('saveInsideGarage', 'Save vehicle in shared garage', {
{
name = "job name",
help = ""
},
}, true, function(source, args)
local src = source
if not args[1] or not QBCore.Shared.Jobs[args[1]] then
Notification(src, 'Job name is wrong!', 'error')
return
end
local Player = QBCore.Functions.GetPlayer(src)
if not cidWhiteListed(Player) then
Notification(src, 'You are not whitelisted', 'error')
return
end
TriggerClientEvent('keep-jobgarages:client:newVehicleSetup', src, args[1], QBCore.Shared.Jobs[args[1]].grades)
end, 'user')

CreateCallback('keep-jobgarages:server:give_keys_to_all_same_job', function(source, cb, PlayerJob)
local players = QBCore.Functions.GetPlayers()
Expand Down

0 comments on commit 91280c6

Please sign in to comment.