Jump to content

[HELP]Display Images


MadMaximus

Recommended Posts

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 by MadMaximus
Link to comment
  • Moderators

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)

 

  • Thanks 1
Link to comment
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 

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