Hello this may be a dumb question or not but i'm pretty much new to Lua and already am a web developper (Junior) working on my own server. I was wondering since i am using a menu and calling the RegisterNetEvent "cehiclekeys:client:GiveKeys" in my menu it cannot get the id of the person close to me.
RegisterNetEvent('vehiclekeys:client:GiveKeys', function(target))
local vehicles = IsPedInAnyVehicle(PlayerPedId())
if vehicles then
local plate = QBCore.Functions.GetPlate(GetVehiclePedIsIn(PlayerPedId(), true))
TriggerServerEvent('vehiclekeys:server:GiveVehicleKeys', plate, target)
else
QBCore.Functions.Notify('you need to be in a vehicle to give key', 'error')
end
end)
I do know there is a another function above that called GetNearbyPed which is this code below.
local function GetNearbyPed()
local retval = nil
local PlayerPeds = {}
for _, player in ipairs(GetActivePlayers()) do
local ped = GetPlayerPed(player)
PlayerPeds[#PlayerPeds+1] = ped
end
local player = PlayerPedId()
local coords = GetEntityCoords(player)
local closestPed, closestDistance = QBCore.Functions.GetClosestPed(coords, PlayerPeds)
if not IsEntityDead(closestPed) and closestDistance < 30.0 then
retval = closestPed
end
return retval
end
I've tryed passing it down into the Givekey target but doesnt seem to work. If someone could help me with this that would be awesome. In the meantime ill try to figure it out.