Skip to content

Commit

Permalink
tweak(all): avoid number as string and avoid err if discount is enabl…
Browse files Browse the repository at this point in the history
…e for all mods
  • Loading branch information
renzuzu committed Oct 20, 2021
1 parent 710360a commit 1e20475
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
10 changes: 5 additions & 5 deletions client/events.lua
Original file line number Diff line number Diff line change
Expand Up @@ -587,9 +587,9 @@ AddEventHandler('renzu_customs:openmenu', function()
cost = v.cost
end
if Config.EnableDiscounts and PlayerData.job ~= nil and v.discount[PlayerData.job.name] ~= nil then
cost = cost * (1-v.discount[PlayerData.job.name])
cost = cost * (1-tonumber(v.discount[PlayerData.job.name]))
elseif Config.EnableDiscounts and PlayerData.job ~= nil and Config.JobDiscounts[PlayerData.job.name] ~= nil then
cost = cost * (1-Config.JobDiscounts[PlayerData.job.name])
cost = cost * (1-tonumber(Config.JobDiscounts[PlayerData.job.name]))
end
if Config.FreeUpgradeToClass[GetVehicleClass(vehicle)] then
cost = 0
Expand All @@ -598,11 +598,11 @@ AddEventHandler('renzu_customs:openmenu', function()
label = v.label or nil,
index = v.index,
name = v.name,
max = max,
max = max or 0,
cost = cost,
list = v.list or {},
type = v.type,
mod = list,
type = v.type or 'cosmetic',
mod = list or {},
action = v.action or false,
multicostperlvl = v.multicostperlvl or false
}
Expand Down
17 changes: 16 additions & 1 deletion config.lua
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ Config.VehicleMod = {
['police'] = 0,-- police is sample only change this!
},
discount = {
['mechanic'] = 0.2, -- 20%
['mechanic'] = 1.0, -- 20%
['ambulance'] = 0.1, -- 10%
['police'] = 0.15, -- 15%
},
Expand Down Expand Up @@ -1327,6 +1327,11 @@ if Config.UseCustomTurboUpgrade then
['mechanic'] = 0,
['police'] = 0,-- police is sample only change this!
},
discount = {
['mechanic'] = 0.2, -- 20%
['ambulance'] = 0.1, -- 10%
['police'] = 0.15, -- 15%
},
label = 'Custom Turbo',
name = 'custom_turbo',
index = 107,
Expand Down Expand Up @@ -1355,6 +1360,11 @@ if Config.UseCustomEngineUpgrade then
['mechanic'] = 0,
['police'] = 0,-- police is sample only change this!
},
discount = {
['mechanic'] = 0.2, -- 20%
['ambulance'] = 0.1, -- 10%
['police'] = 0.15, -- 15%
},
label = 'Custom Engine',
name = 'custom_engine',
index = 106,
Expand Down Expand Up @@ -1384,6 +1394,11 @@ if Config.UseCustomTireUpgrade then
['mechanic'] = 0,
['police'] = 0,-- police is sample only change this!
},
discount = {
['mechanic'] = 0.2, -- 20%
['ambulance'] = 0.1, -- 10%
['police'] = 0.15, -- 15%
},
label = 'Custom Tires',
name = 'custom_tires',
index = 108,
Expand Down
8 changes: 6 additions & 2 deletions server/server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,12 @@ RegisterServerCallBack_('renzu_customs:pay', function (source, cb, t, shop, vcla
local xPlayer = GetPlayerFromId(src)
local identifier = xPlayer.identifier
local prop = t.prop
local cost = t.cost
local cost = tonumber(t.cost)
local jobmoney = 0
if cost == 1 then
cost = 0
t.cost = 0
end
local vclass = tonumber(vclass)
if not Config.FreeUpgradeToClass[vclass] and not Config.JobPermissionAll and xPlayer.getMoney() >= t.cost or not Config.FreeUpgradeToClass[vclass] and Config.JobPermissionAll and Config.Customs[shop].job == xPlayer.job.name and Jobmoney(xPlayer.job.name,xPlayer) >= t.cost then
local result = CustomsSQL(Config.Mysql,'fetchAll','SELECT * FROM '..vehicletable..' WHERE UPPER(plate) = @plate', {
Expand All @@ -135,7 +139,7 @@ RegisterServerCallBack_('renzu_customs:pay', function (source, cb, t, shop, vcla
end
cb(true)
elseif not Config.OwnedVehiclesOnly then
if not Config.JobPermissionAll and xPlayer.getMoney() >= t.cost or Config.JobPermissionAll and Config.Customs[shop].job == xPlayer.job.name and Jobmoney(xPlayer.job.name,xPlayer) >= t.cost then
if not Config.JobPermissionAll and xPlayer.getMoney() >= tonumber(t.cost) or Config.JobPermissionAll and Config.Customs[shop].job == xPlayer.job.name and Jobmoney(xPlayer.job.name,xPlayer) >= tonumber(t.cost) then
if not Config.JobPermissionAll then --if other player
xPlayer.removeMoney(cost)
elseif Config.JobPermissionAll and not Config.UseRenzu_jobs then -- job owned without renzu_jobs
Expand Down

0 comments on commit 1e20475

Please sign in to comment.