[Solved] TriggerEvent('es:getPlayerFromId', source, function(user)

Works in vehshop
Wroks in weashop

But not in mine, i do not know why

Server.lua

RegisterServerEvent('garages:CheckForVeh')
AddEventHandler('garages:CheckForVeh', function(source)
  TriggerEvent('es:getPlayerFromId', source, function(user)
    local player = user.identifier
    local executed_query = MySQL:executeQuery("SELECT personalvehicle FROM users WHERE identifier = '@username'",{['@username'] = player})
    local result = MySQL:getResults(executed_query, {'personalvehicle'}, "identifier")
    if(result)then
      for k,v in ipairs(result)do
        print(v.personalvehicle)
        vehicle = v.personalvehicle
      end
    end
    TriggerClientEvent('garages:SpawnVehicle', source, vehicle)
  end)
end)

Client.lua
TriggerServerEvent('garages:CheckForVeh',source)

Error Screen :

Fixed

AddEventHandler('garages:CheckForVeh', function()

by

AddEventHandler('garages:CheckForVeh', function(source)

have the same problem

this creator for essential mod is noob , no use this mod

essential mod = rotten and the stupid creator delete documentation

1 request per minute for one player with essential = 32 request for minute

1 Like

I have the same, which file is it ?

What do you suggest ?

Can you tell me how to fix that ?

im modify plugin garage for work without essential im push one exemple in the post ready ?

server code /!\ include required for work (MySQL lib and my lib) /!\

require "resources/menu/lib/MySQL"
require "resources/menu/lib/function"
MySQL:open("127.0.0.1", "gta5_gamemode_essential", "root", "")

RegisterServerEvent('garages:CheckForSpawnVeh')
RegisterServerEvent('garages:CheckForVeh')
RegisterServerEvent('garages:SetVehOut')
RegisterServerEvent('garages:SetVehIn')


AddEventHandler('garages:CheckForSpawnVeh', function()
  --print(source)
    local identifiers = GetPlayerIdentifiers(source)
    local player = getIdentifiant(identifiers)
    local executed_query = MySQL:executeQuery("SELECT * FROM user_vehicle WHERE identifier = '@username'",{['@username'] = player})
    local result = MySQL:getResults(executed_query, {'vehicle_model', 'vehicle_plate', 'vehicle_state'}, "identifier")
    if(result)then
      for k,v in ipairs(result)do
        --print(v.personalvehicle)
        vehicle = v.vehicle_model
        plate = v.vehicle_plate
        state = v.vehicle_state
      local vehicle = vehicle
      local plate = plate
      local state = state
      end
    end
    TriggerClientEvent('garages:SpawnVehicle', source, vehicle, plate, state)

end)

AddEventHandler('garages:CheckForVeh', function()
  --print(source)
    local identifiers = GetPlayerIdentifiers(source)
    local player = getIdentifiant(identifiers)
    local executed_query = MySQL:executeQuery("SELECT * FROM user_vehicle WHERE identifier = '@username'",{['@username'] = player})
    local result = MySQL:getResults(executed_query, {'vehicle_model', 'vehicle_plate'}, "identifier")
    if(result)then
      for k,v in ipairs(result)do
        vehicle = v.vehicle_model
        plate = v.vehicle_plate
      local vehicle = vehicle
      local plate = plate
      end
    end
    TriggerClientEvent('garages:StoreVehicle', source, vehicle, plate)

end)


AddEventHandler('garages:SetVehOut', function(vehicle)
    local identifiers = GetPlayerIdentifiers(source)
    local player = getIdentifiant(identifiers)
    local vehicle = vehicle
    local state = "out"

    MySQL:executeQuery("UPDATE user_vehicle SET vehicle_state='@state' WHERE identifier = '@username' AND vehicle_model = '@vehicle'",
      {['@username'] = player, ['@vehicle'] = vehicle, ['@state'] = state})

end)

AddEventHandler('garages:SetVehIn', function(plate)
    local identifiers = GetPlayerIdentifiers(source)
    local player = getIdentifiant(identifiers)
    local plate = plate
    local state = "In"

    MySQL:executeQuery("UPDATE user_vehicle SET vehicle_state='@state' WHERE identifier = '@username' AND vehicle_plate = '@plate'",
      {['@username'] = player, ['@plate'] = plate, ['@state'] = state})

end)

no client code modification
just créate one script function.lua and place you script in lib

function getIdentifiant(id)

	for _, v in ipairs(id) do
	    return v
	end

end

function itemuse(nomitem)
	if(nomitem == "eau") then
		print("vous avez utiliser 1 " ..nomitem)
	end
end


function orderitem(tabl)

	local test
		local i = 1
	    while tableau[i] do
	    	if i == 1 then
	    		test = tostring(tableau[i])

	    	else
	    		test = tostring(test.. "," ..tableau[i])
	    	end
	      i = i + 1
	    end
	    
	    return test

end



And it will gonna fix this error ?