MadMaximus Posted November 27, 2017 Share Posted November 27, 2017 (edited) I was trying to display images when someone his a marker. it works if there is only 1 script. But when I tried to use two scripts, both markers display the 2nd image. Why is that and how can I fix? check1 = createMarker(3569.400390625, -700.599609375, 72.59, "corona", 2, 0, 0, 0, 0) function MarkerHit5 ( hitPlayer, matchingDimension ) vehicle = getPedOccupiedVehicle ( hitPlayer ) if hitPlayer ~= localPlayer then return end if source == check1 then HandleTheRendering() -- Shows image setTimer ( StopHandling, 10000, 1 ) -- 10 sec timer. 1000 = 1 sec end end addEventHandler("onClientMarkerHit", root, MarkerHit5) local screenWidth,screenHeight = guiGetScreenSize() -- Get screen resolution. function renderDisplay ( ) -- ScreenWidth, ScreenHeight, Pixel X, Pixel Y dxDrawImage ( screenWidth/2 - 200, screenHeight/2 + 200, 400, 100, 'img1.png' ) end function StopHandling ( ) removeEventHandler("onClientRender", root, renderDisplay ) -- Destroys the image end function HandleTheRendering ( ) addEventHandler("onClientRender", root, renderDisplay) -- Makes sure image is shown end check2 = createMarker(3696.3000488281, -694, 60.02, "corona", 2, 0, 0, 0, 0) function MarkerHit5 ( hitPlayer, matchingDimension ) vehicle = getPedOccupiedVehicle ( hitPlayer ) if hitPlayer ~= localPlayer then return end if source == check2 then HandleTheRendering() -- Shows image setTimer ( StopHandling, 10000, 1 ) -- 10 sec timer. 1000 = 1 sec end end addEventHandler("onClientMarkerHit", root, MarkerHit5) local screenWidth,screenHeight = guiGetScreenSize() -- Get screen resolution. function renderDisplay ( ) -- ScreenWidth, ScreenHeight, Pixel X, Pixel Y dxDrawImage ( screenWidth/2 - 200, screenHeight/2 + 200, 400, 100, 'img2.png' ) end function StopHandling ( ) removeEventHandler("onClientRender", root, renderDisplay ) -- Destroys the image end function HandleTheRendering ( ) addEventHandler("onClientRender", root, renderDisplay) -- Makes sure image is shown end Edited November 27, 2017 by MadMaximus Link to comment
Moderators IIYAMA Posted November 27, 2017 Moderators Share Posted November 27, 2017 Make all functions unique. MarkerHit5, renderDisplay, StopHandling, HandleTheRendering And attach this addEventHandler to the marker element(of the file) instead of the root element. addEventHandler("onClientMarkerHit", check2, MarkerHit5) 1 Link to comment
MadMaximus Posted November 27, 2017 Author Share Posted November 27, 2017 5 minutes ago, IIYAMA said: Make all functions unique. MarkerHit5, renderDisplay, StopHandling, HandleTheRendering And attach this addEventHandler to the marker element(of the file) instead of the root element. addEventHandler("onClientMarkerHit", check2, MarkerHit5) Thnx a lot. It works. Thank you so much 1 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