Home Blog CS:GO

Onetap V4 Documentation: Callbacks

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.

function onDraw() {
    // draws white text in the top left
    Render.String(0, 0, 0, "Hello World", [255, 255, 255, 255]);
}
Cheat.RegisterCallback("Draw", "onDraw");

Some events have arguments, those are available using the Event module.

Callbacks

CreateMove

This callback is everytime a user command is sent to the server (once every tick).

UserCMD can be accessed during this callback.

Draw

Called everytime a frame is drawn (once every frame).

Render can be accessed during this callback.

FrameStageNotify

Called everytime the framestage changes (multiple times every frame).

Cheat.FrameStage can be accessed during this callback.

Warning: This callback has been deprecated, use the FRAME_ callbacks instead.

FRAME_START

FRAME_RENDER_START

View.Update can be accessed during this callback.

FRAME_RENDER_END

FRAME_NET_UPDATE_START

FRAME_NET_UPDATE_POSTDATAUPDATE_START

FRAME_NET_UPDATE_POSTDATAUPDATE_END

FRAME_NET_UPDATE_END

Unload

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).

Material

Called once every frame before the Draw callback.

Material can be accessed during this callback.

// TODO: when is this called

ragebot_fire

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

player_say

Called everytime a player says something.

Note: This callback is very inconsistent and may have been removed in V4 (TODO).

Arguments:

Name Type Description
userid integer Userid of the message author
text string Content of the message

CSGO Events

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

function on_player_death() {
    entity = Entity.GetEntityFromUserID(Event.GetInt("userid"));
    Cheat.PrintChat(" \x02" + Entity.GetName(entity) + " \x01died!");
}
Cheat.RegisterCallback("player_death", "on_player_death");