Skip to content

Utils

Functions


WorldToScreen()

Parameters

Parameter Type Description
input Vector World space position

Return value

Parameter Type Description
screen_pos Vector Returns a Vector containing the world coordinates represented as screen coordinates. IsValid needs to be called to make sure the function didn't fail
Example

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
Cheat.RegisterCallback("render",function()
  for i = 1, EngineClient:GetMaxClients(), 1 do
    local entity = EntityList:GetEntity(i)

    if(entity ~= nil and entity:EntIndex() ~= EngineClient:GetLocalPlayer() and entity:IsPlayer() and entity:IsAlive() and entity:IsEnemy()) then
      local position = Utils.WorldToScreen(entity:GetPropVector("DT_BaseEntity","m_vecOrigin"))
      if position:IsValid() then
        Renderer:DrawFilledRect(position:x - 1,position:y -1,position.x + 1,position.y + 1,Color(255,255,255,255),0.0)
      end
    end

  end
end)
This code will draw rectangles at each player's origin.