Add files

This commit is contained in:
Jérémie N'gadi
2017-08-08 20:16:19 +02:00
parent 77e93ecee7
commit 57d8abed3d
7 changed files with 1840 additions and 0 deletions
+28
View File
@@ -1,2 +1,30 @@
# fxserver-esx_policejob
FXServer ESX Police Job
[REQUIREMENTS]
* Auto mode
* esx_billing => https://github.com/FXServer-ESX/fxserver-esx_billing
* Player management (boss actions and armory with buyable weapons)
* esx_society => https://github.com/FXServer-ESX/fxserver-esx_society
* esx_datastore => https://github.com/FXServer-ESX/fxserver-esx_datastore
[INSTALLATION]
1) CD in your resources/[esx] folder
2) Clone the repository
```
git clone https://github.com/FXServer-ESX/fxserver-esx_taxijob esx_taxijob
```
3) * Auto mode : Import esx_policejob_minimal.sql in your database
* Player / Armory management : Import esx_policejob_full.sql in your database
4) Add this in your server.cfg :
```
start esx_policejob
```
5) * If you want player management you have to set Config.EnablePlayerManagement to true in config.lua
* If you want armory management you have to set Config.EnableArmoryManagement to true in config.lua
+14
View File
@@ -0,0 +1,14 @@
resource_manifest_version '44febabe-d386-4d18-afbe-5e627f4af937'
description 'ESX Police Job'
server_scripts {
'@mysql-async/lib/MySQL.lua',
'config.lua',
'server/main.lua'
}
client_scripts {
'config.lua',
'client/main.lua'
}
+1430
View File
File diff suppressed because it is too large Load Diff
+77
View File
@@ -0,0 +1,77 @@
Config = {}
Config.DrawDistance = 100.0
Config.MarkerType = 1
Config.MarkerSize = {x = 1.5, y = 1.5, z = 1.0}
Config.MarkerColor = {r = 50, g = 50, b = 204}
Config.EnablePlayerManagement = false
Config.EnableArmoryManagement = false
Config.MaxInService = -1
Config.PoliceStations = {
LSPD = {
Blip = {
Pos = {x = 425.130, y = -979.558, z = 30.711},
Color = 29
},
AuthorizedWeapons = {
{name = 'WEAPON_NIGHTSTICK', price = 200},
{name = 'WEAPON_COMBATPISTOL', price = 300},
{name = 'WEAPON_ASSAULTSMG', price = 1250},
{name = 'WEAPON_ASSAULTRIFLE', price = 1500},
{name = 'WEAPON_PUMPSHOTGUN', price = 600},
{name = 'WEAPON_STUNGUN', price = 500},
{name = 'WEAPON_FLASHLIGHT', price = 80},
{name = 'WEAPON_FIREEXTINGUISHER', price = 120},
{name = 'WEAPON_FLAREGUN', price = 60},
{name = 'WEAPON_STICKYBOMB', price = 250},
{name = 'GADGET_PARACHUTE', price = 300},
},
AuthorizedVehicles = {
{name = 'police' , label = 'Véhicule de patrouille 1'},
{name = 'police2', label = 'Véhicule de patrouille 2'},
{name = 'police3', label = 'Véhicule de patrouille 3'},
{name = 'police4', label = 'Véhicule civil'},
{name = 'policeb', label = 'Moto'},
{name = 'policet', label = 'Van de transport'},
},
Cloakrooms = {
{x = 452.600, y = -993.306, z = 29.750}
},
Armories = {
{x = 451.699, y = -980.356, z = 29.689}
},
Vehicles = {
{
Spawner = {x = 454.69, y = -1017.4, z = 27.430},
SpawnPoint = {x = 438.42, y = -1018.3, z = 27.757},
Heading = 90.0
}
},
Helicopters = {
{
Spawner = {x = 466.477, y = -982.819, z = 42.691},
SpawnPoint = {x = 450.04, y = -981.14, z = 42.691},
Heading = 0.0
}
},
VehicleDeleters = {
{x = 462.74, y = -1014.4, z = 27.065},
{x = 462.40, y = -1019.7, z = 27.104}
},
BossActions = {
{x = 448.417, y = -973.208, z = 29.689}
}
}
}
+18
View File
@@ -0,0 +1,18 @@
INSERT INTO `addon_account` (name, label, shared) VALUES
('society_police','Police',1)
;
INSERT INTO `datastore` (name, label, shared) VALUES
('society_police','Police',1)
;
INSERT INTO `jobs` (name, label) VALUES
('police','LSPD')
;
INSERT INTO `job_grades` (job_name, grade, name, label, salary, skin_male, skin_female) VALUES
('police',0,'recrue','Recrue',20,'{\"tshirt_1\":57,\"torso_1\":55,\"arms\":0,\"pants_1\":35,\"glasses\":0,\"decals_2\":0,\"hair_color_2\":0,\"helmet_2\":0,\"hair_color_1\":5,\"face\":19,\"glasses_2\":1,\"torso_2\":0,\"shoes\":24,\"hair_1\":2,\"skin\":34,\"sex\":0,\"glasses_1\":0,\"pants_2\":0,\"hair_2\":0,\"decals_1\":0,\"tshirt_2\":0,\"helmet_1\":8}','{\"tshirt_1\":34,\"torso_1\":48,\"shoes\":24,\"pants_1\":34,\"torso_2\":0,\"decals_2\":0,\"hair_color_2\":0,\"glasses\":0,\"helmet_2\":0,\"hair_2\":3,\"face\":21,\"decals_1\":0,\"glasses_2\":1,\"hair_1\":11,\"skin\":34,\"sex\":1,\"glasses_1\":5,\"pants_2\":0,\"arms\":14,\"hair_color_1\":10,\"tshirt_2\":0,\"helmet_1\":57}'),
('police',1,'sergeant','Sergent',40,'{\"tshirt_1\":58,\"torso_1\":55,\"shoes\":24,\"pants_1\":35,\"pants_2\":0,\"decals_2\":1,\"hair_color_2\":0,\"face\":19,\"helmet_2\":0,\"hair_2\":0,\"arms\":0,\"decals_1\":8,\"torso_2\":0,\"hair_1\":2,\"skin\":34,\"sex\":0,\"glasses_1\":0,\"glasses_2\":1,\"hair_color_1\":5,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":11}','{\"tshirt_1\":35,\"torso_1\":48,\"arms\":14,\"pants_1\":34,\"pants_2\":0,\"decals_2\":1,\"hair_color_2\":0,\"shoes\":24,\"helmet_2\":0,\"hair_2\":3,\"decals_1\":7,\"torso_2\":0,\"face\":21,\"hair_1\":11,\"skin\":34,\"sex\":1,\"glasses_1\":5,\"glasses_2\":1,\"hair_color_1\":10,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":57}'),
('police',2,'lieutenant','Lieutenant',65,'{\"tshirt_1\":58,\"torso_1\":55,\"shoes\":24,\"pants_1\":35,\"pants_2\":0,\"decals_2\":2,\"hair_color_2\":0,\"face\":19,\"helmet_2\":0,\"hair_2\":0,\"glasses\":0,\"decals_1\":8,\"hair_color_1\":5,\"hair_1\":2,\"skin\":34,\"sex\":0,\"glasses_1\":0,\"glasses_2\":1,\"torso_2\":0,\"arms\":41,\"tshirt_2\":0,\"helmet_1\":11}','{\"tshirt_1\":35,\"torso_1\":48,\"arms\":44,\"pants_1\":34,\"hair_2\":3,\"decals_2\":2,\"hair_color_2\":0,\"hair_color_1\":10,\"helmet_2\":0,\"face\":21,\"shoes\":24,\"torso_2\":0,\"glasses_2\":1,\"hair_1\":11,\"skin\":34,\"sex\":1,\"glasses_1\":5,\"pants_2\":0,\"decals_1\":7,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":57}'),
('police',3,'commandant','Commandant',80,'{\"tshirt_1\":58,\"torso_1\":55,\"shoes\":24,\"pants_1\":35,\"pants_2\":0,\"decals_2\":3,\"hair_color_2\":0,\"face\":19,\"helmet_2\":0,\"hair_2\":0,\"arms\":41,\"torso_2\":0,\"hair_color_1\":5,\"hair_1\":2,\"skin\":34,\"sex\":0,\"glasses_1\":0,\"glasses_2\":1,\"decals_1\":8,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":11}','{\"tshirt_1\":35,\"torso_1\":48,\"arms\":44,\"pants_1\":34,\"pants_2\":0,\"decals_2\":3,\"hair_color_2\":0,\"face\":21,\"helmet_2\":0,\"hair_2\":3,\"decals_1\":7,\"torso_2\":0,\"hair_color_1\":10,\"hair_1\":11,\"skin\":34,\"sex\":1,\"glasses_1\":5,\"glasses_2\":1,\"shoes\":24,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":57}')
;
+10
View File
@@ -0,0 +1,10 @@
INSERT INTO `jobs` (name, label) VALUES
('police','LSPD')
;
INSERT INTO `job_grades` (job_name, grade, name, label, salary, skin_male, skin_female) VALUES
('police',0,'recrue','Recrue',20,'{\"tshirt_1\":57,\"torso_1\":55,\"arms\":0,\"pants_1\":35,\"glasses\":0,\"decals_2\":0,\"hair_color_2\":0,\"helmet_2\":0,\"hair_color_1\":5,\"face\":19,\"glasses_2\":1,\"torso_2\":0,\"shoes\":24,\"hair_1\":2,\"skin\":34,\"sex\":0,\"glasses_1\":0,\"pants_2\":0,\"hair_2\":0,\"decals_1\":0,\"tshirt_2\":0,\"helmet_1\":8}','{\"tshirt_1\":34,\"torso_1\":48,\"shoes\":24,\"pants_1\":34,\"torso_2\":0,\"decals_2\":0,\"hair_color_2\":0,\"glasses\":0,\"helmet_2\":0,\"hair_2\":3,\"face\":21,\"decals_1\":0,\"glasses_2\":1,\"hair_1\":11,\"skin\":34,\"sex\":1,\"glasses_1\":5,\"pants_2\":0,\"arms\":14,\"hair_color_1\":10,\"tshirt_2\":0,\"helmet_1\":57}'),
('police',1,'sergeant','Sergent',40,'{\"tshirt_1\":58,\"torso_1\":55,\"shoes\":24,\"pants_1\":35,\"pants_2\":0,\"decals_2\":1,\"hair_color_2\":0,\"face\":19,\"helmet_2\":0,\"hair_2\":0,\"arms\":0,\"decals_1\":8,\"torso_2\":0,\"hair_1\":2,\"skin\":34,\"sex\":0,\"glasses_1\":0,\"glasses_2\":1,\"hair_color_1\":5,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":11}','{\"tshirt_1\":35,\"torso_1\":48,\"arms\":14,\"pants_1\":34,\"pants_2\":0,\"decals_2\":1,\"hair_color_2\":0,\"shoes\":24,\"helmet_2\":0,\"hair_2\":3,\"decals_1\":7,\"torso_2\":0,\"face\":21,\"hair_1\":11,\"skin\":34,\"sex\":1,\"glasses_1\":5,\"glasses_2\":1,\"hair_color_1\":10,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":57}'),
('police',2,'lieutenant','Lieutenant',65,'{\"tshirt_1\":58,\"torso_1\":55,\"shoes\":24,\"pants_1\":35,\"pants_2\":0,\"decals_2\":2,\"hair_color_2\":0,\"face\":19,\"helmet_2\":0,\"hair_2\":0,\"glasses\":0,\"decals_1\":8,\"hair_color_1\":5,\"hair_1\":2,\"skin\":34,\"sex\":0,\"glasses_1\":0,\"glasses_2\":1,\"torso_2\":0,\"arms\":41,\"tshirt_2\":0,\"helmet_1\":11}','{\"tshirt_1\":35,\"torso_1\":48,\"arms\":44,\"pants_1\":34,\"hair_2\":3,\"decals_2\":2,\"hair_color_2\":0,\"hair_color_1\":10,\"helmet_2\":0,\"face\":21,\"shoes\":24,\"torso_2\":0,\"glasses_2\":1,\"hair_1\":11,\"skin\":34,\"sex\":1,\"glasses_1\":5,\"pants_2\":0,\"decals_1\":7,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":57}'),
('police',3,'commandant','Commandant',80,'{\"tshirt_1\":58,\"torso_1\":55,\"shoes\":24,\"pants_1\":35,\"pants_2\":0,\"decals_2\":3,\"hair_color_2\":0,\"face\":19,\"helmet_2\":0,\"hair_2\":0,\"arms\":41,\"torso_2\":0,\"hair_color_1\":5,\"hair_1\":2,\"skin\":34,\"sex\":0,\"glasses_1\":0,\"glasses_2\":1,\"decals_1\":8,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":11}','{\"tshirt_1\":35,\"torso_1\":48,\"arms\":44,\"pants_1\":34,\"pants_2\":0,\"decals_2\":3,\"hair_color_2\":0,\"face\":21,\"helmet_2\":0,\"hair_2\":3,\"decals_1\":7,\"torso_2\":0,\"hair_color_1\":10,\"hair_1\":11,\"skin\":34,\"sex\":1,\"glasses_1\":5,\"glasses_2\":1,\"shoes\":24,\"glasses\":0,\"tshirt_2\":0,\"helmet_1\":57}')
;
+263
View File
@@ -0,0 +1,263 @@
ESX = nil
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
if Config.MaxInService ~= -1 then
TriggerEvent('esx_service:activateService', 'police', Config.MaxInService)
end
RegisterServerEvent('esx_policejob:giveWeapon')
AddEventHandler('esx_policejob:giveWeapon', function(weapon, ammo)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addWeapon(weapon, ammo)
end)
RegisterServerEvent('esx_policejob:confiscatePlayerItem')
AddEventHandler('esx_policejob:confiscatePlayerItem', function(target, itemType, itemName, amount)
local sourceXPlayer = ESX.GetPlayerFromId(source)
local targetXPlayer = ESX.GetPlayerFromId(target)
if itemType == 'item_standard' then
local label = sourceXPlayer.getInventoryItem(itemName).label
targetXPlayer.removeInventoryItem(itemName, amount)
sourceXPlayer.addInventoryItem(itemName, amount)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, 'Vous avez confisqué ~y~x' .. amount .. ' ' .. label .. '~s~ à ~b~' .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. '~s~ vous a confisqué ~y~x' .. amount .. ' ' .. label )
end
if itemType == 'item_account' then
targetXPlayer.removeAccountMoney(itemName, amount)
sourceXPlayer.addAccountMoney(itemName, amount)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, 'Vous avez confisqué ~y~$' .. amount .. '~s~ à ~b~' .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. '~s~ vous a confisqué ~y~$' .. amount)
end
if itemType == 'item_weapon' then
targetXPlayer.removeWeapon(itemName)
sourceXPlayer.addWeapon(itemName, amount)
TriggerClientEvent('esx:showNotification', sourceXPlayer.source, 'Vous avez confisqué ~y~x1 ' .. ESX.GetWeaponLabel(itemName) .. '~s~ à ~b~' .. targetXPlayer.name)
TriggerClientEvent('esx:showNotification', targetXPlayer.source, '~b~' .. targetXPlayer.name .. '~s~ vous a confisqué ~y~x1 ' .. ESX.GetWeaponLabel(itemName))
end
end)
RegisterServerEvent('esx_policejob:handcuff')
AddEventHandler('esx_policejob:handcuff', function(target)
TriggerClientEvent('esx_policejob:handcuff', target)
end)
RegisterServerEvent('esx_policejob:putInVehicle')
AddEventHandler('esx_policejob:putInVehicle', function(target)
TriggerClientEvent('esx_policejob:putInVehicle', target)
end)
ESX.RegisterServerCallback('esx_policejob:getOtherPlayerData', function(source, cb, target)
local xPlayer = ESX.GetPlayerFromId(target)
local data = {
name = GetPlayerName(source),
job = xPlayer.job,
inventory = xPlayer.inventory,
accounts = xPlayer.accounts,
weapons = xPlayer.loadout
}
TriggerEvent('esx_status:getStatus', _source, 'drunk', function(status)
data.drunk = status:getPercent()
end)
TriggerEvent('esx_license:getLicenses', _source, function(licenses)
data.licenses = licenses
end)
cb(data)
end)
ESX.RegisterServerCallback('esx_policejob:getFineList', function(source, cb, category)
MySQL.Async.fetchAll(
'SELECT * FROM fine_types WHERE category = @category',
{
['@category'] = category
},
function(fines)
cb(fines)
end
)
end)
ESX.RegisterServerCallback('esx_policejob:getVehicleInfos', function(source, cb, plate)
MySQL.Async.fetchAll(
'SELECT * FROM owned_vehicles',
{},
function(result)
local foundIdentifier = nil
for i=1, #result, 1 do
local vehicleData = json.decode(result[i].vehicle)
if vehicleData.plate == plate then
foundIdentifier = result[i].owner
break
end
end
if foundIdentifier ~= nil then
MySQL.Async.fetchAll(
'SELECT * FROM users WHERE identifier = @identifier',
{
['@identifier'] = foundIdentifier
},
function(result)
local infos = {
plate = plate,
owner = result[1].name
}
cb(infos)
end
)
else
local infos = {
plate = plate
}
cb(infos)
end
end
)
end)
ESX.RegisterServerCallback('esx_policejob:getArmoryWeapons', function(source, cb)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
local weapons = store.get('weapons')
if weapons == nil then
weapons = {}
end
cb(weapons)
end)
end)
ESX.RegisterServerCallback('esx_policejob:addArmoryWeapon', function(source, cb, weaponName)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.removeWeapon(weaponName)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
local weapons = store.get('weapons')
if weapons == nil then
weapons = {}
end
local foundWeapon = false
for i=1, #weapons, 1 do
if weapons[i].name == weaponName then
weapons[i].count = weapons[i].count + 1
foundWeapon = true
end
end
if not foundWeapon then
table.insert(weapons, {
name = weaponName,
count = 1
})
end
store.set('weapons', weapons)
cb()
end)
end)
ESX.RegisterServerCallback('esx_policejob:removeArmoryWeapon', function(source, cb, weaponName)
local xPlayer = ESX.GetPlayerFromId(source)
xPlayer.addWeapon(weaponName, 1000)
TriggerEvent('esx_datastore:getSharedDataStore', 'society_police', function(store)
local weapons = store.get('weapons')
if weapons == nil then
weapons = {}
end
local foundWeapon = false
for i=1, #weapons, 1 do
if weapons[i].name == weaponName then
weapons[i].count = (weapons[i].count > 0 and weapons[i].count - 1 or 0)
foundWeapon = true
end
end
if not foundWeapon then
table.insert(weapons, {
name = weaponName,
count = 0
})
end
store.set('weapons', weapons)
cb()
end)
end)
ESX.RegisterServerCallback('esx_policejob:buy', function(source, cb, amount)
TriggerEvent('esx_addonaccount:getSharedAccount', 'society_police', function(account)
if account.money >= amount then
account.removeMoney(amount)
cb(true)
else
cb(false)
end
end)
end)