Jump to content

Burning Car blip


gerlachmax123

Recommended Posts

Posted

No, when its burning...

local vehicleBlipRoot = createElement("vehicleBlipRoot", "vehicleBlipRoot") 
  
  
local function resourceStart() 
    for _, vehicle in ipairs(getElementsByType("vehicle"), root, true) do 
        if vehicle ~= getPedOccupiedVehicle(localPlayer) then 
            if isismafia ( player ) then 
                if getElementHealth( vehicle ) < 255 then 
                    local blip = createBlipAttachedTo(vehicle, 0, 1, 150, 150, 150, 255, -10, 300) 
                    setElementParent(blip, vehicleBlipRoot) 
                end 
            end 
        end 
    end 
end 
addEventHandler("onClientResourceStart", root, resourceStart) 
  
  
local function streamOut() 
    for _, blip in ipairs(getElementChildren(vehicleBlipRoot)) do 
        if getElementAttachedTo(blip) == source then 
            destroyElement(blip) 
        end 
    end 
    removeEventHandler("onClientElementStreamOut", source, streamOut) 
    removeEventHandler("onClientElementDestroy", source, streamOut) 
end 
  
  
local function streamIn() 
    if getElementType(source) ~= "vehicle" then 
        return 
    end 
     
  
    for _, blip in ipairs(getElementChildren(vehicleBlipRoot)) do 
        if getElementAttachedTo(blip) == source then 
            return 
        end 
    end 
     
    if ismafia ( player ) then 
    if getElementHealth( vehicle ) < 255 then 
    local blip = createBlipAttachedTo(source, 0, 1, 150, 150, 150, 255, -10, 300) 
    setElementParent(blip, vehicleBlipRoot) 
    addEventHandler("onClientElementStreamOut", source, streamOut) 
    addEventHandler("onClientElementDestroy", source, streamOut) 
    end 
    end 
end 
addEventHandler("onClientElementStreamIn", root, streamIn) 

In this Script, there will be no blip, when its burning,.. why?

Posted (edited)
-- Server Side 
local blips = { } 
local vehicleBlipRoot = createElement ( "vehicleBlipRoot", "vehicleBlipRoot" ) 
  
function checkVehicles ( ) 
    local player = getVehicleOccupant ( source ) 
    local controller = getVehicleController ( source ) 
    if blips [ source ] then return end 
    if player ~= controller then 
        if isismafia ( player ) then 
            if getElementHealth ( source ) < 255 then 
                blips [ source ] = createBlipAttachedTo ( source, 0, 1, 150, 150, 150, 255, -10, 300 ) 
                setElementParent ( blips [ source ], vehicleBlipRoot ) 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleDamage", root, checkVehicles ) 

If does not Work.

Put Your Full Code !

Edited by Guest
Posted
-- Server Side 
local vehicleBlipRoot = createElement ( "vehicleBlipRoot", "vehicleBlipRoot" ) 
  
function checkVehicles ( ) 
    local player = getVehicleOccupant ( source ) 
    local controller = getVehicleController ( source ) 
    if player ~= controller then 
        if isismafia ( player ) then 
            if getElementHealth ( source ) < 255 then 
                local blip = createBlipAttachedTo ( vehicle, 0, 1, 150, 150, 150, 255, -10, 300 ) 
                setElementParent ( blip, vehicleBlipRoot ) 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleDamage", root, checkVehicles ) 

If does not Work.

Put Your Full Code !

You need to check if the vehicle has a blip already attached to it. Otherwise you will be attaching blips every time vehicle gets damaged once on fire.

Posted
You need to check if the vehicle has a blip already attached to it. Otherwise you will be attaching blips every time vehicle gets damaged once on fire.

Hmmm, It's my fault Check My Code Again.

Posted

No, there is no blip, when a vehicle is burning...

I have it serverside:

-- Server Side 
local blips = { } 
local vehicleBlipRoot = createElement ( "vehicleBlipRoot", "vehicleBlipRoot" ) 
  
function checkVehicles ( ) 
    local player = getVehicleOccupant ( source ) 
    local controller = getVehicleController ( source ) 
    if blips [ source ] then return end 
    if player ~= controller then 
        if isfeuerwehr ( player ) then 
            if getElementHealth ( source ) < 255 then 
                blips [ source ] = createBlipAttachedTo ( source, 0, 1, 150, 150, 150, 255, -10, 300 ) 
                setElementParent ( blips [ source ], vehicleBlipRoot ) 
            end 
        end 
    end 
end 
addEventHandler ( "onVehicleDamage", root, checkVehicles ) 

Posted

So its working client:

barricadeFactions = { [10]=true } 
vehicleBlips = {} 
  
addEventHandler( "onClientElementStreamIn", getRootElement(), 
    function() 
        if getElementType( source ) == "vehicle" then 
            if getElementHealth ( source ) < 255 then 
                if barricadeFactions[getElementData ( lp, "fraktion" )] then 
                    setTimer( 
                        function( v ) 
                            vehicleBlips[v] = createBlipAttachedTo( v, 0, 1, 200, 200, 200, 150, 0 ) 
                        end, 
                    100, 1, source ) 
                end 
            end 
        end 
    end 
) 
  
addEventHandler( "onClientElementStreamOut", getRootElement(), 
    function() 
        if getElementType( source ) == "vehicle" then 
            if vehicleBlips[source] then 
                destroyElement( vehicleBlips[source] ) 
                vehicleBlips[source] = nil 
            end 
        end 
    end 
) 

Thank you :D

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