Untitled diff
455 lines
ESX = nil
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
if Config.MaxInService ~= -1 then
if Config.MaxInService ~= -1 then
TriggerEvent('esx_service:activateService', 'mafia', Config.MaxInService)
TriggerEvent('esx_service:activateService', 'Hitman', Config.MaxInService)
end
end
-- TriggerEvent('esx_phone:registerNumber', 'mafia', _U('alert_mafia'), true, true)
-- TriggerEvent('esx_phone:registerNumber', 'Hitman', _U('alert_Hitman'), true, true)
TriggerEvent('esx_society:registerSociety', 'mafia', 'Mafia', 'society_mafia', 'society_mafia', 'society_mafia', {type = 'public'})
TriggerEvent('esx_society:registerSociety', 'Hitman', 'Hitman', 'society_Hitman', 'society_Hitman', 'society_Hitman', {type = 'public'})
RegisterServerEvent('esx_mafiajob:giveWeapon')
RegisterServerEvent('esx_Hitmanjob:giveWeapon')
AddEventHandler('esx_mafiajob:giveWeapon', function(weapon, ammo)
AddEventHandler('esx_Hitmanjob:giveWeapon', function(weapon, ammo)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addWeapon(weapon, ammo)
xPlayer.addWeapon(weapon, ammo)
end)
end)
RegisterServerEvent('esx_mafiajob:confiscatePlayerItem')
RegisterServerEvent('esx_Hitmanjob:confiscatePlayerItem')
AddEventHandler('esx_mafiajob:confiscatePlayerItem', function(target, itemType, itemName, amount)
AddEventHandler('esx_Hitmanjob:confiscatePlayerItem', function(target, itemType, itemName, amount)
local sourceXPlayer = ESX.GetPlayerFromId(source)
local sourceXPlayer = ESX.GetPlayerFromId(source)
local targetXPlayer = ESX.GetPlayerFromId(target)
local targetXPlayer = ESX.GetPlayerFromId(target)
if itemType == 'item_standard' then
if itemType == 'item_standard' then
local label = sourceXPlayer.getInventoryItem(itemName).label
local label = sourceXPlayer.getInventoryItem(itemName).label
targetXPlayer.removeInventoryItem(itemName, amount)
targetXPlayer.removeInventoryItem(itemName, amount)
sourceXPlayer.addInventoryItem(itemName, amount)
sourceXPlayer.addInventoryItem(itemName, amount)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confinv') .. amount .. ' ' .. label .. _U('from') .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confinv') .. amount .. ' ' .. label .. _U('from') .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confinv') .. amount .. ' ' .. label )
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confinv') .. amount .. ' ' .. label )
end
end
if itemType == 'item_account' then
if itemType == 'item_account' then
targetXPlayer.removeAccountMoney(itemName, amount)
targetXPlayer.removeAccountMoney(itemName, amount)
sourceXPlayer.addAccountMoney(itemName, amount)
sourceXPlayer.addAccountMoney(itemName, amount)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confdm') .. amount .. _U('from') .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confdm') .. amount .. _U('from') .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confdm') .. amount)
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confdm') .. amount)
end
end
if itemType == 'item_weapon' then
if itemType == 'item_weapon' then
targetXPlayer.removeWeapon(itemName)
targetXPlayer.removeWeapon(itemName)
sourceXPlayer.addWeapon(itemName, amount)
sourceXPlayer.addWeapon(itemName, amount)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confweapon') .. ESX.GetWeaponLabel(itemName) .. _U('from') .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, _U('you_have_confweapon') .. ESX.GetWeaponLabel(itemName) .. _U('from') .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confweapon') .. ESX.GetWeaponLabel(itemName))
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. _U('confweapon') .. ESX.GetWeaponLabel(itemName))
end
end
end)
end)
RegisterServerEvent('esx_mafiajob:handcuff')
RegisterServerEvent('esx_Hitmanjob:handcuff')
AddEventHandler('esx_mafiajob:handcuff', function(target)
AddEventHandler('esx_Hitmanjob:handcuff', function(target)
TriggerClientEvent('esx_mafiajob:handcuff', target)
TriggerClientEvent('esx_Hitmanjob:handcuff', target)
end)
end)
RegisterServerEvent('esx_mafiajob:drag')
RegisterServerEvent('esx_Hitmanjob:drag')
AddEventHandler('esx_mafiajob:drag', function(target)
AddEventHandler('esx_Hitmanjob:drag', function(target)
local _source = source
local _source = source
TriggerClientEvent('esx_mafiajob:drag', target, _source)
TriggerClientEvent('esx_Hitmanjob:drag', target, _source)
end)
end)
RegisterServerEvent('esx_mafiajob:putInVehicle')
RegisterServerEvent('esx_Hitmanjob:putInVehicle')
AddEventHandler('esx_mafiajob:putInVehicle', function(target)
AddEventHandler('esx_Hitmanjob:putInVehicle', function(target)
TriggerClientEvent('esx_mafiajob:putInVehicle', target)
TriggerClientEvent('esx_Hitmanjob:putInVehicle', target)
end)
end)
RegisterServerEvent('esx_mafiajob:OutVehicle')
RegisterServerEvent('esx_Hitmanjob:OutVehicle')
AddEventHandler('esx_mafiajob:OutVehicle', function(target)
AddEventHandler('esx_Hitmanjob:OutVehicle', function(target)
TriggerClientEvent('esx_mafiajob:OutVehicle', target)
TriggerClientEvent('esx_Hitmanjob:OutVehicle', target)
end)
end)
RegisterServerEvent('esx_mafiajob:getStockItem')
RegisterServerEvent('esx_Hitmanjob:getStockItem')
AddEventHandler('esx_mafiajob:getStockItem', function(itemName, count)
AddEventHandler('esx_Hitmanjob:getStockItem', function(itemName, count)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mafia', function(inventory)
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_Hitman', function(inventory)
local item = inventory.getItem(itemName)
local item = inventory.getItem(itemName)
if item.count >= count then
if item.count >= count then
inventory.removeItem(itemName, count)
inventory.removeItem(itemName, count)
xPlayer.addInventoryItem(itemName, count)
xPlayer.addInventoryItem(itemName, count)
else
else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
end
end
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn') .. count .. ' ' .. item.label)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('have_withdrawn') .. count .. ' ' .. item.label)
end)
end)
end)
end)
RegisterServerEvent('esx_mafiajob:putStockItems')
RegisterServerEvent('esx_Hitmanjob:putStockItems')
AddEventHandler('esx_mafiajob:putStockItems', function(itemName, count)
AddEventHandler('esx_Hitmanjob:putStockItems', function(itemName, count)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mafia', function(inventory)
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_Hitman', function(inventory)
local item = inventory.getItem(itemName)
local item = inventory.getItem(itemName)
if item.count >= 0 then
if item.count >= 0 then
xPlayer.removeInventoryItem(itemName, count)
xPlayer.removeInventoryItem(itemName, count)
inventory.addItem(itemName, count)
inventory.addItem(itemName, count)
else
else
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('quantity_invalid'))
end
end
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('added') .. count .. ' ' .. item.label)
TriggerClientEvent('esx:showNotification', xPlayer.source, _U('added') .. count .. ' ' .. item.label)
end)
end)
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:getOtherPlayerData', function(source, cb, target)
ESX.RegisterServerCallback('esx_Hitmanjob:getOtherPlayerData', function(source, cb, target)
if Config.EnableESXIdentity then
if Config.EnableESXIdentity then
local xPlayer = ESX.GetPlayerFromId(target)
local xPlayer = ESX.GetPlayerFromId(target)
local identifier = GetPlayerIdentifiers(target)[1]
local identifier = GetPlayerIdentifiers(target)[1]
local result = MySQL.Sync.fetchAll("SELECT * FROM users WHERE identifier = @identifier", {
local result = MySQL.Sync.fetchAll("SELECT * FROM users WHERE identifier = @identifier", {
['@identifier'] = identifier
['@identifier'] = identifier
})
})
local user = result[1]
local user = result[1]
local firstname = user['firstname']
local firstname = user['firstname']
local lastname = user['lastname']
local lastname = user['lastname']
local sex = user['sex']
local sex = user['sex']
local dob = user['dateofbirth']
local dob = user['dateofbirth']
local height = user['height'] .. " Inches"
local height = user['height'] .. " Inches"
local data = {
local data = {
name = GetPlayerName(target),
name = GetPlayerName(target),
job = xPlayer.job,
job = xPlayer.job,
inventory = xPlayer.inventory,
inventory = xPlayer.inventory,
accounts = xPlayer.accounts,
accounts = xPlayer.accounts,
weapons = xPlayer.loadout,
weapons = xPlayer.loadout,
firstname = firstname,
firstname = firstname,
lastname = lastname,
lastname = lastname,
sex = sex,
sex = sex,
dob = dob,
dob = dob,
height = height
height = height
}
}
TriggerEvent('esx_status:getStatus', source, 'drunk', function(status)
TriggerEvent('esx_status:getStatus', source, 'drunk', function(status)
if status ~= nil then
if status ~= nil then
data.drunk = math.floor(status.percent)
data.drunk = math.floor(status.percent)
end
end
end)
end)
if Config.EnableLicenses then
if Config.EnableLicenses then
TriggerEvent('esx_license:getLicenses', source, function(licenses)
TriggerEvent('esx_license:getLicenses', source, function(licenses)
data.licenses = licenses
data.licenses = licenses
cb(data)
cb(data)
end)
end)
else
else
cb(data)
cb(data)
end
end
else
else
local xPlayer = ESX.GetPlayerFromId(target)
local xPlayer = ESX.GetPlayerFromId(target)
local data = {
local data = {
name = GetPlayerName(target),
name = GetPlayerName(target),
job = xPlayer.job,
job = xPlayer.job,
inventory = xPlayer.inventory,
inventory = xPlayer.inventory,
accounts = xPlayer.accounts,
accounts = xPlayer.accounts,
weapons = xPlayer.loadout
weapons = xPlayer.loadout
}
}
TriggerEvent('esx_status:getStatus', _source, 'drunk', function(status)
TriggerEvent('esx_status:getStatus', _source, 'drunk', function(status)
if status ~= nil then
if status ~= nil then
data.drunk = status.getPercent()
data.drunk = status.getPercent()
end
end
end)
end)
TriggerEvent('esx_license:getLicenses', _source, function(licenses)
TriggerEvent('esx_license:getLicenses', _source, function(licenses)
data.licenses = licenses
data.licenses = licenses
end)
end)
cb(data)
cb(data)
end
end
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:getFineList', function(source, cb, category)
ESX.RegisterServerCallback('esx_Hitmanjob:getFineList', function(source, cb, category)
MySQL.Async.fetchAll(
MySQL.Async.fetchAll(
'SELECT * FROM fine_types_mafia WHERE category = @category',
'SELECT * FROM fine_types_Hitman WHERE category = @category',
{
{
['@category'] = category
['@category'] = category
},
},
function(fines)
function(fines)
cb(fines)
cb(fines)
end
end
)
)
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:getVehicleInfos', function(source, cb, plate)
ESX.RegisterServerCallback('esx_Hitmanjob:getVehicleInfos', function(source, cb, plate)
if Config.EnableESXIdentity then
if Config.EnableESXIdentity then
MySQL.Async.fetchAll(
MySQL.Async.fetchAll(
'SELECT * FROM owned_vehicles',
'SELECT * FROM owned_vehicles',
{},
{},
function(result)
function(result)
local foundIdentifier = nil
local foundIdentifier = nil
for i=1, #result, 1 do
for i=1, #result, 1 do
local vehicleData = json.decode(result[i].vehicle)
local vehicleData = json.decode(result[i].vehicle)
if vehicleData.plate == plate then
if vehicleData.plate == plate then
foundIdentifier = result[i].owner
foundIdentifier = result[i].owner
break
break
end
end
end
end
if foundIdentifier ~= nil then
if foundIdentifier ~= nil then
MySQL.Async.fetchAll(
MySQL.Async.fetchAll(
'SELECT * FROM users WHERE identifier = @identifier',
'SELECT * FROM users WHERE identifier = @identifier',
{
{
['@identifier'] = foundIdentifier
['@identifier'] = foundIdentifier
},
},
function(result)
function(result)
local ownerName = result[1].firstname .. " " .. result[1].lastname
local ownerName = result[1].firstname .. " " .. result[1].lastname
local infos = {
local infos = {
plate = plate,
plate = plate,
owner = ownerName
owner = ownerName
}
}
cb(infos)
cb(infos)
end
end
)
)
else
else
local infos = {
local infos = {
plate = plate
plate = plate
}
}
cb(infos)
cb(infos)
end
end
end
end
)
)
else
else
MySQL.Async.fetchAll(
MySQL.Async.fetchAll(
'SELECT * FROM owned_vehicles',
'SELECT * FROM owned_vehicles',
{},
{},
function(result)
function(result)
local foundIdentifier = nil
local foundIdentifier = nil
for i=1, #result, 1 do
for i=1, #result, 1 do
local vehicleData = json.decode(result[i].vehicle)
local vehicleData = json.decode(result[i].vehicle)
if vehicleData.plate == plate then
if vehicleData.plate == plate then
foundIdentifier = result[i].owner
foundIdentifier = result[i].owner
break
break
end
end
end
end
if foundIdentifier ~= nil then
if foundIdentifier ~= nil then
MySQL.Async.fetchAll(
MySQL.Async.fetchAll(
'SELECT * FROM users WHERE identifier = @identifier',
'SELECT * FROM users WHERE identifier = @identifier',
{
{
['@identifier'] = foundIdentifier
['@identifier'] = foundIdentifier
},
},
function(result)
function(result)
local infos = {
local infos = {
plate = plate,
plate = plate,
owner = result[1].name
owner = result[1].name
}
}
cb(infos)
cb(infos)
end
end
)
)
else
else
local infos = {
local infos = {
plate = plate
plate = plate
}
}
cb(infos)
cb(infos)
end
end
end
end
)
)
end
end
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:getArmoryWeapons', function(source, cb)
ESX.RegisterServerCallback('esx_Hitmanjob:getArmoryWeapons', function(source, cb)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_mafia', function(store)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_Hitman', function(store)
local weapons = store.get('weapons')
local weapons = store.get('weapons')
if weapons == nil then
if weapons == nil then
weapons = {}
weapons = {}
end
end
cb(weapons)
cb(weapons)
end)
end)
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:addArmoryWeapon', function(source, cb, weaponName)
ESX.RegisterServerCallback('esx_Hitmanjob:addArmoryWeapon', function(source, cb, weaponName)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeWeapon(weaponName)
xPlayer.removeWeapon(weaponName)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_mafia', function(store)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_Hitman', function(store)
local weapons = store.get('weapons')
local weapons = store.get('weapons')
if weapons == nil then
if weapons == nil then
weapons = {}
weapons = {}
end
end
local foundWeapon = false
local foundWeapon = false
for i=1, #weapons, 1 do
for i=1, #weapons, 1 do
if weapons[i].name == weaponName then
if weapons[i].name == weaponName then
weapons[i].count = weapons[i].count + 1
weapons[i].count = weapons[i].count + 1
foundWeapon = true
foundWeapon = true
end
end
end
end
if not foundWeapon then
if not foundWeapon then
table.insert(weapons, {
table.insert(weapons, {
name = weaponName,
name = weaponName,
count = 1
count = 1
})
})
end
end
store.set('weapons', weapons)
store.set('weapons', weapons)
cb()
cb()
end)
end)
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:removeArmoryWeapon', function(source, cb, weaponName)
ESX.RegisterServerCallback('esx_Hitmanjob:removeArmoryWeapon', function(source, cb, weaponName)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addWeapon(weaponName, 1000)
xPlayer.addWeapon(weaponName, 1000)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_mafia', function(store)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_Hitman', function(store)
local weapons = store.get('weapons')
local weapons = store.get('weapons')
if weapons == nil then
if weapons == nil then
weapons = {}
weapons = {}
end
end
local foundWeapon = false
local foundWeapon = false
for i=1, #weapons, 1 do
for i=1, #weapons, 1 do
if weapons[i].name == weaponName then
if weapons[i].name == weaponName then
weapons[i].count = (weapons[i].count > 0 and weapons[i].count - 1 or 0)
weapons[i].count = (weapons[i].count > 0 and weapons[i].count - 1 or 0)
foundWeapon = true
foundWeapon = true
end
end
end
end
if not foundWeapon then
if not foundWeapon then
table.insert(weapons, {
table.insert(weapons, {
name = weaponName,
name = weaponName,
count = 0
count = 0
})
})
end
end
store.set('weapons', weapons)
store.set('weapons', weapons)
cb()
cb()
end)
end)
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:buy', function(source, cb, amount)
ESX.RegisterServerCallback('esx_Hitmanjob:buy', function(source, cb, amount)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_mafia', function(account)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_Hitman', function(account)
if account.money >= amount then
if account.money >= amount then
account.removeMoney(amount)
account.removeMoney(amount)
cb(true)
cb(true)
else
else
cb(false)
cb(false)
end
end
end)
end)
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:getStockItems', function(source, cb)
ESX.RegisterServerCallback('esx_Hitmanjob:getStockItems', function(source, cb)
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_mafia', function(inventory)
TriggerEvent('esx_addoninventory:getSharedInventory', 'society_Hitman', function(inventory)
cb(inventory.items)
cb(inventory.items)
end)
end)
end)
end)
ESX.RegisterServerCallback('esx_mafiajob:getPlayerInventory', function(source, cb)
ESX.RegisterServerCallback('esx_Hitmanjob:getPlayerInventory', function(source, cb)
local xPlayer = ESX.GetPlayerFromId(source)
local xPlayer = ESX.GetPlayerFromId(source)
local items = xPlayer.inventory
local items = xPlayer.inventory
cb({
cb({
items = items
items = items
})
})
end)
end)