Skip to content

Timo972/altv-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

alt:V Go

license

Documentation   •   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"
  // the altv-go/event package is a required import. if you are not using it, do a sideeffect import
  // if you are not importing it, the module will log errors calling the ServerStarted and ResourceStopEvent
  // either do (when using events)
  "github.com/timo972/altv-go/event"
  // or (when not using events)
  // _ "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.
  // Full api is available once the event.on.Start callbacks are executed.

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

  event.On.Start(func () {
    // this event is called when the resource is being started by the alt:V Core
    // full api available
    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 reach out to me at Discord.

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