EVENT

this callback is called every time csgo fires an event, along with it the event object is passed. you can get a list of all events and their fields here

local function on_event(event)
    print("received event", event.name)

    -- only react to specific events
    if event.name == "player_death" then
        -- all fields can be found here: https://wiki.alliedmods.net/Counter-Strike:_Global_Offensive_Events#player_death
        print("a player got killed by a", event.weapon)

        -- all event fields are also mutable
        -- the following code will force all kills to show as headshots
        event.headshot = true
    end
end

callbacks.add(e_callbacks.EVENT, on_event)

alternatively, if you only want to react to a specific event, there is an optional argument you can pass into the callbacks.add function

-- this function will only be called for "player_death" events
local function on_player_death(event)
    -- all fields can be found here: https://wiki.alliedmods.net/Counter-Strike:_Global_Offensive_Events#player_death
    print("a player got killed by a", event.weapon)
end

callbacks.add(e_callbacks.EVENT, on_event, "player_death")

Last updated