DrawBox: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
Line 1: | Line 1: | ||
{{Info|Function|Client|1.0}} | {{Info|Function|Client|1.0}} | ||
{{FuncDescription| | {{FuncDescription|Draws a box in screen space.}} | ||
{{FuncSyntax|DrawBox(sX, sY, sW, sH [, thickness])}} | {{FuncSyntax|DrawBox(sX, sY, sW, sH [, thickness])}} | ||
{{FuncParameters}} | {{FuncParameters}} | ||
{{FuncParam|sX| | {{FuncParam|sX|Start X location.}} | ||
{{FuncParam|sY| | {{FuncParam|sY|Start Y location.}} | ||
{{FuncParam|sW| | {{FuncParam|sW|Width}} | ||
{{FuncParam|sH | | {{FuncParam|sH|Height}} | ||
{{FuncParamOptional|thickness| | {{FuncParamOptional|thickness|Line thickness of the box, default: 1.0}} | ||
{{FuncReturnValue| | {{FuncReturnValue|Returns nothing.}} | ||
== Example == | == Example == | ||
<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}} |
Revision as of 13:27, 30 August 2020
Description
Draws a box in screen space.
Syntax
DrawBox(sX, sY, sW, sH [, thickness])
Parameters
- sX
Start X location. - sY
Start Y location. - sW
Width - sH
Height - thickness (optional)
Line thickness of the box, 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)