surface.DrawPoly question


buybutton = surface.Color(200, 0, 0, 255)
buybuttonvertex =  {{ }, { }, { }, { }}

It doesnt want to work and just creates this error :


[ERROR] addons/kun_weaponsystem/lua/autorun/cl_kwepz.lua:23: attempt to call field 'Color' (a nil value)
  1. unknown - addons/kun_weaponsystem/lua/autorun/cl_kwepz.lua:23


So how can it be used just as a color. In the wiki page it want me to use a texture but is it needed cant i just draw the color on the it?

Look at the surface libraries functions, you’re using it incorrectly.

-snip-

Here’s a simple example.

[lua]
surface.SetDrawColor( 255, 255, 255, 255 )
tex = surface.GetTextureID( “cs_italy/black” )
tbl = { {}, {}, {}, {} }
tbl[1][“x”] = 10
tbl[1][“y”] = 10
tbl[2][“x”] = 100
tbl[2][“y”] = 10
tbl[3][“x”] = 50
tbl[3][“y”] = 50
tbl[4][“x”] = 10
tbl[4][“y”] = 50
surface.SetTexture( tex )
surface.DrawPoly( tbl )
[/lua]

This will make a small polygon in the top left of your HUD that looks like this:

Think of the table like this, the first point is your top left, second is top right, third is bottom right, and fourth is bottom left. It always starts at one point and goes clockwise from there.