Skip to content

Callbacks

fantasy.moonlight is currently being developed. This page will be consistently updated as development continues.

PostInitialize

Condition

  • Called whenever a script is loaded/reloaded.
  • When fantasy.moonlight starts, this callback is triggered after Moonlight has calibrated with CS:GO/TF2 and started the hooking modules.

OnMapLoad

Condition

  • Called whenever the player enters a server.

OnMapExit

Condition

  • Called whenever the player exit a server.

OnSound

Condition

  • Called whenever a sound is networked.

Parameters

  • string name
  • number volume
  • number index

Returns

  • number - New volume.

OnConfigurationLoad

Condition

  • Called whenever the member load their configuration.

Parameters

  • string dump - The JSON dump.

OnConfigurationSave

Condition

  • Called whenever the member saves their configuration.

Parameters

  • string dump - The JSON dump.

OnButtonPressed

Condition

  • Called whenever a button is pressed inside of your ImGUI menu.

Parameters

  • string name - The name of the button.

OnMenuRender

Condition

  • Called whenever your menu is intended to be open.
  • This will always be called when the FantasyVar "menu" is set to 1.

Parameters

  • number width - The width of your screen.
  • number height - The height of your screen.

OnFrameStageNotify

Condition

  • Called during CS:GO/TF2 engine execution.
  • https://developer.valvesoftware.com/wiki/Frame_Order#Engine

Notes

  • This is only called during FRAME_NET_UPDATE_POSTDATAUPDATE_START

Initialize

Condition

  • Called right when fantasy.moonlight starts.

Parameters

  • string game - "CS:GO" or "TF2"

OnOverrideView

Condition

  • Called right when CS:GO/TF2 updates your view.

Parameters

  • number fov

Returns

  • number

Notes

  • Whatever value you return with this callback will change your FOV to such.

OnGetViewModelFOV

Condition

  • Called right when CS:GO/TF2 reads your viewmodel FOV.

Returns

  • number

Notes

  • Whatever value you return with this callback will change your Viewmodel FOV to such.

OnRunCommand

Condition

  • This is called whenever a UserCMD is sent from the client to the server.

Parameters

  • number entity
  • number move_helper
  • table cmd
    • address
    • x
    • y
    • z
    • buttons
    • command_number
    • tick_count
    • aim_direction_x (CS:GO Only)
    • aim_direction_y (CS:GO Only)
    • aim_direction_z (CS:GO Only)
    • forward_move
    • side_move
    • up_move
    • impulse
    • weapon_select
    • weapon_sub_type
    • random_seed
    • mouse_x
    • mouse_y
    • has_been_predicted

Notes

  • This passes the same table as OnCreateMove. Use moonlight.game.push_cmd to submit the cmd changes.

OnPostScreenEffects

Condition

  • Post-Processing Screen effects in CS:GO/TF2.

OnSignatureLoad

Condition

  • Called whenever a signature is loaded.
  • See sig.lua

Parameters

  • string name
  • string pattern
  • number offset
  • number extra
  • string module
  • number address

Notes

  • Despite this callback being documented, it cannot be accessed anymore.

OnScriptLoad

Condition

  • Called whenever a script is loaded.

Parameters

  • string file - The name of the script.
  • string path - The full path of the script.
  • string script - The contents of the script.

OnScriptError

Condition

  • Called whenever a script encounters an error.

Parameters

  • string file - The name of the script.
  • string path - The full path of the script.
  • string script - The contents of the script.

OnPaint

Condition

  • https://developer.valvesoftware.com/wiki/ISurface (PaintTraverse)

Parameters

  • string panel
  • number width - The width of your screen.
  • number height - The height of your screen.

OnDrawModel

Condition

  • Called whenever a model is drawn in CS:GO/TF2

Parameters

  • number ent - The model entity.
  • string name - The model name.
  • number flags - The flags attached to the model.

Notes

  • This callback is also triggered in the main menu of CS:GO.
  • Despite this callback being documented, it cannot be accessed anymore.

OnEndScene

Condition

  • Called whenever Direct3D renders visuals.
  • https://docs.microsoft.com/en-us/windows/win32/api/d3d9/nf-d3d9-idirect3ddevice9-endscene

Parameters

  • number device - The Direct3D device.
  • number width - The width of your screen.
  • number height - The height of your screen.

OnVisualsInitialize

Condition

  • Called whenever the visuals module is activated.

Parameters

  • number device - The Direct3D device.
  • number width - The width of your screen.
  • number height - The height of your screen.

Notes

  • Use this callback to add fonts and images. Do not use OnEndScene for that.

OnHumanizerIdle

Condition

  • Called when the humanizer runs its routine.
  • This callback will only work in humanizer.lua

Notes

  • This will determine whether the humanizer calculates or not.
  • All algorithm related to whether the humanizer should be active or not belong here.
  • This should be the place where you set the FantasyVar "settings_humanizer_active" to 1.
  • Regardless of what you change, the humanizer will not trigger this callback if you do not have a gun or if you are dead.

OnHumanizerReady

Condition

  • Called when the humanizer is ready to move towards the target.
  • Called after OnHumanizerIdle.
  • This callback will only work in humanizer.lua

Parameters

  • number target - The entity
  • number hitbox

Notes

  • This will not be called if you if the humanizer cannot find a target.
  • This can be stopped by setting the FantasyVar "settings_humanizer_active" to 0.
  • Even if this callback is triggered, if the humanizer suddenly recognizes the target is invalid, it will not continue.

OnHumanizerPostFight

Condition

  • Called when the humanizer either loses the target, kills the target or simply chooses not to activate anymore.
  • This callback will only work in humanizer.lua

Parameters

  • number target - The entity
  • number hitbox

OnHumanizerPreFight

Condition

  • Called when the humanizer is about to communicate with the mouse driver or change your viewangles.
  • This callback will only work in humanizer.lua

Parameters

  • number target - The entity
  • number hitbox
  • number x
  • number y
  • number z

Notes

  • The FantasyVars "humanizer_x" "humanizer_y" and "humanizer_z" are the same exact values as x, y, and z. Modifying the FantasyVars will change the aim direction of your humanizer.

OnHumanizerActivate

Condition

  • Called when the humanizer passes all checks and has assisted your aim.
  • This callback will only work in humanizer.lua

Parameters

  • number target - The entity
  • number hitbox
  • number x
  • number y
  • number z

OnCreateMove

Condition

  • Called whenever client data is being sent to the server.
  • https://developer.valvesoftware.com/wiki/Usercmd

Parameters

  • number localplayer_address
  • table cmd
    • address
    • x
    • y
    • z
    • buttons
    • command_number
    • tick_count
    • aim_direction_x (CS:GO Only)
    • aim_direction_y (CS:GO Only)
    • aim_direction_z (CS:GO Only)
    • forward_move
    • side_move
    • up_move
    • impulse
    • weapon_select
    • weapon_sub_type
    • random_seed
    • mouse_x
    • mouse_y
    • has_been_predicted
  • number localweapon_address

Notes

  • For safety purposes, modifications to the cmd parameter must be submitted through moonlight.game.push_cmd
  • localweapon_address will provide a nil or a 0 value if the player isn't holding a weapon.

OnEventFired

Condition

  • Whenever an event is fired in CS:GO or TF2. This checks ALL events.
  • CSGO Events: https://wiki.alliedmods.net/Counter-Strike:_Global_Offensive_Events
  • TF2 Events: https://wiki.alliedmods.net/Team_Fortress_2_Events
  • See player_hurt.lua

Parameters

string name number data - The event data. See link above.

Notes

  • moonlight.game.events.listen is depreciated and is no longer required.

OnEntityCreate

Condition

  • Whenever an entity is created in CS:GO/TF2

Parameters

  • table entity
    • address
    • id
    • name

OnEntityDelete

Condition

  • Whenever an entity is deleted in CS:GO/TF2

Parameters

  • table entity
    • address
    • id
    • name