Jump to content

[HELP] Drug script error


Galactix

Recommended Posts

Hello, I made a script that makes a command (/useheroin) which uses the heroin drug and give 200 max hp to the player aswell as Healing him for 60 seconds. However I'm having the issue where if two players use the command in less than 60 seconds, one of them won't get their health set back to 100.

--HEROIN DRUG EFFECT ON
function heroinDrugOn(player)
    theDrugPlayer = player
	setPedStat ( player, 24, 1000)
	setTimer(heroinDrugOff, 60000,1)
	setElementHealth(player, 200)
	triggerClientEvent ( theDrugPlayer, "heroinOnMessage", root)

end
addCommandHandler("useheroin", heroinDrugOn)

--HEROIN DRUG EFFECT GOING OFF
function heroinDrugOff(client)
		local playerHealth = getElementHealth(theDrugPlayer)

		if (playerHealth > 100) then			
				setPedStat (theDrugPlayer, 24, 590)
				setElementHealth(theDrugPlayer, 100)
			else
				setPedStat (theDrugPlayer, 24, 590)
				setElementHealth(theDrugPlayer, playerHealth)
				end
		triggerClientEvent ( theDrugPlayer, "heroinOffMessage", root)
end

 

Link to comment
  • Moderators

 

--HEROIN DRUG EFFECT ON
function heroinDrugOn(player)
	setPedStat ( player, 24, 1000)
	setElementHealth(player, 200)
	setTimer(heroinDrugOff, 60000, 1, player)
	triggerClientEvent ( player, "heroinOnMessage", root)
end
addCommandHandler("useheroin", heroinDrugOn)

--HEROIN DRUG EFFECT GOING OFF
function heroinDrugOff(player)
    local playerHealth = getElementHealth(player)

    if (playerHealth > 100) then
        setElementHealth(player, 100)
    end
    setPedStat (player, 24, 590)
    triggerClientEvent ( player, "heroinOffMessage", root)
end

 

Edited by Patrick2562
  • Thanks 1
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...