Jump to content
七龙的秘密基地
Search In
  • More options...
Find results that contain...
Find results in...

Hell Let Loose人间地狱使用rcon来查询游戏服务器信息


elstp_gf@foxmail.com

220 views

 Share

使用rcon可以用

"github.com/verocity-gaming/rcon"

的rcon依赖,新建Go项目,然后导入

import (
	"github.com/verocity-gaming/rcon"
)

初始化rcon连接 IP例如127.0.0.1:27015 

c, err := rcon.New(ip, password)
		if err != nil {
			println("连接服务器失败!")
			panic(err)
		}

 

假如我要执行RCON指令来换图 mapName 这个变量就是地图名了

		p := c.SetMap(rcon.MapName(mapName))
		if p == nil {
			fmt.Sprintf("操作成功!")
		} else {
			 fmt.Sprintf("%s", p)
		}

 

 

然后下面是可用的功能 可以自行实现:

func New(addr string, password string) (*Conn, error)
func (c *Conn) AdminAdd(a Admin) error
func (c *Conn) AdminGroups() ([]string, error)
func (c *Conn) AdminRemove(a Admin) error
func (c *Conn) Admins() ([]Admin, error)
func (c *Conn) AutoBalance() (bool, error)
func (c *Conn) AutoBalanceThreshold() (int, error)
func (c *Conn) BanPermanently(p Player, reason, admin string) error
func (c *Conn) BanRemove(p Player) error
func (c *Conn) BanTemporarily(p Player, hours int, reason, admin string) error
func (c *Conn) Close() error
func (c *Conn) IdleTime() (time.Duration, error)
func (c *Conn) Kick(p Player, reason string) error
func (c *Conn) Map() (Map, error)
func (c *Conn) Maps() ([]Map, error)
func (c *Conn) MaxPing() (time.Duration, error)
func (c *Conn) Name() (string, error)
func (c *Conn) PermanentlyBanned() ([]Ban, error)
func (c *Conn) Player(username string) (Player, error)
func (c *Conn) Players() ([]Player, error)
func (c *Conn) Profanities() ([]string, error)
func (c *Conn) Punish(p Player, reason string) error
func (c *Conn) ResetVoteKickThreshold() error
func (c *Conn) Rotation() ([]Map, error)
func (c *Conn) RotationAdd(n MapName) error
func (c *Conn) RotationRemove(n MapName) error
func (c *Conn) SetAutoBalance(enabled bool) error
func (c *Conn) SetAutoBalanceThreshold(diff int) error
func (c *Conn) SetBroadcast(message string) error
func (c *Conn) SetIdleTime(m time.Duration) error
func (c *Conn) SetMap(n MapName) error
func (c *Conn) SetMaxPing(ms time.Duration) error
func (c *Conn) SetProfanities(words ...string) error
func (c *Conn) SetQueueLength(length int) error
func (c *Conn) SetSwitchTeamCooldown(m time.Duration) error
func (c *Conn) SetSwitchTeamNow(p Player) error
func (c *Conn) SetSwitchTeamOnDeath(p Player) error
func (c *Conn) SetVIPSlots(slots int) error
func (c *Conn) SetVoteKick(enabled bool) error
func (c *Conn) SetVoteKickThreshold(pairs ...VoteKickThreshold) error        
func (c *Conn) Slots() (numerator, denominator int, err error)
func (c *Conn) SwitchTeamCooldown() (time.Duration, error)
func (c *Conn) TemporarilyBanned() ([]Ban, error)
func (c *Conn) UnsetProfanities(words ...string) error
func (c *Conn) VIPAdd(v VIP) error
func (c *Conn) VIPRemove(v VIP) error
func (c *Conn) VIPSlots() (int, error)
func (c *Conn) VIPs() ([]VIP, error)
func (c *Conn) VoteKick() (bool, error)

 

 

写的一个小栗子:

 

TEST.go

 Share

0 Comments


Recommended Comments

There are no comments to display.

×
×
  • Create New...