samp

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Aug 9, 2026 License: Apache-2.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	RPCClientJoin          uint8 = 25
	RPCRequestClass        uint8 = 128
	RPCRequestSpawn        uint8 = 129
	RPCSpawn               uint8 = 52
	RPCWorldPlayerAdd      uint8 = 32
	RPCSetSpawnInfo        uint8 = 68
	RPCSetPlayerPos        uint8 = 12
	RPCSetPlayerPosFindZ   uint8 = 13
	RPCSetPlayerSkin       uint8 = 153
	RPCSetPlayerTeam       uint8 = 69
	RPCSetFacingAngle      uint8 = 19
	RPCPutPlayerInVehicle  uint8 = 70
	RPCRemoveFromVehicle   uint8 = 71
	RPCSetPlayerColor      uint8 = 72
	RPCSetPlayerDrunkLevel uint8 = 35
	RPCClickPlayer         uint8 = 23
	RPCEnterVehicle        uint8 = 26
	RPCDialogResponse      uint8 = 62
	RPCClickTextDraw       uint8 = 83
	RPCChat                uint8 = 101
	RPCServerCommand       uint8 = 50
	RPCExitVehicle         uint8 = 154
	RPCUpdateScores        uint8 = 155
	RPCServerJoin          uint8 = 137
	RPCServerQuit          uint8 = 138
	RPCInitGame            uint8 = 139
	RPCClientMessage       uint8 = 93
	RPCClientCheck         uint8 = 103
	RPCDialogBox           uint8 = 61
	RPCShowTextDraw        uint8 = 134
	RPCHideTextDraw        uint8 = 135
	RPCSetTextDrawString   uint8 = 105
	RPCCreateObject        uint8 = 44
	RPCDestroyObject       uint8 = 47
	RPCWorldVehicleAdd     uint8 = 164
	RPCWorldVehicleRemove  uint8 = 165
)

Variables

View Source
var (
	ErrNicknameTooLong = errors.New("samp: nickname is too long")
	ErrMessageTooLong  = errors.New("samp: message is too long")
	ErrMalformedPacket = errors.New("samp: malformed packet")
)

Functions

func AuthKey

func AuthKey(challenge string) string

func DecodeServerText

func DecodeServerText(charset, value string) string

Types

type ChatEvent

type ChatEvent struct {
	PlayerID *uint16
	Text     string
	Color    uint32
}

type Client

type Client struct {
	// contains filtered or unexported fields
}

func DialClient

func DialClient(ctx context.Context, address, nickname, password, charset string) (*Client, error)

func (*Client) ClickPlayer

func (c *Client) ClickPlayer(ctx context.Context, playerID uint16) error

func (*Client) ClickTextDraw

func (c *Client) ClickTextDraw(ctx context.Context, textDrawID uint16) error

func (*Client) Close

func (c *Client) Close() error

func (*Client) EnterVehicle

func (c *Client) EnterVehicle(ctx context.Context, vehicleID uint16, passenger bool) error

func (*Client) Events

func (c *Client) Events() <-chan Event

func (*Client) ExitVehicle

func (c *Client) ExitVehicle(ctx context.Context) error

func (*Client) RefreshScores

func (c *Client) RefreshScores(ctx context.Context) error

func (*Client) RespondDialog

func (c *Client) RespondDialog(ctx context.Context, id int16, button uint8, item int16, input string) error

func (*Client) RespondDialogBytes

func (c *Client) RespondDialogBytes(ctx context.Context, id int16, button uint8, item int16, input []byte) error

func (*Client) SendChat

func (c *Client) SendChat(ctx context.Context, text string) error

func (*Client) SendCommand

func (c *Client) SendCommand(ctx context.Context, command string) error

func (*Client) SetAFK

func (c *Client) SetAFK(enabled bool)

func (*Client) SetKeys

func (c *Client) SetKeys(ctx context.Context, mask uint32) error

func (*Client) Teleport

func (c *Client) Teleport(ctx context.Context, x, y, z float32) error

type DialogEvent

type DialogEvent struct {
	ID                               int16
	Style                            uint8
	Title, Button1, Button2, Message string
	RawMessage                       []byte
}

type Event

type Event struct {
	Type EventType
	Data any
}

type EventType

type EventType string
const (
	EventJoined        EventType = "joined"
	EventChat          EventType = "chat"
	EventPlayerJoin    EventType = "player.join"
	EventPlayerQuit    EventType = "player.quit"
	EventScores        EventType = "scores"
	EventDialog        EventType = "dialog"
	EventDisconnected  EventType = "disconnected"
	EventProtocolError EventType = "protocol.error"
	EventTextDrawShow  EventType = "textdraw.show"
	EventTextDrawHide  EventType = "textdraw.hide"
	EventTextDrawText  EventType = "textdraw.text"
	EventObjectAdd     EventType = "object.add"
	EventObjectRemove  EventType = "object.remove"
	EventVehicleAdd    EventType = "vehicle.add"
	EventVehicleRemove EventType = "vehicle.remove"
	EventPlayerSync    EventType = "player.sync"
	EventPosition      EventType = "position"
	EventAppearance    EventType = "appearance"
	EventVehicleState  EventType = "vehicle.state"
	EventSpawned       EventType = "spawned"
	EventVehicleSync   EventType = "vehicle.sync"
)

type Info

type Info struct {
	Password                     bool
	Players, MaxPlayers          int
	Hostname, GameMode, Language string
}

func Query

func Query(ctx context.Context, host string, port int) (Info, error)

type ObjectEvent

type ObjectEvent struct {
	ID      uint16
	ModelID int32
	X, Y, Z float32
}

type PlayerEvent

type PlayerEvent struct {
	ID          uint16
	Name        string
	Score, Ping int32
	X, Y, Z     float32
	Health      float32
	Armour      float32
	Skin        int32
	Team        uint8
	Rotation    float32
	HasPosition bool
	HasSkin     bool
	HasTeam     bool
	HasRotation bool
	Color       uint32
	HasColor    bool
}

type SpawnInfo

type SpawnInfo struct {
	Team     uint8
	Skin     int32
	Position [3]float32
	Rotation float32
}

func (SpawnInfo) PlayerEvent

func (s SpawnInfo) PlayerEvent() PlayerEvent

type TextDrawEvent

type TextDrawEvent struct {
	ID                                                     uint16
	Text                                                   string
	Style, Flags, Shadow, Outline, Selectable              uint8
	LetterColor, BoxColor, BackgroundColor                 uint32
	X, Y, LetterWidth, LetterHeight, LineWidth, LineHeight float32
	ModelID                                                uint16
}

type VehicleEvent

type VehicleEvent struct {
	ID              uint16
	ModelID         int32
	X, Y, Z, Health float32
}

type VehicleStateEvent

type VehicleStateEvent struct {
	InVehicle bool
	Passenger bool
	VehicleID uint16
}

Jump to

Keyboard shortcuts

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