Jump to content

BLIP GPS AJUDA


Recommended Posts

Pessoal preciso da ajuda de vocês, estou com um problema no meu gps, estou fazendo de tudo, mais os blips não aparecem nele, queria que os blips do mapa mostrasse nele, unico blip que mostra nele é o do player, alguem poderia me ajudar, desde ja agradeço a atenção de todos! <3 

 

local sW,sH = guiGetScreenSize();
local worldW,worldH = 3072/2,3072/2;
local blip = 25;

local rt = dxCreateRenderTarget(180,130);

local frameW,frameH = 210,200;
local gpsW,gpsH = 168,120;
local xOffset = 3;

function findRotation(x1,y1,x2,y2)
	local t = -math.deg(math.atan2(x2-x1,y2-y1));
	if (t < 0) then t = t+360 end;
	return t;
end

function getPointFromDistanceRotation(x, y, dist, angle)
	local a = math.rad(90-angle);
	local dx = math.cos(a)*dist;
	local dy = math.sin(a)*dist;
	return x+dx, y+dy;
end

addEventHandler("onClientRender",root,function()
	if (getElementData(localPlayer,"logedin") and getElementData(localPlayer,"GPS") >= 1) then
		if exports.e_map:isPlayerMapVisible() then return; end
		local mW,mH = dxGetMaterialSize(rt);
		local camX,camY,camZ = getElementRotation(getCamera());
		local playerX,playerY,playerZ = getElementRotation(localPlayer);
		local x,y = getElementPosition(localPlayer);
		local xx,yy = mW/2-(x/(6000/worldW)), mH/2+(y/(6000/worldH));
		local xFactor,yFactor = 15,sH-frameH+23;
		local cX, cY = gpsW/2+xFactor, gpsH/2+yFactor;
		dxSetRenderTarget(rt,true);
		dxDrawRectangle(0, 0, mW, mH, 0xFF7CA7D1);
		dxDrawImage(xx-worldW/2,yy-worldH/2+20,worldW,worldH,"images/world.jpg",camZ,(x/(6000/worldW)),-(y/(6000/worldH)));
		--outputChatBox("x: "..(mW/2-(x/3072)).." y: "..(mH/2-(y/3072)))
		dxDrawImage(mW/2-(x/3072)-(blip/2),mH/2-(y/3072)-(blip/2)+20,blip,blip, "images/player.png", camZ-playerZ, 0, 0, tocolor(255, 0, 0, 255));
		dxSetRenderTarget();
		dxDrawImage(xOffset+6+xFactor,yFactor,gpsW,gpsH,rt);
		local toLeft, toTop, toRight, toBottom = cX-gpsW, cY-gpsH, cX+gpsW, cY+gpsH;
		for _,v in ipairs(getElementsByType("player")) do
			local gang = getElementData(localPlayer,"gang") or "None";
			if (gang ~= "None") then
				if (getElementData(v, "gang") == gang and v ~= localPlayer and not getElementData(v, "isDead")) then
				for k, v in ipairs(getElementsByType("blip")) do
					local px, py, pz = getElementPosition(localPlayer)	
						local _,_,camZ = getElementRotation(getCamera())			
						local bx, by, bz = getElementPosition(v)
						local actualDist = getDistanceBetweenPoints2D(px, py, bx, by)
						local maxDist = getBlipVisibleDistance(v)
						if ( actualDist <= maxDist ) then
							local dist = actualDist/(6000/((worldW+worldH)/2))
							local rot = findRotation(bx, by, px, py)-camZ
							local bpx, bpy = getPointFromDistanceRotation(cX, cY, dist, rot)
							local bpx = math.max(lB, math.min(rB, bpx))
							local bpy = math.max(tB, math.min(bB, bpy))
							local blipID = getElementData(v, "customIcon") or getBlipIcon(v)
							local _, _, _, bcA = getBlipColor(v)
							local bcR, bcG, bcB = 255, 255, 255
							if getBlipIcon(v) == 0 then
								bcR, bcG, bcB = getBlipColor(v)
							end
							local bUD = "img/blip.png"
							if (bz - pz) >= 5 then
								bUD = "img/blip_up.png"
							elseif (bz - pz) <= -5 then
								bUD = "img/blip_down.png"
							end				
							local bS = getBlipSize(v)
							dxDrawImage(bpx -(blip*bS)*sW/2, bpy -(blip*bS)*sH/2, (blip*bS)*sW, (blip*bS)*sH, "img/blips/"..blipID..".png", 0, 0, 0, tocolor(bcR, bcG, bcB, bcA))
						--dxDrawImage(bpx-(blip/2+5), bpy, blip+10, blip+10, "images/players.png", 0, 0, 0, tocolor(0, 0, 255, 100));
						dxDrawImage(bpx-(blip/2)+xOffset+6, bpy+5, blip, blip, "images/player.png", camZ-ppZ, 0, 0, tocolor(0, 0, 255, 255));
						if ( renderNorthBlip ) then
						local _,_,camZ = getElementRotation(getCamera())		
						local toLeft, toTop, toRight, toBottom = cX-lB, cY-tB, rB-cX, b-cY
						local bpx, bpy = getPointFromDistanceRotation(cX, cY, math.sqrt(toTop^2 + toLeft^2), -camZ+180)
						local bpx = math.max(lB, math.min(rB, bpx))
						local bpy = math.max(tB, math.min(bB, bpy))
						dxDrawImage(bpx -(blip*2)/2, bpy -(blip*2)/2, blip*2, blip*2, "img/blips/4.png", 0, 0, 0)
					end
					-- local _,_,camZ = getElementRotation(getCamera())
					-- dxDrawImage(cX -(blip*1.5)*sW/2, cY -(blip*1.5)*sH/2, (blip*1.5)*sW, (blip*1.5)*sH, "img/player.png", camZ-rz, 0, 0)
					end
				end
			end
		end
		dxDrawImage(xOffset,sH-frameH,frameW,frameH,"images/gps.png");
	   end
	end
end);

 

Link to post

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