|
| 1 | +--- |
| 2 | +description: List of events that you can listen to using client.set_event_callback |
| 3 | +--- |
| 4 | +# Events |
| 5 | + |
| 6 | +### List of events: |
| 7 | + |
| 8 | +#### paint |
| 9 | + |
| 10 | +Fired every time the game renders a frame while being connected to a server. Can be used to draw to the screen using the renderer.* functions |
| 11 | + |
| 12 | + |
| 13 | +{% page-ref page="/developers/globals/renderer" %} |
| 14 | + |
| 15 | + |
| 16 | +#### run_command |
| 17 | + |
| 18 | +Fired every time the game runs a command (usually 64 times a second, equal to tickrate) while you're alive. This is the best event for processing data that only changes when the game receives an update from the server, like information about other players. |
| 19 | + |
| 20 | +Key | Description |
| 21 | +--- | ----------- |
| 22 | + **chokedcommands** | Amount of commands that the client has choked |
| 23 | + **command_number** | Current command number |
| 24 | + |
| 25 | + |
| 26 | + |
| 27 | +#### setup_command |
| 28 | + |
| 29 | +Fired every time the game prepares a move command that's sent to the server. This is ran before cheat features like antiaim and can be used to modify user input (view angles, pressed keys, movement) how it's seen by the cheat. For example, setting `in_use = 1` will disable antiaim the same way pressing use key ingame does. This is the preferred method of setting user input and should be used instead of `client.exec` whenever possible |
| 30 | + |
| 31 | +Key | Description |
| 32 | +--- | ----------- |
| 33 | + **chokedcommands** | Amount of commands that the client has choked |
| 34 | + **command_number** | Current command number |
| 35 | + **pitch** | Pitch view angle |
| 36 | + **yaw** | Yaw view angle |
| 37 | + **forwardmove** | Forward / backward speed (-450 to 450) |
| 38 | + **sidemove** | Left / right speed (-450 to 450) |
| 39 | + **move_yaw** | Yaw angle that's used for movement. If not set, view yaw is used |
| 40 | + **allow_send_packet** | Set to false to make the cheat choke the current command (when possible) |
| 41 | + **in_attack** | IN_ATTACK Button |
| 42 | + **in_jump** | IN_JUMP Button |
| 43 | + **in_duck** | IN_DUCK Button |
| 44 | + **in_forward** | IN_FORWARD Button |
| 45 | + **in_back** | IN_BACK Button |
| 46 | + **in_use** | IN_USE Button |
| 47 | + **in_cancel** | IN_CANCEL Button |
| 48 | + **in_left** | IN_LEFT Button |
| 49 | + **in_right** | IN_RIGHT Button |
| 50 | + **in_moveleft** | IN_MOVELEFT Button |
| 51 | + **in_moveright** | IN_MOVERIGHT Button |
| 52 | + **in_attack2** | IN_ATTACK2 Button |
| 53 | + **in_run** | IN_RUN Button |
| 54 | + **in_reload** | IN_RELOAD Button |
| 55 | + **in_alt1** | IN_ALT1 Button |
| 56 | + **in_alt2** | IN_ALT2 Button |
| 57 | + **in_score** | IN_SCORE Button |
| 58 | + **in_speed** | IN_SPEED Button |
| 59 | + **in_walk** | IN_WALK Button |
| 60 | + **in_zoom** | IN_ZOOM Button |
| 61 | + **in_weapon1** | IN_WEAPON1 Button |
| 62 | + **in_weapon2** | IN_WEAPON2 Button |
| 63 | + **in_bullrush** | IN_BULLRUSH Button |
| 64 | + **in_grenade1** | IN_GRENADE1 Button |
| 65 | + **in_grenade2** | IN_GRENADE2 Button |
| 66 | + **in_attack3** | IN_ATTACK3 Button |
| 67 | + **weaponselect** | |
| 68 | + **weaponsubtype** | |
| 69 | + |
| 70 | + |
| 71 | + |
| 72 | +#### console_input |
| 73 | + |
| 74 | +Fired every time the user types something in the game console and presses enter. Return false from the event handler to make the game not process the input |
| 75 | + |
| 76 | +|| Property |
| 77 | +------ | -------- |
| 78 | + 1 | console input text |
| 79 | + |
| 80 | + |
| 81 | +**Examples:** |
| 82 | + |
| 83 | +{% code-tabs %} |
| 84 | +{% code-tabs-item %} |
| 85 | +```lua |
| 86 | +client.set_event_callback("console_input", function(text) |
| 87 | + client.log("entered: '", text, "'") |
| 88 | +end) |
| 89 | +``` |
| 90 | +{% endcode-tabs-item %} |
| 91 | +{% endcode-tabs %} |
| 92 | + |
| 93 | +#### net_update_start |
| 94 | + |
| 95 | +Fired before the game processes entity updates from the server. (`FrameStageNotify FRAME_NET_UPDATE_START`) Be careful when using this event to modify entity data, some things have to be restored manually as not even a full update will update them |
| 96 | + |
| 97 | + |
| 98 | + |
| 99 | +#### net_update_end |
| 100 | + |
| 101 | +Fired after an entity update packet is received from the server. (`FrameStageNotify FRAME_NET_UPDATE_END`) |
| 102 | + |
| 103 | + |
| 104 | + |
| 105 | +#### predict_command |
| 106 | + |
| 107 | +Fired when the game prediction is ran |
| 108 | + |
| 109 | +Key | Description |
| 110 | +--- | ----------- |
| 111 | + **command_number** | Command number of the predicted command |
| 112 | + |
| 113 | + |
| 114 | + |
| 115 | +#### aim_fire |
| 116 | + |
| 117 | +Fired when the rage aimbot shoots at a player |
| 118 | + |
| 119 | +Key | Description |
| 120 | +--- | ----------- |
| 121 | + **id** | Shot ID, this can be used to find the corresponding aim_hit / aim_miss event |
| 122 | + **target** | Target player entindex |
| 123 | + **hit_chance** | Chance the shot will hit, depends on spread |
| 124 | + **hitgroup** | Targeted hit group, this is not the same thing as a hitbox |
| 125 | + **damage** | Predicted damage the shot will do |
| 126 | + **backtrack** | Amount of ticks the player was backtracked |
| 127 | + **boosted** | True if accuracy boost was used to increase the accuracy of the shot |
| 128 | + **high_priority** | True if the shot was at a high priority record, like on shot backtrack |
| 129 | + **interpolated** | Player was interpolated |
| 130 | + **extrapolated** | Player was extrapolated |
| 131 | + **teleported** | Target player was teleporting (breaking lag compensation) |
| 132 | + **tick** | Tick the shot was fired at. This can be used to draw the hitboxes using client.draw_hitboxes |
| 133 | + **x** | X world coordinate of the aim point |
| 134 | + **y** | X world coordinate of the aim point |
| 135 | + **z** | Z world coordinate of the aim point |
| 136 | + |
| 137 | + |
| 138 | +**Examples:** |
| 139 | + |
| 140 | +{% code-tabs %} |
| 141 | +{% code-tabs-item %} |
| 142 | +```lua |
| 143 | +local function time_to_ticks(t) |
| 144 | + return floor(0.5 + (t / globals.tickinterval())) |
| 145 | +end |
| 146 | + |
| 147 | +local hitgroup_names = {'generic', 'head', 'chest', 'stomach', 'left arm', 'right arm', 'left leg', 'right leg', 'neck', '?', 'gear'} |
| 148 | + |
| 149 | +local function aim_fire(e) |
| 150 | + local flags = { |
| 151 | + e.teleported and 'T' or '', |
| 152 | + e.interpolated and 'I' or '', |
| 153 | + e.extrapolated and 'E' or '', |
| 154 | + e.boosted and 'B' or '', |
| 155 | + e.high_priority and 'H' or '' |
| 156 | + } |
| 157 | + local group = hitgroup_names[e.hitgroup + 1] or '?' |
| 158 | + print(string.format('Fired at %s (%s) for %d dmg (chance=%d%%, bt=%2d, flags=%s)', entity.get_player_name(e.target), group, e.damage, math.floor(e.hit_chance + 0.5), time_to_ticks(e.backtrack), table.concat(flags))) |
| 159 | +end |
| 160 | +client.set_event_callback('aim_fire', aim_fire) |
| 161 | +``` |
| 162 | +{% endcode-tabs-item %} |
| 163 | +{% endcode-tabs %} |
| 164 | + |
| 165 | +#### aim_hit |
| 166 | + |
| 167 | +Fired when the rage aimbot hit a shot at a player |
| 168 | + |
| 169 | +Key | Description |
| 170 | +--- | ----------- |
| 171 | + **id** | Shot ID, the corresponding aim_fire event has the same ID |
| 172 | + **target** | Target player entindex |
| 173 | + **hit_chance** | Actual hit chance the shot had |
| 174 | + **hitgroup** | Hit group that was hit. This is not the same thing as a hitbox |
| 175 | + **damage** | Actual damage the shot did |
| 176 | + |
| 177 | + |
| 178 | +**Examples:** |
| 179 | + |
| 180 | +{% code-tabs %} |
| 181 | +{% code-tabs-item %} |
| 182 | +```lua |
| 183 | +local hitgroup_names = {'generic', 'head', 'chest', 'stomach', 'left arm', 'right arm', 'left leg', 'right leg', 'neck', '?', 'gear'} |
| 184 | + |
| 185 | +local function aim_hit(e) |
| 186 | + local group = hitgroup_names[e.hitgroup + 1] or '?' |
| 187 | + print(string.format('Hit %s in the %s for %d damage (%d health remaining)', entity.get_player_name(e.target), group, e.damage, entity.get_prop(e.target, 'm_iHealth'))) |
| 188 | +end |
| 189 | +client.set_event_callback('aim_hit', aim_hit) |
| 190 | +``` |
| 191 | +{% endcode-tabs-item %} |
| 192 | +{% endcode-tabs %} |
| 193 | + |
| 194 | +#### aim_miss |
| 195 | + |
| 196 | +Fired when the rage aimbot missed a shot at a player |
| 197 | + |
| 198 | +Key | Description |
| 199 | +--- | ----------- |
| 200 | + **id** | Shot ID, the corresponding aim_fire event has the same ID |
| 201 | + **target** | Target player entindex |
| 202 | + **hit_chance** | Actual hit chance the shot had |
| 203 | + **hitgroup** | Hit group that was missed. This is not the same thing as a hitbox |
| 204 | + **reason** | Reason the shot was missed. This can be 'spread', 'prediction error', 'death' or '?' (unknown / resolver) |
| 205 | + |
| 206 | + |
| 207 | +**Examples:** |
| 208 | + |
| 209 | +{% code-tabs %} |
| 210 | +{% code-tabs-item %} |
| 211 | +```lua |
| 212 | +local hitgroup_names = {'generic', 'head', 'chest', 'stomach', 'left arm', 'right arm', 'left leg', 'right leg', 'neck', '?', 'gear'} |
| 213 | + |
| 214 | +local function aim_miss(e) |
| 215 | + local group = hitgroup_names[e.hitgroup + 1] or '?' |
| 216 | + print(string.format('Missed %s (%s) due to %s', entity.get_player_name(e.target), group, e.reason)) |
| 217 | +end |
| 218 | +client.set_event_callback('aim_miss', aim_miss) |
| 219 | +``` |
| 220 | +{% endcode-tabs-item %} |
| 221 | +{% endcode-tabs %} |
| 222 | + |
0 commit comments