Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lots of changes and fixes cleanup too #27

Closed
wants to merge 36 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
a30eb00
Update admin.lua
DevX32 Oct 14, 2023
eb2c4db
Update admin.lua
DevX32 Oct 14, 2023
43947be
Update commands.lua
DevX32 Oct 17, 2023
7e9e364
Merge pull request #1 from DevX32/patch-1
DevX32 Oct 17, 2023
b9ac86a
Update main.lua
DevX32 Oct 17, 2023
d432146
Update en.lua
DevX32 Oct 17, 2023
6b2b12a
Update admin.lua
DevX32 Oct 17, 2023
3630988
Update commands.lua
DevX32 Oct 17, 2023
8935202
Update main.lua
DevX32 Oct 17, 2023
05491ce
Update commands.lua
DevX32 Oct 17, 2023
a12298e
Update commands.lua
DevX32 Oct 17, 2023
5424c51
Update main.lua
DevX32 Oct 17, 2023
1be50ba
Update main.lua
DevX32 Oct 17, 2023
a8be369
Update main.lua
DevX32 Oct 17, 2023
54e3237
Update main.lua
DevX32 Oct 17, 2023
c64e915
Update config.lua
DevX32 Oct 17, 2023
eaed172
Update main.lua
DevX32 Oct 17, 2023
a531e12
Update commands.lua
DevX32 Oct 17, 2023
b7f470d
Update main.lua
DevX32 Oct 17, 2023
d10095d
Update main.lua
DevX32 Oct 17, 2023
72823ac
Update commands.lua
DevX32 Oct 17, 2023
1588ea9
Update dev.lua
DevX32 Oct 17, 2023
ffdab2b
Update admin.lua
DevX32 Oct 17, 2023
3be54d6
Update commands.lua
DevX32 Oct 18, 2023
c888c87
Update main.lua
DevX32 Oct 18, 2023
fd220b3
Update commands.lua
DevX32 Oct 18, 2023
26ada48
Update main.lua
DevX32 Oct 18, 2023
77c8552
Update admin.lua
DevX32 Oct 18, 2023
a660296
Update admin.lua
DevX32 Oct 18, 2023
51e8708
Update main.lua
DevX32 Oct 18, 2023
abb3f7e
Update main.lua
DevX32 Oct 18, 2023
ff0eabc
Update admin.lua
DevX32 Oct 18, 2023
4ccae11
Update main.lua
DevX32 Oct 18, 2023
1c291f6
Update admin.lua
DevX32 Oct 18, 2023
d2e3aac
Update en.lua
DevX32 Oct 18, 2023
a31bef7
Update main.lua
DevX32 Oct 18, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions client/admin.lua
Original file line number Diff line number Diff line change
Expand Up @@ -481,3 +481,22 @@ RegisterNetEvent('qb-admin:client:Show', function(players)
end
end
end)

RegisterNetEvent('qb-admin:client:SaveCar', function()
local ped = cache.ped
local veh = GetVehiclePedIsIn(ped)

if veh ~= nil and veh ~= 0 then
local plate = GetPlate(veh)
local props = lib.getVehicleProperties(veh)
local hash = props.model
local vehname = GetDisplayNameFromVehicleModel(hash):lower()
if exports.qbx_core:GetVehiclesByName()[vehname] then
TriggerServerEvent('admin:server:SaveCar', props, exports.qbx_core:GetVehiclesByName()[vehname], plate)
else
exports.qbx_core:Notify(Lang:t("error.no_store_vehicle_garage"), 'error')
end
else
exports.qbx_core:Notify(Lang:t("error.no_vehicle"), 'error')
end
end)
3 changes: 1 addition & 2 deletions client/dev.lua
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,7 @@ lib.registerMenu({
{label = Lang:t('dev_options.label4'), description = Lang:t('dev_options.desc4'), icon = 'fas fa-compass'},
{label = Lang:t('dev_options.label5'), description = Lang:t('dev_options.desc5'), icon = 'fas fa-compass-drafting', close = false},
{label = Lang:t('dev_options.label6'), description = Lang:t('dev_options.desc6'), icon = 'fas fa-car-side', close = false},
{label = Lang:t('admin_options.label1'), description = Lang:t('admin_options.desc1'), icon = 'fab fa-fly', close = false},
}
}, function(selected)
Options[selected]()
end)
end)
1 change: 1 addition & 0 deletions config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Config.Events = {
['playeroptionsgeneral'] = 'mod',
['kick'] = 'mod',
['ban'] = 'admin',
['savecar'] = 'god',
['changeperms'] = 'admin',
['clothing menu'] = 'admin',
['play sounds'] = 'admin',
Expand Down
4 changes: 4 additions & 0 deletions locales/en.lua
Original file line number Diff line number Diff line change
Expand Up @@ -146,11 +146,15 @@ local Translations = {
names_activated = 'Names activated',
coords_copied = 'Coordinates copied to clipboard',
heading_copied = 'Heading copied to clipboard',
success_vehicle_owner = 'The vehicle is now yours!',
},
error = {
no_perms = 'You don\'t have permission to do this',
blips_deactivated = 'Blips deactivated',
names_deactivated = 'Names deactivated',
failed_vehicle_owner = 'This vehicle is already yours..',
no_store_vehicle_garage = 'You cant store this vehicle in your garage..',
no_vehicle = 'You are not in a vehicle..',
}
}

Expand Down
9 changes: 8 additions & 1 deletion server/commands.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,13 @@ lib.addCommand('noclip', {
TriggerClientEvent('qb-admin:client:noclip', source)
end)

lib.addCommand('admincar', {
help = 'Toggle Admin Car',
restricted = 'admin',
}, function(source)
TriggerClientEvent('qb-admin:client:SaveCar', source)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this needs to be a client event. Can't the spawning and configuration of the car largely be handled server side? Is this command even useful? Admins can already do /car [model] after all

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

its saves the car / give owership of veh/car

end)

lib.addCommand('names', {
help = 'Toggle Player Names',
restricted = 'admin',
Expand Down Expand Up @@ -67,4 +74,4 @@ lib.addCommand('heading', {
restricted = 'admin',
}, function(source)
TriggerClientEvent('qb-admin:client:copyToClipboard', source, 'heading')
end)
end)
27 changes: 26 additions & 1 deletion server/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,31 @@ RegisterNetEvent('qb-admin:server:changeplayerdata', function(Selected, Selected
PlayerDataOptions[Selected](Target, Input)
end)

RegisterNetEvent('qb-admin:server:SaveCar', function(mods, vehicle, plate)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should call https://qbox-project.github.io/resources/core/functions/server#spawnvehicle. It should not be calling the database directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i will do all thing what u said

local Player = exports.qbx_core:GetPlayer(source)
local result = MySQL.Sync.fetchAll('SELECT plate FROM player_vehicles WHERE plate = ?', { plate })
if result[1] ~= nil then
TriggerClientEvent('ox_lib:notify', source, Lang:t("error.failed_vehicle_owner"), 'error', 3000)
return
end
if not exports.qbx_core:HasPermission(source, Config.Events['savecar']) then NoPerms(source) return end
local playerName = GetPlayerName(source)
local citizenID = Player.PlayerData.citizenid
TriggerEvent('qb-log:server:CreateLog', 'admin', 'Admin menu', 'pink', string.format(
"**%s** (CitizenID: %s | ID: %s) - Saved a car to their garage **%s**",
playerName, citizenID, source, vehicle.model
))
MySQL.Async.insert('INSERT INTO player_vehicles (license, citizenid, vehicle, hash, mods, plate, state) VALUES (?, ?, ?, ?, ?, ?, ?)', {
Player.PlayerData.license,
citizenID,
vehicle.model,
vehicle.hash,
json.encode(mods),
plate,
0
})
TriggerClientEvent('ox_lib:notify', source, Lang:t("success.success_vehicle_owner"), 'success', 5000)
end)
RegisterNetEvent('qb-admin:server:giveallweapons', function(Weapontype, PlayerID)
local src = PlayerID or source
local Target = exports.qbx_core:GetPlayer(src)
Expand Down Expand Up @@ -250,4 +275,4 @@ CreateThread(function()
sounds[#sounds + 1] = filename:match('(.+)%..+$')
end
end
end)
end)
Loading