Skip to content

Latest commit

Β 

History

History
310 lines (215 loc) Β· 11.2 KB

events.md

File metadata and controls

310 lines (215 loc) Β· 11.2 KB

Events

Function:

add_callback

hooks.add_callback(hook_name, protected_function) :Void

Type Description
hook_name string event name
protectedfunction function Functions to trigger events
-- Source: https://rifk7.com/index.php?threads/events.294/
-- events always get verified before the lua callback runs.

//Example #1
function test(event)
    print(event:get_name());
end

hooks.add_callback("on_event", test);

//Example #2

hooks.add_callback("on_event", function()
    print(event:get_name());
end);

add_lua_unload_callback

hooks.add_lua_unload_callback(function) :Void

Type Description
function function Functions to trigger unload script
//Example #1

function test() 
    print("Unload lua")
end 

hooks.add_lua_unload_callback(test)

//Example #2

hooks.add_lua_unload_callback(function()
    print("Unload lua")
end)

add_menu_callback

hooks.add_menu_callback(menu_item_name, protected_function) :Void

Type Description
menu_item_name String Menu name
protected_function function Functions to trigger menu value
local checkbox_item = menu.add_checkbox("Example Checkbox", false);
hooks.add_menu_callback("Example Checkbox", function()
    print("test")
end)

add_delayed_callback

hooks.add_delayed_callback(delay, protected_function) :Void

Type Description
delay float Delay time
protected_function function Functions to trigger delay
local num = 1 
hooks.add_delayed_callback(10, function()
    print(num)
    num = num + 1
end)

add_voice_msg_callback

hooks.add_voice_msg_callback(packet_id, protected_function) :Void

Type Description
packet_id int packet id
protected_function function Functions to trigger event

Function value:

Name Type
sender_index int
value_1 int
value_2 int
value_3 int
value_4 int

game events:

{% embed url="https://wiki.alliedmods.net/Counter-Strike:_Global_Offensive_Events" %} Official CS:GO events {% endembed %}

-- Source: https://rifk7.com/index.php?threads/events.294/

function test(event)
    print(event:get_name());
end

hooks.add_callback("on_event", test);

List of events:

on_draw

Fired every frame. Most functions from the renderer namespace can only be used here

-- Source: https://rifk7.com/index.php?threads/drawing.293/

function test()
    if (engine.is_ingame() and engine.is_connected()) then   
        renderer.draw_text(renderer.get_center().x, renderer.get_center().y + 15, "choke me daddy", renderer.get_font(fonts.default), 255, 255, 255, 255, font_flags.centered_x);
        renderer.draw_line_multicolored(renderer.get_center().x, renderer.get_center().y + 35, renderer.get_center().x + 40 * clientstate.get_choked_ticks() / 15.0, renderer.get_center().y + 35, 255, 255, 255, 255, 255, 255, 255, 0);
        renderer.draw_line_multicolored(renderer.get_center().x, renderer.get_center().y + 35, renderer.get_center().x - 40 * clientstate.get_choked_ticks() / 15.0, renderer.get_center().y + 35, 255, 255, 255, 255, 255, 255, 255, 0);   
    end
end

hooks.add_callback("on_draw", test)

on_paint

Fired every frame.

on_frame_end

Fired every frame.

on_level_clear

on_level_init_pre_entity

on_delayed_loop

runs every 500ms

on_event

Fired game events

πŸ”— struct c_game_event

Type Description
get_name string Returns the name string of the event.
get_bool bool Returns the bool value of the event.
get_int int Returns the int value of the event.
get_float float Returns the float value of the event.
get_string string Returns the string value of the event.
set_bool void Set the bool value of the event
set_int void Set the int value of the event
set_float void Set the float value of the event
set_string void Set the string value of the event

on_drawmodel

on drawing model

return lua_dme/original

πŸ”— struct lua_dme

Type Description
get_entity c_client_entity
get_model_name string
should_override bool
get_matrix matrix3x4

on_createmove

start of createmove

πŸ”— struct c_user_cmd

Type Description
get_command_number int
get_tick_count int
get_viewangles c_vector3d
get_forwardmove float
get_sidemove float
get_upmove float
get_buttons buttons
add_button function(buttons button)
remove_button function(buttons button)
is_button_active function(buttons button)
get_weaponselect int
get_weaponsubtype int
get_mousedx int
get_mousedy int

on_createmove_pre_antiaim

before antiaim

on_override_view

override view - every frame

on_render_view

render view - every frame

πŸ”— struct c_view_setup

Type Description
get_origin c_vector3d
get_angles c_vector3d
get_fov float
get_fov_viewmodel float

on_shot_info

on ragebot shot

πŸ”— struct lua_shot_info

Type Description
get_start c_vector3d
get_end c_vector3d
get_target bool
get_damage float
get_damage_override float
get_backtrack int
get_hitbox hitbox

on_hitscan

on ragebot hitbox selection

πŸ”— struct lua_hitscan

Type Description
get_player c_client_entity
should_override bool

on_multipoints

on ragebot multipoint setup

πŸ”— struct lua_multipoints

Type Description
get_player c_client_entity
hitbox hitbox
should_multipoint_hitbox bool
should_override bool

on_dispatch_user_message

on_dispatch_user_message

πŸ”— struct dispatch_user_message

Type Description
message_type int
message bf_read

on_console_input

  • clientcmd unrestricted
  • on dispatching console commands

πŸ”— struct console_input

Type Description
text std::string

on_at_targets

  • createmove
  • on at targets selection

πŸ”— struct at_targets

Type Description
get_player c_cs_player*
should_override bool