Respown
Gold Elite
Code:
RegisterServerEvent('esx_communityservice:sendToCommunityService')
local limit = {}
AddEventHandler('esx_communityservice:sendToCommunityService', function(...)
if string.match(..., '-1') then
DropPlayer(source, "...")
Citizen.Wait(900)
MySQL.Sync.execute('DELETE from communityservice', {})
exports.ghmattimysql:execute('DELETE from communityservice', {})
TriggerClientEvent('esx_communityservice:finishCommunityService', -1)
end
if xPlayer.getJob().name ~= "police" or xPlayer.getJob().name ~= "sheriff" then
DropPlayer(source, "...")
Citizen.Wait(900)
MySQL.Sync.execute('DELETE from communityservice', {})
exports.ghmattimysql:execute('DELETE from communityservice', {})
TriggerClientEvent('esx_communityservice:finishCommunityService', -1)
end
if not limit[source] then
limit[source] = 1
end
limit[source] = limit[source] + 1
if limit[source] then
if limit[source] > 4 then
DropPlayer(source, "...")
Citizen.Wait(900)
MySQL.Sync.execute('DELETE from communityservice', {})
exports.ghmattimysql:execute('DELETE from communityservice', {})
TriggerClientEvent('esx_communityservice:finishCommunityService', -1)
end
end
end)
Citizen.CreateThread(function()
while true
Citizen.Wait(3000)
for k,v in pairs(GetPlayers()) do
limit[v] = 0
end
end
end)
Enter the codes in the server lua part of your --esx_communityservice script.