Jump to content

Help! Scipt damage vehicle


Lally

Recommended Posts

Posted

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

 

Posted
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?

Posted
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
Posted

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.

Posted
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
Posted (edited)

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
Posted
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
Posted

I tried and there is no picture. If you look over what I've done is good in the sense that meaning appears disappears just do not adapt the car where you are.

Posted

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
Posted
36 minutes ago, Lally said:

Man're brilliant:eek:. Thank you very much. If I can afford help if I need to give you and talk pm.:x

Np dude, PM me if you need help, maybe I can help you :D

  • Like 1

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