Skip to main content

Events

enum DrawContextColor

MouseButton = {
--- Left mouse button.
LBUTTON = 0,
--- Right mouse button.
RBUTTON = 1,
--- Middle mouse button.
MBUTTON = 2,
}

enum MouseClickRegion

MouseClickRegion = {
--- Mouse click within the game area.
GAME = 0,
--- Mouse click within the menu area.
MENU = 1,
}

events.on_player_join

Registers a callback that is called when a player joins.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t):voidThe callback function to be invoked when a player joins.
  • Methods:

    • events.on_player_join(callback)

events.on_player_left

Registers a callback that is called when a player leaves.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t):voidThe callback function to be invoked when a player leaves.
  • Methods:

    • events.on_player_left(callback)

events.on_player_active

Registers a callback that is called when a player becomes active.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t):voidThe callback function to be invoked when a player becomes active.
  • Methods:

    • events.on_player_active(callback)

events.on_player_adding

Registers a callback that is called when adding a player.

  • Parameters:

    NameTypeDescription
    callbackfun(name: string, rid: number):booleannil
  • Methods:

    • events.on_player_adding(callback)

events.on_session_join

Registers a callback that is called when a session is joined.

  • Parameters:

    NameTypeDescription
    callbackfun():voidThe callback function to be invoked when a session is joined.
  • Methods:

    • events.on_session_join(callback)

events.on_session_left

Registers a callback that is called when a session is left.

  • Parameters:

    NameTypeDescription
    callbackfun():voidThe callback function to be invoked when a session is left.
  • Methods:

    • events.on_session_left(callback)

events.on_game_state

Registers a callback that is called when the game state changes.

  • Parameters:

    NameTypeDescription
    callbackfun(prev_state: number, cur_state: number):voidThe callback function to be invoked when the game state changes.
  • Methods:

    • events.on_game_state(callback)

events.on_spawn

Registers a callback that is called when the local player is spawned.

  • Parameters:

    NameTypeDescription
    callbackfun(is_online: boolean):voidThe callback function to be invoked when the local player is spawned.
  • Methods:

    • events.on_spawn(callback)

events.on_death

Registers a callback that is called when the local player dies.

  • Parameters:

    NameTypeDescription
    callbackfun():voidThe callback function to be invoked when the local player dies.
  • Methods:

    • events.on_death(callback)

events.on_script_started

Registers a callback that is called when a script starts.

  • Parameters:

    NameTypeDescription
    callbackfun(script_name: string):voidThe callback function to be invoked when a script starts.
  • Methods:

    • events.on_script_started(callback)

events.on_script_stopped

Registers a callback that is called when a script stops.

  • Parameters:

    NameTypeDescription
    callbackfun(script_name: string, reason: number):voidThe callback function to be invoked when a script stops.
  • Methods:

    • events.on_script_stopped(callback)

events.on_key_state

Registers a callback that is called on key state change.

  • Parameters:

    NameTypeDescription
    callbackfun(key: string, is_down: boolean):voidThe callback function to be invoked on key state change.
  • Methods:

    • events.on_key_state(callback)

events.on_transition_end

Registers a callback that is called at the end of the transition to online or single-player mode.

  • Parameters:

    NameTypeDescription
    callbackfun(is_online: boolean):voidThe callback function to be invoked at the end of the transition.
  • Methods:

    • events.on_transition_end(callback)

events.on_first_singleplayer_join

Registers a callback that is called when the player fully enters single-player for the first time.

  • Parameters:

    NameTypeDescription
    callbackfun():voidThe callback function to be invoked when the player fully enters single-player.
  • Methods:

    • events.on_first_singleplayer_join(callback)

events.on_window_proc

Registers a callback that is called for the game window's WindowProc.

  • Parameters:

    NameTypeDescription
    callbackfun(hwnd: number, uMsg: number, wParam: number, lParam: number):numbernil
  • Methods:

    • events.on_window_proc(callback)

events.on_player_shot

Registers a callback that is called when a player shoots a weapon.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t, weapon: number):voidThe callback function to be invoked when a player shoots a weapon.
  • Methods:

    • events.on_player_shot(callback)

events.on_modder_detected

Registers a callback that is called when a player is detected as a modder.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t, flag: number, params: table):voidThe callback function to be invoked when a player is detected as a modder.
  • Methods:

    • events.on_modder_detected(callback)

events.on_script_migrate

Registers a callback that is called when a script migrates to another player.

  • Parameters:

    NameTypeDescription
    callbackfun(is_freemode: boolean, is_you: boolean, script_name: string, ply: player_t):voidThe callback function to be invoked when a script migrates to another player.
  • Methods:

    • events.on_script_migrate(callback)

events.on_sync_blocked

Registers a callback that is called when synchronization is blocked for a player.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t, reason: string, ban_time: number):voidThe callback function to be invoked when synchronization is blocked for a player.
  • Methods:

    • events.on_sync_blocked(callback)

events.on_script_event

Registers a callback that is called when a script event is received.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t, hash: number, args: table):voidThe callback function to be invoked when a script event is received.
  • Methods:

    • events.on_script_event(callback)

events.on_session_host_changed

Registers a callback that is called when the session host changes.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t):voidThe callback function to be invoked when the session host changes.
  • Methods:

    • events.on_session_host_changed(callback)

events.on_weapon_received

Registers a callback that is called when a pedestrian receives a weapon.

  • Parameters:

    NameTypeDescription
    callbackfun(ped: number, weapon_hash: number, ammo_count: number):voidThe callback function to be invoked when a pedestrian receives a weapon.
  • Methods:

    • events.on_weapon_received(callback)

events.on_chat_msg

Registers a callback that is called when a chat message is received from a player.

  • Parameters:

    NameTypeDescription
    callbackfun(ply: player_t, text: string):voidThe callback function to be invoked when a chat message is received from a player.
  • Methods:

    • events.on_chat_msg(callback)

events.on_frame

Registers a callback that is called during the UI drawing call of the product.

  • Parameters:

    NameTypeDescription
    callbackfun():voidThe callback function to be invoked during the UI drawing call.
  • Methods:

    • events.on_frame(callback)

events.on_script_tick

Registers a callback that is called every script tick.

  • Parameters:

    NameTypeDescription
    callbackfun():voidThe callback function to be invoked every script tick