Jump to content

[HELP] F11 Map


India

Recommended Posts

I tried to add RadarAreas (greenzones) on Map, but i couldn't do, anyone can help me?

 

Width, Height = guiGetScreenSize()
IsVisible = false
Alpha = 205
Zoom = 1
mapH = Height
lBlip = false

function drawBlips()
	for k,v in ipairs(getElementsByType("blip")) do
		if not getElementData(v,"DoNotDrawOnMaximap") then
			local icon=getBlipIcon(v) or 0
			local size=(getBlipSize(v) or 2)*4
			local r,g,b,a=getBlipColor(v)
			
			if icon~=0 then
				r,g,b,a=255,255,255,240
				size=20
			end
			
			local x,y,z=getElementPosition(v)
			x,y=getMapFromWorldPosition(x,y)
			
			local halfsize=size/2
			
			dxDrawImage(x-halfsize,y-halfsize,size,size,"images/blips/"..icon..".png",0,0,0,tocolor(r,g,b,a),true)
		end
	end
end

function dxDrawMap()
	if getElementData(localPlayer,"logedin") then
		if getElementData(localPlayer,"Harita") <= 0 then
			startDxmap()
		end
		dxDrawImage((Width/2)-(mapH/2), ((Height-mapH)/2),mapH, mapH,"data/world.png",0,0,0,tocolor(255, 255, 255, Alpha))
		for _, blip in ipairs(getElementsByType('blip')) do
			local blipX, blipY, blipZ = getElementPosition(blip)
			local dx = (((blipX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
			local dy = mapH - (((blipY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
			if getBlipIcon(blip) == 0 then
				if getElementAttachedTo(blip) ~= localPlayer then
					red, green, blue, alpha = getBlipColor(blip)
					dxDrawImage(dx-8,dy-8,16,16,"data/blips/0.png",0,0,0,tocolor(red,green,blue,alpha))
				end
			elseif getBlipIcon(blip) == 41 then
				dxDrawImage(dx-12,dy-12,24,24,"data/blips/label.png",0,0,0,tocolor(25, 25, 255, 255))
			else
				dxDrawImage(dx-8,dy-8,16,16,"images/blips/"..getBlipIcon(blip)..".png")
			end
		end
		for _, player in ipairs(getElementsByType("player")) do
			if getElementData(player,"logedin") then
				if player == localPlayer then
					local blipX, blipY, blipZ = getElementPosition(localPlayer)
					rx,ry,rz = getElementRotation(localPlayer)
					local dx = (((blipX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
					local dy = mapH - (((blipY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
					dxDrawImage(dx-11,dy-11,22,22,"data/blips/2.png", -rz,0,0,tocolor(255, 25, 25, 255))
				elseif ((getElementData(localPlayer,"gang") == getElementData(player,"gang") and getElementData(player,"gang") ~= "None") or ((getElementData(localPlayer,"gang") == "TRZ" or getElementData(localPlayer,"gang") == "Türkiye'DayZ") and getElementData(localPlayer,"gang_leader") == "leader")) and player ~= localPlayer  then
					local blipX, blipY, blipZ = getElementPosition(player)
					rx,ry,rz = getElementRotation(player)
					local dx = (((blipX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
					local dy = mapH - (((blipY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
					local text = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")
					-- dxDrawImage(dx-6,dy-6,12,12,"data/blips/0.png", -rz,0,0,tocolor(50, 220, 50, 220))
					dxDrawRectangle(dx, dy+10,dxGetTextWidth(tostring(text), 1, "default")+6,dxGetFontHeight(1, "default"),tocolor(0,0,0,50))
					dxDrawText(tostring(text),dx+3, dy+11,dxGetTextWidth(tostring(text), 1, "default"),dxGetFontHeight(1, "default"),tocolor(255,255,255),1,"default")
				elseif (getElementData(player,"gang") == getElementData(localPlayer,"alliance")) and (getElementData(player,"alliance") == getElementData(localPlayer,"gang")) then
					local blipX, blipY, blipZ = getElementPosition(player)
					rx,ry,rz = getElementRotation(player)
					local dx = (((blipX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
					local dy = mapH - (((blipY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
					local text = string.gsub(getPlayerName(player), "#%x%x%x%x%x%x", "")
					-- dxDrawImage(dx-6,dy-6,12,12,"data/blips/0.png", -rz,0,0,tocolor(220, 220, 50, 220))
					dxDrawRectangle(dx, dy+10,dxGetTextWidth(tostring(text), 1, "default")+6,dxGetFontHeight(1, "default"),tocolor(0,0,0,50))
					dxDrawText(tostring(text),dx+3, dy+11,dxGetTextWidth(tostring(text), 1, "default"),dxGetFontHeight(1, "default"),tocolor(255,255,255),1,"default")
				end
			end
		end
		local text = "Sağ Tık - İmlec Göster      Sol Tık - İşaretle     Harita Açmak/Kapatmak Için /openmap [F11]"
		dxDrawText(text,((Width/2)+20)-200, (Height-10),100,Height,tocolor(0,0,0),1,"default-bold","left","center",false,false,false)
		dxDrawText(text,((Width/2)+22)-200, (Height-12),100,Height,tocolor(255,255,255),1,"default-bold","left","center",false,false,false)
	end
end

function alphaMapUp()
	if Alpha >= 0 then
		Alpha = Alpha + 50
		if Alpha > 255 then Alpha = 255 end
	else
		Alpha = 0
	end
end
bindKey("num_div","down",alphaMapUp)

function alphaMapDown()
	if Alpha <= 255 then
		Alpha = Alpha - 50
		if Alpha < 0 then Alpha = 0 end
	else
		Alpha = 255
	end
end
bindKey("num_mul","down",alphaMapDown)

function setCursorUp() showCursor(true) end
function setCursorDown() showCursor(false) end

function onClickOffect(button, state, cursorX, cursorY)
	if IsVisible then
		if (button == 'left' and state == 'down') then
			if isElement(lBlip) then
				destroyElement(lBlip)
				setElementData(localPlayer,"labelBlip",nil)
				lBlip = false
				return
			end
			mX = ((cursorX-((Width/2)-(mapH/2))-(mapH/2))*6000)/mapH
			mY = ((mapH-cursorY-(mapH/2))*6000)/mapH
			setElementData(localPlayer,"labelBlip",{mX,mY,getGroundPosition(mX,mY,1000)})
			lBlip = createBlip (mX, mY, 300, 41)
		end
	end
end

function createMapDot(x,y,z)
	if isElement(lBlip) then
		destroyElement(lBlip)
		setElementData(localPlayer,"labelBlip",nil)
		lBlip = false
	end
	setElementData(localPlayer,"labelBlip",{x,y,getGroundPosition(x,y,1000)})
	lBlip = createBlip (x,y, 300, 41)
end
addEvent( "createMapDot", true )
addEventHandler( "createMapDot", localPlayer, createMapDot )
shwochat = false
function startDxmap()
	if not getElementData(localPlayer,"logedin") then return end
	if (getElementData(localPlayer,"Harita") or 0) > 0 then
		IsVisible = not IsVisible
		if (IsVisible) then
			--bindKey("mouse1","down",setPoint)
			bindKey("mouse2","down",setCursorUp)
			bindKey("mouse2","up",setCursorDown)
			addEventHandler('onClientRender', root,dxDrawMap)
			addEventHandler('onClientClick', root,onClickOffect)
			if isChatVisible() then
				showChat(false)
				shwochat = true
			end
		else
			--unbindKey("mouse1","down",setPoint)
			unbindKey("mouse2","down",setCursorUp)
			unbindKey("mouse2","up",setCursorDown)
			removeEventHandler('onClientRender', root,dxDrawMap)
			showCursor(false)
			removeEventHandler('onClientClick', root,onClickOffect)
			if shwochat then
				showChat(true)
				shwochat = false
			end
		end
	end
end
bindKey("F11","down",startDxmap)
addCommandHandler("openmap",startDxmap)

function zoomMap(key)
	if IsVisible then
		if key == "num_add" then
			Zoom = Zoom+0.1
			if Zoom >= 1.9 then
				Zoom = 1.9
			end
		elseif key == "num_sub" then
			Zoom = Zoom-0.1
			if Zoom <= 0.1 then
				Zoom = 0.1
			end
		end
		mapH = Height * Zoom
	end
end
bindKey("num_add","down",zoomMap)
bindKey("num_sub","down",zoomMap)

 

Link to comment
  • Moderators
for _, area in ipairs(getElementsByType('radararea')) do
    local areaX, areaY = getElementPosition(area)
    local sizeX, sizeY = getRadarAreaSize(area)
    local dx = (((areaX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
    local dy = mapH - (((areaY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
    local dendx = ((((areaX+sizeX)*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
    local dendy = mapH - ((((areaY+sizeY)*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
    local red,green,blue,alpha = getRadarAreaColor(area)
    dxDrawRectangle(dx, dy, dendx-dx, dendy-dy, tocolor(red,green,blue,alpha))
end

Should look like something like that, based on the blip's one.

  • Thanks 1
Link to comment
10 hours ago, Patrick said:

for _, area in ipairs(getElementsByType('radararea')) do
    local areaX, areaY = getElementPosition(area)
    local sizeX, sizeY = getRadarAreaSize(area)
    local dx = (((areaX*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
    local dy = mapH - (((areaY*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
    local dendx = ((((areaX+sizeX)*mapH)/6000)+(mapH/2))+((Width/2)-(mapH/2))
    local dendy = mapH - ((((areaY+sizeY)*mapH)/6000)+(mapH/2))+((Height-mapH)/2)
    local red,green,blue,alpha = getRadarAreaColor(area)
    dxDrawRectangle(dx, dy, dendx-dx, dendy-dy, tocolor(red,green,blue,alpha))
end

Should look like something like that, based on the blip's one.

Thanks ❤️

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