what do you mean you added them to the database? if you add new cars to the system, you need to do it in es_garages, in that script you can add cars in the vehicles tables in server file and client file.
Oh ok may not work out then, don’t want civs buying out cop cars haha. But I added them to the vehicle table on mysql
I know I am always asking questions and such but did we confirm the replacement codes you posted for the vehicle check plate work? I am running all 3 of these scripts and esm 3.x. Have my everything on couchdb minus the ply_garages and ply_prefecture.
This is the code that allows check-plate feature on police script this is server.lua
local couchFunctions = {}
local namesforperps = {
"Trisha Blevins",
"Kyle Smith",
"Timmothy Holland",
"Reba Forks",
"Jennifer Rollins",
"Sandy Barns",
"Alexandria Scott",
"Dillone Scott",
}
if(db.driver == "mysql") then
require "resources/essentialmode/lib/MySQL"
MySQL:open(db.sql_host, db.sql_database, db.sql_user, db.sql_password)
elseif(db.driver == "mysql-async") then
require "resources/mysql-async/lib/MySQL"
TriggerEvent('es:exposeDBFunctions', function(dbExposed)
couchFunctions = dbExposed
dbExposed.createDatabase("police", function()end)
end)
end
local inServiceCops = {}
function addCop(identifier)
if(db.driver == "mysql") then
local result = "nil"
local query = MySQL:executeQuery("SELECT * FROM police WHERE identifier = '@identifier'", { ['@identifier'] = identifier})
local resultq = MySQL:getResults(query, {'rank'}, "identifier")
if(not resultq[1]) then
result = "nil"
else
result = resultq[1].rank
end
if(result == "nil") then
MySQL:executeQuery("INSERT INTO police (`identifier`) VALUES ('@identifier')", { ['@identifier'] = identifier})
end
elseif(db.driver == "mysql-async") then
MySQL.Async.fetchAll("SELECT * FROM police WHERE identifier = @identifier", { ['@identifier'] = identifier}, function (result)
if(result[1] == nil) then
MySQL.Async.execute("INSERT INTO police (`identifier`) VALUES @identifier", { ['@identifier'] = identifier})
end
end)
couchFunctions.getDocumentByRow("police", "identifier", identifier, function(document)
if(document == false) then
couchFunctions.createDocument("police", {
identifier = identifier,
rank = "Recruit"
}, function()end)
end
end)
end
end
function remCop(identifier)
if(db.driver == "mysql") then
MySQL:executeQuery("DELETE FROM police WHERE identifier = '@identifier'", { ['@identifier'] = identifier})
elseif(db.driver == "mysql-async") then
MySQL.Async.execute("DELETE FROM police WHERE identifier = @identifier", { ['@identifier'] = identifier})
couchFunctions.getDocumentByRow("police", "identifier", identifier, function(document)
if(document ~= false) then
couchFunctions.updateDocument("police", document._id, {
identifier = document.identifier .. "/"
}, function()end)
end
end)
end
end
function checkIsCop(identifier)
if(db.driver == "mysql") then
local query = MySQL:executeQuery("SELECT * FROM police WHERE identifier = '@identifier'", { ['@identifier'] = identifier})
local result = MySQL:getResults(query, {'rank'}, "identifier")
if(not result[1]) then
TriggerClientEvent('police:receiveIsCop', source, "unknown")
else
TriggerClientEvent('police:receiveIsCop', source, result[1].rank)
end
elseif(db.driver == "mysql-async") then
MySQL.Async.fetchAll("SELECT * FROM police WHERE identifier = @identifier", { ['@identifier'] = identifier}, function (result)
if(result[1] == nil) then
TriggerClientEvent('police:receiveIsCop', source, "unknown")
else
TriggerClientEvent('police:receiveIsCop', source, result[1].rank)
end
end)
couchFunctions.getDocumentByRow("police", "identifier", identifier, function(document)
if(document == false) then
TriggerClientEvent('police:receiveIsCop', source, "unknown")
else
TriggerClientEvent('police:receiveIsCop', source, document.rank)
end
end)
end
end
AddEventHandler('playerDropped', function()
if(inServiceCops[source]) then
inServiceCops[source] = nil
if(config.useJobSystem == true) then
TriggerEvent("jobssystem:disconnectReset", source, config.job.officer_not_on_duty_job_id)
end
for i, c in pairs(inServiceCops) do
TriggerClientEvent("police:resultAllCopsInService", i, inServiceCops)
end
end
end)
if(config.useCopWhitelist == true) then
RegisterServerEvent('police:checkIsCop')
AddEventHandler('police:checkIsCop', function()
local identifier = getPlayerID(source)
checkIsCop(identifier)
end)
end
RegisterServerEvent('bank:withdrawAmende')
AddEventHandler('bank:withdrawAmende', function(amount)
TriggerEvent('es:getPlayerFromId', source, function(user)
local player = user.identifier
local bankbalance = bankBalance(player)
withdraw(player, amount)
local new_balance = bankBalance(player)
TriggerClientEvent("es_freeroam:notify", source, "CHAR_BANK_MAZE", 1, "Maze Bank", false, "New Balance: ~g~$" .. new_balance)
TriggerClientEvent("banking:updateBalance", source, new_balance)
TriggerClientEvent("banking:removeBalance", source, amount)
CancelEvent()
end)
end)
RegisterServerEvent('police:takeService')
AddEventHandler('police:takeService', function()
if(not inServiceCops[source]) then
inServiceCops[source] = GetPlayerName(source)
for i, c in pairs(inServiceCops) do
TriggerClientEvent("police:resultAllCopsInService", i, inServiceCops)
end
end
end)
RegisterServerEvent('police:breakService')
AddEventHandler('police:breakService', function()
if(inServiceCops[source]) then
inServiceCops[source] = nil
for i, c in pairs(inServiceCops) do
TriggerClientEvent("police:resultAllCopsInService", i, inServiceCops)
end
end
end)
RegisterServerEvent('police:getAllCopsInService')
AddEventHandler('police:getAllCopsInService', function()
TriggerClientEvent("police:resultAllCopsInService", source, inServiceCops)
end)
RegisterServerEvent('police:checkingPlate')
AddEventHandler('police:checkingPlate', function(plate)
if(db.driver == "mysql") then
local executed_query = MySQL:executeQuery("SELECT Nom FROM user_vehicle JOIN users ON user_vehicle.identifier = users.identifier WHERE vehicle_plate = '@plate'", { ['@plate'] = plate })
local result = MySQL:getResults(executed_query, { 'Nom' }, "identifier")
if (result[1]) then
for _, v in ipairs(result) do
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["vehicle_checking_plate_part_1"]..plate..txt[config.lang]["vehicle_checking_plate_part_2"] .. v.Nom..txt[config.lang]["vehicle_checking_plate_part_3"])
end
else
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["vehicle_checking_plate_part_1"]..plate..txt[config.lang]["vehicle_checking_plate_not_registered"])
end
elseif(db.driver == "mysql-async") then
MySQL.Async.fetchAll("SELECT * FROM user_vehicle WHERE vehicle_plate = @plate", { ['@plate'] = plate }, function (result)
local isworking = false
local name = " "
local rands = math.random(1, 8)
local chances = math.random(1, 1000)
--TriggerClientEvent("chatMessage", source, "test ", {255, 0, 0}, " " .. tostring(result) .. " " .. tostring(plate))
for _, v in ipairs(result) do
--TriggerClientEvent("chatMessage", source, "test ", {255, 0, 0}, " " .. tostring(v.id))
for i = 0, 31 do
--if NetworkIsPlayerActive( i ) then
--TriggerClientEvent("chatMessage", source, "test ", {255, 0, 0}, " " .. tostring(v.id))
--local ids = GetPlayerFromServerId(1)
--TriggerClientEvent("chatMessage", source, "test ", {255, 0, 0}, " " .. tostring(v.id))
TriggerEvent('es:getPlayerFromId', i, function(user)
--TriggerClientEvent("chatMessage", source, "test ", {255, 0, 0}, " " .. tostring(v.id))
if user.identifier == v.identifier then
name = GetPlayerName(tonumber(i))
if name ~= " " then
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["vehicle_checking_plate_part_1"]..plate..txt[config.lang]["vehicle_checking_plate_part_2"] .. name..txt[config.lang]["vehicle_checking_plate_part_3"])
end
end
end)
--end
end
--end
end
if name == " " and chances < 500 then
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["vehicle_checking_plate_part_1"]..plate..txt[config.lang]["vehicle_checking_plate_part_2"] .. namesforperps[rands]..txt[config.lang]["vehicle_checking_plate_part_3"] .. " It seems the owner of this vehicle has not registered it!")
elseif name == " " then
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["vehicle_checking_plate_part_1"]..plate..txt[config.lang]["vehicle_checking_plate_part_2"] .. namesforperps[rands]..txt[config.lang]["vehicle_checking_plate_part_3"] .. " It seems the owner has not registered the vehicle!")
end
end)
end
end)
-- jail addon
RegisterServerEvent('jail:teleportToJail')
AddEventHandler('jail:teleportToJail', function(t, amount)
TriggerClientEvent('jail:teleportPlayer', t, amount)
end)
-- jail addon end
RegisterServerEvent('police:confirmUnseat')
AddEventHandler('police:confirmUnseat', function(t)
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["unseat_sender_notification_part_1"] .. GetPlayerName(t) .. txt[config.lang]["unseat_sender_notification_part_2"])
TriggerClientEvent('police:unseatme', t)
end)
RegisterServerEvent('police:dragRequest')
AddEventHandler('police:dragRequest', function(t)
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["drag_sender_notification_part_1"] .. GetPlayerName(t) .. txt[config.lang]["drag_sender_notification_part_2"])
TriggerClientEvent('police:toggleDrag', t, source)
end)
RegisterServerEvent('police:targetCheckInventory')
AddEventHandler('police:targetCheckInventory', function(target)
local identifier = getPlayerID(target)
if(config.useVDKInventory == true) then
if(db.driver == "mysql") then
local strResult = txt[config.lang]["checking_inventory_part_1"] .. GetPlayerName(target) .. txt[config.lang]["checking_inventory_part_2"]
local executed_query = MySQL:executeQuery("SELECT * FROM `user_inventory` JOIN items ON items.id = user_inventory.item_id WHERE user_id = '@username'", { ['@username'] = identifier })
local result = MySQL:getResults(executed_query, { 'quantity', 'libelle', 'item_id', 'isIllegal' }, "item_id")
if (result) then
for _, v in ipairs(result) do
if(v.quantity ~= 0) then
strResult = strResult .. v.quantity .. "*" .. v.libelle .. ", "
end
if(v.isIllegal == "1" or v.isIllegal == "True" or v.isIllegal == 1 or v.isIllegal == true) then
TriggerClientEvent('police:dropIllegalItem', target, v.item_id)
end
end
end
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, strResult)
elseif(db.driver == "mysql-async") then
MySQL.Async.fetchAll("SELECT * FROM `user_inventory` JOIN items ON items.id = user_inventory.item_id WHERE user_id = @username", { ['@username'] = identifier }, function (result)
local strResult = txt[config.lang]["checking_inventory_part_1"] .. GetPlayerName(target) .. txt[config.lang]["checking_inventory_part_2"]
for _, v in ipairs(result) do
if(v.quantity ~= 0) then
strResult = strResult .. v.quantity .. "*" .. v.libelle .. ", "
end
if(v.isIllegal == "1" or v.isIllegal == "True" or v.isIllegal == 1 or v.isIllegal == true) then
TriggerClientEvent('police:dropIllegalItem', target, v.item_id)
end
end
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, strResult)
end)
end
end
local check = true
if(check == true) then
if(db.driver == "mysql") then
local strResult = txt[config.lang]["checking_weapons_part_1"] .. GetPlayerName(target) .. txt[config.lang]["checking_weapons_part_2"]
local executed_query = MySQL:executeQuery("SELECT * FROM user_weapons WHERE identifier = '@username'", { ['@username'] = identifier })
local result = MySQL:getResults(executed_query, { 'weapon_model' }, 'identifier' )
if (result) then
for _, v in ipairs(result) do
strResult = strResult .. v.weapon_model .. ", "
end
end
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, strResult)
elseif(db.driver == "mysql-async") then
local del = {}
local strResult = txt[config.lang]["checking_weapons_part_1"] .. GetPlayerName(target) .. txt[config.lang]["checking_weapons_part_2"]
TriggerEvent('es:getPlayerFromId', target, function(user)
TriggerEvent('es:exposeDBFunctions', function(db)
db.getDocumentByRow('es_weashop', 'identifier', user.identifier, function(dbuser)
for i=1, #dbuser.weapons do
strResult = strResult .. dbuser.weapons[i] .. ", "
end
RemoveAllPedWeapons(target, true)
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, strResult)
db.updateDocument('es_weashop', dbuser._id, {weapons = del, cost = del})
end)
end)
end)
end
end
end)
RegisterServerEvent('police:finesGranted')
AddEventHandler('police:finesGranted', function(target, amount)
TriggerClientEvent('police:payFines', target, amount, source)
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["send_fine_request_part_1"]..amount..txt[config.lang]["send_fine_request_part_2"]..GetPlayerName(target))
end)
RegisterServerEvent('police:finesETA')
AddEventHandler('police:finesETA', function(officer, code)
if(code==1) then
TriggerClientEvent("police:notify", officer, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, GetPlayerName(source)..txt[config.lang]["already_have_a_pendind_fine_request"])
elseif(code==2) then
TriggerClientEvent("police:notify", officer, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, GetPlayerName(source)..txt[config.lang]["request_fine_timeout"])
elseif(code==3) then
TriggerClientEvent("police:notify", officer, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, GetPlayerName(source)..txt[config.lang]["request_fine_refused"])
elseif(code==0) then
TriggerClientEvent("police:notify", officer, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, GetPlayerName(source)..txt[config.lang]["request_fine_accepted"])
end
end)
RegisterServerEvent('police:cuffGranted')
AddEventHandler('police:cuffGranted', function(t)
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["toggle_cuff_player_part_1"]..GetPlayerName(t)..txt[config.lang]["toggle_cuff_player_part_2"])
TriggerClientEvent('police:getArrested', t)
end)
RegisterServerEvent('police:forceEnterAsk')
AddEventHandler('police:forceEnterAsk', function(t, v)
TriggerClientEvent("police:notify", source, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["force_player_get_in_vehicle_part_1"]..GetPlayerName(t)..txt[config.lang]["force_player_get_in_vehicle_part_2"])
TriggerClientEvent('police:forcedEnteringVeh', t, v)
end)
-----------------------------------------------------------------------
----------------------EVENT SPAWN POLICE VEH---------------------------
-----------------------------------------------------------------------
RegisterServerEvent('CheckPoliceVeh')
AddEventHandler('CheckPoliceVeh', function(vehicle)
TriggerClientEvent('FinishPoliceCheckForVeh',source)
TriggerClientEvent('policeveh:spawnVehicle', source, vehicle)
end)
-----------------------------------------------------------------------
---------------------COMMANDE ADMIN AJOUT / SUPP COP-------------------
-----------------------------------------------------------------------
if(config.useCopWhitelist) then
TriggerEvent('es:addGroupCommand', 'copadd', "admin", function(source, args, user)
if(not args[2]) then
TriggerClientEvent('chatMessage', source, txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["usage_command_copadd"])
else
if(GetPlayerName(tonumber(args[2])) ~= nil)then
local player = tonumber(args[2])
addCop(getPlayerID(player))
TriggerClientEvent('chatMessage', source, txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["command_received"])
TriggerClientEvent("police:notify", player, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["become_cop_success"])
TriggerClientEvent('police:nowCop', player)
else
TriggerClientEvent('chatMessage', source, txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["no_player_with_this_id"])
end
end
end, function(source, args, user)
TriggerClientEvent('chatMessage', source, txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["not_enough_permission"])
end)
TriggerEvent('es:addGroupCommand', 'coprem', "admin", function(source, args, user)
if(not args[2]) then
print("nein")
TriggerClientEvent('chatMessage', source, txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["usage_command_coprem"])
else
if(GetPlayerName(tonumber(args[2])) ~= nil)then
local player = tonumber(args[2])
remCop(getPlayerID(player))
TriggerClientEvent("police:notify", player, "CHAR_ANDREAS", 1, txt[config.lang]["title_notification"], false, txt[config.lang]["remove_from_cops"])
TriggerClientEvent('chatMessage', source, txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["command_received"])
TriggerClientEvent('police:noLongerCop', player)
else
TriggerClientEvent('chatMessage', source, txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["no_player_with_this_id"])
end
end
end, function(source, args, user)
TriggerClientEvent('chatMessage', source, txt[config.lang]["title_notification"], {255, 0, 0}, txt[config.lang]["not_enough_permission"])
end)
end
-- get's the player id without having to use bugged essentials
function getPlayerID(source)
local identifiers = GetPlayerIdentifiers(source)
local player = getIdentifiant(identifiers)
return player
end
-- gets the actual player id unique to the player,
-- independent of whether the player changes their screen name
function getIdentifiant(id)
for _, v in ipairs(id) do
return v
end
end
Dont worry about asking questions, I am here because i like to help people and i would hope if i needed help with a script then someone would help me and so far people have!
If this for mysql, async or couch? I am running Couch for pretty much everything.
the car system is made to use both async and couch. It requires both right now.
Anyone who is wanting to see this pack in action can go here:
This is my buddies server who I mostly did all of this for.
this is a picture of the fire script
Alright, gave it a shot with that exact code my whole police script stops working, was thinking it was cause it was using async or mysql as the driver so i changed the
elseif(db.driver == "mysql-async") then
MySQL.Async.fetchAll("SELECT * FROM user_vehicle WHERE vehicle_plate = @plate", { ['@plate'] = plate }, function (result)
to
elseif(db.driver == "couchdb") then
MySQL.Async.fetchAll("SELECT * FROM user_vehicle WHERE vehicle_plate = @plate", { ['@plate'] = plate }, function (result)
maybe hoping it would run the async fetch still with my couchdb drivers (since that is where all of my cops are stored and what not) but it just kept coming back with no vehicle nearby
thinking I may have to wait since alot of scripts of ours are scattered, cops/esm/and the es_garages are all on couchdb where as the ply_vehicles ply_prefecture and all of that is on mysqlAsync
What script is that down with Toilet etc???
I am getting this when launching for all 3.
I have “mysql-async” in resources and I know it works because we have other scripts that use it.
Any idea?
it keeps giving me a error about the server.lua
Hi rjross2013, sorry if you read a messenge like this, but does vrp_showroom or vehshop work with this script? and if not will u make a update for it ?
thanks for all the work u do for the fivem community.
Same here man.