Skip to content

callbacks

These are event-based triggers inside of FC2.

on_loaded

Description

Calls when the current script gets loaded.

Parameters

  • table script
  • table session

on_worker

Description

This is the main background worker of FC2. This is called every X amount of ticks (default: 1ms). This is where you usually should do your main work.

Parameters

  • boolean is_calibrated
  • number GAME ID

on_scripts_reloading

Description

Whenever scripts are marked to be reloaded, this callback is triggered.


on_scripts_reloaded

Description

Called after all scripts are successfully reloaded.


on_process_close

Description

Called when a monitored process is closed. This requires process:monitor to be called on a target process. If using Constellation4, CS:GO is already pre-monitored. Therefore this callback is triggered when CS:GO closes.

Parameters

  • string name

on_notification_created

Description

Called whenever FC2 creates a notification. This is also triggered by fantasy.notification.

Returning false with this callback will stop the notification from being created. Returning a string with this callback with change the message of the notification to the string value.

Parameters

  • string title
  • string message

Example

Lua
local notification_test = {}

function notification_test.on_loaded()

    fantasy.notification( "fantasy.cat", "Hello World" )

end

function notification_test.on_notification_created( title, message )

    -- returning false prevents the notification from showing.
    -- return false

    --[[
        is our notification title called "fantasy.cat"? of course.

        this callback gets triggered when ANY notification gets created.
        therefore a check to make sure we are actually modifying the message of the correct notification is important.
    --]]
    if title == "fantasy.cat" then

        -- change the message of the notification
        return "Welcome to fantasy.cat!"

    end

    -- on_notification_created always returns "true" if nothing is specified.
end

return notification_test

on_solution_load

Description

This is called when a solution is loaded via fantasy.load.

Parameters

  • table sessions
  • string args

on_sound_esp

Description

This callback is only triggered in Constellation4 when the Sound ESP is activated. Returning false in this callback will stop the Sound ESP from executing in the current worker tick.

Parameters

  • table data
    • number current_time
    • number next_allowed_time
    • number fov
    • entity entity
    • number bone_id
    • number direction
    • number true_fov
    • number distance
    • vector angle
    • vector bone

on_http_request

Description

Called when a GET or POST request is sent to FC2.

Returning a string in this callback only works when the path is /luar. See the http module for documentation on /luar. The returned string must be in JSON format. Consider using the lib_json library to do this. Click me for an example.

Parameters

  • table data
    • string ip
    • number port
    • string method
    • string path
    • string body
    • string script
    • table [string, string] params

Returns

  • string (optional)

Description

This callback is no longer triggered in FC2. This used to be called whenever netvars were searched. This is useless now as you can simply dump netvars another way.

Parameters

  • string class
  • string var
  • string value

on_humanizer_pre

Description

This callback is only triggered in Constellation4 when the Humanizer is idling and pre-calculating its next target and what operations to perform. Returning false in this callback will stop the Humanizer from executing in the current tick.

Returning an integer value will disable the pulling module in Humanizer4 and force a smoothing value instead. By doing this, the one-tap module will be disabled. Furthermore, constellation.lua Humanizer4 settings will be ignored (range, threshold).

Parameters

  • entity localplayer
  • entity localweapon
  • table data
    • number ammo
    • number shots_fired
    • entity last_target
    • entity entity
    • number bone_id
    • number direction
    • number true_fov
    • number static_fov
    • number distance
    • vector angle
    • vector bone

on_humanizer_lost_target

Description

This callback is only triggered in Constellation4 when the Humanizer loses a target it was focusing on.

Parameters

  • entity localplayer
  • entity localweapon
  • table data
    • entity last_target

on_humanizer_idle

Description

This callback is only triggered in Constellation4 when the Humanizer has no target because conditions weren't met. Therefore it has nothing to do besides idle.

Parameters

  • entity localplayer
  • entity localweapon
  • table data
    • entity last_target
    • entity entity
    • number bone_id
    • number direction
    • number true_fov
    • number static_fov
    • number distance
    • vector angle
    • vector bone

on_humanizer

Description

This callback is only triggered in Constellation4 when the Humanizer is successfully ready to perform mouse simulation. Returning false in this callback will stop the Humanizer from executing in the current tick.

Parameters

  • entity localplayer
  • entity localweapon
  • table data
    • number x
    • number y
    • number pull
    • number ammo
    • number shots_fired
    • entity last_target
    • entity entity
    • number bone_id
    • number direction
    • number true_fov
    • number static_fov
    • number distance
    • vector angle
    • vector bone
    • boolean is_one_tapping

on_constelia_speak

Description

This is triggered whenever the Constelia module activates voice.

Parameters

  • string voiceline

on_scripts_loaded

Description

This is triggered when all scripts are completely loaded.


on_solution_calibrated

Description

This is called moments after a FC2 solution is calibrated. If you return false with this callback, it will stop the script from executing any further.

Parameters

  • table
    • string name
    • string version
    • number gameid

Returns

  • boolean

Description

No practical usage right now. It doesn't work because scripts are loaded after Zombie check. Maybe in the future. Returning a string here will change the process to compromise.

Use fc2.lua:zombie in your configuration instead.

Parameters

  • string process

on_blender_start

Description

This is called when Blender is requested to start its worker.


on_blender_recovery

Description

This is called when Blender is requested to start its recovery worker.


on_blender_recovery_end

Description

This is called when Blender finishes its recovery worker.


on_blender_end

Description

This is called when Blender finishes its general worker.


on_parallax_loaded

Description

This is after Parallax2 has loaded. However, this is only invoked if you have editor_mode on.


on_team_call

Description

This is called when an FC2T project invokes fc2::call. See documentation for FC2T. See examples/call on the FC2T repository for several examples.

Parameters

  • string identifier
  • table json

on_project_loaded

Description

This is called when an FC2T project is launched.

The virustotal, checksum, and file values passed in the table are OS-dependent. For example: The virustotal link will share the Linux version link if you are using FC2 Linux. But will share the Windows version link if you are using FC2 Windows.

This callback is not synchronized with the process that is launched. This callback will always be triggered before the project process is loaded. If you are trying to synchronize this, you would need to halt the Lua worker until the process is found. Consider using the engine:process module for this.

Parameters

  • table data
    • string name
    • string author
    • number id
    • number last_update
    • string virustotal
    • string thread
    • string checksum
    • string file

on_project_load

Description

This is called before an FC2T project is processed. Returning false in this callback will stop the FC2T project from loading.

Parameters

  • table data
  • string name
  • string author
  • number id
  • number last_update
  • string virustotal
  • string thread
  • string checksum
  • string file

on_overlay_requested

Description

This is called before the overlay module starts (if enabled). Returning false on this callback will stop the overlay from starting.

Parameters

  • string window_name