initial main dll extension using a3go as template

This commit is contained in:
Valmo Trindade
2024-07-17 03:03:28 -03:00
parent 5e3b86f417
commit 02a1e0343a
4 changed files with 128 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
package main
type Mission struct {
MissionName string `json:"missionName"`
Worldname string `json:"worldname"`
MissionAuthor string `json:"missionAuthor"`
MissionType string `json:"missionType"`
Victory string `json:"victory"`
MissionStart string `json:"missionStart"`
MissionEnd string `json:"missionEnd"`
Date string `json:"date"`
ScoreBlue string `json:"scoreBlue"`
ScoreRed string `json:"scoreRed"`
ScoreGreen string `json:"scoreGreen"`
Players []Player `json:"players"`
Kills []Kill `json:"kills"`
FPS []float64 `json:"fps"`
}
type Player struct {
UID string `json:"uid"`
Name string `json:"name"`
Side string `json:"side"`
Shots int `json:"shots"`
Hits int `json:"hits"`
Squad string `json:"squad"`
Role string `json:"role"`
Class string `json:"class"`
}
type Kill struct {
Time string `json:"time"`
Victim string `json:"victim"`
Killer string `json:"killer"`
Weapon string `json:"weapon"`
Distance string `json:"distance"`
}
type DiscordPayload struct {
Content string `json:"content"`
Username string `json:"username,omitempty"` // Optional field
}

View File

@@ -0,0 +1,5 @@
module statsLoggerExtension
go 1.20
require github.com/indig0fox/a3go v0.2.1

View File

@@ -0,0 +1,2 @@
github.com/indig0fox/a3go v0.2.1 h1:Ixr/182pGd5qPbFYgHINWt5YtyKaO7Yo/va/17nF/Vg=
github.com/indig0fox/a3go v0.2.1/go.mod h1:8htVwBiIAVKpT1Jyb+5dm7GuLAAevTXgw7UKxSlOawY=

View File

@@ -0,0 +1,79 @@
package main
import (
"bytes"
"encoding/json"
"fmt"
"net/http"
"path"
"github.com/indig0fox/a3go/a3interface"
"github.com/indig0fox/a3go/assemblyfinder"
)
// modulePath is the absolute path to the compiled DLL, which should be the addon folder
var modulePath string = assemblyfinder.GetModulePath()
// modulePathDir is the containing folder
var modulePathDir string = path.Dir(modulePath)
var EXTENSION_NAME = "STATS_LOGGER"
var mission Mission
var RVExtensionChannels = map[string]chan string{
":timeNow:": make(chan string),
}
var RVExtensionArgsChannels = map[string]chan []string{
":RESET:": make(chan []string),
":MISSION:": make(chan []string),
":WIN:": make(chan []string),
":PLAYER:": make(chan []string),
":KILL:": make(chan []string),
":SHOT:": make(chan []string),
":HIT:": make(chan []string),
":EXPORT:": make(chan []string),
":FPS:": make(chan []string),
}
var a3ErrorChan = make(chan error)
func init() {
a3interface.SetVersion("1.0.0")
a3interface.RegisterRvExtensionArgsChannels(RVExtensionArgsChannels)
webhookURL := "YOUR_WEBHOOK_URL"
// Create the payload with the message
payload := DiscordPayload{
Content: "Hello World!",
}
// Convert the payload to JSON format
jsonData, err := json.Marshal(payload)
if err != nil {
fmt.Println("Error marshalling payload:", err)
return
}
// Create a POST request to the Discord webhook URL
req, err := http.Post(webhookURL, "application/json", bytes.NewReader(jsonData))
if err != nil {
fmt.Println("Error creating request:", err)
return
}
// Close the request body
defer req.Body.Close()
// Check the response status code
if req.StatusCode != http.StatusOK {
fmt.Println("Error sending request:", req.Status)
return
}
}
func main() {
fmt.Scanln()
}