[Release] [ESX] ESX_CommunityService

i am tying /comserv on chat but says is not a valic command, how to add it for admins? cant understand where to put it thanks

Use this to register command.

I am not able to test the code here at work. So use it with caution.

RegisterCommand(“comserv”, function(src, args, raw)
if args[1] and GetPlayerName(args[1]) ~= nil and tonumber(args[2]) then
TriggerEvent(‘esx_communityservice:sendToCommunityService’, tonumber(args[1]), tonumber(args[2]))
else
TriggerClientEvent(‘chat:addMessage’, source, { args = { _U(‘system_msn’), _U(‘invalid_player_id_or_actions’) } } )
end
end,true)

RegisterCommand(“endcomserv”, function(src, args, raw)
if args[1] then
if GetPlayerName(args[1]) ~= nil then
TriggerEvent(‘esx_communityservice:endCommunityServiceCommand’, tonumber(args[1]))
else
TriggerClientEvent(‘chat:addMessage’, source, { args = { _U(‘system_msn’), _U(‘invalid_player_id’) } } )
end
else
TriggerEvent(‘esx_communityservice:endCommunityServiceCommand’, source)
end
end,true)

In theory this should be fine. Needs testing.

1 month = 1 action

i have a similar problem when the player reconnect the moths up crazy with the message “you cant escape the common serve” even if the player is doing the actions

What is the line where you have to add the code?

ESX_CommunityService :: Problem matching player identifier in database to reduce actions.
what is this?

1 Like
RegisterServerEvent('esx_communityservice:completeService')
AddEventHandler('esx_communityservice:completeService', function()

	local _source = source
	--local identifier = GetPlayerIdentifiers(_source)[1]
	--local identifier = ESX.GetPlayerFromId(ID).identifier
	local identifier = ESX.GetPlayerFromId(_source).identifier

	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 - 1 WHERE identifier = @identifier', {
				['@identifier'] = identifier
			})
		else
			print ("ESX_CommunityService :: Problem matching player identifier in database to reduce actions.")
		end
	end)
end)
RegisterServerEvent('esx_communityservice:extendService')
AddEventHandler('esx_communityservice:extendService', function()

	local _source = source
	local identifier = ESX.GetPlayerFromId(_source).identifier

	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 + @extension_value WHERE identifier = @identifier', {
				['@identifier'] = identifier,
				['@extension_value'] = Config.ServiceExtensionOnEscape
			})
		else
			print ("ESX_CommunityService :: Problem matching player identifier in database to reduce actions.")
		end
	end)
end)

Replace those :slight_smile:

Why tho?
I mean whats the difference
And why the creator didn’t update his resource ?

how to change 1 service job time?

1 Like

Hi, in this case i want put the Character Name in place of Steam Name.

i am having same problem again ESX_CommunityService :: Problem matching player identifier in database to reduce actions.

Hello, is there any way to make logs of when you get the community service

i have a problem with this script the commands wont work

2 Likes

same problem

2 Likes

So the script works perfectly, but if you reconnect while doing your com work and you come back on the server, you still have blips and you still have ti do work, but when you finish, it doesn’t spawn you on the configured location and you are not dressed as a prisoner anymore…

1 Like

Which line should I write in?

When he reconnects he does not get the public works?

I have one good idea how to resolve this error.

Find this on client.lua

Citizen.CreateThread(function()

    Citizen.Wait(120000) --Wait for mysql-async

    TriggerServerEvent('esx_communityservice:checkIfSentenced')

end)

Citizen.Wait(120000) <<< original Client.lua maybe 2000 this amount. Change 120000 and your problem is resolved.

hello did you figure it out?

main.lua (5.4 KB) guys if you are using esx final v1 replace the main lua in the server folder with this one

1 Like

My policejob menu dont working

this shows me: