Jump to content

TargetBox enemy radar thing


Charan

Recommended Posts

thanks ill try

5 minutes ago, Fist said:

getElementsByType("player")
getPedOccupiedVehicle
dxDrawLine

if i wont be too lazy i will edit this topic and put fully working code. :D

it doesn't work bro

Spoiler

[2017-04-25 23:38:58] start: Requested by Console
[2017-04-25 23:38:58] Starting dxdrawline
[2017-04-25 23:38:58] SCRIPT ERROR: dxdrawline\client.lua:3: '=' expected near 'dxDrawLine'
[2017-04-25 23:38:58] ERROR: Loading script failed: dxdrawline\client.lua:3: '=' expected near 'dxDrawLine'
[2017-04-25 23:38:58] start: Resource 'dxdrawline' started


 

Link to comment
40 minutes ago, Charan said:

thanks ill try

it doesn't work bro

  Reveal hidden contents

[2017-04-25 23:38:58] start: Requested by Console
[2017-04-25 23:38:58] Starting dxdrawline
[2017-04-25 23:38:58] SCRIPT ERROR: dxdrawline\client.lua:3: '=' expected near 'dxDrawLine'
[2017-04-25 23:38:58] ERROR: Loading script failed: dxdrawline\client.lua:3: '=' expected near 'dxDrawLine'
[2017-04-25 23:38:58] start: Resource 'dxdrawline' started


 

sorry for late reply, here you go i wrote it. Tested and its working.

local playerColors = {} -- player color table
local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value)

-- this will get random color for every player (you can use your own system if you want to)
function addNewPlayerColor(player)
	playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255))
end

for _,player in pairs(getElementsByType("player")) do
	addNewPlayerColor(player)
end

addEventHandler("onClientPlayerJoin",root,function()
	addNewPlayerColor(source)
end)

addEventHandler("onClientPlayerQuit",root,function()
	playerColors[source] = {}
end)
-- this will get random color for every player (you can use your own system if you want to)

addEventHandler("onClientRender",root,function()
	for _,players in pairs(getElementsByType("player")) do
		if (players ~= localPlayer) then -- check or players is not local player
			if (getPedOccupiedVehicle(players) == 520) then -- check or player is on hidra
				local pX,pY,pZ = getElementPosition(players)
				local newX,newY = getScreenFromWorldPosition(pX,pY,pZ)
				local localX,localY,localZ = getElementPosition(localPlayer)
				local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ)
				if (newX and newY and dist >= 500) then -- check or newX newY exists and if dist is over than 500 meters.
					-- this is Rectangle
					dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false)
					dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false)
					-- this is X (center one)
					dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					-- this is player info
					dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025)
				end
			end
		end
	end
end)

 

  • Like 1
Link to comment
Just now, Fist said:

sorry for late reply, here you go i wrote it. Tested and its working.


local playerColors = {} -- player color table
local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value)

-- this will get random color for every player (you can use your own system if you want to)
function addNewPlayerColor(player)
	playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255))
end

for _,player in pairs(getElementsByType("player")) do
	addNewPlayerColor(player)
end

addEventHandler("onClientPlayerJoin",root,function()
	addNewPlayerColor(source)
end)

addEventHandler("onClientPlayerQuit",root,function()
	playerColors[source] = {}
end)
-- this will get random color for every player (you can use your own system if you want to)

addEventHandler("onClientRender",root,function()
	for _,players in pairs(getElementsByType("player")) do
		if (players ~= localPlayer) then -- check or players is not local player
			if (getPedOccupiedVehicle(players) == 520) then -- check or player is on hidra
				local pX,pY,pZ = getElementPosition(players)
				local newX,newY = getScreenFromWorldPosition(pX,pY,pZ)
				local localX,localY,localZ = getElementPosition(localPlayer)
				local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ)
				if (newX and newY and dist >= 500) then -- check or newX newY exists and if dist is over than 500 meters.
					-- this is Rectangle
					dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false)
					dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false)
					-- this is X (center one)
					dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					-- this is player info
					dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025)
				end
			end
		end
	end
end)

 

You are a legend omg thank you

Link to comment
Just now, Charan said:

ehm i found a error... 

is this bad or should i ignore it? [2017-04-26 00:19:59] ERROR: dxdrawline\client.lua:6: attempt to call global 'tocolor' (a nil value)

 

 

idk i didn't have this error, i think its not my side of code and i accidently put greater than 500 distance to show that target :D

to fix it change this

if (newX and newY and dist >= 500) then -- check or newX newY exists and if dist is over than 500 meters.

to this

if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters.

 

Link to comment
1 minute ago, Fist said:

idk i didn't have this error, i think its not my side of code and i accidently put greater than 500 distance to show that target :D

to fix it change this


if (newX and newY and dist >= 500) then -- check or newX newY exists and if dist is over than 500 meters.

to this


if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters.

 

tried but till error , idk if it works because right now i don't have anyone to test it with :/ 

Link to comment
1 minute ago, Charan said:

tried but till error , idk if it works because right now i don't have anyone to test it with :/ 

you can just comment those parts of code that checks or if "players" is local player and you will be able to see on yourself it.

this version is that you have to use for everyone so it doesn't show yourself while you are doing it.

local playerColors = {} -- player color table
local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value)

-- this will get random color for every player (you can use your own system if you want to)
function addNewPlayerColor(player)
	playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255))
end

for _,player in pairs(getElementsByType("player")) do
	addNewPlayerColor(player)
end

addEventHandler("onClientPlayerJoin",root,function()
	addNewPlayerColor(source)
end)

addEventHandler("onClientPlayerQuit",root,function()
	playerColors[source] = {}
end)
-- this will get random color for every player (you can use your own system if you want to)

addEventHandler("onClientRender",root,function()
	for _,players in pairs(getElementsByType("player")) do
		if (players ~= localPlayer) then -- check or players is not local player
			if (getPedOccupiedVehicle(players) == 520) then -- check or player is on hidra
				local pX,pY,pZ = getElementPosition(players)
				local newX,newY = getScreenFromWorldPosition(pX,pY,pZ)
				local localX,localY,localZ = getElementPosition(localPlayer)
				local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ)
				if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters.
					-- this is Rectangle
					dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false)
					dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false)
					-- this is X (center one)
					dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					-- this is player info
					dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025)
				end
			end
		end
	end
end)

and this is that it works even with yourself

local playerColors = {} -- player color table
local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value)

-- this will get random color for every player (you can use your own system if you want to)
function addNewPlayerColor(player)
	playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255))
end

for _,player in pairs(getElementsByType("player")) do
	addNewPlayerColor(player)
end

addEventHandler("onClientPlayerJoin",root,function()
	addNewPlayerColor(source)
end)

addEventHandler("onClientPlayerQuit",root,function()
	playerColors[source] = {}
end)
-- this will get random color for every player (you can use your own system if you want to)

addEventHandler("onClientRender",root,function()
	for _,players in pairs(getElementsByType("player")) do
		--if (players ~= localPlayer) then -- check or players is not local player
			--if (getPedOccupiedVehicle(players) == 520) then -- check or player is on hidra
				local pX,pY,pZ = getElementPosition(players)
				local newX,newY = getScreenFromWorldPosition(pX,pY,pZ)
				local localX,localY,localZ = getElementPosition(localPlayer)
				local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ)
				if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters.
					-- this is Rectangle
					dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false)
					dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false)
					-- this is X (center one)
					dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					-- this is player info
					dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025)
				end
			--end
		--end
	end
end)

 

Edited by Fist
Link to comment
6 minutes ago, Charan said:

k ill let you know if it works

i made little mistake on getPedOccupiedVehicle i thought that it returns vehicle id but it returns vehicle userdata, so this is last and fully working code. Here you go dude. enjoy :D

local playerColors = {} -- player color table
local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value)

-- this will get random color for every player (you can use your own system if you want to)
function addNewPlayerColor(player)
	playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255))
end

for _,player in pairs(getElementsByType("player")) do
	addNewPlayerColor(player)
end

addEventHandler("onClientPlayerJoin",root,function()
	addNewPlayerColor(source)
end)

addEventHandler("onClientPlayerQuit",root,function()
	playerColors[source] = {}
end)
-- this will get random color for every player (you can use your own system if you want to)

addEventHandler("onClientRender",root,function()
	for _,players in pairs(getElementsByType("player")) do
		if (players ~= localPlayer) then -- check or players is not local player
			if (getVehicleName(getPedOccupiedVehicle(players)) == "Hydra") then -- check or player is on hidra
				local pX,pY,pZ = getElementPosition(players)
				local newX,newY = getScreenFromWorldPosition(pX,pY,pZ)
				local localX,localY,localZ = getElementPosition(localPlayer)
				local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ)
				if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters.
					-- this is Rectangle
					dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false)
					dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false)
					-- this is X (center one)
					dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					-- this is player info
					dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025)
				end
			end
		end
	end
end)

 

Link to comment
4 minutes ago, Fist said:

i made little mistake on getPedOccupiedVehicle i thought that it returns vehicle id but it returns vehicle userdata, so this is last and fully working code. Here you go dude. enjoy :D


local playerColors = {} -- player color table
local offset = 100 -- offset of position (this will make rectangle bigger or smaller depending on value)

-- this will get random color for every player (you can use your own system if you want to)
function addNewPlayerColor(player)
	playerColors[player] = tocolor(math.random(255),math.random(255),math.random(255))
end

for _,player in pairs(getElementsByType("player")) do
	addNewPlayerColor(player)
end

addEventHandler("onClientPlayerJoin",root,function()
	addNewPlayerColor(source)
end)

addEventHandler("onClientPlayerQuit",root,function()
	playerColors[source] = {}
end)
-- this will get random color for every player (you can use your own system if you want to)

addEventHandler("onClientRender",root,function()
	for _,players in pairs(getElementsByType("player")) do
		if (players ~= localPlayer) then -- check or players is not local player
			if (getVehicleName(getPedOccupiedVehicle(players)) == "Hydra") then -- check or player is on hidra
				local pX,pY,pZ = getElementPosition(players)
				local newX,newY = getScreenFromWorldPosition(pX,pY,pZ)
				local localX,localY,localZ = getElementPosition(localPlayer)
				local dist = getDistanceBetweenPoints3D(localX,localY,localZ,pX,pY,pZ)
				if (newX and newY and dist <= 500) then -- check or newX newY exists and if dist is over than 500 meters.
					-- this is Rectangle
					dxDrawLine(newX-offset,newY-offset,newX+offset,newY-offset,playerColors[players],5,false)
					dxDrawLine(newX+offset,newY-offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY+offset,newX+offset,newY+offset,playerColors[players],5,false)
					dxDrawLine(newX-offset,newY-offset,newX-offset,newY+offset,playerColors[players],5,false)
					-- this is X (center one)
					dxDrawLine(newX-offset*0.2,newY-offset*0.2,newX+offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					dxDrawLine(newX+offset*0.2,newY-offset*0.2,newX-offset*0.2,newY+offset*0.2,playerColors[players],5,false)
					-- this is player info
					dxDrawText(getPlayerName(players):gsub("#%x%x%x%x%x%x",""),newX-offset,newY+offset*1.1,0,0,playerColors[players],offset*0.025)
				end
			end
		end
	end
end)

 

still no luck mind to give me the (name).zip? also what server version do you use?

Link to comment
2 minutes ago, Charan said:

still no luck mind to give me the (name).zip? also what server version do you use?

what? I'm using latest version and what does that matter with it lol. That latest version won't show local player (yourself) only other players once you are in hydra and if only nearest players that are in radius of 500 meters will be shown. You can change how long distance is in code. 

Link to comment
Just now, Fist said:

what? I'm using latest version and what does that matter with it lol. That latest version won't show local player (yourself) only other players once you are in hydra and if only nearest players that are in radius of 500 meters will be shown. You can change how long distance is in code. 

if i message you tomorrow will you get it?

 

Link to comment
2 minutes ago, Charan said:

if i message you tomorrow will you get it?

 

will i get what? For me works perfect. Btw i think your problem is that you are using this script on server side. That's why it gave you tocolor global error. lol

Put it on CLIENT side

Link to comment
2 minutes ago, Fist said:

will i get what? For me works perfect. Btw i think your problem is that you are using this script on server side. That's why it gave you tocolor global error. lol

Put it on CLIENT side

NVM I FIGURED IT OUT

3 minutes ago, Fist said:

will i get what? For me works perfect. Btw i think your problem is that you are using this script on server side. That's why it gave you tocolor global error. lol

Put it on CLIENT side

k i fixed it 

it now shows no errors now i will test it on my Friend tomorrow

and i will message you but will you receive the message is what im asking

Edited by Charan
Link to comment
  • MTA Anti-Cheat Team

This is the exact script you're asking for (from screenshots).. it's on Community but I can't find because I forgot its title.

function showPlayerSquares()
	if getElementData(getLocalPlayer(), "state.hud") == "disabled" then
	return
	end
local vehicle = getPedOccupiedVehicle(getLocalPlayer())
	if not vehicle then
	return
	end
	if getElementModel(vehicle) == 425 or getElementModel(vehicle) == 476 or getElementModel(vehicle) == 520 then
	
	players = getElementsByType("player")
	
	
	for _, thePlayer in ipairs(players)do
		if thePlayer ~= getLocalPlayer() then
		local x,y,z = getElementPosition(thePlayer)
		local cx,cy,cz = getElementPosition(getLocalPlayer())
		if getDistanceBetweenPoints3D(x,y,z, cx,cy,cz) <= 1000 then
			sX, sY, sZ = getScreenFromWorldPosition(x,y,z)
			if(sX and sY and sZ)then
				
				color = tocolor(getPlayerNametagColor(thePlayer))
				
				dxDrawLine(sX+20, sY+20, sX-20, sY+20,color, 2)
				dxDrawLine(sX+20, sY-20, sX-20, sY-20,color, 2)
				dxDrawLine(sX+20, sY-20, sX+20, sY+20,color, 2)
				dxDrawLine(sX-20, sY-20, sX-20, sY+20,color, 2)
				
				dxDrawText(getPlayerName(thePlayer), sX-20, sY+25, 25, 20, color, 0.9)
				dxDrawText(math.floor(getDistanceBetweenPoints3D(x,y,z, cx,cy,cz)).." m", sX-20, sY+40, 25, 20, color, 0.9)
				
				color = tocolor(255, 255, 255)
				
				x,y,z = getPedBonePosition ( thePlayer, 8)
				x,y = getScreenFromWorldPosition( x, y, z)
					
				x2,y2,z2 = getPedBonePosition ( thePlayer, 2)
				x2,y2 = getScreenFromWorldPosition(x2, y2, z2)
				
				if x and y and x2 and y2 then	
				dxDrawLine(x,y,x2,y2, color, 1.5)
				end
					
				-----------------SHOULDERS-----------------
				
				Hx,Hy,Hz = getPedBonePosition ( thePlayer, 4)
				Hx,Hy = getScreenFromWorldPosition( Hx, Hy, Hz)
					
				Sx2,Sy2,Sz2 = getPedBonePosition ( thePlayer, 22)
				Sx2,Sy2 = getScreenFromWorldPosition(Sx2, Sy2, Sz2)
					
				Sx3,Sy3,Sz3 = getPedBonePosition ( thePlayer, 32)
				Sx3,Sy3 = getScreenFromWorldPosition(Sx3, Sy3, Sz3)
				
				if Hx and Hy and Sx2 and Sy2 then
				dxDrawLine(Hx,Hy,Sx2,Sy2, color, 1.5)
				end
				if Hx and Hy and Sx3 and Sy3 then
				dxDrawLine(Hx,Hy,Sx3,Sy3, color, 1.5)
				end
					
				-----------------UPPER ARMS-----------------
				ERx,ERy,ERz = getPedBonePosition ( thePlayer, 23)
				ERx,ERy = getScreenFromWorldPosition( ERx,ERy,ERz)
				
				ELx,ELy,ELz = getPedBonePosition ( thePlayer, 33)
				ELx,ELy = getScreenFromWorldPosition(ELx,ELy,ELz)
					
				if ERx and ERy and Sx2 and Sy2 then	
				dxDrawLine(ERx,ERy,Sx2,Sy2, color, 1.5)
				end
				if ELx and ELy and Sx3 and Sy3 then
				dxDrawLine(ELx,ELy,Sx3,Sy3, color, 1.5)
				end
					
				-----------------LOWER ARMS-----------------
				HRx,HRy,HRz = getPedBonePosition ( thePlayer, 24)
				HRx,HRy = getScreenFromWorldPosition( HRx,HRy,HRz)
					
				HLx,HLy,HLz = getPedBonePosition ( thePlayer, 34)
				HLx,HLy = getScreenFromWorldPosition(HLx,HLy,HLz)
				
				if ERx and ERy and HRx and HRy then
				dxDrawLine(ERx,ERy,HRx,HRy, color, 1.5)
				end
				if ELx and ELy and HLx and HLy then
				dxDrawLine(ELx,ELy,HLx,HLy, color, 1.5)
				end
				
				-----------------UPPER LEGS-----------------
				KRx,KRy,KRz = getPedBonePosition ( thePlayer, 52)
				KRx,KRy = getScreenFromWorldPosition( KRx,KRy,KRz)
					
				KLx,KLy,KLz = getPedBonePosition ( thePlayer, 42)
				KLx,KLy = getScreenFromWorldPosition(KLx,KLy,KLz)
				
				if x2 and y2 and KRx and KRy then	
				dxDrawLine(x2,y2,KRx,KRy, color, 1.5)
				end
				if x2 and y2 and KLx and KLy then
				dxDrawLine(x2,y2,KLx,KLy, color, 1.5)
				end
					
				-----------------LOWER LEGS-----------------
				LRx,LRy,LRz = getPedBonePosition ( thePlayer, 53)
				LRx,LRy = getScreenFromWorldPosition( LRx,LRy,LRz )
					
				LLx,LLy,LLz = getPedBonePosition ( thePlayer, 43)
				LLx,LLy = getScreenFromWorldPosition(LLx,LLy,LLz)
					
				if LRx and LRy and KRx and KRy then	
				dxDrawLine(LRx,LRy,KRx,KRy, color, 1.5)
				end
				if LLx and LLy and KLx and KLy then
				dxDrawLine(LLx,LLy,KLx,KLy, color, 1.5)
				end
				end
				end
			end
		end
	end
end
addEventHandler("onClientRender", getRootElement(), showPlayerSquares)

 

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