Documentation
¶
Index ¶
- Constants
- Variables
- func AuthKey(challenge string) string
- func DecodeServerText(charset, value string) string
- type ChatEvent
- type Client
- func (c *Client) ClickPlayer(ctx context.Context, playerID uint16) error
- func (c *Client) ClickTextDraw(ctx context.Context, textDrawID uint16) error
- func (c *Client) Close() error
- func (c *Client) DriveTo(vehicleID uint16, target [3]float32, speed, tolerance float32) (uint64, error)
- func (c *Client) EnterVehicle(ctx context.Context, vehicleID uint16, passenger bool, ...) error
- func (c *Client) Events() <-chan Event
- func (c *Client) ExitVehicle(ctx context.Context) error
- func (c *Client) NotifyLocalPlayerDeath(source DeathSource)
- func (c *Client) NotifyLocalPlayerDeathWithCause(source DeathSource, reason uint8, killerID uint16)
- func (c *Client) NotifyLocalVehicleDestroyed(vehicleID uint16, remoteControlled bool)
- func (c *Client) RefreshScores(ctx context.Context) error
- func (c *Client) RequestSpawn(ctx context.Context) error
- func (c *Client) RespondDialog(ctx context.Context, id int16, button uint8, item int16, input string) error
- func (c *Client) RespondDialogBytes(ctx context.Context, id int16, button uint8, item int16, input []byte) error
- func (c *Client) SendChat(ctx context.Context, text string) error
- func (c *Client) SendCommand(ctx context.Context, command string) error
- func (c *Client) SetAFK(enabled bool)
- func (c *Client) SetKeys(ctx context.Context, mask uint32) error
- func (c *Client) StopMovement()
- func (c *Client) Teleport(ctx context.Context, x, y, z float32) error
- func (c *Client) WalkTo(target [3]float32, speed, tolerance float32) (uint64, error)
- type ClientOptions
- type DeathCause
- type DeathSource
- type DialogEvent
- type Event
- type EventType
- type Info
- type MotionEvent
- type MotionKind
- type MotionState
- type ObjectEvent
- type PlayerDeathEvent
- type PlayerEvent
- type PlayerHealthEvent
- type PlayerLifeState
- type PlayerLifeStateEvent
- type RespawnPolicy
- type SpawnInfo
- type SpawnedEvent
- type TextDrawEvent
- type VehicleEntryMode
- type VehicleEvent
- type VehicleHealthEvent
- type VehicleStateEvent
Constants ¶
const ( RPCClientJoin uint8 = 25 RPCDeath uint8 = 53 RPCRequestClass uint8 = 128 RPCRequestSpawn uint8 = 129 RPCConnectionRejected uint8 = 130 RPCSpawn uint8 = 52 RPCWorldPlayerAdd uint8 = 32 RPCSetSpawnInfo uint8 = 68 RPCSetPlayerPos uint8 = 12 RPCSetPlayerPosFindZ uint8 = 13 RPCSetPlayerHealth uint8 = 14 RPCSetPlayerSkin uint8 = 153 RPCSetPlayerTeam uint8 = 69 RPCSetFacingAngle uint8 = 19 RPCSetPlayerArmour uint8 = 66 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 RPCVehicleDeath uint8 = 136 RPCSetVehicleHealth uint8 = 147 )
const InvalidSAMPPlayerID uint16 = ^uint16(0)
InvalidSAMPPlayerID is the wire representation of an unknown killer.
const UnknownDeathReason uint8 = ^uint8(0)
UnknownDeathReason is the public-event sentinel for a death whose weapon cannot be recovered from the authoritative update. Weapon ID 0 means "fist" in SA-MP and must not be reused for an unknown cause.
Variables ¶
var ( ErrNicknameTooLong = errors.New("samp: nickname is too long") ErrConnectionRejected = errors.New("samp: connection rejected") ErrBadVersion = errors.New("samp: incorrect client version") ErrBadNickname = errors.New("samp: unacceptable nickname") ErrBadMod = errors.New("samp: bad client mod version") ErrBadPlayerID = errors.New("samp: unable to allocate a player slot") ErrMessageTooLong = errors.New("samp: message is too long") ErrMalformedPacket = errors.New("samp: malformed packet") ErrClientNotConnected = errors.New("samp: client is not connected") ErrClientNotSpawned = errors.New("samp: client is not spawned") ErrSpawnNotReady = errors.New("samp: spawn information is not ready") ErrSpawnCooldown = errors.New("samp: respawn cooldown is active") ErrVehicleEntryInProgress = errors.New("samp: another vehicle entry is already in progress") ErrVehicleEntryCanceled = errors.New("samp: vehicle entry was canceled before completion") ErrVehicleEntryOutOfRange = errors.New("samp: vehicle is not streamed or is outside the normal entry range") )
Functions ¶
func DecodeServerText ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
func DialClient ¶
func DialClientWithOptions ¶ added in v0.1.3
func (*Client) ClickPlayer ¶
func (*Client) ClickTextDraw ¶
func (*Client) EnterVehicle ¶
func (*Client) NotifyLocalPlayerDeath ¶ added in v0.1.4
func (c *Client) NotifyLocalPlayerDeath(source DeathSource)
NotifyLocalPlayerDeath lets a native backend report a ped death when it can observe the local GTA ped directly. The cause remains explicitly unknown because this compatibility entry point carries no damage metadata.
func (*Client) NotifyLocalPlayerDeathWithCause ¶ added in v0.1.4
func (c *Client) NotifyLocalPlayerDeathWithCause(source DeathSource, reason uint8, killerID uint16)
NotifyLocalPlayerDeathWithCause reports a native-confirmed death and its SA-MP weapon/killer metadata. It is intentionally separate from server health handling: RPC_SetPlayerHealth cannot establish either field.
func (*Client) NotifyLocalVehicleDestroyed ¶ added in v0.1.4
NotifyLocalVehicleDestroyed is the integration point for a future native GTA backend. Vehicle removal is not by itself enough to kill the local player, so this only detaches the local occupant. A native backend that has independently confirmed ped death must call NotifyLocalPlayerDeath.
func (*Client) RequestSpawn ¶ added in v0.1.3
RequestSpawn mirrors the two SA-MP spawn paths. During class selection the client asks the server for spawn authorization with RPC_RequestSpawn. After a confirmed death, PC SA-MP keeps the existing spawn information and sends RPC_Spawn directly; repeating RPC_RequestSpawn would incorrectly reopen the class-selection transaction on servers that enforce the native protocol.
func (*Client) RespondDialog ¶
func (*Client) RespondDialogBytes ¶
func (*Client) SendCommand ¶
func (*Client) StopMovement ¶ added in v0.1.4
func (c *Client) StopMovement()
type ClientOptions ¶ added in v0.1.3
type ClientOptions struct {
EmulatePCClientCheck bool
RespawnPolicy RespawnPolicy
// GPCI is the persisted per-installation client identifier used in the
// SA-MP join handshake. An empty value generates a fallback identifier for
// callers that do not have access to the application store.
GPCI string
}
ClientOptions controls compatibility behavior that is optional in the Android raksamp client. In particular, PC client-check emulation is off by default there and must not be advertised unless explicitly requested.
type DeathCause ¶ added in v0.1.4
DeathCause is supplied by a native GTA integration when it can inspect the actual ped damage state. Server health RPCs do not contain this information.
type DeathSource ¶ added in v0.1.4
type DeathSource string
const ( DeathSourceServerHealth DeathSource = "server_health" // Vehicle and RC vehicle sources are reserved for an integration that has // confirmed ped death; server vehicle RPCs only detach the occupant. DeathSourceVehicle DeathSource = "vehicle" DeathSourceRCVehicle DeathSource = "rc_vehicle" )
type DialogEvent ¶
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" EventPlayerHealth EventType = "player.health" EventPlayerLifeState EventType = "player.state" EventPlayerDeath EventType = "player.death" EventVehicleHealth EventType = "vehicle.health" EventSpawned EventType = "spawned" EventVehicleSync EventType = "vehicle.sync" EventMovement EventType = "movement" )
type MotionEvent ¶ added in v0.1.4
type MotionEvent struct {
TaskID uint64
Kind MotionKind
State MotionState
Position [3]float32
Target [3]float32
Progress float32
Error string
}
MotionEvent is deliberately small: it is emitted at task boundaries and at a throttled progress cadence, not once per network sync frame.
type MotionKind ¶ added in v0.1.4
type MotionKind string
const ( MotionWalk MotionKind = "walk" MotionDrive MotionKind = "drive" )
type MotionState ¶ added in v0.1.4
type MotionState string
const ( MotionStarted MotionState = "started" MotionProgress MotionState = "progress" MotionCompleted MotionState = "completed" MotionStopped MotionState = "stopped" MotionFailed MotionState = "failed" )
type ObjectEvent ¶
type PlayerDeathEvent ¶ added in v0.1.4
type PlayerDeathEvent struct {
Reason uint8
KillerID uint16
ReasonKnown bool
Source DeathSource
}
type PlayerEvent ¶
type PlayerHealthEvent ¶ added in v0.1.4
type PlayerLifeState ¶ added in v0.1.4
type PlayerLifeState string
PlayerLifeState is the protocol-visible lifecycle of the local player. Internal transaction phases deliberately remain private: plugins should see stable semantic states, while the client can still distinguish a request being written from a spawn already being committed.
const ( PlayerLifeStateClassSelection PlayerLifeState = "class_selection" PlayerLifeStateSpawnReady PlayerLifeState = "spawn_ready" PlayerLifeStateSpawnRequestPending PlayerLifeState = "spawn_request_pending" PlayerLifeStateSpawned PlayerLifeState = "spawned" PlayerLifeStateDead PlayerLifeState = "dead" )
type PlayerLifeStateEvent ¶ added in v0.1.4
type PlayerLifeStateEvent struct {
State PlayerLifeState
}
type RespawnPolicy ¶ added in v0.1.4
type RespawnPolicy uint8
RespawnPolicy controls who drives the spawn transaction after class data or death is available. The protocol client remains usable in manual mode, while the application can opt into Android-like automatic spawning.
const ( RespawnPolicyManual RespawnPolicy = iota RespawnPolicyAutomatic )
type SpawnInfo ¶
func (SpawnInfo) PlayerEvent ¶
func (s SpawnInfo) PlayerEvent() PlayerEvent
type SpawnedEvent ¶ added in v0.1.4
type TextDrawEvent ¶
type VehicleEntryMode ¶ added in v0.1.4
type VehicleEntryMode string
VehicleEntryMode controls how the headless client transitions from on-foot to vehicle synchronization. Direct is the historical behavior: the local state changes as soon as RPC_EnterVehicle is sent. Normal preserves the network sequence of a regular client: RPC_EnterVehicle marks the beginning of entry, on-foot sync continues during the entry task, and vehicle sync starts only after the entry phase completes.
const ( VehicleEntryDirect VehicleEntryMode = "direct" VehicleEntryNormal VehicleEntryMode = "normal" )
func NormalizeVehicleEntryMode ¶ added in v0.1.4
func NormalizeVehicleEntryMode(mode VehicleEntryMode) (VehicleEntryMode, error)
NormalizeVehicleEntryMode validates an entry mode and maps the empty value to the backward-compatible direct mode.