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

Money glitch fix #35

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
20 changes: 12 additions & 8 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -800,14 +800,18 @@ CreateThread(function()
end
end, ESX.Math.Trim(GetVehicleNumberPlateText(CurrentActionData.vehicle)))
elseif CurrentAction == 'resell_vehicle' then
ESX.TriggerServerCallback('esx_vehicleshop:resellVehicle', function(vehicleSold)
if vehicleSold then
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
ESX.ShowNotification(TranslateCap('vehicle_sold_for', CurrentActionData.label, ESX.Math.GroupDigits(CurrentActionData.price)))
else
ESX.ShowNotification(TranslateCap('not_yours'))
end
end, CurrentActionData.plate, CurrentActionData.model)
if not pressed then
pressed = true
ESX.TriggerServerCallback('esx_vehicleshop:resellVehicle', function(vehicleSold, keypressed)
if vehicleSold then
ESX.Game.DeleteVehicle(CurrentActionData.vehicle)
ESX.ShowNotification(TranslateCap('vehicle_sold_for', CurrentActionData.label, ESX.Math.GroupDigits(CurrentActionData.price)))
else
ESX.ShowNotification(TranslateCap('not_yours'))
end
pressed = keypressed
end, CurrentActionData.plate, CurrentActionData.model)
end
elseif CurrentAction == 'boss_actions_menu' then
OpenBossActionsMenu()
end
Expand Down
24 changes: 16 additions & 8 deletions server/main.lua
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
local categories, vehicles = {}, {}
local vehiclesByModel = {}
local antispam = {}

CreateThread(function()
exports["esx_society"]:registerSociety('cardealer', TranslateCap('car_dealer'), 'society_cardealer', 'society_cardealer', 'society_cardealer', {type = 'private'})
Expand Down Expand Up @@ -282,12 +283,12 @@ ESX.RegisterServerCallback('esx_vehicleshop:resellVehicle', function(source, cb,

if not resellPrice then
print(('[^3WARNING^7] Player ^5%s^7 Attempted To Resell Invalid Vehicle - ^5%s^7!'):format(source, model))
return cb(false)
return cb(false, false)
end
MySQL.single('SELECT * FROM rented_vehicles WHERE plate = ?', {plate},
function(result)
if result then -- is it a rented vehicle?
return cb(false) -- it is, don't let the player sell it since he doesn't own it
return cb(false, false) -- it is, don't let the player sell it since he doesn't own it
end
MySQL.single('SELECT * FROM owned_vehicles WHERE owner = ? AND plate = ?', {xPlayer.identifier, plate},
function(result)
Expand All @@ -298,16 +299,23 @@ ESX.RegisterServerCallback('esx_vehicleshop:resellVehicle', function(source, cb,

if vehicle.model ~= model then
print(('[^3WARNING^7] Player ^5%s^7 Attempted To Resell Vehicle With Invalid Model - ^5%s^7!'):format(source, model))
return cb(false)
return cb(false, false)
end
if vehicle.plate ~= plate then
print(('[^3WARNING^7] Player ^5%s^7 Attempted To Resell Vehicle With Invalid Plate - ^5%s^7!'):format(source, plate))
return cb(false)
return cb(false, false)
end
if antispam[source] == nil then
antispam[source] = true
xPlayer.addMoney(resellPrice, "Sold Vehicle")
RemoveOwnedVehicle(plate)
cb(true, false)
Wait(5000)
antispam[source] = nil
else
print(('[^3WARNING^7] Player ^5%s^7 Attempted To Exploit Vehicle With Plate - ^5%s^7!'):format(source, plate))
cb(false, false)
end

xPlayer.addMoney(resellPrice, "Sold Vehicle")
RemoveOwnedVehicle(plate)
cb(true)
end)
end)
end
Expand Down