Fixed cheating exploit, empty shop bug, broken translation

This commit is contained in:
ElPumpo
2018-04-30 17:21:59 +02:00
parent d357703229
commit d43ff45bfa
4 changed files with 77 additions and 80 deletions
+5 -6
View File
@@ -10,25 +10,24 @@ Citizen.CreateThread(function()
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
Citizen.Wait(0)
end
end)
AddEventHandler('onClientMapStart', function()
Citizen.Wait(5000)
ESX.TriggerServerCallback('esx_shops:requestDBItems', function(ShopItems)
for k,v in pairs(ShopItems) do
Config.Zones[k].Items = v
end
end)
end)
function OpenShopMenu(zone)
local elements = {}
for i=1, #Config.Zones[zone].Items, 1 do
local item = Config.Zones[zone].Items[i]
table.insert(elements, {
label = item.label .. ' - <span style="color: green;">' .. item.price .. '$</span>',
label = item.label .. ' - <span style="color: green;">$' .. item.price .. '</span>',
realLabel = item.label,
value = item.name,
price = item.price
+39 -40
View File
@@ -1,50 +1,49 @@
Config = {}
Config = {}
Config.DrawDistance = 100
Config.Size = {x = 1.5, y = 1.5, z = 1.5}
Config.Color = {r = 0, g = 128, b = 255}
Config.Type = 1
Config.Locale = 'en'
Config.Locale = 'en'
Config.Zones = {
TwentyFourSeven = {
Items = {},
Pos = {
{x = 373.875, y = 325.896, z = 102.566},
{x = 2557.458, y = 382.282, z = 107.622},
{x = -3038.939, y = 585.954, z = 6.908},
{x = -3241.927, y = 1001.462, z = 11.830},
{x = 547.431, y = 2671.710, z = 41.156},
{x = 1961.464, y = 3740.672, z = 31.343},
{x = 2678.916, y = 3280.671, z = 54.241},
{x = 1729.216, y = 6414.131, z = 34.037}
}
},
TwentyFourSeven = {
Items = {},
Pos = {
{x = 373.875, y = 325.896, z = 102.566},
{x = 2557.458, y = 382.282, z = 107.622},
{x = -3038.939, y = 585.954, z = 6.908},
{x = -3241.927, y = 1001.462, z = 11.830},
{x = 547.431, y = 2671.710, z = 41.156},
{x = 1961.464, y = 3740.672, z = 31.343},
{x = 2678.916, y = 3280.671, z = 54.241},
{x = 1729.216, y = 6414.131, z = 34.037}
}
},
RobsLiquor = {
Items = {},
Pos = {
{x = 1135.808, y = -982.281, z = 45.415},
{x = -1222.915, y = -906.983, z = 11.326},
{x = -1487.553, y = -379.107, z = 39.163},
{x = -2968.243, y = 390.910, z = 14.043},
{x = 1166.024, y = 2708.930, z = 37.157},
{x = 1392.562, y = 3604.684, z = 33.980},
{x = 127.830, y = -1284.796, z = 28.280}, --StripClub
{x = -1393.409, y = -606.624, z = 29.319}, --Tequila la
{x = -559.906, y = 287.093, z = 81.176} --Bahamamas
}
},
RobsLiquor = {
Items = {},
Pos = {
{x = 1135.808, y = -982.281, z = 45.415},
{x = -1222.915, y = -906.983, z = 11.326},
{x = -1487.553, y = -379.107, z = 39.163},
{x = -2968.243, y = 390.910, z = 14.043},
{x = 1166.024, y = 2708.930, z = 37.157},
{x = 1392.562, y = 3604.684, z = 33.980},
{x = 127.830, y = -1284.796, z = 28.280}, --StripClub
{x = -1393.409, y = -606.624, z = 29.319}, --Tequila la
{x = -559.906, y = 287.093, z = 81.176} --Bahamamas
}
},
LTDgasoline = {
Items = {},
Pos = {
{x = -48.519, y = -1757.514, z = 28.421},
{x = 1163.373, y = -323.801, z = 68.205},
{x = -707.501, y = -914.260, z = 18.215},
{x = -1820.523, y = 792.518, z = 137.118},
{x = 1698.388, y = 4924.404, z = 41.063}
}
}
LTDgasoline = {
Items = {},
Pos = {
{x = -48.519, y = -1757.514, z = 28.421},
{x = 1163.373, y = -323.801, z = 68.205},
{x = -707.501, y = -914.260, z = 18.215},
{x = -1820.523, y = 792.518, z = 137.118},
{x = 1698.388, y = 4924.404, z = 41.063}
}
}
}
+2 -4
View File
@@ -1,10 +1,8 @@
Locales['br'] = {
['shop'] = 'Comprar',
['shops'] = 'Lojas',
['press_menu'] = 'Pressione ~INPUT_CONTEXT~ para acessar a loja.',
['bought'] = 'você comprou ~b~1x ',
['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~.'
['player_cannot_hold'] = 'Você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!',
['not_enough'] = 'você não tem ~r~dinheiro suficiente~s~.',
['player_cannot_hold'] = 'Você ~r~não~s~ tem bastante ~y~espaço livre~s~ no seu inventário!',
}
+31 -30
View File
@@ -3,52 +3,53 @@ local ItemsLabels = {}
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
AddEventHandler('onMySQLReady', function()
-- Load item labels
Citizen.CreateThread(function()
Citizen.Wait(5000)
MySQL.Async.fetchAll(
'SELECT * FROM items',
{},
function(result)
for i=1, #result, 1 do
ItemsLabels[result[i].name] = result[i].label
end
'SELECT * FROM items',
{},
function(result)
for i=1, #result, 1 do
ItemsLabels[result[i].name] = result[i].label
end
)
end)
end)
ESX.RegisterServerCallback('esx_shops:requestDBItems', function(source, cb)
MySQL.Async.fetchAll(
'SELECT * FROM shops',
{},
function(result)
local shopItems = {}
for i=1, #result, 1 do
if shopItems[result[i].name] == nil then
shopItems[result[i].name] = {}
end
table.insert(shopItems[result[i].name], {
name = result[i].item,
price = result[i].price,
label = ItemsLabels[result[i].item]
})
'SELECT * FROM shops',
{},
function(result)
local shopItems = {}
for i=1, #result, 1 do
if shopItems[result[i].name] == nil then
shopItems[result[i].name] = {}
end
cb(shopItems)
table.insert(shopItems[result[i].name], {
name = result[i].item,
price = result[i].price,
label = ItemsLabels[result[i].item]
})
end
)
cb(shopItems)
end)
end)
RegisterServerEvent('esx_shops:buyItem')
AddEventHandler('esx_shops:buyItem', function(itemName, price)
local _source = source
local xPlayer = ESX.GetPlayerFromId(_source)
local sourceItem = xPlayer.getInventoryItem(itemName)
-- is the player trying to cheat?
if price < 0 then
print('esx_shops: ' .. xPlayer.identifier .. ' attempted to cheat money!')
return
end
-- can the player afford this item?
if xPlayer.getMoney() >= price then