gamesense-lua
  • Overview
  • Using the cheat
    • Using lua scripts
    • Unlisted features
    • Common issues
  • Developers
    • Writing lua scripts
      • Getting started
      • Examples
        • Simple watermark
        • Head Dot ESP
        • Talk shit
        • Auto buy on round start
        • Create Interface
      • Editors
        • VS Code
        • Sublime Text
        • Atom
      • Events
      • Snippets
      • Compiling lua scripts
    • API Documentation
      • bit
      • client
      • config
      • cvar
      • database
      • entity
      • globals
      • json
      • materialsystem
      • panorama
      • plist
      • renderer
      • ui
      • vector
    • Netprops
      • Important
        • CCSGameRulesProxy
        • CCSPlayer
        • CCSPlayerResource
      • Items
        • CAK47
        • CBaseCSGrenade
        • CBaseGrenade
        • CBreachCharge
        • CBumpMine
        • CC4
        • CDEagle
        • CDecoyGrenade
        • CEconEntity
        • CFists
        • CFlashbang
        • CHEGrenade
        • CIncendiaryGrenade
        • CItem_Healthshot
        • CItemCash
        • CItemDogtags
        • CKnife
        • CKnifeGG
        • CMelee
        • CMolotovGrenade
        • CSCAR17
        • CSensorGrenade
        • CSmokeGrenade
        • CSnowball
        • CTablet
        • CWeaponAug
        • CWeaponAWP
        • CWeaponBaseItem
        • CWeaponBizon
        • CWeaponCSBase
        • CWeaponCSBaseGun
        • CWeaponCycler
        • CWeaponElite
        • CWeaponFamas
        • CWeaponFiveSeven
        • CWeaponG3SG1
        • CWeaponGalil
        • CWeaponGalilAR
        • CWeaponGlock
        • CWeaponHKP2000
        • CWeaponM249
        • CWeaponM3
        • CWeaponM4A1
        • CWeaponMAC10
        • CWeaponMag7
        • CWeaponMP5Navy
        • CWeaponMP7
        • CWeaponMP9
        • CWeaponNegev
        • CWeaponNOVA
        • CWeaponP228
        • CWeaponP250
        • CWeaponP90
        • CWeaponSawedoff
        • CWeaponSCAR20
        • CWeaponScout
        • CWeaponSG550
        • CWeaponSG552
        • CWeaponSG556
        • CWeaponShield
        • CWeaponSSG08
        • CWeaponTaser
        • CWeaponTec9
        • CWeaponTMP
        • CWeaponUMP45
        • CWeaponUSP
        • CWeaponXM1014
        • CWeaponZoneRepulsor
        • ParticleSmokeGrenade
      • Projectiles
        • CBaseCSGrenadeProjectile
        • CBreachChargeProjectile
        • CBumpMineProjectile
        • CDecoyProjectile
        • CMolotovProjectile
        • CSensorGrenadeProjectile
        • CSmokeGrenadeProjectile
        • CSnowballProjectile
      • Environment
        • CColorCorrection
        • CColorCorrectionVolume
        • CEnvAmbientLight
        • CEnvDetailController
        • CEnvDOFController
        • CEnvGasCanister
        • CEnvParticleScript
        • CEnvProjectedTexture
        • CEnvQuadraticBeam
        • CEnvScreenEffect
        • CEnvScreenOverlay
        • CEnvTonemapController
        • CEnvWind
        • CSun
        • CSunlightShadowControl
      • Controllers
        • CDangerZoneController
        • CFogController
        • CFootstepControl
        • CMapVetoPickController
        • CMaterialModifyControl
        • CPoseController
        • CPostProcessController
        • CShadowControl
        • CTeam
        • CTeamplayRoundBasedRulesProxy
        • CVoteController
        • CWaterLODControl
      • Temp Entities
        • CTEArmorRicochet
        • CTEBaseBeam
        • CTEBeamEntPoint
        • CTEBeamEnts
        • CTEBeamFollow
        • CTEBeamLaser
        • CTEBeamPoints
        • CTEBeamRing
        • CTEBeamRingPoint
        • CTEBeamSpline
        • CTEBloodSprite
        • CTEBloodStream
        • CTEBreakModel
        • CTEBSPDecal
        • CTEBubbles
        • CTEBubbleTrail
        • CTEClientProjectile
        • CTEDecal
        • CTEDust
        • CTEDynamicLight
        • CTEEffectDispatch
        • CTEEnergySplash
        • CTEExplosion
        • CTEFireBullets
        • CTEFizz
        • CTEFootprintDecal
        • CTEFoundryHelpers
        • CTEGaussExplosion
        • CTEGlowSprite
        • CTEImpact
        • CTEKillPlayerAttachments
        • CTELargeFunnel
        • CTEMetalSparks
        • CTEMuzzleFlash
        • CTEParticleSystem
        • CTEPhysicsProp
        • CTEPlantBomb
        • CTEPlayerAnimEvent
        • CTEPlayerDecal
        • CTEProjectedDecal
        • CTERadioIcon
        • CTEShatterSurface
        • CTEShowLine
        • CTESmoke
        • CTESparks
        • CTESprite
        • CTESpriteSpray
        • CTEWorldDecal
      • Base Entities
        • CBaseAnimating
        • CBaseAnimatingOverlay
        • CBaseAttributableItem
        • CBaseButton
        • CBaseCombatCharacter
        • CBaseCombatWeapon
        • CBaseDoor
        • CBaseEntity
        • CBaseFlex
        • CBaseParticleEntity
        • CBasePlayer
        • CBasePropDoor
        • CBaseTeamObjectiveResource
        • CBaseTempEntity
        • CBaseToggle
        • CBaseTrigger
        • CBaseViewModel
        • CBaseVPhysicsTrigger
        • CBaseWeaponWorldModel
      • Other
        • CAI_BaseNPC
        • CBeam
        • CBeamSpotlight
        • CBoneFollower
        • CBRC4Target
        • CBreakableProp
        • CBreakableSurface
        • CCascadeLight
        • CChicken
        • CCSRagdoll
        • CCSTeam
        • CDangerZone
        • CDrone
        • CDronegun
        • CDynamicLight
        • CDynamicProp
        • CEconWearable
        • CEmbers
        • CEntityDissolve
        • CEntityFlame
        • CEntityFreezing
        • CEntityParticleTrail
        • CFEPlayerDecal
        • CFireCrackerBlast
        • CFireSmoke
        • CFireTrail
        • CFish
        • CFunc_Dust
        • CFunc_LOD
        • CFuncAreaPortalWindow
        • CFuncBrush
        • CFuncConveyor
        • CFuncLadder
        • CFuncMonitor
        • CFuncMoveLinear
        • CFuncOccluder
        • CFuncReflectiveGlass
        • CFuncRotating
        • CFuncSmokeVolume
        • CFuncTrackTrain
        • CGameRulesProxy
        • CGrassBurn
        • CHandleTest
        • CHostage
        • CHostageCarriableProp
        • CInferno
        • CInfoLadderDismount
        • CInfoMapRegion
        • CInfoOverlayAccessor
        • CLightGlow
        • CMovieDisplay
        • CParadropChopper
        • CParticleFire
        • CParticlePerformanceMonitor
        • CParticleSystem
        • CPhysBox
        • CPhysBoxMultiplayer
        • CPhysicsProp
        • CPhysicsPropMultiplayer
        • CPhysMagnet
        • CPhysPropAmmoBox
        • CPhysPropLootCrate
        • CPhysPropRadarJammer
        • CPhysPropWeaponUpgrade
        • CPlantedC4
        • CPlasma
        • CPlayerPing
        • CPlayerResource
        • CPointCamera
        • CPointCommentaryNode
        • CPointWorldText
        • CPrecipitation
        • CPrecipitationBlocker
        • CPredictedViewModel
        • CProp_Hallucination
        • CPropCounter
        • CPropDoorRotating
        • CPropJeep
        • CPropVehicleDriveable
        • CRagdollManager
        • CRagdollProp
        • CRagdollPropAttached
        • CRopeKeyframe
        • CSceneEntity
        • CSlideshowDisplay
        • CSmokeStack
        • CSnowballPile
        • CSpatialEntity
        • CSpotlightEnd
        • CSprite
        • CSpriteOriented
        • CSpriteTrail
        • CStatueProp
        • CSteamJet
        • CSurvivalSpawnChopper
        • CTesla
        • CTest_ProxyToggle_Networkable
        • CTestTraceline
        • CTriggerPlayerMovement
        • CTriggerSoundOperator
        • CVGuiScreen
        • CWaterBullet
        • CWorld
        • CWorldVguiText
        • DustTrail
        • MovieExplosion
        • RocketTrail
        • SmokeTrail
        • SporeExplosion
        • SporeTrail
Powered by GitBook
On this page
  1. Developers
  2. Writing lua scripts
  3. Examples

Head Dot ESP

PreviousSimple watermarkNextTalk shit

Last updated 3 years ago

This script, if enabled, draws small dots on the heads of enemies. The dots are white if the head is invisible and red if visible

-- localize often used API variables to improve performance. It's usually fine to not do this, but lua then has to look them up as globals every time.
local client_eye_position, client_trace_line, entity_get_local_player, entity_get_players, entity_hitbox_position, renderer_circle, renderer_world_to_screen = client.eye_position, client.trace_line, entity.get_local_player, entity.get_players, entity.hitbox_position, renderer.circle, renderer.world_to_screen

local function on_paint()
	local local_player = entity_get_local_player()
	local eye_x, eye_y, eye_z = client_eye_position()

	-- get all alive, non-dormant enemy players
	local enemies = entity_get_players(true)

	for i=1, #enemies do
		local entindex = enemies[i]

		-- get the world coordinates of the head hitbox of the enemy
		local head_x, head_y, head_z = entity_hitbox_position(entindex, 0)

		-- transform world coordinates to screen coordinates
		local wx, wy = renderer_world_to_screen(head_x, head_y, head_z)

		-- make sure to always check if the screen coordinates are valid. it's enough to only check wx
		if wx ~= nil then
			local r, g, b, a = 255, 255, 255, 100

			-- ray trace from your eye position to the enemy head, ignoring our local player, to determine if it's visible
			local fraction, entindex_hit = client_trace_line(local_player, eye_x, eye_y, eye_z, head_x, head_y, head_z)

			if entindex_hit == entindex or fraction == 1 then
				-- the trace either hit the enemy or hit nothing, meaning the head is visible, so we change the color
				r, g, b, a = 255, 16, 16, 255
			end

			-- draw circle with radius 4, so we offset the x and y by -2
			renderer_circle(wx-2, wy-2, r, g, b, a, 4, 0, 1)
		end
	end
end
client.set_event_callback("paint", on_paint)