Jump to content

Help! Scipt damage vehicle


Lally

Recommended Posts

Hello community!
I myself need a little help. I like when the car has 300 hp appear as an icon on the screen as the kicker motor. But I can not find the wiki community.
Here is what I tried to do:

Quote

function createSpeedo()
    cars = getElementsByType("vehicle",root,true)
    for num, car in ipairs(cars) do
       local dividedCarHealth = getElementHealth(car) / 10
        local motor = math.floor(getElementHealth(car))
        if motor > 500 then
            dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png")
            ax = ax - 34
        end
    end
end

 

Link to comment
7 minutes ago, Lally said:

Hello community!
I myself need a little help. I like when the car has 300 hp appear as an icon on the screen as the kicker motor. But I can not find the wiki community.
Here is what I tried to do:

 

Is there's anything comes up in debugscript 3?

Link to comment
function createSpeedo()
    cars = getElementsByType("vehicle",root,true)
    for num, car in ipairs(cars) do
       local carHP = math.floor(getElementHealth(car) / 10)
        if carHP < 500 then
            dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png")
            ax = ax - 34
        end
    end
end

 

  • Like 1
Link to comment
1 hour ago, Lally said:

Thank you very much! But now I have another problem. Gender car if I stay out of the picture and not get rid of it until you are back in that car hp. If you can help me with this problem.

Here you go.

function createSpeedo()
    cars = getElementsByType("vehicle",root,true)
    for num, car in ipairs(cars) do
       local carHP = math.floor(getElementHealth(car) / 10)
       if carHP < 500 then
            local theVehicle = getPedOccupiedVehicle(getLocalPlayer())
            if theVehicle then
                dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png")
                ax = ax - 34
            end
        end
    end
end

 

Or try this one, it's more simple and more efective.

function createSpeedo()
    local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) -- Check if the player is in Vehicle, if he is not in any vehicle then it will return false
    if theVehicle then -- If true (the player is in his Vehicle), this argument will pass this block and execute the code below
        local carHP = math.floor(getElementHealth(theVehicle) / 10)
        if carHP < 500 then
            dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png")
            ax = ax - 34
        end
    end
end

 

  • Like 1
Link to comment

When leaving the car damaged the image disappears but when I climb into another car appears to me that it is not damaged though. I did something but nush if you can help solve the problem

cars = getElementsByType("vehicle",root,true)
for num, car in ipairs(cars) do
	local carHP = math.floor (getElementHealth(car))
	if carHP < 640 then
		local getTickStart = getTickCount ()
		getTickStart = math.floor(getTickStart / 1000)
		if math.mod(getTickStart, 2) == 0 then
			local masina = getPedOccupiedVehicle(getLocalPlayer())
			if masina then
		dxDrawImage( screenWidth - 200, 970,32,37,"images/hud/accident.png")
		ax = ax - 34
			end
		end
	end
end

 

Edited by Lally
Link to comment
15 minutes ago, Lally said:

When leaving the car damaged the image disappears but when I climb into another car appears to me that it is not damaged though. I did something but nush if you can help solve the problem


cars = getElementsByType("vehicle",root,true)
for num, car in ipairs(cars) do
	local carHP = math.floor (getElementHealth(car))
	if carHP < 640 then
		local getTickStart = getTickCount ()
		getTickStart = math.floor(getTickStart / 1000)
		if math.mod(getTickStart, 2) == 0 then
			local masina = getPedOccupiedVehicle(getLocalPlayer())
			if masina then
		dxDrawImage( screenWidth - 200, 970,32,37,"images/hud/accident.png")
		ax = ax - 34
			end
		end
	end
end

 

Yes because you are looping all vehicles that streamed by client.

Try this.

function createSpeedo()
    local theVehicle = getPedOccupiedVehicle(getLocalPlayer()) -- Check if the player is in Vehicle, if he is not in any vehicle then it will return false
    if theVehicle then -- If true (the player is in his Vehicle), this argument will pass this block and execute the code below
        local carHP = math.floor(getElementHealth(theVehicle) / 10)
        if carHP < 500 then
            dxDrawImage( screenWidth - 200, 32,32,37,"images/hud/damage.png")
            ax = ax - 34
        end
    end
end

 

  • Like 1
Link to comment

Try this.

cars = getElementsByType("vehicle",root,true)
for num, car in ipairs(cars) do
	local carHP = math.floor (getElementHealth(car))
	if carHP < 640 then
		local getTickStart = getTickCount ()
		getTickStart = math.floor(getTickStart / 1000)
		if math.mod(getTickStart, 2) == 0 then
			local masina = getPedOccupiedVehicle(getLocalPlayer())
			if masina then
        		if masina == car then
                  dxDrawImage( screenWidth - 200, 970,32,37,"images/hud/accident.png")
                  ax = ax - 34
          		end
			end
		end
	end
end

 

  • Like 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...