I’ve had this on the shelf for like a year because I pushed it to the side. Today I decided to use a bridge for the first time to support both QB and ESX (go easy on me). Pretty simple script that allows Players with the police jobs to send a player in to community service at legion square. Using ox lib zones, players have to perform sweeping tasks to reduce their tasks remaining. Draw markers are ugly but it’s kinda needed so people can see where they are actually supposed to complete their task.
Task sentences are persistent through restarts and when the player loads in, if they have tasks remaining, they will be teleported back to legion. Whilst doing tasks, trying to run away from the task area will teleport you back.
Link: GitHub - Randolio/randol_service: An up to date community service script. [QB/ESX]
9 Likes
Hello, thank you very much for sharing this.
Would it be possible to add a teleport point after the end of the task?
That is indeed possible. I guess I’ll make it a config option
Hi !
Thanks for this update!
I’m trying to create a menu that displays the name/first name of nearby players.
This works, but I cannot retrieve the first and last name of the ESX players, do you have a solution?
function GetNearbyPlayersWithNames(distance)
local nearbyPlayers = {}
local playerPed = PlayerPedId()
local playerCoords = GetEntityCoords(playerPed)
-- Ajouter le joueur local à la liste des joueurs proches
local localPlayerName = GetPlayerName(PlayerId())
nearbyPlayers[PlayerId()] = localPlayerName
-- Boucler à travers tous les joueurs pour trouver ceux qui sont proches
for _, playerId in ipairs(GetActivePlayers()) do
if playerId ~= PlayerId() then -- Exclure le joueur lui-même
local targetPed = GetPlayerPed(playerId)
local targetCoords = GetEntityCoords(targetPed)
local distanceBetweenPlayers = #(playerCoords - targetCoords)
if distanceBetweenPlayers <= distance then
local playerName = GetPlayerName(playerId)
nearbyPlayers[playerId] = playerName
end
end
end
return nearbyPlayers
end
RegisterNetEvent('randol_cs:client:dialog')
AddEventHandler('randol_cs:client:dialog', function()
local nearbyPlayers = GetNearbyPlayersWithNames(10) -- Obtenez les joueurs proches dans un rayon de 10 unités
local playerOptions = {}
for playerId, playerName in pairs(nearbyPlayers) do
table.insert(playerOptions, { value = playerId, label = playerName })
end
local input = lib.inputDialog('Condamnation', {
{ type = 'select', label = 'Joueur', description = 'Sélectionnez le joueur', icon = 'hashtag', options = playerOptions },
{ type = 'number', label = 'Nombre de taches', description = 'Nombre de taches', icon = 'hashtag' },
}, function(data)
local target = tonumber(data[1].value)
local tasks = tonumber(data[2])
if target and tasks then
ESX.TriggerServerCallback('esx:getPlayers', function(players)
local selectedPlayerName = nearbyPlayers[target]
local selectedPlayerData = nil
for _, player in ipairs(players) do
if player.name == selectedPlayerName then
selectedPlayerData = player
break
end
end
if selectedPlayerData then
print("Joueur sélectionné:", selectedPlayerData.name)
print("ID du joueur sélectionné:", selectedPlayerData.identifier)
print("Nombre de taches:", tasks)
TriggerServerEvent('randol_cs:server:createcondamnation', selectedPlayerData.identifier, tasks)
else
print("Joueur non trouvé.")
end
end)
else
print("Veuillez saisir des données valides.")
end
end)
end)
I’m not really sure what this has to do with my script?
I’m trying to integrate this into your script instead of doing a /cs command, have a menu with ox_lib, and have the identifiers of the players close to us
Respectfully you’ll have to do that yourself. I release a fully functional script. Any changes you make to it is down to you to figure out.