DrawLine: Difference between revisions

From Onset Developer Wiki
Created page with "{{Info|Function|Client|1.0}} {{FuncDescription|__EDIT_ME__}} {{FuncSyntax|DrawLine(sX, sY, eX, eY [, thickness, r, g, b])}} {{FuncParameters}} {{FuncParam|sX|__EDIT_ME__}}..."
 
No edit summary
 
(3 intermediate revisions by 2 users not shown)
Line 1: Line 1:
{{Info|Function|Client|1.0}}
{{Info|Function|Client|1.0}}


{{FuncDescription|__EDIT_ME__}}
{{FuncDescription|Draws a line in screen space.}}


{{FuncSyntax|DrawLine(sX, sY, eX, eY [, thickness, r, g, b])}}
{{FuncSyntax|DrawLine(sX, sY, eX, eY [, thickness])}}


{{FuncParameters}}
{{FuncParameters}}
{{FuncParam|sX|__EDIT_ME__}}
{{FuncParam|sX|Start X location.}}
{{FuncParam|sY|__EDIT_ME__}}
{{FuncParam|sY|Start Y location.}}
{{FuncParam|eX|__EDIT_ME__}}
{{FuncParam|eX|End X location.}}
{{FuncParam|eY |__EDIT_ME__}}
{{FuncParam|eY|End Y location.}}
{{FuncParam|thickness|__EDIT_ME__}}
{{FuncParamOptional|thickness|Line thickness, default: 1.0}}
{{FuncParam|r|__EDIT_ME__}}
{{FuncParam|g|__EDIT_ME__}}
{{FuncParamOptional|b|__EDIT_ME__}}


{{FuncReturnValue|__EDIT_ME__}}
{{FuncReturnValue|Returns nothing.}}


== Example ==
== Example ==
__EDIT_ME__
<syntaxhighlight lang="Lua">
local EnableESP = 0
 
function SetEnableESP(enable)
EnableESP = enable
end
AddRemoteEvent("SetEnableESP", SetEnableESP)
 
function OnRenderHUD()
if EnableESP ~= 1 then
return
end
 
local x, y, z
local ScreenX, ScreenY = GetScreenSize()
local t = { 1 }
for k, v in pairs(GetStreamedPlayers()) do
local x, y, z = GetPlayerLocation(v)
local sX, sY, sZ = WorldToScreen(x, y, z)
if sZ ~= 0.0 then
DrawLine(ScreenX / 2, ScreenY, sX, sY)
DrawBox(sX - 50, sY - 100, 100, 200)
end
end
end
AddEvent("OnRenderHUD", OnRenderHUD)
</syntaxhighlight>


{{RelatedFunctions}}
{{RelatedFunctions}}
__EDIT_ME__
* [[DrawText]]
* [[SetDrawColor]]
* [[SetTextDrawScale]]
* [[GetTextSize]]
* [[DrawLine]]
* [[DrawLine3D]]
* [[DrawPoint3D]]
* [[DrawCircle3D]]
* [[DrawBox]]
* [[DrawRect]]
* [[DrawTexture]]
* [[DrawTextureEx]]
* [[DrawMaterial]]

Latest revision as of 20:25, 30 August 2020

DrawLine

Type: Function
Context: Client
Introduced: v1.0

Description

Draws a line in screen space.

Syntax

DrawLine(sX, sY, eX, eY [, thickness])

Parameters

  • sX
    Start X location.
  • sY
    Start Y location.
  • eX
    End X location.
  • eY
    End Y location.
  • thickness (optional)
    Line thickness, default: 1.0

Return Value

  • Returns nothing.

Example

local EnableESP = 0

function SetEnableESP(enable)
	EnableESP = enable
end
AddRemoteEvent("SetEnableESP", SetEnableESP)

function OnRenderHUD()
	if EnableESP ~= 1 then
		return
	end

	local x, y, z
	local ScreenX, ScreenY = GetScreenSize()
	local t = { 1 }
	for k, v in pairs(GetStreamedPlayers()) do
		local x, y, z = GetPlayerLocation(v)
		local sX, sY, sZ = WorldToScreen(x, y, z)
		if sZ ~= 0.0 then
			DrawLine(ScreenX / 2, ScreenY, sX, sY)
			DrawBox(sX - 50, sY - 100, 100, 200)
		end
	end
end
AddEvent("OnRenderHUD", OnRenderHUD)

See also