mirror of
https://github.com/esx-framework/esx_core.git
synced 2026-08-31 18:28:52 +00:00
Resolved #33
This commit is contained in:
+65
-107
@@ -10,31 +10,24 @@ local Keys = {
|
||||
["NENTER"] = 201, ["N4"] = 108, ["N5"] = 60, ["N6"] = 107, ["N+"] = 96, ["N-"] = 97, ["N7"] = 117, ["N8"] = 61, ["N9"] = 118
|
||||
}
|
||||
|
||||
local PlayerData = {}
|
||||
local menuIsShowed = false
|
||||
local hintIsShowed = false
|
||||
local PlayerData = {}
|
||||
local menuIsShowed = false
|
||||
local hintIsShowed = false
|
||||
local hasAlreadyEnteredMarker = false
|
||||
local Blips = {}
|
||||
local JobBlips = {}
|
||||
local Blips = {}
|
||||
local JobBlips = {}
|
||||
local isInMarker = false
|
||||
local isInPublicMarker = false
|
||||
|
||||
local collectedItem = nil
|
||||
local collectedQtty = 0
|
||||
local isInMarker = false
|
||||
local isInPublicMarker = false
|
||||
local hintToDisplay = "no hint to display"
|
||||
local onDuty = false
|
||||
local spawner = 0
|
||||
local myPlate = {}
|
||||
|
||||
local hintToDisplay = "no hint to display"
|
||||
local onDuty = false
|
||||
local spawner = 0
|
||||
local myPlate = {}
|
||||
local isJobVehicleDestroyed = false
|
||||
local vehicleObjInCaseofDrop = nil
|
||||
local vehicleInCaseofDrop = nil
|
||||
|
||||
local cautionVehicleInCaseofDrop = 0
|
||||
local maxCautionVehicleInCaseofDrop = 0
|
||||
local vehicleObjInCaseofDrop = nil
|
||||
local vehicleInCaseofDrop = nil
|
||||
local vehicleHashInCaseofDrop = nil
|
||||
local vehicleMaxHealthInCaseofDrop = nil
|
||||
local vehicleOldHealthInCaseofDrop = nil
|
||||
local vehicleMaxHealth = nil
|
||||
|
||||
ESX = nil
|
||||
|
||||
@@ -55,7 +48,6 @@ end)
|
||||
RegisterNetEvent('esx:playerLoaded')
|
||||
AddEventHandler('esx:playerLoaded', function(xPlayer)
|
||||
PlayerData = xPlayer
|
||||
TriggerServerEvent('esx_jobs:giveBackCautionInCaseOfDrop')
|
||||
refreshBlips()
|
||||
end)
|
||||
|
||||
@@ -75,7 +67,6 @@ function OpenMenu()
|
||||
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin)
|
||||
TriggerEvent('skinchanger:loadSkin', skin)
|
||||
end)
|
||||
|
||||
elseif data.current.value == 'job_wear' then
|
||||
onDuty = true
|
||||
ESX.TriggerServerCallback('esx_skin:getPlayerSkin', function(skin, jobSkin)
|
||||
@@ -129,11 +120,7 @@ AddEventHandler('esx_jobs:action', function(job, zone)
|
||||
end
|
||||
|
||||
if ESX.Game.IsSpawnPointClear(spawnPoint.Pos, 5.0) then
|
||||
TriggerServerEvent('esx_jobs:setCautionInCaseOfDrop', zone.Caution)
|
||||
cautionVehicleInCaseofDrop = zone.Caution
|
||||
maxCautionVehicleInCaseofDrop = cautionVehicleInCaseofDrop
|
||||
|
||||
spawnVehicle(spawnPoint, vehicle)
|
||||
spawnVehicle(spawnPoint, vehicle, zone.Caution)
|
||||
else
|
||||
ESX.ShowNotification(_U('spawn_blocked'))
|
||||
end
|
||||
@@ -146,37 +133,45 @@ AddEventHandler('esx_jobs:action', function(job, zone)
|
||||
for l,w in pairs(v.Zones) do
|
||||
if w.Type == "vehdelete" and w.Spawner == zone.Spawner then
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
if IsPedInAnyVehicle(playerPed, false) then
|
||||
local vehicle = GetVehiclePedIsIn(playerPed, 0)
|
||||
|
||||
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
local plate = GetVehicleNumberPlateText(vehicle)
|
||||
plate = string.gsub(plate, " ", "")
|
||||
local driverPed = GetPedInVehicleSeat(vehicle, -1)
|
||||
|
||||
for i=1, #myPlate, 1 do
|
||||
if myPlate[i] == plate and playerPed == driverPed then
|
||||
TriggerServerEvent('esx_jobs:caution', "give_back", cautionVehicleInCaseofDrop, 0, 0)
|
||||
DeleteVehicle(GetVehiclePedIsIn(playerPed, 0))
|
||||
if playerPed == driverPed then
|
||||
|
||||
if w.Teleport ~= 0 then
|
||||
SetEntityCoords(PlayerPedId(), w.Teleport.x, w.Teleport.y, w.Teleport.z)
|
||||
for i=1, #myPlate, 1 do
|
||||
if myPlate[i] == plate then
|
||||
|
||||
local vehicleHealth = GetVehicleEngineHealth(vehicleInCaseofDrop)
|
||||
local giveBack = ESX.Math.Round(vehicleHealth / vehicleMaxHealth, 2)
|
||||
|
||||
TriggerServerEvent('esx_jobs:caution', "give_back", giveBack, 0, 0)
|
||||
DeleteVehicle(GetVehiclePedIsIn(playerPed, false))
|
||||
|
||||
if w.Teleport ~= 0 then
|
||||
ESX.Game.Teleport(playerPed, w.Teleport)
|
||||
end
|
||||
|
||||
table.remove(myPlate, i)
|
||||
|
||||
if vehicleObjInCaseofDrop.HasCaution then
|
||||
vehicleInCaseofDrop = nil
|
||||
vehicleObjInCaseofDrop = nil
|
||||
vehicleMaxHealth = nil
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
table.remove(myPlate, i)
|
||||
|
||||
if vehicleObjInCaseofDrop.HasCaution then
|
||||
cautionVehicleInCaseofDrop = 0
|
||||
maxCautionVehicleInCaseofDrop = 0
|
||||
vehicleInCaseofDrop = nil
|
||||
vehicleHashInCaseofDrop = nil
|
||||
vehicleMaxHealthInCaseofDrop = nil
|
||||
vehicleOldHealthInCaseofDrop = nil
|
||||
vehicleObjInCaseofDrop = nil
|
||||
TriggerServerEvent('esx_jobs:setCautionInCaseOfDrop', 0)
|
||||
end
|
||||
|
||||
break
|
||||
end
|
||||
|
||||
else
|
||||
ESX.ShowNotification(_U('not_your_vehicle'))
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
looping = false
|
||||
@@ -231,7 +226,6 @@ AddEventHandler('esx:setJob', function(job)
|
||||
PlayerData.job = job
|
||||
onDuty = false
|
||||
myPlate = {} -- loosing vehicle caution in case player changes job.
|
||||
isJobVehicleDestroyed = false
|
||||
spawner = 0
|
||||
deleteBlips()
|
||||
refreshBlips()
|
||||
@@ -276,10 +270,10 @@ function refreshBlips()
|
||||
end
|
||||
end
|
||||
|
||||
function spawnVehicle(spawnPoint, vehicle)
|
||||
hintToDisplay = "no hint to display"
|
||||
function spawnVehicle(spawnPoint, vehicle, vehicleCaution)
|
||||
hintToDisplay = 'no hint to display'
|
||||
hintIsShowed = false
|
||||
TriggerServerEvent('esx_jobs:caution', "take", cautionVehicleInCaseofDrop, spawnPoint, vehicle)
|
||||
TriggerServerEvent('esx_jobs:caution', 'take', vehicleCaution, spawnPoint, vehicle)
|
||||
end
|
||||
|
||||
RegisterNetEvent('esx_jobs:spawnJobVehicle')
|
||||
@@ -301,14 +295,11 @@ AddEventHandler('esx_jobs:spawnJobVehicle', function(spawnPoint, vehicle)
|
||||
plate = string.gsub(plate, " ", "")
|
||||
|
||||
TaskWarpPedIntoVehicle(playerPed, spawnedVehicle, -1)
|
||||
isJobVehicleDestroyed = false
|
||||
|
||||
if vehicle.HasCaution then
|
||||
vehicleInCaseofDrop = spawnedVehicle
|
||||
vehicleHashInCaseofDrop = vehicle.Hash
|
||||
vehicleObjInCaseofDrop = vehicle
|
||||
vehicleMaxHealthInCaseofDrop = GetEntityMaxHealth(spawnedVehicle)
|
||||
vehicleOldHealthInCaseofDrop = vehicleMaxHealthInCaseofDrop
|
||||
vehicleMaxHealth = GetVehicleEngineHealth(spawnedVehicle)
|
||||
end
|
||||
end)
|
||||
end)
|
||||
@@ -317,6 +308,7 @@ end)
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(10)
|
||||
|
||||
if hintIsShowed then
|
||||
ESX.ShowHelpNotification(hintToDisplay)
|
||||
else
|
||||
@@ -367,18 +359,18 @@ end)
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(10)
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
local position = nil
|
||||
local zone = nil
|
||||
local coords = GetEntityCoords(PlayerPedId())
|
||||
local position = nil
|
||||
local zone = nil
|
||||
|
||||
for k,v in pairs(Config.PublicZones) do
|
||||
if(GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x) then
|
||||
if GetDistanceBetweenCoords(coords, v.Pos.x, v.Pos.y, v.Pos.z, true) < v.Size.x then
|
||||
isInPublicMarker = true
|
||||
position = v.Teleport
|
||||
zone = v
|
||||
break
|
||||
else
|
||||
isInPublicMarker = false
|
||||
isInPublicMarker = false
|
||||
end
|
||||
end
|
||||
|
||||
@@ -450,21 +442,21 @@ Citizen.CreateThread(function()
|
||||
local playerPed = PlayerPedId()
|
||||
|
||||
if IsPedInAnyVehicle(playerPed, false) then
|
||||
local vehicle = GetVehiclePedIsIn(playerPed)
|
||||
local vehicle = GetVehiclePedIsIn(playerPed, false)
|
||||
local driverPed = GetPedInVehicleSeat(vehicle, -1)
|
||||
local isVehicleOwner = false
|
||||
local plate = GetVehicleNumberPlateText(vehicle)
|
||||
plate = string.gsub(plate, " ", "")
|
||||
|
||||
for i=1, #myPlate, 1 do
|
||||
if myPlate[i] == plate and playerPed == driverPed then
|
||||
hintToDisplay = _U('security_deposit', zone.Hint, cautionVehicleInCaseofDrop)
|
||||
isVehicleOwner = true
|
||||
break
|
||||
end
|
||||
end
|
||||
if playerPed == driverPed then
|
||||
|
||||
if not isVehicleOwner then
|
||||
for i=1, #myPlate, 1 do
|
||||
if myPlate[i] == plate then
|
||||
hintToDisplay = zone.Hint
|
||||
break
|
||||
end
|
||||
end
|
||||
|
||||
else
|
||||
hintToDisplay = _U('not_your_vehicle')
|
||||
end
|
||||
else
|
||||
@@ -495,40 +487,6 @@ Citizen.CreateThread(function()
|
||||
end
|
||||
end)
|
||||
|
||||
-- Vehicle caution
|
||||
Citizen.CreateThread(function()
|
||||
while true do
|
||||
Citizen.Wait(0)
|
||||
if vehicleInCaseofDrop ~= nil then
|
||||
if onDuty and IsVehicleModel(vehicleInCaseofDrop, vehicleHashInCaseofDrop) then
|
||||
local vehicleHealth = GetEntityHealth(vehicleInCaseofDrop)
|
||||
|
||||
if vehicleOldHealthInCaseofDrop ~= vehicleHealth then
|
||||
local cautionValue = 0
|
||||
vehicleOldHealthInCaseofDrop = vehicleHealth
|
||||
if vehicleHealth == vehicleMaxHealthInCaseofDrop then
|
||||
cautionValue = maxCautionVehicleInCaseofDrop
|
||||
cautionVehicleInCaseofDrop = cautionValue
|
||||
else
|
||||
local healthPct = (vehicleHealth * 100) / vehicleMaxHealthInCaseofDrop
|
||||
local damagePct = 100 - healthPct
|
||||
cautionValue = math.ceil(cautionVehicleInCaseofDrop - cautionVehicleInCaseofDrop * damagePct * 2.5 / 100)
|
||||
if cautionValue < 0 then
|
||||
cautionValue = 0
|
||||
elseif cautionValue >= cautionVehicleInCaseofDrop then
|
||||
cautionValue = cautionVehicleInCaseofDrop
|
||||
end
|
||||
cautionVehicleInCaseofDrop = cautionValue
|
||||
end
|
||||
TriggerServerEvent('esx_jobs:setCautionInCaseOfDrop', cautionValue)
|
||||
end
|
||||
end
|
||||
else
|
||||
Citizen.Wait(1000)
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Citizen.CreateThread(function()
|
||||
-- Slaughterer
|
||||
RemoveIpl("CS1_02_cf_offmission")
|
||||
|
||||
@@ -8,7 +8,6 @@ Locales['br'] = {
|
||||
['bank_deposit_taken'] = 'um depósito de segurança de ~g~$%s~s~ foi tirado de você.',
|
||||
['foot_work'] = 'você deve estar a pé para poder trabalhar.',
|
||||
['next_point'] = 'vá para o próximo passo depois de completar este.',
|
||||
['security_deposit'] = '%s \nA segurança dada será ~g~$%s~s~',
|
||||
['not_your_vehicle'] = 'este não é o seu veículo ou você deve ser um motorista.',
|
||||
['in_vehicle'] = 'você deve estar em um veículo.',
|
||||
['wrong_point'] = 'você não está no ponto certo de entrega.',
|
||||
|
||||
@@ -8,7 +8,6 @@ Locales['en'] = {
|
||||
['bank_deposit_taken'] = 'a security deposit of ~r~$%s~s~ was taken from you.',
|
||||
['foot_work'] = 'you have to be on foot to be able to work.',
|
||||
['next_point'] = 'go to the next step after completing this one.',
|
||||
['security_deposit'] = '%s \nYou will be given ~g~$%s~s~',
|
||||
['not_your_vehicle'] = 'this is not your vehicle or you must be a driver.',
|
||||
['in_vehicle'] = 'you must sit in a vehicle.',
|
||||
['wrong_point'] = 'you are not at the right point of delivery.',
|
||||
|
||||
@@ -8,7 +8,6 @@ Locales['fi'] = {
|
||||
['bank_deposit_taken'] = 'vakuuden summa ~r~€%s~s~ otettiin sinulta.',
|
||||
['foot_work'] = 'sinun täytyy olla jalan, jotta voit työskennellä',
|
||||
['next_point'] = 'mene seuraavaan pisteeseen kun olet valmis täällä',
|
||||
['security_deposit'] = '%s \nVakuus joka annetaan on ~g~€%s~s~',
|
||||
['not_your_vehicle'] = 'tämä ei ole sinun ajoneuvo tai et ole sen kuski',
|
||||
['in_vehicle'] = 'sinun täytyy olla ajoneuvossa',
|
||||
['wrong_point'] = 'et ole oikeassa paikassa',
|
||||
|
||||
@@ -8,7 +8,6 @@ Locales['fr'] = {
|
||||
['bank_deposit_taken'] = 'une caution de ~g~$%s~s~ vous a été prélevée.',
|
||||
['foot_work'] = 'vous devez être à pied pour pouvoir travailler.',
|
||||
['next_point'] = 'rendez-vous à la prochaine étape après avoir complété celle-ci.',
|
||||
['security_deposit'] = '%s \nLa caution rendue sera de ~g~$%s~s~',
|
||||
['not_your_vehicle'] = 'ce n\'est pas votre véhicule ou vous devez être conducteur.',
|
||||
['in_vehicle'] = 'vous devez être dans un véhicule.',
|
||||
['wrong_point'] = 'vous n\'êtes pas au bon point de livraison.',
|
||||
|
||||
@@ -8,7 +8,6 @@ Locales['sv'] = {
|
||||
['bank_deposit_taken'] = 'en deposition på ~r~%s SEK~s~ togs från dig.',
|
||||
['foot_work'] = 'du måste vara till fots för att kunna arbeta.',
|
||||
['next_point'] = 'gå till nästa steg efter att du har avslutat här.',
|
||||
['security_deposit'] = '%s \nDu kommer få tillbaka ~g~%s SEK~s~',
|
||||
['not_your_vehicle'] = 'det här är inte ditt fordon eller så måste du vara föraren.',
|
||||
['in_vehicle'] = 'du måste sitta i ett fordon!',
|
||||
['wrong_point'] = 'du är inte på rätt leveranspunkt!',
|
||||
|
||||
+21
-45
@@ -1,46 +1,8 @@
|
||||
local PlayersWorking = {}
|
||||
local Players = {}
|
||||
|
||||
ESX = nil
|
||||
|
||||
TriggerEvent('esx:getSharedObject', function(obj) ESX = obj end)
|
||||
|
||||
AddEventHandler('esx:playerLoaded', function(source)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
xPlayer.set('caution', 0)
|
||||
end)
|
||||
|
||||
AddEventHandler('esx:playerDropped', function(source)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
local caution = xPlayer.get('caution')
|
||||
TriggerEvent('esx_addonaccount:getAccount', 'caution', xPlayer.identifier, function(account)
|
||||
account.addMoney(caution)
|
||||
end)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_jobs:setCautionInCaseOfDrop')
|
||||
AddEventHandler('esx_jobs:setCautionInCaseOfDrop', function(caution)
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
xPlayer.set('caution', caution)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('esx_jobs:giveBackCautionInCaseOfDrop')
|
||||
AddEventHandler('esx_jobs:giveBackCautionInCaseOfDrop', function()
|
||||
local _source = source
|
||||
local xPlayer = ESX.GetPlayerFromId(_source)
|
||||
|
||||
TriggerEvent('esx_addonaccount:getAccount', 'caution', xPlayer.identifier, function(account)
|
||||
local caution = account.money
|
||||
account.removeMoney(caution)
|
||||
if caution > 0 then
|
||||
xPlayer.addAccountMoney('bank', caution)
|
||||
TriggerClientEvent('esx:showNotification', _source, _U('bank_deposit_returned', caution))
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
||||
local function Work(source, item)
|
||||
|
||||
SetTimeout(item[1].time, function()
|
||||
@@ -117,13 +79,27 @@ AddEventHandler('esx_jobs:caution', function(cautionType, cautionAmount, spawnPo
|
||||
local xPlayer = ESX.GetPlayerFromId(source)
|
||||
|
||||
if cautionType == "take" then
|
||||
xPlayer.removeAccountMoney('bank', cautionAmount)
|
||||
xPlayer.set('caution', cautionAmount)
|
||||
TriggerClientEvent('esx:showNotification', source, _U('bank_deposit_taken', cautionAmount))
|
||||
TriggerEvent('esx_addonaccount:getAccount', 'caution', xPlayer.identifier, function(account)
|
||||
xPlayer.removeAccountMoney('bank', cautionAmount)
|
||||
account.addMoney(cautionAmount)
|
||||
end)
|
||||
|
||||
TriggerClientEvent('esx:showNotification', source, _U('bank_deposit_taken', ESX.Math.GroupDigits(cautionAmount)))
|
||||
TriggerClientEvent('esx_jobs:spawnJobVehicle', source, spawnPoint, vehicle)
|
||||
elseif cautionType == "give_back" then
|
||||
xPlayer.addAccountMoney('bank', cautionAmount)
|
||||
xPlayer.set('caution', 0)
|
||||
TriggerClientEvent('esx:showNotification', source, _U('bank_deposit_returned', cautionAmount))
|
||||
|
||||
if cautionAmount > 1 then
|
||||
print(('esx_jobs: %s is using cheat engine!'):format(xPlayer.identifier))
|
||||
return
|
||||
end
|
||||
|
||||
TriggerEvent('esx_addonaccount:getAccount', 'caution', xPlayer.identifier, function(account)
|
||||
local caution = account.money
|
||||
local toGive = ESX.Math.Round(caution * cautionAmount)
|
||||
|
||||
xPlayer.addAccountMoney('bank', toGive)
|
||||
account.removeMoney(toGive)
|
||||
TriggerClientEvent('esx:showNotification', source, _U('bank_deposit_returned', ESX.Math.GroupDigits(toGive)))
|
||||
end)
|
||||
end
|
||||
end)
|
||||
|
||||
Reference in New Issue
Block a user