gerlachmax123 Posted February 8, 2013 Share Posted February 8, 2013 How i create Blips on the radar, when a car is burning? Link to comment
iPrestege Posted February 8, 2013 Share Posted February 8, 2013 onVehicleExplode createBlip Link to comment
gerlachmax123 Posted February 8, 2013 Author Share Posted February 8, 2013 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? Link to comment
3NAD Posted February 8, 2013 Share Posted February 8, 2013 Because this Function will start only one time ' onClientResourceStart ' So, Use : "onVehicleDamage" or setTimer Link to comment
gerlachmax123 Posted February 8, 2013 Author Share Posted February 8, 2013 I dont know what you mean.. I must create it serverside, or? Link to comment
3NAD Posted February 8, 2013 Share Posted February 8, 2013 (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 February 8, 2013 by Guest Link to comment
50p Posted February 8, 2013 Share Posted February 8, 2013 -- 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. Link to comment
3NAD Posted February 8, 2013 Share Posted February 8, 2013 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. Link to comment
gerlachmax123 Posted February 8, 2013 Author Share Posted February 8, 2013 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 ) Link to comment
gerlachmax123 Posted February 8, 2013 Author Share Posted February 8, 2013 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 Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now