csgolog

package module
v1.1.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 18, 2020 License: MIT Imports: 8 Imported by: 4

README

Build Status

csgo-log

Go package for parsing csgo server logfiles. It exports types for csgo logfiles, their regular expressions, a function for parsing and a function for converting to non-html-escaped JSON.

Usage

For more examples look at the tests and the command-line utility in examples folder. Have also a look at godoc.

package main

import (
  "fmt"

  "github.com/FlowingSPDG/csgo-log"
)

func main() {

  var msg csgolog.Message

  // a line from a server logfile
  line := `L 11/05/2018 - 15:44:36: "Player<12><STEAM_1:1:0101011><CT>" purchased "m4a1"`

  // parse into Message
  msg, err := csgolog.Parse(line)

  if err != nil {
    panic(err)
  }

  fmt.Println(msg.GetType(), msg.GetTime().String())

  // cast Message interface to PlayerPurchase type
  playerPurchase, ok := msg.(csgolog.PlayerPurchase)

  if ok != true {
    panic("casting failed")
  }

  fmt.Println(playerPurchase.Player.SteamID, playerPurchase.Item)

  // get json non-htmlescaped
  jsn := csgolog.ToJSON(msg) 

  fmt.Println(jsn)
}

Example JSON output:

{
  "time": "2018-11-05T15:44:36Z",
  "type": "PlayerPurchase",
  "player": {
    "name": "Player",
    "id": 12,
    "steam_id": "STEAM_1:1:0101011",
    "side": "CT"
  },
  "item": "m4a1"
}

Documentation

Overview

Package csgolog provides utilities for parsing a csgo server logfile. It exports types for csgo logfiles, their regular expressions, a function for parsing and a function for converting to non-html-escaped JSON.

Look at the examples for Parse and ToJSON for usage instructions.

You will find a command-line utility in examples folder as well as an example logfile with ~3000 lines.

Index

Examples

Constants

View Source
const (
	// ServerMessagePattern regular expression
	ServerMessagePattern = `server_message: "(\w+)"`
	// FreezTimeStartPattern regular expression
	FreezTimeStartPattern = `Starting Freeze period`
	// WorldMatchStartPattern regular expression
	WorldMatchStartPattern = `World triggered "Match_Start" on "(\w+)"`
	// WorldRoundStartPattern regular expression
	WorldRoundStartPattern = `World triggered "Round_Start"`
	// WorldRoundRestartPattern regular expression
	WorldRoundRestartPattern = `World triggered "Restart_Round_\((\d+)_second\)`
	// WorldRoundEndPattern regular expression
	WorldRoundEndPattern = `World triggered "Round_End"`
	// WorldGameCommencingPattern regular expression
	WorldGameCommencingPattern = `World triggered "Game_Commencing"`
	// TeamScoredPattern regular expression
	TeamScoredPattern = `Team "(CT|TERRORIST)" scored "(\d+)" with "(\d+)" players`
	// TeamNoticePattern regular expression
	TeamNoticePattern = `Team "(CT|TERRORIST)" triggered "(\w+)" \(CT "(\d+)"\) \(T "(\d+)"\)`
	// PlayerConnectedPattern regular expression
	PlayerConnectedPattern = `"(.+)<(\d+)><([\w:]+)><>" connected, address "(.*)"`
	// PlayerDisconnectedPattern regular expression
	PlayerDisconnectedPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT|Unassigned|)>" disconnected \(reason "(.+)"\)`
	// PlayerEnteredPattern regular expression
	PlayerEnteredPattern = `"(.+)<(\d+)><([\w:]+)><>" entered the game`
	// PlayerBannedPattern regular expression
	PlayerBannedPattern = `Banid: "(.+)<(\d+)><([\w:]+)><\w*>" was banned "([\w. ]+)" by "(\w+)"`
	// PlayerSwitchedPattern regular expression
	PlayerSwitchedPattern = `"(.+)<(\d+)><([\w:]+)>" switched from team <(Unassigned|Spectator|TERRORIST|CT)> to <(Unassigned|Spectator|TERRORIST|CT)>`
	// PlayerSayPattern regular expression
	PlayerSayPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" say(_team)? "(.*)"`
	// PlayerPurchasePattern regular expression
	PlayerPurchasePattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" purchased "(\w+)"`
	// PlayerKillPattern regular expression
	PlayerKillPattern = `` /* 207-byte string literal not displayed */
	// PlayerKillAssistPattern regular expression
	PlayerKillAssistPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" assisted killing "(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>"`
	// PlayerAttackPattern regular expression
	PlayerAttackPattern = `` /* 262-byte string literal not displayed */
	// PlayerKilledBombPattern regular expression
	PlayerKilledBombPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" \[(-?\d+) (-?\d+) (-?\d+)\] was killed by the bomb\.`
	// PlayerKilledSuicidePattern regular expression
	PlayerKilledSuicidePattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" \[(-?\d+) (-?\d+) (-?\d+)\] committed suicide with "(.*)"`
	// PlayerPickedUpPattern regular expression
	PlayerPickedUpPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" picked up "(\w+)"`
	// PlayerDroppedPattern regular expression
	PlayerDroppedPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT|Unassigned)>" dropped "(\w+)"`
	// PlayerMoneyChangePattern regular expression
	PlayerMoneyChangePattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" money change (\d+)\+?(-?\d+) = \$(\d+) \(tracked\)( \(purchase: (\w+)\))?`
	// PlayerBombGotPattern regular expression
	PlayerBombGotPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" triggered "Got_The_Bomb"`
	// PlayerBombPlantedPattern regular expression
	PlayerBombPlantedPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" triggered "Planted_The_Bomb"`
	// PlayerBombDroppedPattern regular expression
	PlayerBombDroppedPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" triggered "Dropped_The_Bomb"`
	// PlayerBombBeginDefusePattern regular expression
	PlayerBombBeginDefusePattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" triggered "Begin_Bomb_Defuse_With(out)?_Kit"`
	// PlayerBombDefusedPattern regular expression
	PlayerBombDefusedPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" triggered "Defused_The_Bomb"`
	// PlayerThrewPattern regular expression
	PlayerThrewPattern = `"(.+)<(\d+)><([\w:]+)><(TERRORIST|CT)>" threw (\w+) \[(-?\d+) (-?\d+) (-?\d+)\]( flashbang entindex (\d+))?\)?`
	// PlayerBlindedPattern regular expression
	PlayerBlindedPattern = `` /* 133-byte string literal not displayed */
	// ProjectileSpawnedPattern regular expression
	ProjectileSpawnedPattern = `Molotov projectile spawned at (-?\d+\.\d+) (-?\d+\.\d+) (-?\d+\.\d+), velocity (-?\d+\.\d+) (-?\d+\.\d+) (-?\d+\.\d+)`
	// GameOverPattern regular expression
	GameOverPattern = `Game Over: (\w+) (\w+) (\w+) score (\d+):(\d+) after (\d+) min`
	// ServerCvarPattern regular expression
	ServerCvarPattern = `server_cvar: "(\w+)" "(.*)"`
	// Get5EventPattern regular expression
	Get5EventPattern = `` /* 334-byte string literal not displayed */
	// RconEventPattern regular expression
	RconEventPattern = `rcon from "(.*):(\d+)": command "(.*)"`
	// PlayerKillOtherPattern regular expression
	PlayerKillOtherPattern = `` /* 135-byte string literal not displayed */

)

Variables

View Source
var DefaultPatterns = map[*regexp.Regexp]MessageFunc{
	regexp.MustCompile(ServerMessagePattern):         NewServerMessage,
	regexp.MustCompile(FreezTimeStartPattern):        NewFreezTimeStart,
	regexp.MustCompile(WorldMatchStartPattern):       NewWorldMatchStart,
	regexp.MustCompile(WorldRoundStartPattern):       NewWorldRoundStart,
	regexp.MustCompile(WorldRoundRestartPattern):     NewWorldRoundRestart,
	regexp.MustCompile(WorldRoundEndPattern):         NewWorldRoundEnd,
	regexp.MustCompile(WorldGameCommencingPattern):   NewWorldGameCommencing,
	regexp.MustCompile(TeamScoredPattern):            NewTeamScored,
	regexp.MustCompile(TeamNoticePattern):            NewTeamNotice,
	regexp.MustCompile(PlayerConnectedPattern):       NewPlayerConnected,
	regexp.MustCompile(PlayerDisconnectedPattern):    NewPlayerDisconnected,
	regexp.MustCompile(PlayerEnteredPattern):         NewPlayerEntered,
	regexp.MustCompile(PlayerBannedPattern):          NewPlayerBanned,
	regexp.MustCompile(PlayerSwitchedPattern):        NewPlayerSwitched,
	regexp.MustCompile(PlayerSayPattern):             NewPlayerSay,
	regexp.MustCompile(PlayerPurchasePattern):        NewPlayerPurchase,
	regexp.MustCompile(PlayerKillPattern):            NewPlayerKill,
	regexp.MustCompile(PlayerKillAssistPattern):      NewPlayerKillAssist,
	regexp.MustCompile(PlayerAttackPattern):          NewPlayerAttack,
	regexp.MustCompile(PlayerKilledBombPattern):      NewPlayerKilledBomb,
	regexp.MustCompile(PlayerKilledSuicidePattern):   NewPlayerKilledSuicide,
	regexp.MustCompile(PlayerPickedUpPattern):        NewPlayerPickedUp,
	regexp.MustCompile(PlayerDroppedPattern):         NewPlayerDropped,
	regexp.MustCompile(PlayerMoneyChangePattern):     NewPlayerMoneyChange,
	regexp.MustCompile(PlayerBombGotPattern):         NewPlayerBombGot,
	regexp.MustCompile(PlayerBombPlantedPattern):     NewPlayerBombPlanted,
	regexp.MustCompile(PlayerBombDroppedPattern):     NewPlayerBombDropped,
	regexp.MustCompile(PlayerBombBeginDefusePattern): NewPlayerBombBeginDefuse,
	regexp.MustCompile(PlayerBombDefusedPattern):     NewPlayerBombDefused,
	regexp.MustCompile(PlayerThrewPattern):           NewPlayerThrew,
	regexp.MustCompile(PlayerBlindedPattern):         NewPlayerBlinded,
	regexp.MustCompile(ProjectileSpawnedPattern):     NewProjectileSpawned,
	regexp.MustCompile(GameOverPattern):              NewGameOver,
	regexp.MustCompile(ServerCvarPattern):            NewServerCvar,
	regexp.MustCompile(Get5EventPattern):             NewGet5Event,
	regexp.MustCompile(RconEventPattern):             NewRconEvent,
	regexp.MustCompile(PlayerKillOtherPattern):       NewPlayerKillOther,
}
View Source
var ErrorNoMatch = errors.New("no match")

ErrorNoMatch error when pattern is not matching

View Source
var HTTPLinePattern = regexp.MustCompile(`(\d{2}\/\d{2}\/\d{4} - \d{2}:\d{2}:\d{2}.\d{3}) - (.*)`)

HTTPLinePattern is the regular expression to capture a line of a HTTP logging

View Source
var LogLinePattern = regexp.MustCompile(`L (\d{2}\/\d{2}\/\d{4} - \d{2}:\d{2}:\d{2}): (.*)`)

LogLinePattern is the regular expression to capture a line of a logfile

Functions

func ToJSON

func ToJSON(m Message) string

ToJSON marshals messages to JSON without escaping html

Example
// parse Message
msg, _ := Parse(`L 11/05/2018 - 15:44:36: "Player-Name<12><STEAM_1:1:0101011><CT>" purchased "m4a1"`)

// cast Message interface type to PlayerPurchase type
playerPurchase, _ := msg.(PlayerPurchase)

fmt.Println(playerPurchase.Player.SteamID)
fmt.Println(playerPurchase.Item)

// get json non-html-escaped
jsn := ToJSON(msg)

fmt.Println(jsn)
Output:

STEAM_1:1:0101011
m4a1
{"time":"2018-11-05T15:44:36Z","type":"PlayerPurchase","player":{"name":"Player-Name","id":12,"steam_id":"STEAM_1:1:0101011","side":"CT"},"item":"m4a1"}

Types

type Equation

type Equation struct {
	A      int `json:"a"`
	B      int `json:"b"`
	Result int `json:"result"`
}

Equation holds the parameters and result of a money change equation in the form A + B = Result

type FreezTimeStart

type FreezTimeStart struct{ Meta }

FreezTimeStart is received before each round

type GameOver

type GameOver struct {
	Meta
	Mode     string `json:"mode"`
	MapGroup string `json:"map_group"`
	Map      string `json:"map"`
	ScoreCT  int    `json:"score_ct"`
	ScoreT   int    `json:"score_t"`
	Duration int    `json:"duration"`
}

GameOver is received when a team won and the game ends

type Get5Event

type Get5Event struct {
	Meta
	Matchid string          `json:"matchid"`
	Params  Get5EventParams `json:"params"`
	Event   string          `json:"event"`
}

type Get5EventParams

type Get5EventParams struct {
	MapNumber        int    `json:"map_number,omitempty"`
	MapName          string `json:"map_name,omitempty"`
	Team1Name        string `json:"team1_name,omitempty"`
	Team1Score       int    `json:"team1_score,omitempty"`
	Team1SeriesScore int    `json:"team1_series_score,omitempty"`
	Team2Name        string `json:"team2_name,omitempty"`
	Team2Score       int    `json:"team2_score,omitempty"`
	Team2SeriesScore int    `json:"team2_series_score,omitempty"`
	Headshot         int    `json:"headshot,omitempty"`
	Weapon           string `json:"weapon,omitempty"`
	Reason           int    `json:"reason,omitempty"`
	Message          string `json:"message,omitempty"`
	File             string `json:"file,omitempty"`
	Site             int    `json:"site,omitempty"`
	Stage            string `json:"stage,omitempty"`
	Victim           string `json:"victim"`
	Attacker         string `json:"attacker"`
	Winner           string `json:"winner"`
	WinnerSide       string `json:"winner_side"`
}

type Get5Events

type Get5Events string

Get5Event event types(enum)

const (
	Get5SeriesStart         Get5Events = "series_start"
	Get5MapVeto             Get5Events = "map_veto"
	Get5MapPick             Get5Events = "map_pick"
	Get5SidePicked          Get5Events = "side_picked"
	Get5KnifeStart          Get5Events = "knife_start"
	Get5KnifeWon            Get5Events = "knife_won"
	Get5GoingLive           Get5Events = "going_live"
	Get5PlayerDeath         Get5Events = "player_death"
	Get5RoundEnd            Get5Events = "round_end"
	Get5SideSwap            Get5Events = "side_swap"
	Get5MapEnd              Get5Events = "map_end"
	Get5SeriesEnd           Get5Events = "series_end"
	Get5BackupLoaded        Get5Events = "backup_loaded"
	Get5MatchConfigLoadFail Get5Events = "match_config_load_fail"
	Get5ClientSay           Get5Events = "client_say"
	Get5BombPlanted         Get5Events = "bomb_planted"
	Get5BombDefused         Get5Events = "bomb_defused"
	Get5BombExploded        Get5Events = "bomb_exploded"
	Get5PlayerConnected     Get5Events = "player_connect"
	Get5PlayerDisconnect    Get5Events = "player_disconnect"
	Get5TeamReady           Get5Events = "team_ready"
	Get5TeamUnready         Get5Events = "team_unready"
)

type Message

type Message interface {
	GetType() string
	GetTime() time.Time
}

Message is the interface for all messages

func NewFreezTimeStart

func NewFreezTimeStart(ti time.Time, r []string) Message

func NewGameOver

func NewGameOver(ti time.Time, r []string) Message

func NewGet5Event

func NewGet5Event(ti time.Time, r []string) Message

func NewPlayerAttack

func NewPlayerAttack(ti time.Time, r []string) Message

func NewPlayerBanned

func NewPlayerBanned(ti time.Time, r []string) Message

func NewPlayerBlinded

func NewPlayerBlinded(ti time.Time, r []string) Message

func NewPlayerBombBeginDefuse

func NewPlayerBombBeginDefuse(ti time.Time, r []string) Message

func NewPlayerBombDefused

func NewPlayerBombDefused(ti time.Time, r []string) Message

func NewPlayerBombDropped

func NewPlayerBombDropped(ti time.Time, r []string) Message

func NewPlayerBombGot

func NewPlayerBombGot(ti time.Time, r []string) Message

func NewPlayerBombPlanted

func NewPlayerBombPlanted(ti time.Time, r []string) Message

func NewPlayerConnected

func NewPlayerConnected(ti time.Time, r []string) Message

func NewPlayerDisconnected

func NewPlayerDisconnected(ti time.Time, r []string) Message

func NewPlayerDropped

func NewPlayerDropped(ti time.Time, r []string) Message

func NewPlayerEntered

func NewPlayerEntered(ti time.Time, r []string) Message

func NewPlayerKill

func NewPlayerKill(ti time.Time, r []string) Message

func NewPlayerKillAssist

func NewPlayerKillAssist(ti time.Time, r []string) Message

func NewPlayerKillOther

func NewPlayerKillOther(ti time.Time, r []string) Message

func NewPlayerKilledBomb

func NewPlayerKilledBomb(ti time.Time, r []string) Message

func NewPlayerKilledSuicide

func NewPlayerKilledSuicide(ti time.Time, r []string) Message

func NewPlayerMoneyChange

func NewPlayerMoneyChange(ti time.Time, r []string) Message

func NewPlayerPickedUp

func NewPlayerPickedUp(ti time.Time, r []string) Message

func NewPlayerPurchase

func NewPlayerPurchase(ti time.Time, r []string) Message

func NewPlayerSay

func NewPlayerSay(ti time.Time, r []string) Message

func NewPlayerSwitched

func NewPlayerSwitched(ti time.Time, r []string) Message

func NewPlayerThrew

func NewPlayerThrew(ti time.Time, r []string) Message

func NewProjectileSpawned

func NewProjectileSpawned(ti time.Time, r []string) Message

func NewRconEvent

func NewRconEvent(ti time.Time, r []string) Message

func NewServerCvar

func NewServerCvar(ti time.Time, r []string) Message

func NewServerMessage

func NewServerMessage(ti time.Time, r []string) Message

func NewTeamNotice

func NewTeamNotice(ti time.Time, r []string) Message

func NewTeamScored

func NewTeamScored(ti time.Time, r []string) Message

func NewUnknown

func NewUnknown(ti time.Time, r []string) Message

func NewWorldGameCommencing

func NewWorldGameCommencing(ti time.Time, r []string) Message

func NewWorldMatchStart

func NewWorldMatchStart(ti time.Time, r []string) Message

func NewWorldRoundEnd

func NewWorldRoundEnd(ti time.Time, r []string) Message

func NewWorldRoundRestart

func NewWorldRoundRestart(ti time.Time, r []string) Message

func NewWorldRoundStart

func NewWorldRoundStart(ti time.Time, r []string) Message

func Parse

func Parse(line string) (Message, error)

Parse parses a plain log message and returns message type or error if there's no match

Example
var msg Message

// a line from a server logfile
line := `L 11/05/2018 - 15:44:36: "Player-Name<12><STEAM_1:1:0101011><CT>" purchased "m4a1"`

// parse Message
msg, _ = Parse(line)

fmt.Println(msg.GetType())
fmt.Println(msg.GetTime().String())
Output:

PlayerPurchase
2018-11-05 15:44:36 +0000 UTC

func ParseWithPatterns

func ParseWithPatterns(line string, patterns map[*regexp.Regexp]MessageFunc) (Message, error)

Parse attempts to match a plain log message against the map of provided patterns, if the line matches a key from the map, the corresponding MessageFunc is called on the line to parse it into a Message

type MessageFunc

type MessageFunc func(ti time.Time, r []string) Message

type Meta

type Meta struct {
	Time time.Time `json:"time"`
	Type string    `json:"type"`
}

Meta holds time and type of a log message

func NewMeta

func NewMeta(ti time.Time, ty string) Meta

func (Meta) GetTime

func (m Meta) GetTime() time.Time

GetTime is the getter for Meta.Time

func (Meta) GetType

func (m Meta) GetType() string

GetType is the getter fo Meta.Type

type Player

type Player struct {
	Name    string `json:"name"`
	ID      int    `json:"id"`
	SteamID string `json:"steam_id"`
	Side    string `json:"side"`
}

Player holds the information about a player known from log

type PlayerAttack

type PlayerAttack struct {
	Meta
	Attacker         Player   `json:"attacker"`
	AttackerPosition Position `json:"attacker_pos"`
	Victim           Player   `json:"victim"`
	VictimPosition   Position `json:"victim_pos"`
	Weapon           string   `json:"weapon"`
	Damage           int      `json:"damage"`
	DamageArmor      int      `json:"damage_armor"`
	Health           int      `json:"health"`
	Armor            int      `json:"armor"`
	Hitgroup         string   `json:"hitgroup"`
}

PlayerAttack is recieved when a player attacks another

type PlayerBanned

type PlayerBanned struct {
	Meta
	Player   Player `json:"player"`
	Duration string `json:"duration"`
	By       string `json:"by"`
}

PlayerBanned is received when a player gots banned from the server

type PlayerBlinded

type PlayerBlinded struct {
	Meta
	Attacker Player  `json:"attacker"`
	Victim   Player  `json:"victim"`
	For      float32 `json:"for"`
	Entindex int     `json:"entindex"`
}

PlayerBlinded is received when a player got blinded

type PlayerBombBeginDefuse

type PlayerBombBeginDefuse struct {
	Meta
	Player Player `json:"player"`
	Kit    bool   `json:"kit"`
}

PlayerBombBeginDefuse is received when a player begins defusing the bomb

type PlayerBombDefused

type PlayerBombDefused struct {
	Meta
	Player Player `json:"player"`
}

PlayerBombDefused is received when a player defused the bomb

type PlayerBombDropped

type PlayerBombDropped struct {
	Meta
	Player Player `json:"player"`
}

PlayerBombDropped is received when a player drops the bomb

type PlayerBombGot

type PlayerBombGot struct {
	Meta
	Player Player `json:"player"`
}

PlayerBombGot is received when a player picks up the bomb

type PlayerBombPlanted

type PlayerBombPlanted struct {
	Meta
	Player Player `json:"player"`
}

PlayerBombPlanted is received when a player plants the bomb

type PlayerConnected

type PlayerConnected struct {
	Meta
	Player  Player `json:"player"`
	Address string `json:"address"`
}

PlayerConnected message is received when a player connects and holds the address from where the player is connecting

type PlayerDisconnected

type PlayerDisconnected struct {
	Meta
	Player Player `json:"player"`
	Reason string `json:"reason"`
}

PlayerDisconnected is received when a player disconnets and holds the reason why the player left

type PlayerDropped

type PlayerDropped struct {
	Meta
	Player Player `json:"player"`
	Item   string `json:"item"`
}

PlayerDropped is recieved when a player drops an item

type PlayerEntered

type PlayerEntered struct {
	Meta
	Player Player `json:"player"`
}

PlayerEntered is received when a player enters the game

type PlayerKill

type PlayerKill struct {
	Meta
	Attacker         Player   `json:"attacker"`
	AttackerPosition Position `json:"attacker_pos"`
	Victim           Player   `json:"victim"`
	VictimPosition   Position `json:"victim_pos"`
	Weapon           string   `json:"weapon"`
	Headshot         bool     `json:"headshot"`
	Penetrated       bool     `json:"penetrated"`
}

PlayerKill is received when a player kills another

type PlayerKillAssist

type PlayerKillAssist struct {
	Meta
	Attacker Player `json:"attacker"`
	Victim   Player `json:"victim"`
}

PlayerKillAssist is received when a player assisted killing another

type PlayerKillOther

type PlayerKillOther struct {
	Meta
	Attacker         Player   `json:"attacker"`
	AttackerPosition Position `json:"attacker_pos"`
	Victim           string   `json:"victim"`
	VictimID         string   `json:"victim_id"`
	VictimPosition   Position `json:"victim_pos"`
	Weapon           string   `json:"weapon"`
}

PlayerKillOther is received when a player destroys map resources

type PlayerKilledBomb

type PlayerKilledBomb struct {
	Meta
	Player   Player   `json:"player"`
	Position Position `json:"pos"`
}

PlayerKilledBomb is received when a player is killed by the bomb

type PlayerKilledSuicide

type PlayerKilledSuicide struct {
	Meta
	Player   Player   `json:"player"`
	Position Position `json:"pos"`
	With     string   `json:"with"`
}

PlayerKilledSuicide is received when a player commited suicide

type PlayerMoneyChange

type PlayerMoneyChange struct {
	Meta
	Player   Player   `json:"player"`
	Equation Equation `json:"equation"`
	Purchase string   `json:"purchase"`
}

PlayerMoneyChange is received when a player loses or receives money TODO: add before +-money

type PlayerPickedUp

type PlayerPickedUp struct {
	Meta
	Player Player `json:"player"`
	Item   string `json:"item"`
}

PlayerPickedUp is received when a player picks up an item

type PlayerPurchase

type PlayerPurchase struct {
	Meta
	Player Player `json:"player"`
	Item   string `json:"item"`
}

PlayerPurchase holds info about which player bought an item

type PlayerSay

type PlayerSay struct {
	Meta
	Player Player `json:"player"`
	Text   string `json:"text"`
	Team   bool   `json:"team"`
}

PlayerSay is received when a player writes into chat

type PlayerSwitched

type PlayerSwitched struct {
	Meta
	Player Player `json:"player"`
	From   string `json:"from"`
	To     string `json:"to"`
}

PlayerSwitched is received when a player switches sides

type PlayerThrew

type PlayerThrew struct {
	Meta
	Player   Player   `json:"player"`
	Position Position `json:"pos"`
	Entindex int      `json:"entindex"`
	Grenade  string   `json:"grenade"`
}

PlayerThrew is received when a player threw a grenade

type Position

type Position struct {
	X int `json:"x"`
	Y int `json:"y"`
	Z int `json:"z"`
}

Position holds the coords for a event happend on the map

type PositionFloat

type PositionFloat struct {
	X float32 `json:"x"`
	Y float32 `json:"y"`
	Z float32 `json:"z"`
}

PositionFloat holds more exact coords

type ProjectileSpawned

type ProjectileSpawned struct {
	Meta
	Position PositionFloat `json:"pos"`
	Velocity Velocity      `json:"velocity"`
}

ProjectileSpawned is received when a molotov spawned

type Rcon

type Rcon struct {
	Meta
	IP      string `json:"ip"`
	Port    uint   `json:"port"`
	Command string `json:"command"`
}

type ServerCvar

type ServerCvar struct {
	Meta
	Key   string `json:"mode"`
	Value string `json:"value"`
}

type ServerMessage

type ServerMessage struct {
	Meta
	Text string `json:"text"`
}

ServerMessage is received on a server event

type TeamNotice

type TeamNotice struct {
	Meta
	Side    string `json:"side"`
	Notice  string `json:"notice"`
	ScoreCT int    `json:"score_ct"`
	ScoreT  int    `json:"score_t"`
}

TeamNotice message is received at the end of a round and holds information about which team won the round and the score

type TeamScored

type TeamScored struct {
	Meta
	Side       string `json:"side"`
	Score      int    `json:"score"`
	NumPlayers int    `json:"num_players"`
}

TeamScored is received at the end of each round and holds the scores for a team

type Unknown

type Unknown struct {
	Meta
	Raw string `json:"raw"`
}

Unknown holds the raw log message of a message that is not defined in patterns but starts with time

type Velocity

type Velocity struct {
	X float32 `json:"x"`
	Y float32 `json:"y"`
	Z float32 `json:"z"`
}

Velocity holds information about the velocity of a projectile

type WorldGameCommencing

type WorldGameCommencing struct{ Meta }

WorldGameCommencing message is received when a game is commencing

type WorldMatchStart

type WorldMatchStart struct {
	Meta
	Map string `json:"map"`
}

WorldMatchStart holds the map wich will be played when match starts

type WorldRoundEnd

type WorldRoundEnd struct{ Meta }

WorldRoundEnd message is received when a round ends

type WorldRoundRestart

type WorldRoundRestart struct {
	Meta
	Timeleft int `json:"timeleft"`
}

WorldRoundRestart is received when the server wants to restart a round

type WorldRoundStart

type WorldRoundStart struct{ Meta }

WorldRoundStart message is received when a new round starts

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL