[HOW TO] Remove Stress w/ Smoking Cigarette

Thought I would share this since I’ve seen it asked here and there.

Please note the animation sucks and im sure this could be greatly improved but it does work.
I’ll update this when I’ve improved it.

Requirements:
esx_basicneeds
linden-inventory (only if using this inventory of course, you may have a diff requirement)

Step #1: Follow this for adding stress system:

Add the following in esx_basicneeds\server\main.lua:

ESX.RegisterUsableItem('cigarette', function(source)
	local xPlayer = ESX.GetPlayerFromId(source)
	xPlayer.removeInventoryItem('cigarette', 1)

	TriggerClientEvent('esx_status:remove', source, 'stress', 100000)
	TriggerClientEvent('esx_basicneeds:onSmoke', source)
	xPlayer.showNotification(_U('used_cigarette'))
end)

Add the following to esx_basicneeds\client\main.lua:

RegisterNetEvent('esx_basicneeds:onSmoke')
AddEventHandler('esx_basicneeds:onSmoke', function(prop_name)
	if not IsAnimated then
		prop_name = prop_name or 'ng_proc_cigarette01a'
		IsAnimated = true

		Citizen.CreateThread(function()
		local playerPed = PlayerPedId()
		local x,y,z = table.unpack(GetEntityCoords(playerPed))
		local prop = CreateObject(GetHashKey(prop_name), x, y, z + 0.2, true, true, true)
		local boneIndex = GetPedBoneIndex(playerPed, 18905)
		AttachEntityToEntity(prop, playerPed, boneIndex, 0.12, 0.028, 0.001, 10.0, 175.0, 0.0, true, true, false, true, 1, true)
		
		ESX.Streaming.RequestAnimDict('amb@world_human_aa_smoke@male@idle_a', function()
			TaskStartScenarioInPlace(playerPed, 'WORLD_HUMAN_SMOKING', 0, false)

			Citizen.Wait(3000)
			IsAnimated = false
			ClearPedSecondaryTask(playerPed)
			DeleteObject(prop)
		end)
	end)

	end
end)

For linden-inventory users:

linden_inventory\shared\items.lua:

	['cigarette'] = {
		removeStress = 200000,
		animDict = 'amb@world_human_aa_smoke@male@idle_a',
		anim = 'idle_a',
		model = 'ng_proc_cigarette01a',
		coords = { x = 0.03, y = 0.0, z = 0.02 },
		rotation = { x = 0.0, y = -13.5, z = -1.5 },
		useTime = 2500,
		event = 'linden_inventory:cigarette'
	},

linden_inventory\client\main.lua:

					if data.stress then 
						TriggerEvent('esx_status:add', 'stress', data.stress) 
					end
					if data.removeStress then 
						TriggerEvent('esx_status:remove', 'stress', data.removeStress) 
					end
2 Likes

my inventory doesnt have item.lua . how sir ?

1 Like

In my thread I stated this part was only for linden-inventory. Whatever inventory system you use you may or may not have to do something similar.

i think it’s working now . btw how do i set how much time to finish the cig ? because when im using the cig the animation started and stayed about 10 minutes like that . and one time using the cig will decrease the stress . and need to use about 10 cig to make the stress empty

1 Like

I’m not sure why yours would do that, mine is actually too fast.

nvm all looks good now . only the animation . if not pressing X it will stay forever haha

Could you please add Weed as secondary option to relive stress?

Just follow this and adjust for weed

1 Like

You can control that in basicneeds, optionalneeds, status… all manner of places. If you’re still stuck, send me a message and I’ll give you my code snippets.

Hey guys , ik this maybe off topic but do anyone have the slightest idea on how I can modify the esx_basicneed script so that I can choose the Prop of the food that I’m eating so that It doesn’t always look like I’m just eating a burger.
esx_basicneeds/client/main.lua

The picture up above is what I’m trying to change , I tried to follow other ways which I thought was the correct way & still didn’t receive the results I was looking for.
esx_basicneeds/client/main.lua

I have found the prop names for the props I want but I have no idea how to modify this script in the way that I can replace the prop_cs_burger_01 selection to another prop selection ( prop_choc_meto ) that would show me eating a different food instead of a burger. If anyone with any knowledge could help me out in any way , I’d would be very thankful for your help .

Can someone share how you would also do these things using devcore realistic needs?