altv

package module
v0.2.0-dev.2 Latest Latest
Warning

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

Go to latest
Published: Sep 2, 2023 License: MIT Imports: 13 Imported by: 0

README

alt:V Go

license

Troubleshooting   •   Contributing   •   alt:V   •   Discord   •   Twitter

Go package and runtime for alt:V Multiplayer.

⚠️ Notice: updated occasionally, not actively maintained - hit me up on Discord if you are interested in this project.
⛔ Module is currently in development and not ready for production use - expect heavy api changes (and bugs).
Contributions of any kind are always welcome!

Requirements

Package depends heavily on cgo. To build on Windows, a gcc compiler is required (ex: mingw-w64).
See our Requirements Guide for more information on requirements and how to install them.

Get started

Main function is left blank on purpose and must be included before building process. Do not try to initialize stuff inside as it won't get called.

package main

import "C"
import (
  "github.com/timo972/altv-go/altlog"
  // this package is a required import. if you are not using the event package, import it like this
  // _ "github.com/timo972/altv-go/event"
  // if you are not importing it, the module will log errors calling the ServerStarted and ResourceStopEvent
	"github.com/timo972/altv-go/event"
)

func init() {
	// You may want to initialize something here.
  // However the alt:V api is limited due to the reason
  // that the package did not load the go-module's c-api yet!
  // As of now you can only use the event features here.

  // e.g.
  event.On.ServerStarted(func () {
      altlog.Println("Server Started")
  })

  event.On.Start(func () {
    // this event is called when the resource is about to start
    altlog.Println("Resource Started")
  })

  event.On.Stop(func () {
    // this event is called when on resource shutdown
    altlog.Println("Resource Stopped")
  })
}

// main function is left blank on purpose and must be included before building process
func main() {
	// You dont want to initialize something here because this wont work
}

For more examples take a look at the altv-go-examples repository.

Building your Resource

Windows

go build -o my-resource.dll -buildmode=c-shared

Linux

go build -o my-resource.so -buildmode=c-shared

Something went wrong? A build error? See the Troubleshooting Guide.

Help

If you need help to get started contact me on Discord: Timo9#4468

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateVehicle

func CreateVehicle(model uint32, pos Vector3, rot Vector3) (entity.Vehicle, error)

func Hash

func Hash(data []byte) uint32

Hash uses the case sensitive joaat algorithm to hash the given data.

func HashSHA256

func HashSHA256(data []byte) []byte

HashSHA256 hashes the given data using the sha256 algorithm.

func IsMetaNotExist

func IsMetaNotExist(err error) bool

func PlayerByID

func PlayerByID(id uint32) (entity.Player, error)

func Players

func Players() []entity.Player

func StopServer

func StopServer()

StopServer stops the server and it's resources.

func VehicleByID

func VehicleByID(id uint32) (entity.Vehicle, error)

func Vehicles

func Vehicles() []entity.Vehicle

Types

type BoneInfo

type BoneInfo struct {
	ID    uint16
	Index uint16
	Name  string
}

type Cloth

type Cloth struct {
	DrawableId uint16
	TextureId  uint8
	PaletteId  uint8
}

type ConnectionInfo

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

func NewConnectionInfo

func NewConnectionInfo(ptr unsafe.Pointer, id uint32, name string, socialID uint64, socialName string, hwidHash uint64, hwidExHash uint64, authToken string, debug bool, branch string, build uint32, cdnUrl string, passwordHash uint64, ip string, discordUserId int64, cloudAuthHash string) *ConnectionInfo

NewConnectionInfo ! INTERNAL ONLY !

func (*ConnectionInfo) Accept

func (c *ConnectionInfo) Accept(sendNames bool)

func (*ConnectionInfo) Accepted

func (c *ConnectionInfo) Accepted() bool

func (*ConnectionInfo) AuthToken

func (c *ConnectionInfo) AuthToken() string

func (*ConnectionInfo) Branch

func (c *ConnectionInfo) Branch() string

func (*ConnectionInfo) Build

func (c *ConnectionInfo) Build() uint32

func (*ConnectionInfo) CDNUrl

func (c *ConnectionInfo) CDNUrl() string

func (*ConnectionInfo) CloudAuthHash

func (c *ConnectionInfo) CloudAuthHash() string

func (*ConnectionInfo) Debug

func (c *ConnectionInfo) Debug() bool

func (*ConnectionInfo) Decline

func (c *ConnectionInfo) Decline(reason string)

func (*ConnectionInfo) DiscordUserID

func (c *ConnectionInfo) DiscordUserID() int64

func (*ConnectionInfo) HwIdExHash

func (c *ConnectionInfo) HwIdExHash() uint64

func (*ConnectionInfo) HwIdHash

func (c *ConnectionInfo) HwIdHash() uint64

func (*ConnectionInfo) ID

func (c *ConnectionInfo) ID() uint32

func (*ConnectionInfo) IP

func (c *ConnectionInfo) IP() string

func (*ConnectionInfo) Name

func (c *ConnectionInfo) Name() string

func (*ConnectionInfo) PasswordHash

func (c *ConnectionInfo) PasswordHash() uint64

func (*ConnectionInfo) SocialID

func (c *ConnectionInfo) SocialID() uint64

func (*ConnectionInfo) SocialName

func (c *ConnectionInfo) SocialName() string

type DlcCloth

type DlcCloth struct {
	Dlc        uint32
	DrawableId uint16
	TextureId  uint8
	PaletteId  uint8
}

type DlcProp

type DlcProp struct {
	Dlc        uint32
	DrawableId uint16
	TextureId  uint8
}

type FireInfo

type FireInfo struct {
	WeaponHash uint32
	Position   Vector3
}

type HeadBlendData

type HeadBlendData struct {
	ShapeFirstID  uint32
	ShapeSecondID uint32
	ShapeThirdID  uint32
	SkinFirstID   uint32
	SkinSecondID  uint32
	SkinThirdID   uint32
	ShapeMix      float32
	SkinMix       float32
	ThirdMix      float32
}

type HeadOverlay

type HeadOverlay struct {
	Index            uint8
	Opacity          float32
	ColorType        uint8
	ColorIndex       uint8
	SecondColorIndex uint8
}

type PedModelInfo

type PedModelInfo struct {
	Name  string
	Hash  uint32
	Bones []BoneInfo
}

type Prop

type Prop struct {
	DrawableId uint16
	TextureId  uint8
}

type RGBA

type RGBA struct {
	json.Marshaler
	R uint8 `json:"r"`
	G uint8 `json:"g"`
	B uint8 `json:"b"`
	A uint8 `json:"a"`
}

func (RGBA) MarshalJSON

func (c RGBA) MarshalJSON() ([]byte, error)

type Vector2

type Vector2 struct {
	json.Marshaler
	json.Unmarshaler
	X float32
	Y float32
}

func (Vector2) MarshalJSON

func (v Vector2) MarshalJSON() ([]byte, error)

func (Vector2) String

func (v Vector2) String() string

func (*Vector2) UnmarshalJSON

func (v *Vector2) UnmarshalJSON(raw []byte) error

type Vector3

type Vector3 struct {
	json.Marshaler
	json.Unmarshaler
	X float32
	Y float32
	Z float32
}

func (Vector3) Add

func (v Vector3) Add(v2 Vector3) Vector3

func (Vector3) AngleTo

func (v Vector3) AngleTo(v2 Vector3) (float64, bool)

func (Vector3) AngleToDegrees

func (v Vector3) AngleToDegrees(v2 Vector3) (float64, bool)

func (Vector3) Cross

func (v Vector3) Cross(v2 Vector3) Vector3

func (Vector3) DistanceTo

func (v Vector3) DistanceTo(v2 Vector3) float64

func (Vector3) DistanceToSquared

func (v Vector3) DistanceToSquared(v2 Vector3) float64

func (Vector3) Div

func (v Vector3) Div(v2 Vector3) Vector3

func (Vector3) Dot

func (v Vector3) Dot(v2 Vector3) float32

func (Vector3) IsInRange

func (v Vector3) IsInRange(v2 Vector3, r float64) bool

func (Vector3) Length

func (v Vector3) Length() float64

func (Vector3) Lerp

func (v Vector3) Lerp(v2 Vector3, ratio float32) Vector3

func (Vector3) MarshalJSON

func (v Vector3) MarshalJSON() ([]byte, error)

func (Vector3) Mul

func (v Vector3) Mul(v2 Vector3) Vector3

func (Vector3) Negative

func (v Vector3) Negative() Vector3

func (Vector3) Normalize

func (v Vector3) Normalize() Vector3

func (Vector3) String

func (v Vector3) String() string

func (Vector3) Sub

func (v Vector3) Sub(v2 Vector3) Vector3

func (Vector3) ToDegrees

func (v Vector3) ToDegrees() Vector3

func (Vector3) ToRadians

func (v Vector3) ToRadians() Vector3

func (*Vector3) UnmarshalJSON

func (v *Vector3) UnmarshalJSON(raw []byte) error

type VehicleModelInfo

type VehicleModelInfo struct {
	Title             string
	ModelType         VehicleModelType
	WheelsCount       uint8
	ArmoredWindows    bool
	AutoAttachTrailer bool
	Bones             []BoneInfo
	PrimaryColor      uint8
	SecondaryColor    uint8
	PearlColor        uint8
	WheelsColor       uint8
	InteriorColor     uint8
	DashboardColor    uint8

	ModKits       [2]uint16
	Extras        uint16
	DefaultExtras uint16
}

func (*VehicleModelInfo) DoesExtraDefault

func (v *VehicleModelInfo) DoesExtraDefault(extraId uint8) bool

func (*VehicleModelInfo) DoesExtraExist

func (v *VehicleModelInfo) DoesExtraExist(extraId uint8) bool

type VehicleModelType

type VehicleModelType = uint8
const (
	VehicleInvalid VehicleModelType = iota
	VehiclePed
	VehicleAutomobile
	VehiclePlane
	VehicleTrailer
	VehicleQuadBike
	VehicleSubmarineCar
	VehicleAmphibiousAutomobile
	VehicleAmphibiousQuadBike
	VehicleHeli
	VehicleBlimp
	VehicleAutogyro
	VehicleBike
	VehicleBMX
	VehicleBoat
	VehicleTrain
	VehicleSubmarine
	VehicleObject
)

Directories

Path Synopsis
cmd
gencapi command
internal
lib

Jump to

Keyboard shortcuts

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