• Creating DrawCircle on a player position?
    4 replies, posted
Not sure why this doesn't work. It's suppose to record the position of LocalPlayer and draw a circle on the screen. Anyone know what's wrong? [CODE] function Set() c = LocalPlayer():GetPos():ToScreen() end function setpos() surface.SetDrawColor( 255, 40, 80, 255 ) surface.DrawCircle( math.floor(c.x), math.floor(c.y) + 50, 50, Color(255,100,100,255) ) end concommand.Add("set", Set) hook.Add("HUDPaint", "SetPos" ,setpos)[/CODE]
You are taking a World Vector, and drawing onto the screen with those values. Use the ToScreen function and you should be good to go.
Well, among other things c is going to be nil before you run the console command "set" and the HUDPaint hook is going to just go whether c is available or not. I'm assuming you're getting an error that says something along the lines of attempting to index a nil value I'm not 100% sure why you need the console command but if you want it for some reason, put an if statement before drawing things, like this [lua]if ( c ) then surface.SetDrawColor( 255, 40, 80, 255 ) surface.DrawCircle( math.floor(c.x), math.floor(c.y) + 50, 50, Color(255,100,100,255) ) end[/lua]
It isn't nil I tested it. It sets the value of the location but doesn't paint it on the screen.
Sorry, you need to Log In to post a reply to this thread.