Need Help making a working drug

I need help, im trying to make a x-pill item and make it so when the consume it it makes them temporarily move faster. (i use ox_inventory btw) below i have the code i tried to make but it dosent work for me.

["xpills"] = {
		label = "X-Pills",
		weight = 1,
		stack = true,
		client = {
			anim = 'eating',
			usetime = 1500,
			notification = 'You popped a X-Pill'
			status = { Citizen.CreateThread(function()

				SetPedMoveRateOverride(PlayerId(),10.0)
				SetRunSprintMultiplierForPlayer(PlayerId(),1.49)
				
				end) },
		},
	
	},
1 Like
["xpills"] = {
    label = "X-Pills",
    weight = 1,
    stack = true,
    client = {
        anim = 'eating',
        usetime = 1500,
        notification = 'You popped a X-Pill',
        effect = function()
            SetPedMoveRateOverride(PlayerId(), 10.0)
            SetRunSprintMultiplierForPlayer(PlayerId(), 1.49)

            -- Reset movement speed after 30 seconds
            Citizen.SetTimeout(30000, function()
                SetPedMoveRateOverride(PlayerId(), 1.0)
                SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)
            end)
        end,
    },
},

Try if it’s working now. Citizen.CreateThread function is not necessary in this case, as the effect function will be called automatically by ox_inventory.


If you need this kind of support I recommend you move to the section I mentioned below:

sadly it dosen’t work for me when i use the item i get all the animation and the notification but no effect happens

I can fix it in QBCore. I have X in my server.

okay but i use esx btw

That shouldn’t matter, there’s no framework-dependent stuff here as far as I see. Make sure you don’t have some other resource overriding the relevant natives being used, BTW.

– Skrypt do FiveM: xpills
local speedBoostDuration = 30 – czas trwania w sekundach
local speedBoostMultiplier = 1.5 – mnożnik szybkości

RegisterNetEvent(‘xpills:use’)
AddEventHandler(‘xpills:use’, function()
local playerPed = PlayerPedId()
local originalSpeed = GetEntitySpeed(playerPed)

-- Ustawienie nowej szybkości
SetRunSprintMultiplierForPlayer(PlayerId(), speedBoostMultiplier)

-- Czas trwania boosta
Citizen.Wait(speedBoostDuration * 1000)

-- Przywrócenie oryginalnej szybkości
SetRunSprintMultiplierForPlayer(PlayerId(), 1.0)

end)

– Komenda do użycia xpills
RegisterCommand(‘usexpills’, function()
TriggerEvent(‘xpills:use’)
end, false)
here