lua sa-mp draw line

Joined
Jun 4, 2018
Messages
14
Likes
0
Points
1
Location
Netherlands
1
#1
is it possible to draw a line from your own coordinates to the other player?

i have something like this now. 

before this I write give the id of myself and the other player so that it can draw a line from coordinate XY to XY but it doesnt work.

Code:
function gfx(arg,posX,posY)
 if #arg > 0 then
id = tonumber(arg)
result, ped = sampGetCharHandleBySampPlayerId(id)
if result then
myX, myY, myZ = getCharCoordinates(ped)
while true do
renderDrawLine(myX, myY, posX,posY, 2.0, 0xFF0000)
wait ( 0 ) 
end
end
end
end
 

supahdupahnubah

Well-Known Member
Joined
Dec 31, 2015
Messages
680
Likes
3
Points
33
#2
You have to translate 3d coords into 2d coords, look up for worldToScreen functions on the internet, i bet theyre mostly on C++ but it's not hard to make em work on lua i guess
 
OP
OP
6jorn_
Joined
Jun 4, 2018
Messages
14
Likes
0
Points
1
Location
Netherlands
1
#3
Already tried that before still shows no line
Code:
function gfx(arg,posX,posY,posZ)
	if #arg > 0 then
		id = tonumber(arg)
		result, ped = sampGetCharHandleBySampPlayerId(id)
		if result then
			myX, myY, myZ = getCharCoordinates(ped)
			local pedX, pedY = convert3DCoordsToScreen(posX,posY,posZ)
            local meX, meY = convert3DCoordsToScreen(myX, myY, myZ)    
			while result do
				renderDrawLine(pedX ,pedY ,meX, meY, 2, 0xFF00FF00)
				wait ( 0 ) 
			end
		end
	end
end
 
OP
OP
6jorn_
Joined
Jun 4, 2018
Messages
14
Likes
0
Points
1
Location
Netherlands
1
#5
DavidRO99 said:
Wait, ill pull this out of my old LUA cheat.
I got it man its working but it only shows it for like 1 second. & I need something that keeps refresehing the coordinates of the given id or will that lag my game? I just have to type /find (playerId) now to refresh the coordinates

Code:
--info
 meposX, meposY, meposZ = getCharCoordinates(PLAYER_PED)
--_, getId = sampGetPlayerIdByCharHandle(PLAYER_PED)


local GET_COORDS_X, GET_COORDS_Y = convert3DCoordsToScreen(posX, posY, posZ)
local GET_COORDS_me_X, GET_COORDS_me_Y = convert3DCoordsToScreen(meposX, meposY, meposZ)  

for i = 1,60 do
renderDrawLine(GET_COORDS_X, GET_COORDS_Y ,GET_COORDS_me_X, GET_COORDS_me_Y, 2, 0xFF00FF00)
end
 

_=Gigant=_

Well-Known Member
Joined
Mar 21, 2017
Messages
382
Likes
8
Points
23
#7
ItsYaBoii32 said:
is it possible to draw a line from your own coordinates to the other player?

i have something like this now. 

before this I write give the id of myself and the other player so that it can draw a line from coordinate XY to XY but it doesnt work.

Code:
function gfx(arg,posX,posY)
 if #arg > 0 then
id = tonumber(arg)
result, ped = sampGetCharHandleBySampPlayerId(id)
if result then
myX, myY, myZ = getCharCoordinates(ped)
while true do
renderDrawLine(myX, myY, posX,posY, 2.0, 0xFF0000)
wait ( 0 ) 
end
end
end
end
if imgui.Button('Tracers') then
lua_thread.create(function()
wait (0)
  for id= 0, 1000 do
   local result = sampIsPlayerConnected(id) 
  local _, other_player = sampGetCharHandleBySampPlayerId(id)
  local PedPosX, PedPosY, PedPosZ = getCharCoordinates(other_player)   
  local meposX, meposY, meposZ = getCharCoordinates(PLAYER_PED)
  local GET_COORDS_X, GET_COORDS_Y = convert3DCoordsToScreen(PedPosX, PedPosY, PedPosZ)
  local GET_COORDS_me_X, GET_COORDS_me_Y = convert3DCoordsToScreen(meposX, meposY, meposZ)   
  renderDrawLine(GET_COORDS_X, GET_COORDS_Y, GET_COORDS_me_X, GET_COORDS_me_Y, 2, 0xFF00FF00)
end            
end)
end
 
OP
OP
6jorn_
Joined
Jun 4, 2018
Messages
14
Likes
0
Points
1
Location
Netherlands
1
#8
Code:
function gfx()

	--info
	meposX, meposY, meposZ = getCharCoordinates(PLAYER_PED)
	--_, getId = sampGetPlayerIdByCharHandle(PLAYER_PED)
	
	
	local GET_COORDS_X, GET_COORDS_Y = convert3DCoordsToScreen(posX, posY, posZ)
	local GET_COORDS_me_X, GET_COORDS_me_Y = convert3DCoordsToScreen(meposX, meposY, meposZ)  
	
	while true do
		renderDrawLine(GET_COORDS_X, GET_COORDS_Y ,GET_COORDS_me_X, GET_COORDS_me_Y, 2, 0xFF00FF00)
		wait ( 0 ) <---- giving c callback error?
	end	
	
end




moonloader.log



Code:
[13:01:56.551288] (error)	PlayerFinder: ...ckstar Games\GTA San Andreas\moonloader\playerFinder.lua:61: attempt to yield across C-call boundary
stack traceback:
	[C]: in function 'wait'
	...ckstar Games\GTA San Andreas\moonloader\playerFinder.lua:61: in function 'gfx'
	...ckstar Games\GTA San Andreas\moonloader\playerFinder.lua:23: in function <...ckstar Games\GTA San Andreas\moonloader\playerFinder.lua:16>
 
Top