[Release] [ESX] ESX_CommunityService

Hi, in this case i want put the Character Name in place of Steam Name. but i when copy the function from “esx_rpchat” the script doesn´t work. anyone can help me? thank you and sorry for my bad english :smiley:
config.lua

Config = {}

-- # Locale to be used. You can create your own by simple copying the 'en' and translating the values.
Config.Locale = 'en'
-- Enable this to use Esx Identity
Config.EnableESXIdentity = true

-- # By how many services a player's community service gets extended if he tries to escape
Config.ServiceExtensionOnEscape		= 8

-- # Don't change this unless you know what you are doing.
Config.ServiceLocation 				= {x =  189.41, y = -855.36, z = 31.37}

-- # Don't change this unless you know what you are doing.
Config.ReleaseLocation				= {x = 427.33, y = -979.51, z = 30.2}


-- # Don't change this unless you know what you are doing.
Config.ServiceLocations = {
	{ type = "cleaning", coords = vector3(199.04, -855.07, 30.89) },
	{ type = "cleaning", coords = vector3(190.36, -851.04, 31.14) },
	{ type = "cleaning", coords = vector3(193.61, -860.53, 31.37) },
	{ type = "cleaning", coords = vector3(186.19, -851.58, 31.17) },
	{ type = "cleaning", coords = vector3(185.73, -862.31, 31.28) },
	{ type = "cleaning", coords = vector3(179.48, -865.32, 31.04) },
	{ type = "cleaning", coords = vector3(183.68, -854.87, 31.15) },
	{ type = "cleaning", coords = vector3(186.40, -846.50, 31.06) },
	{ type = "gardening", coords = vector3(202.57, -854.32, 30.61) },
	{ type = "gardening", coords = vector3(208.52, -856.76, 30.45) },
	{ type = "gardening", coords = vector3(216.04, -859.86, 30.25) },
	{ type = "gardening", coords = vector3(186.14, -869.08, 31.5) },
	{ type = "gardening", coords = vector3(194.86, -867.43, 31.5) }
}



Config.Uniforms = {
	prison_wear = {
		male = {
			['tshirt_1'] = 15,  ['tshirt_2'] = 0,
			['torso_1']  = 146, ['torso_2']  = 0,
			['decals_1'] = 0,   ['decals_2'] = 0,
			['arms']     = 119, ['pants_1']  = 3,
			['pants_2']  = 7,   ['shoes_1']  = 12,
			['shoes_2']  = 12,  ['chain_1']  = 0,
			['chain_2']  = 0
		},
		female = {
			['tshirt_1'] = 3,   ['tshirt_2'] = 0,
			['torso_1']  = 38,  ['torso_2']  = 3,
			['decals_1'] = 0,   ['decals_2'] = 0,
			['arms']     = 120,  ['pants_1'] = 3,
			['pants_2']  = 15,  ['shoes_1']  = 66,
			['shoes_2']  = 5,   ['chain_1']  = 0,
			['chain_2']  = 0
		}
	}
}

server/main.lua

RegisterServerEvent('esx_communityservice:sendToCommunityService')
AddEventHandler('esx_communityservice:sendToCommunityService', function(target, actions_count)

	local identifier = GetPlayerIdentifiers(target)[1]
	local name = GetPlayerName(target)
	if Config.EnableESXIdentity then name = GetCharacterName(target) end

	TriggerClientEvent('chat:addMessage', -1, { args = { _U('judge'), _U('comserv_msg', name, actions_count) }, color = { 147, 196, 109 } })

	MySQL.Async.fetchAll('SELECT * FROM communityservice WHERE identifier = @identifier', {
		['@identifier'] = identifier
	}, function(result)
		if result[1] then
			MySQL.Async.execute('UPDATE communityservice SET actions_remaining = @actions_remaining WHERE identifier = @identifier', {
				['@identifier'] = identifier,
				['@actions_remaining'] = actions_count
			})
		else
			MySQL.Async.execute('INSERT INTO communityservice (identifier, actions_remaining) VALUES (@identifier, @actions_remaining)', {
				['@identifier'] = identifier,
				['@actions_remaining'] = actions_count
			})
		end
	end)
	TriggerClientEvent('chat:addMessage', -1, { args = { _U('judge'), _U('comserv_msg', name, actions_count) }, color = { 147, 196, 109 } })
	TriggerClientEvent('esx_policejob:unrestrain', target)
	TriggerClientEvent('esx_communityservice:inCommunityService', target, actions_count)
end)

Don’t know why but this resource seems to load but the commands do not work.
Anyone ideas on how to solve this issue??

1 Like

Let me guess you are using latest ESX right? If YES then the commands won´t work because they are created for ES (EssentialMode) but I don´t know how to solve it sorry. (You can install older ESX with support for EssentialMode.)

Thankyou, the police menu seems to work, so no problem :slight_smile:

When I load in my character is invisible

Did you ever get this working?

When i send someone to community service it does not change their outfit anyway to fix this?

HeidiSQL offers a SQL Import Feature.

the script works well but when the player disconnects and reconnects he no longer has the penalties

Please help.

2 Likes

And I have this problem

1 Like

no ? :smiley:

where i have toput this ?

-- ADDITION [3]
-- add this function
function SendToCommunityService(player)
	ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'Community Service Menu', {
		title = "Community Service Menu",
	}, function (data2, menu)
		local community_services_count = tonumber(data2.value)
		
		if community_services_count == nil then
			ESX.ShowNotification('Invalid services count.')
		else
			TriggerServerEvent("esx_communityservice:sendToCommunityService", player, community_services_count)
			menu.close()
		end
	end, function (data2, menu)
		menu.close()
	end)
end

les gars ça il faut le mettre ou???

function SendToCommunityService(player)

ESX.UI.Menu.Open('dialog', GetCurrentResourceName(), 'Community Service Menu', {

    title = "Community Service Menu",

}, function (data2, menu)

    local community_services_count = tonumber(data2.value)

    

    if community_services_count == nil then

        ESX.ShowNotification('Invalid services count.')

    else

        TriggerServerEvent("esx_communityservice:sendToCommunityService", player, community_services_count)

        menu.close()

    end

end, function (data2, menu)

    menu.close()

end)

end

Does anyone know what a mistake this is


This script have too many bugs

cant find which line to put the code on esx_policejob :confused:

Is there a way to duplicate this script with a different command for A government community service? That way we can use the original for police and the other one for people who get warnings.

How can I make the latest version work for ESX? but the commands do not work for me

Did you get it to work for ESX?

hello