Callbacks are functions that you can set which will be called when certain events happen.
You can register your callbacks using the Cheat.RegisterCallback function.
Cheat.RegisterCallback("Draw", function() {
// draws white text in the top left
Render.String(0, 0, 0, "Hello World", [255, 255, 255, 255]);
});Some events have arguments, those are available using the Event module.
This callback is everytime a user command is sent to the server (once every tick).
UserCMD can be accessed during this callback.
Called everytime a frame is drawn (once every frame).
Render can be accessed during this callback.
Called everytime the framestage changes (multiple times every frame).
Cheat.FrameStage can be accessed during this callback.
Called when the script is unloaded, this can be used for cleanup (e.g. resetting AntiAim.SetOverride).
This may not be called if the game is closed (or crashes).
Called once every frame before the Draw callback.
Material can be accessed during this callback.
// TODO: when is this called
Called everytime the ragebot shoots at an entity.
Arguments:
| Name | Type | Description |
|---|---|---|
| exploit | integer | 0 = no exploit, 1 = 1st dt shot or hideshot, 2 = 2nd dt shot |
| target_index | integer | Entityindex of the target |
| hitchance | integer | Hitchance of the shot (between 0 and 100) |
| safepoint | integer | Targetting a safepoint |
| hitbox | integer | Targetted Hitbox |
Called everytime a player says something.
Note: This callback is very inconsistent and may not work.
Arguments:
| Name | Type | Description |
|---|---|---|
| userid | integer | Userid of the message author |
| text | string | Content of the message |
CS:GO has builtin events which can also be used as callbacks and with the Event module.
Event list: https://wiki.alliedmods.net/Counter-Strike:_Global_Offensive_Events
Cheat.RegisterCallback("player_death", function() {
entity = Entity.GetEntityFromUserID(Event.GetInt("userid"));
Cheat.PrintChat(" \x02" + Entity.GetName(entity) + " \x01died!");
});