Jump to content

How to add blips to the dxradar?


Recommended Posts

i tried this, but the blips are doesn't show

addEventHandler( "onClientResourceStart", resourceRoot,
	function()

		showPlayerHudComponent("radar", false)
        hudMaskShader = dxCreateShader("hud_mask.fx")
		radarTexture = dxCreateTexture("images/radar.jpg")
		maskTexture1 = dxCreateTexture("images/circle_mask.png")
		localplayerblip = dxCreateTexture("images/arrow.png") -- this is the localplayer blip
		otherplayerblip = dxCreateTexture("images/target.png") -- this is the otherplayer blip

		bAllValid = hudMaskShader and radarTexture and maskTexture1 and localplayerblip and otherplayerblip

		if not bAllValid then
			outputChatBox( "Could not create some things. Please use debugscript 3" )
		else
			dxSetShaderValue( hudMaskShader, "sPicTexture", radarTexture )
			dxSetShaderValue( hudMaskShader, "sMaskTexture", maskTexture1 )
			dxSetShaderValue( hudMaskShader, "lPlayerTexture", localplayerblip )
		end
	end
)

addEventHandler( "onClientRender", root,
    function()
		if not bAllValid then return end
		local x,y = getElementPosition(localPlayer)
		x = ( x ) / 6000
		y = ( y ) / -6000
		dxSetShaderValue( hudMaskShader, "gUVPosition", x,y )
		local _,_,camrot = getElementRotation( getCamera() )
		dxSetShaderValue( hudMaskShader, "gUVRotAngle", math.rad(-camrot) )
		dxDrawImage( 30, 650, 300, 250, hudMaskShader, 0,0,0, tocolor(255,255,255,230) )
    end
)

how to create blips? :| 

sorry for my bad english

Link to comment

I don't know but i think...

local r,g,b = math.random(255),math.random(255),math.random(255)
  for _,player in ipairs(getElementsByType("player")) do    createBlipAttachedTo(player,0,2,r,g,b)

 

Edited by Function
Link to comment
6 minutes ago, Function said:

I don't know but i think...


function blips()
local r,g,b = math.random(255),math.random(255),math.random(255)
  for _,player in ipairs(getElementsByType("player")) do
    createBlipAttachedTo(player,0,2,r,g,b)
  end
end

 

doesn't working :/ 

Link to comment

If you created the script yourself you will have to write script that takes care of the blips (and radar areas too I guess).
You will have to do something like this:

	local blips = getElementsByType( "blip" )
	for i, blip in ipairs(blips) do
		local x, y, _ = getElementPosition( blip )
		local v = 0
  		dxDrawImageSection( x, y, 10, 10, 0, v, 16, 16, blipTexture )
	end

This is assuming that you have a sprite with all blips, which seems like a good idea to me.
Also you will need to calculate the V position based on the ID the blip is, if the blip has a color you might want to take that into account etc.

Oh and of course you will need a render target so the radar map can be updated by dx drawing on it.

Edited by 3aGl3
Link to comment
20 hours ago, 3aGl3 said:

If you created the script yourself you will have to write script that takes care of the blips (and radar areas too I guess).
You will have to do something like this:


	local blips = getElementsByType( "blip" )
	for i, blip in ipairs(blips) do
		local x, y, _ = getElementPosition( blip )
		local v = 0
  		dxDrawImageSection( x, y, 10, 10, 0, v, 16, 16, blipTexture )
	end

This is assuming that you have a sprite with all blips, which seems like a good idea to me.
Also you will need to calculate the V position based on the ID the blip is, if the blip has a color you might want to take that into account etc.

Oh and of course you will need a render target so the radar map can be updated by dx drawing on it.

ahh, i don't understand this :( how? :| 

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