Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(esx_mechanicjob): rework and rewrite by Tizas #25

Open
wants to merge 3 commits into
base: dev
Choose a base branch
from

Conversation

Arctos2win
Copy link
Contributor

No description provided.

client/main.lua Outdated
cb(vehicle)
end)

Citizen.CreateThread(function()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove Citizen. you can just trigger CreateThread no need for Citizen in front of it.

client/main.lua Outdated
local playerPed = ESX.PlayerData.ped
local playerCoords = GetEntityCoords(playerPed)
local vehicle = ESX.Game.GetClosestVehicle(playerCoords)
if vehicle == -1 then cb(false) end
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not vehicle or vehicle == -1 then
return cb(false) -- return otherwise it will trigger cb(vehicle) as well
end

cb(vehicle)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Arctos2win ESX.Game.GetClosestVehicle will either return -1 or an entity handle. No need to check for nil

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Arctos2win ESX.Game.GetClosestVehicle will either return -1 or an entity handle. No need to check for nil

didnt know the point was just the return before cb(false) otherwise cb(true) will also run even if there is no vehicle

)
end

Citizen.CreateThread(function()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Citizen. can be removed

end

local function EndJob()
if activeJob then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not activeJob then
return ESX.ShowNotification(TranslateCap('no_active_job'))
end

end,
inside = function()
DrawText3D(job.vehicleCoords, "~INPUT_PICKUP~ Start the job", 0.4)
if IsControlJustReleased(0, 38) then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use an outside local variabel for this
and then trigger this:

ESX.RegisterInteraction("mechanicjob", function()
MonitorRepair()
SetEntityDrawOutline(vehicle, false)
repairPoint:delete()
print("Delete Point")
end, function()
return isInside
end)
check how it works in here:
https://github.com/esx-framework/esx_core/blob/0426e760859f0d73213b499801165e6ad392ca38/%5Bcore%5D/es_extended/client/modules/interactions.lua#L9

end

if not xPlayer.canCarryItem(itemName, count) then
xPlayer.showNotification('You cannot carry this amount of items.')
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return xPlayer.showNotification

ESX.RegisterUsableItem('tirekit', function(source)
local source = source
local xPlayer = ESX.GetPlayerFromId(source)
ESX.TriggerClientCallback(source , "esx_mechanicjob:client:checkForVehicle", function(closeVehicle)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same thing as the repairkit

end,
inside = function()
DrawText3D(job.vehicleCoords, "~INPUT_PICKUP~ Start the job", 0.4)
if IsControlJustReleased(0, 38) then
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do this with interactionkey

end

local function MonitorRepair()
Citizen.CreateThread(function()
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove Citizen.

return EndJob()
end
print("Player Entered Zone")
SpawnVehicle(job.vehicleCoords, job.carModel)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Spawn server side vehicle and add an extra step on server to check timing

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Brb, ill go bash my head into a wall

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: 🆕 To be Discussed
Development

Successfully merging this pull request may close these issues.

3 participants