render

the render.* functions can only be called from within a few select callbacks, make sure you check if the callback youre in right now supports it

create_font

Creates a font object

Only call this OUTSIDE of callbacks to prevent infinite font creation and crashing

font_t create_font(<string> font_name, <int> font_size, <int> font_weight, [optional] <e_font_flags> font_flags...)
FieldsDescription

font_name string

render font name

font_size int

size of created font

font_weight int

weight of created font

font_flags e_font_flags

[optional] [variadic] font flags

Example

local main_font = render.create_font("Arial", 20, 600, e_font_flags.ANTIALIAS, e_font_flags.ITALIC, e_font_flags.DROPSHADOW)

text

Renders text

void text(<font_t> font_object, <string> text, <vec2_t> screen_pos, <color_t> text_color, [optional] <bool> centered)
FieldsDescription

font_object font_t

font object

text string

text to render

screen_pos vec2_t

position of text

text_color color_t

color of text

centered bool

should text be centered

Example

render.text(main_font, "test123", vec2_t(2, 0), color_t(255, 255, 255, 255))

get_text_size

Returns size of text as a vec2_t

vec2_t get_text_size(<font_t> font_object, <string> text)
FieldsDescription

font_object font_t

render font object

text string

text to measure

Example

local text_size = render.get_text_size(main_font, "Hello World")
print(text_size)

weapon_icon

renders the weapon icon of the specified weapon id

void weapon_icon(<int> weapon_id, <vec2_t> screen_pos, <color_t> text_color, [optional] <bool> centered)
FieldsDescription

weapon_id int

weapon id to render

screen_pos vec2_t

position of text

text_color color_t

color of text

centered bool

should text be centered

Example

render.weapon_icon(e_items.WEAPON_AK47 vec2_t(2, 0), color_t(255, 255, 255, 255))

get_default_font

Returns the cheat's default font

font_t get_default_font()

Example

local default_font = render.get_default_font()
callbacks.add(e_callbacks.PAINT,function()
    render.text(default_font,"Hi",vec2_t(0,25),color_t(255,255,255))
end)

push_clip

Pushes a clip onto render elements

void push_clip(<vec2_t> start, <vec2_t> size)
FieldsDescription

start vec2_t

clip start

size vec2_t

clip size

Example

render.push_clip(vec2_t(100, 100), vec2_t(100, 100))

pop_clip

Stops all other render calls from being clipped

void pop_clip()

Example

render.push_clip(vec2_t(100, 100), vec2_t(100, 100))
render.rect_filled(vec2_t(100, 100), vec2_t(200, 100), color_t(255, 255, 255, 255)) -- this rectangle will be cut off in the middle
render.pop_clip() -- you always have to pop it to stop other render.* calls from being clipped

push_alpha_modifier

Pushes a alpha modifier onto render elements

void push_alpha_modifier(<float> alpha_modifier)
FieldsDescription

alpha_modifier float

alpha modifier

Example

render.push_alpha_modifier(0.5)

pop_alpha_modifier

Stops all other elements from having their alpha modified

void pop_alpha_modifier()

Example

render.push_alpha_modifier(0.5)
render.rect_filled(vec2_t(100, 100), vec2_t(100, 100), color_t(255, 255, 255, 200)) -- this will draw with only 100 alpha
render.pop_alpha_modifier() -- you always have to pop the alpha modifier to end it

get_screen_size

Returns current screen size as a vec2_t

vec2_t get_screen_size()

Example

local screen_size = render.get_screen_size()
print(screen_size)

line

Renders a 2D line

void line(<vec2_t> from, <vec2_t> to, <color_t> color )
FieldsDescription

from vec2_t

starting point

to vec2_t

end point

color color_t

line color

Example

render.line(vec2_t(100, 50), vec2_t(150, 75), color_t(255,0,0))

rect

Renders a 2D rectangle

void rect(<vec2_t> screen_coords, <vec2_t> rectangle_size, <color_t> color, [optional] <float> rounding)
FieldsDescription

screen_coords vec2_t

x and y coordinates

rectangle_size vec2_t

rectangle width and height

color color_t

rectangle color

rounding float

rectangle rounding

Example

render.rect(vec2_t(100, 50), vec2_t(150, 75), color_t(255,0,0))

rect_filled

Renders a 2D filled rectangle

void rect_filled(<vec2_t> screen_coords, <vec2_t> rectangle_size, <color_t> color, [optional] <float> rounding)
FieldsDescription

screen_coords vec2_t

x and y coordinates

rectangle_size vec2_t

rectangle width and height

color color_t

rectangle fill color

rounding float

rectangle fill rounding

Example

render.rect_filled(vec2_t(100, 50), vec2_t(150, 75), color_t(255,0,0))

rect_fade

Renders a 2D rectangle with a gradient

void rect_fade(<vec2_t> screen_coords, <vec2_t> rectangle_size, <color_t> color_start, <color_t> color_end, [optional] <bool> horizontal)
FieldsDescription

screen_coords vec2_t

x and y coordinates

rectangle_size vec2_t

rectangle width and height

color_start color_t

rectangle gradient color start

color_end color_t

rectangle gradient color end

horizontal bool

[optional] makes the gradient horizontal

Example

render.rect_fade(vec2_t(100, 50), vec2_t(150, 75), color_t(255,0,0), color_t(0,255,0))

triangle

Renders a 2D triangle

void triangle(<vec2_t> screen_coords, <int> size, <color_t> color, [optional] <int> rotation)
FieldsDescription

screen_coords vec2_t

x and y coordinates

size int

triangle size

color color_t

triangle color

rotation int

[optional] triangle rotation

Example

render.triangle(vec2_t.new(100, 500), 50, color_t.new(255,0,0), 90)

triangle_filled

Renders a 2D triangle

void triangle_filled(<vec2_t> screen_coords, <int> size, <color_t> color, [optional] <int> rotation)
FieldsDescription

screen_coords vec2_t

x and y coordinates

size int

triangle size

color color_t

triangle color

rotation int

[optional] triangle rotation

Example

render.triangle_filled(vec2_t.new(100, 500), 50, color_t.new(255,0,0), 90)

circle

Renders a 2D circle

void circle(<vec2_t> screen_coords, <int> radius, <color_t> color, [optional] <int> thickness)
FieldsDescription

screen_coords vec2_t

x and y coordinates

radius int

circle size

color color_t

circle color

thickness int

Example

render.circle(vec2_t.new(125, 575), 25, color_t.new(255,0,0))

circle_filled

Renders a 2D filled circle

void circle_filled(<vec2_t> screen_coords, <int> radius, <color_t> color)
FieldsDescription

screen_coords vec2_t

x and y coordinates

radius int

circle size

color color_t

circle fill color

Example

render.circle_filled(vec2_t.new(125, 575), 25, color_t.new(255,0,0))

progress_circle

Renders a 2D progress_circle

void progress_circle(<vec2_t> screen_coords, <int> radius, <color_t> color, <int> width, <float> progress)
FieldsDescription

screen_coords vec2_t

x and y coordinates

radius int

progress bar size

color color_t

progress bar color

width int

progress bar width

progress float

progress value

Example

render.progress_circle(vec2_t.new(125, 650), 25, color_t.new(255,0,0), 2, 0.75)

polygon

Renders a 2D polygon

void polygon([table] <vec2_t> points, <color_t> color)
FieldsDescription

points [table] vec2_t

array of 2D points

color color_t

polygon color

Example

    render.polygon({vec2_t(100, 100), vec2_t(150, 100), vec2_t(150, 200), vec2_t(100, 200), vec2_t(50, 150), vec2_t(100, 200), vec2_t(150, 200), vec2_t(150, 100)}, color_t(255,255,255))

polyline

Renders a 2D polyline

void polyline([table] <vec2_t> points, <color_t> color)
FieldsDescription

points [table] vec2_t

array of 2D points

color color_t

polygon color

Example

    render.polyline({vec2_t(100, 100), vec2_t(150, 100), vec2_t(150, 200), vec2_t(100, 200), vec2_t(50, 150), vec2_t(100, 200), vec2_t(150, 200), vec2_t(150, 100)}, color_t(255,255,255))

world_to_screen

Returns 2D coordinates for a 3D world point or nil on failure

vec2_t world_to_screen(<vec3_t> world_position)
FieldsDescription

world_position vec3_t

x, y, z coordinates

Example

local screen_pos = render.world_to_screen(world_position)
if screen_pos ~= nil then
    print(screen_pos) --unpacks 2D vector
end

load_image

loads an image from a path and returns a texture supports .jpg, .jpeg, .png, .svg, .tga, .bmp

texture_t load_image(<string> path)

load_image_buffer

loads an image from the raw file (has to include header) and returns a texture supports .jpg, .jpeg, .png, .svg, .tga, .bmp

texture_t load_image_buffer(<string> raw_file)

texture

renders a texture received from load_image or load_image_buffer

void texture(<int> texture_id, <vec2_t> screen_pos, <vec2_t> size, [optional] <color_t> color_tint)

Example

local img = render.load_image("ak47.svg")
print(img.size.x, img.size.y)

function on_paint()
    render.texture(img.id, vec2_t(100, 100), img.size)
end

Last updated