[RELEASE] [ESX] Lenzh_Chopshop v2!

If your es_extended and essential mode were up to date, this would already be included. Thanks for the help, but unfortunately still doesn’t fix the lack of cooldown for me.

Players go into the marker, they see the cooldown message saying they need to wait x amount of seconds, they simply leave the marker, return at any point with a vehicle and can still chop.

I didn’t notice you were talking to someone else, I thought you had the same issue I had, sorry. Gonna edit.

I have tested my version and his version on brand new test server and cooldown and selling works properly.

1 Like

Man you are… nope, YOU’re tyhe MAN thx a lot. work like a charm

1 Like

Aka you didnt update es extended …

yes i have 3 times but didn’t work. with my old es_extended + that that work. this is the only way for me

Atleast you can use the resource now… enjoy

Yeah thx a lot dude, this is really awesome

for some reason i don’t get any items when i scrap the car. The are in my database under ITEMS but they don’t go into my inventory ingame. Anybody that can tell me what i am doing wrong?

Again update es extended cuz probably you have a error in f8 console with nil value math

an update is coming soon :smiley:
This fixes the menu not showing up when not closing it before walking out.
No rewards if leaving the marker.
Cooldown still needs fix so it’s not global. If anyone knows how. Feel free to let us know.

1 Like

Keep rocking guys, I’ll gladly wait for the update with those fixes, for now I’ve disabled cooldowns in my server and lowered the prices a lot so people don’t farm as much and get paid as it were farming weed…

New update out! v1.7

2 Likes

@Lenzh_FX
It would be possible to define number of police officers online so that you can cut the vehicle

Yes thats possible

@Lenzh_FX
I looked at config but I did not find it
is it on client / main.lua ??
Could you show me which line

config.lua
Config.CopsRequired = 3

server.lua

ESX.RegisterServerCallback('Lenzh_chopshop:anycops',function(source, cb)
  local anycops = 0
  local playerList = GetPlayers()
  for i=1, #playerList, 1 do
    local _source = playerList[i]
    local xPlayer = ESX.GetPlayerFromId(_source)
    local playerjob = xPlayer.job.name
    if playerjob == 'police' then
      anycops = anycops + 1
    end
  end
  cb(anycops)
end)
client.lua
ESX.TriggerServerCallback('Lenzh_chopshop:isCooldown', function(cooldown)
        if cooldown <= 0 then
            ESX.TriggerServerCallback('Lenzh_chopshop:anycops', function(anycops)
                if anycops >= Config.CopsRequired then


after last pNotify that states the vehicle has been chopped
else
                  ESX.ShowNotification(_U('not_enough_cops'))    
                end
            end)

and locale
[‘not_enough_cops’] = ‘Not enough cops in service’

Hey man, I wanted to make something just like this and took apart your script to use as the base. I made a few optimizations I can send you if you’d like to see. I noticed you update this script a lot and had comments for some nice features so I added those. For example, your VehiclePartsRemoval() can basically be done with

		local ped = PlayerPedId()
		local vehicle = GetVehiclePedIsIn( ped, false )
		local doors = GetNumberOfVehicleDoors(vehicle)
		for i = 0,doors do
			if DoesVehicleHaveDoor(vehicle, i) then
				SetVehicleDoorShut(vehicle, i, false )
				Wait(2000)
				SetVehicleDoorOpen(vehicle, i, false, false)
				Wait(5000)
				SetVehicleDoorBroken(vehicle, i, true)
			end
		end

That just checks any vehicle for its max doors and checks if the door is attached, if so then close it then open it fully, wait and then delete.

I was able to remove the functions you used to check for passengers and used this function

function butts(vehicle)
	local meh = GetVehicleNumberOfPassengers(vehicle)
	return meh
end
local seats = butts(vehicle)
if seats ~= 0 then
	TriggerEvent('chat:addMessage', { args = { '[^1Chopshop^0]: Cannot chop with passengers' } })
end

I did that cause I don’t care if they are actually the driver, I just don’t want more than one person in the car to be able to start a 2nd chop process while this one is active. I also use that function again before I reward the player to make sure they are still a lone in the car at the end of the chop process. The cooldown callback prevents this as well.

For the cooldown you can take a look at esx_advancedrobbery and see how that resource uses os.timer() to make a cooldown. I made this callback to make the chopshop usable once every hour. This way its just a 1 time check instead of using your cooldown manager.

local TimeBeforeNewRob = 3600
local lastrobbed = 0
ESX.RegisterServerCallback('Lenzh_chopshop:isCooldown',function(source, cb)
    if lastrobbed ~= 0 and (os.time() - lastrobbed) < TimeBeforeNewRob then
        --local timerNewRob = TimeBeforeNewRob - (os.time() - lastrobbed)
        --print('timeleft is '..timerNewRob)
        cb(true)
    else
        cb(false)
    end
end)

The cooldown is triggered when the client begins the actual chop process with

client:
TriggerServerEvent('Lenzh_chopshop:BerryTime')

which is this on the server side

server:
RegisterServerEvent('Lenzh_chopshop:BerryTime')
AddEventHandler('Lenzh_chopshop:BerryTime', function()
    lastrobbed = os.time()
end)

Instead of copying esx_outlawalert into your script, if you look at the newest releast of it you can see an update for isPlayerWhitelisted. You can most likely make a function within that resource which returns true if whitelisted and then export that function into your chopshop for a cop check and trigger a blip to them with that.

Some other stuff I had is moving your markers and blips off to a separate markers.lua, adding a vehicle class check to only allow certain vehicle types, and some other fluff. Keep in mind, if you spawn an NPC like that and people use a default esx_drugstonpc or a mugging script, they can sell and mug that NPC again and again. You are also going to want to change the way you prevent players from driving the vehicle after starting the chop process.

I wouldn’t use

	SetVehicleUndriveable(vehicle, false)

If someone disconnects, crashes or drops while chopping I am pretty sure this leaves the vehicle stuck in the marker and a normal client wont be able to start or move it.

Try something like this instead, I think this should work. You can probably slim this function down even more.

Citizen.CreateThread(function()
	while true do
		Citizen.Wait(1000)
		if turnEngineOff then
			local nowVehicle = GetVehiclePedIsIn(PlayerPedId())
			if nowVehicle then
				SetVehicleEngineOn(nowVehicle, false, false, true)
			end

			if (not IsPedInAnyVehicle(PlayerPedId(), false) and turnEngineOff) then
				currentlyChopping = false
				turnEngineOff = false
			end

		end
	end
end)

I used currentlyChopping as my global variable and you can just set turnEngineOff = true/false if you wanna toggle the engine. We can prevent players from manually turning the engine on and driving off with that. This also checks if a player leaves the vehicle after starting the job and cancels it if they did.

Thanks for releasing this, hopefully this helps you out for the next update. I’ll send you the full resource just message me.

So I’m guessing this now requires progressBars script cause I’m getting errors like crazy cause I don’t have that resource. Here is the link to progressBars if you want his update to actually work [RELEASE] Progress Bars 1.0 [STANDALONE]

1 Like

@SoldatMI
I belive you do, he posted in my progress bar resource that he is happy to have it in his chop shop resource. It is easy to install just put it in your reousrces folder and auto start it and you should be able to use this resource fully!