Skip to content

zMoooooritz/go-let-loose

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

65 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

go-let-loose

Go Latest Release Go Doc Software License Build Status Go ReportCard

Go bindings and interface for the remote console of Hell Let Loose.


🚀 Features

  • Bindings for all supported RCONv2 operations.
  • Proper typing for maps, armaments, squads, and more.
  • Event system that expands on the HLL provided logs.
  • Support for Lua plugins.

📦 Installation

Install the Go package:

To install the Go package, simply run:

go get github.com/zMoooooritz/go-let-loose

🚨 Warning

Warning

Important API Changes:

  • Library update required: Since the official implementation of the legacy RCON protocol got removed, everyone needs to update to the new library version
  • Module rename: The rconv2 implementation has been renamed to the rcon module
    • Users currently using rconv2 will need to update their import paths and code
    • Users who remained on the original rcon should experience minimal disruption
  • Unified event system: The event system has been consolidated into the rcon module, providing a more elegant, uniform, and easy-to-use interface

📖 Usage

Using the rcon API

Below is an example of how to use the go-let-loose/rcon module in a Go project:

func onKill(e hll.KillEvent) {
  fmt.Printf("Kill: %s -> %s (%s)\n", e.Killer.Name, e.Victim.Name, e.Weapon.Name)
}

func main() {
  logger.DefaultLogger()

  cfg := rcon.ServerConfig{
    Host:     "123.123.123.123",
    Port:     "12345",
    Password: "password",
  }

  const workerCount = 10
  rcn, err := rcon.NewRcon(cfg, workerCount, rcon.WithCache(), rcon.WithEvents())
  if err != nil {
    log.Fatal(err)
  }

  serverName, err := rcn.GetServerName()
  if err == nil {
    fmt.Printf("Connected to the Server: %s\n", serverName)
  } else {
    fmt.Println(err)
  }

  rcn.OnKill(onKill)

  time.Sleep(time.Second)

  gameState, err := rcn.GetGameState()
  if err == nil {
    fmt.Printf("Current game state: %+v\n", gameState)
  }

  sc := make(chan os.Signal, 1)
  signal.Notify(sc, syscall.SIGINT, syscall.SIGTERM)
  <-sc

  rcn.Close()
}

Lua Plugins

To use Lua plugins, place your Lua scripts in the plugins directory. The system will automatically detect and load them.

Example:

function Init()
  print("Initializing Plugin")
end

function Run()
  local err, name = getServerName()
  if name then
    print("Connected to the Server: " .. name)
    onKill(function(event)
      print("Kill: " .. event.Killer.Name .. " -> " .. event.Victim.Name .. " (" .. event.Weapon.Name .. ")")
    end)
  else
    print("Error: " .. err)
  end
end

function Stop()
  print("Exiting Plugin")
  exit()
end

For a more in-depth example, see hello_world.lua.

To run the plugins, use the following command:

go run cmd/go-let-loose-lua/main.go

🔧 Built with


📄 License

This project is licensed under the MIT License. You can view the full license here.

About

HLL RCON implementation written in Go

Resources

License

Stars

Watchers

Forks