OnRenderHUD: Difference between revisions
From Onset Developer Wiki
No edit summary |
No edit summary |
||
(2 intermediate revisions by 2 users not shown) | |||
Line 6: | Line 6: | ||
== Example == | == Example == | ||
https://github.com/BlueMountainsIO/OnsetLuaScripts/blob/master/horizon/client/esp.lua | |||
<syntaxhighlight lang="Lua"> | <syntaxhighlight lang="Lua"> | ||
local EnableESP = 0 | |||
function SetEnableESP(enable) | |||
EnableESP = enable | |||
end | |||
AddRemoteEvent("SetEnableESP", SetEnableESP) | |||
function OnRenderHUD() | |||
if EnableESP ~= 1 then | |||
return | |||
end | |||
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> | </syntaxhighlight> | ||
{{RelatedFunctions}} | {{RelatedFunctions}} | ||
[[ | {{GameClientEvents}} | ||
* [[DrawText]] | |||
* [[SetDrawColor]] | |||
* [[SetTextDrawScale]] | |||
* [[GetTextSize]] | |||
* [[DrawLine]] | |||
* [[DrawLine3D]] | |||
* [[DrawPoint3D]] | |||
* [[DrawCircle3D]] | |||
* [[DrawBox]] | |||
* [[DrawRect]] | |||
* [[DrawTexture]] | |||
* [[DrawTextureEx]] | |||
* [[DrawMaterial]] |
Latest revision as of 12:25, 2 September 2020
Description
This function is called every time the HUD is rendered for the player. This function can be used as a game tick event.
Syntax
OnRenderHUD()
Example
https://github.com/BlueMountainsIO/OnsetLuaScripts/blob/master/horizon/client/esp.lua
local EnableESP = 0
function SetEnableESP(enable)
EnableESP = enable
end
AddRemoteEvent("SetEnableESP", SetEnableESP)
function OnRenderHUD()
if EnableESP ~= 1 then
return
end
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)