diff --git a/.gitignore b/.gitignore index 197610c..f6d4437 100644 --- a/.gitignore +++ b/.gitignore @@ -92,3 +92,5 @@ go.work .ionide # End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,go,c + +.vscode/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..7e8a9b5 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "capi"] + path = capi + url = https://github.com/openmultiplayer/omp-capi.git diff --git a/actor.cpp b/actor.cpp deleted file mode 100644 index b3d5734..0000000 --- a/actor.cpp +++ /dev/null @@ -1,79 +0,0 @@ -#include "include/actor.h" - -extern "C" { - void* actor_create(int skin, float posX, float posY, float posZ, float angle) { - return call("actor_create", skin, posX, posY, posZ, angle); - } - - void actor_release(void* actor) { - return call("actor_release", actor); - } - - void actor_setSkin(void* actor, int skin) { - return call("actor_setSkin", actor, skin); - } - - int actor_getSkin(void* actor) { - return call("actor_getSkin", actor); - } - - void actor_applyAnimation(void* actor, float delta, unsigned char loop, unsigned char lockX, unsigned char lockY, unsigned char freeze, uint32_t time, String lib, String name) { - return call("actor_applyAnimation", actor, delta, loop, lockX, lockY, freeze, time, lib, name); - } - - CAnimationData actor_getAnimation(void* actor) { - return call("actor_getAnimation", actor); - } - - void actor_clearAnimations(void* actor) { - return call("actor_clearAnimations", actor); - } - - void actor_setHealth(void* actor, float health) { - return call("actor_setHealth", actor, health); - } - - float actor_getHealth(void* actor) { - return call("actor_getHealth", actor); - } - - void actor_setInvulnerable(void* actor, unsigned char invuln) { - return call("actor_setInvulnerable", actor, invuln); - } - - unsigned char actor_isInvulnerable(void* actor) { - return call("actor_isInvulnerable", actor); - } - - unsigned char actor_isStreamedInForPlayer(void* actor, void* player) { - return call("actor_isStreamedInForPlayer", actor, player); - } - - ActorSpawnData actor_getSpawnData(void* actor) { - return call("actor_getSpawnData", actor); - } - - void actor_setPosition(void* actor, float posX, float posY, float posZ) { - return call("actor_setPosition", actor, posX, posY, posZ); - } - - Vector3 actor_getPosition(void* actor) { - return call("actor_getPosition", actor); - } - - void actor_setVirtualWorld(void* actor, int vw) { - return call("actor_setVirtualWorld", actor, vw); - } - - int actor_getVirtualWorld(void* actor) { - return call("actor_getVirtualWorld", actor); - } - - void actor_setFacingAngle(void* actor, float angle) { - return call("actor_setFacingAngle", actor, angle); - } - - float actor_getFacingAngle(void* actor) { - return call("actor_getFacingAngle", actor); - } -} diff --git a/actor.go b/actor.go index 0360b7a..284fd8b 100644 --- a/actor.go +++ b/actor.go @@ -1,9 +1,11 @@ package omp -// #include "include/actor.h" +// #include +// #include "include/wrappers.h" import "C" import ( "errors" + "time" "unsafe" ) @@ -18,7 +20,8 @@ type Actor struct { } func NewActor(skin int, pos Vector3, angle float32) (*Actor, error) { - cActor := C.actor_create(C.int(skin), C.float(pos.X), C.float(pos.Y), C.float(pos.Z), C.float(angle)) + var cID C.int + cActor := C.Actor_Create(C.int(skin), C.float(pos.X), C.float(pos.Y), C.float(pos.Z), C.float(angle), &cID) if cActor == nil { return nil, errors.New("actor limit was reached") } @@ -27,119 +30,140 @@ func NewActor(skin int, pos Vector3, angle float32) (*Actor, error) { } func FreeActor(actor *Actor) { - C.actor_release(actor.handle) + C.Actor_Destroy(actor.handle) +} + +func (a *Actor) ID() int { + return int(C.Actor_GetID(a.handle)) } func (a *Actor) SetSkin(skin int) { - C.actor_setSkin(a.handle, C.int(skin)) + C.Actor_SetSkin(a.handle, C.int(skin)) } func (a *Actor) Skin() int { - return int(C.actor_getSkin(a.handle)) + return int(C.Actor_GetSkin(a.handle)) } func (a *Actor) ApplyAnimation(anim Animation) { - cLib := newCString(anim.Lib) - defer freeCString(cLib) + cLib := C.CString(anim.Lib) + defer C.free(unsafe.Pointer(cLib)) - cName := newCString(anim.Name) - defer freeCString(cName) + cName := C.CString(anim.Name) + defer C.free(unsafe.Pointer(cName)) - C.actor_applyAnimation( + C.Actor_ApplyAnimation( a.handle, - C.float(anim.Delta), - newCUchar(anim.Loop), - newCUchar(anim.LockX), - newCUchar(anim.LockY), - newCUchar(anim.Freeze), - C.uint(anim.Duration.Milliseconds()), - cLib, cName, + cLib, + C.float(anim.Delta), + C.bool(anim.Loop), + C.bool(anim.LockX), + C.bool(anim.LockY), + C.bool(anim.Freeze), + C.int(anim.Duration.Milliseconds()), ) } func (a *Actor) Animation() Animation { - cAnim := C.actor_getAnimation(a.handle) + var ( + cLib C.struct_CAPIStringView + cName C.struct_CAPIStringView + cDelta C.float + cLoop C.bool + cLockX C.bool + cLockY C.bool + cFreeze C.bool + cTime C.int + ) + + C.Actor_GetAnimation(a.handle, &cLib, &cName, &cDelta, &cLoop, &cLockX, &cLockY, &cFreeze, &cTime) return Animation{ - Lib: C.GoStringN(cAnim.lib.buf, C.int(cAnim.lib.length)), - Name: C.GoStringN(cAnim.name.buf, C.int(cAnim.name.length)), - Delta: float32(cAnim.delta), - Loop: cAnim.loop != 0, - LockX: cAnim.lockX != 0, - LockY: cAnim.lockY != 0, - Freeze: cAnim.freeze != 0, + Lib: C.GoStringN(cLib.data, C.int(cLib.len)), + Name: C.GoStringN(cName.data, C.int(cName.len)), + Delta: float32(cDelta), + Loop: bool(cLoop), + LockX: bool(cLockX), + LockY: bool(cLockY), + Freeze: bool(cFreeze), + Duration: time.Duration(cTime) * time.Millisecond, } } func (a *Actor) ClearAnimations() { - C.actor_clearAnimations(a.handle) + C.Actor_ClearAnimations(a.handle) } func (a *Actor) SetHealth(health float32) { - C.actor_setHealth(a.handle, C.float(health)) + C.Actor_SetHealth(a.handle, C.float(health)) } func (a *Actor) Health() float32 { - return float32(C.actor_getHealth(a.handle)) + return float32(C.Actor_GetHealth(a.handle)) } func (a *Actor) MakeInvulnerable() { - C.actor_setInvulnerable(a.handle, 1) + C.Actor_SetInvulnerable(a.handle, true) } func (a *Actor) UnmakeInvulnerable() { - C.actor_setInvulnerable(a.handle, 0) + C.Actor_SetInvulnerable(a.handle, false) } func (a *Actor) IsInvulnerable() bool { - return C.actor_isInvulnerable(a.handle) != 0 + return bool(C.Actor_IsInvulnerable(a.handle)) } -func (a *Actor) IsStreamedInFor(plr *Player) bool { - return C.actor_isStreamedInForPlayer(a.handle, plr.handle) != 0 +func (a *Actor) IsStreamedInFor(player *Player) bool { + return bool(C.Actor_IsStreamedInFor(a.handle, player.handle)) } func (a *Actor) SpawnData() ActorSpawnData { - data := C.actor_getSpawnData(a.handle) + var cPosX, cPosY, cPosZ, cAngle C.float + var cSkin C.int + + C.Actor_GetSpawnInfo(a.handle, &cPosX, &cPosY, &cPosZ, &cAngle, &cSkin) return ActorSpawnData{ Position: Vector3{ - X: float32(data.position.x), - Y: float32(data.position.y), - Z: float32(data.position.z), + X: float32(cPosX), + Y: float32(cPosY), + Z: float32(cPosZ), }, - FacingAngle: float32(data.facingAngle), - Skin: int(data.skin), + FacingAngle: float32(cAngle), + Skin: int(cSkin), } } func (a *Actor) SetPosition(pos Vector3) { - C.actor_setPosition(a.handle, C.float(pos.X), C.float(pos.Y), C.float(pos.Z)) + C.Actor_SetPos(a.handle, C.float(pos.X), C.float(pos.Y), C.float(pos.Z)) } func (a *Actor) Position() Vector3 { - cPos := C.actor_getPosition(a.handle) + var cPosX, cPosY, cPosZ C.float + + C.Actor_GetPos(a.handle, &cPosX, &cPosY, &cPosZ) return Vector3{ - X: float32(cPos.x), - Y: float32(cPos.y), - Z: float32(cPos.z), + X: float32(cPosX), + Y: float32(cPosY), + Z: float32(cPosZ), } } func (a *Actor) SetVirtualWorld(vw int) { - C.actor_setVirtualWorld(a.handle, C.int(vw)) + C.Actor_SetVirtualWorld(a.handle, C.int(vw)) } func (a *Actor) VirtualWorld() int { - return int(C.actor_getVirtualWorld(a.handle)) + return int(C.Actor_GetVirtualWorld(a.handle)) } func (a *Actor) SetFacingAngle(angle float32) { - C.actor_setFacingAngle(a.handle, C.float(angle)) + C.Actor_SetFacingAngle(a.handle, C.float(angle)) } func (a *Actor) FacingAngle() float32 { - return float32(C.actor_getFacingAngle(a.handle)) + return float32(C.Actor_GetFacingAngle(a.handle)) } diff --git a/c.go b/c.go deleted file mode 100644 index db71e0a..0000000 --- a/c.go +++ /dev/null @@ -1,28 +0,0 @@ -package omp - -// #include -// #include -// #include "include/omp.h" -import "C" -import "unsafe" - -func newCUchar(goBool bool) C.uchar { - if goBool { - return 1 - } - - return 0 -} - -func newCString(goStr string) C.String { - cStr := C.CString(goStr) - - return C.String{ - buf: cStr, - length: C.strlen(cStr), - } -} - -func freeCString(cStr C.String) { - C.free(unsafe.Pointer(cStr.buf)) -} diff --git a/capi b/capi new file mode 160000 index 0000000..854a0cb --- /dev/null +++ b/capi @@ -0,0 +1 @@ +Subproject commit 854a0cbc41deb70e40d4b9ade7f4f0e2401ffbf2 diff --git a/checkpoint.cpp b/checkpoint.cpp deleted file mode 100644 index b0a64bf..0000000 --- a/checkpoint.cpp +++ /dev/null @@ -1,83 +0,0 @@ -#include "include/checkpoint.h" - -extern "C" { - void* checkpoint_setPosition(void* checkpoint, float posX, float posY, float posZ) { - return call("checkpoint_setPosition", checkpoint, posX, posY, posZ); - } - - Vector3 checkpoint_getPosition(void* checkpoint) { - return call("checkpoint_getPosition", checkpoint); - } - - void checkpoint_setRadius(void* checkpoint, float radius) { - return call("checkpoint_setRadius", checkpoint, radius); - } - - float checkpoint_getRadius(void* checkpoint) { - return call("checkpoint_getRadius", checkpoint); - } - - unsigned char checkpoint_isPlayerInside(void* checkpoint) { - return call("checkpoint_isPlayerInside", checkpoint); - } - - void checkpoint_enable(void* checkpoint) { - return call("checkpoint_enable", checkpoint); - } - - void checkpoint_disable(void* checkpoint) { - return call("checkpoint_disable", checkpoint); - } - - unsigned char checkpoint_isEnabled(void* checkpoint) { - return call("checkpoint_isEnabled", checkpoint); - } - - void* raceCheckpoint_setPosition(void* checkpoint, float posX, float posY, float posZ) { - return call("raceCheckpoint_setPosition", checkpoint, posX, posY, posZ); - } - - Vector3 raceCheckpoint_getPosition(void* checkpoint) { - return call("raceCheckpoint_getPosition", checkpoint); - } - - void raceCheckpoint_setRadius(void* checkpoint, float radius) { - return call("raceCheckpoint_setRadius", checkpoint, radius); - } - - float raceCheckpoint_getRadius(void* checkpoint) { - return call("raceCheckpoint_getRadius", checkpoint); - } - - unsigned char raceCheckpoint_isPlayerInside(void* checkpoint) { - return call("raceCheckpoint_isPlayerInside", checkpoint); - } - - void raceCheckpoint_enable(void* checkpoint) { - return call("raceCheckpoint_enable", checkpoint); - } - - void raceCheckpoint_disable(void* checkpoint) { - return call("raceCheckpoint_disable", checkpoint); - } - - unsigned char raceCheckpoint_isEnabled(void* checkpoint) { - return call("raceCheckpoint_isEnabled", checkpoint); - } - - void raceCheckpoint_setType(void* checkpoint, int type) { - return call("raceCheckpoint_setType", checkpoint, type); - } - - int raceCheckpoint_getType(void* checkpoint) { - return call("raceCheckpoint_getType", checkpoint); - } - - void raceCheckpoint_setNextPosition(void* checkpoint, float posX, float posY, float posZ) { - return call("raceCheckpoint_setNextPosition", checkpoint, posX, posY, posZ); - } - - Vector3 raceCheckpoint_getNextPosition(void* checkpoint) { - return call("raceCheckpoint_getNextPosition", checkpoint); - } -} diff --git a/checkpoint.go b/checkpoint.go index 4ea19f7..80e31c1 100644 --- a/checkpoint.go +++ b/checkpoint.go @@ -4,15 +4,15 @@ package omp import "C" import "unsafe" -type DefaultCheckpoint struct { +type Checkpoint struct { handle unsafe.Pointer } -func (c *DefaultCheckpoint) SetPosition(pos Vector3) { +func (c *Checkpoint) SetPosition(pos Vector3) { C.checkpoint_setPosition(c.handle, C.float(pos.X), C.float(pos.Y), C.float(pos.Z)) } -func (c *DefaultCheckpoint) Position() Vector3 { +func (c *Checkpoint) Position() Vector3 { cPos := C.checkpoint_getPosition(c.handle) return Vector3{ @@ -22,27 +22,27 @@ func (c *DefaultCheckpoint) Position() Vector3 { } } -func (c *DefaultCheckpoint) SetRadius(radius float32) { +func (c *Checkpoint) SetRadius(radius float32) { C.checkpoint_setRadius(c.handle, C.float(radius)) } -func (c *DefaultCheckpoint) Radius() float32 { +func (c *Checkpoint) Radius() float32 { return float32(C.checkpoint_getRadius(c.handle)) } -func (c *DefaultCheckpoint) IsPlayerInside() bool { +func (c *Checkpoint) IsPlayerInside() bool { return C.checkpoint_isPlayerInside(c.handle) != 0 } -func (c *DefaultCheckpoint) Enable() { +func (c *Checkpoint) Enable() { C.checkpoint_enable(c.handle) } -func (c *DefaultCheckpoint) Disable() { +func (c *Checkpoint) Disable() { C.checkpoint_disable(c.handle) } -func (c *DefaultCheckpoint) IsEnabled() bool { +func (c *Checkpoint) IsEnabled() bool { return C.checkpoint_isEnabled(c.handle) != 0 } diff --git a/class.cpp b/class.cpp deleted file mode 100644 index ee69322..0000000 --- a/class.cpp +++ /dev/null @@ -1,23 +0,0 @@ -#include "include/class.h" - -extern "C" { - void* class_create(ClassData* data) { - return call("class_create", data); - } - - void class_release(void* _class) { - return call("class_release", _class); - } - - int class_getID(void* class_) { - return call("class_getID", class_); - } - - void class_setClass(void* class_, ClassData* data) { - return call("class_setClass", class_, data); - } - - ClassData class_getClass(void* class_) { - return call("class_getClass", class_); - } -} diff --git a/cmd/codegen/main.go b/cmd/codegen/main.go index daad222..34d371b 100644 --- a/cmd/codegen/main.go +++ b/cmd/codegen/main.go @@ -1,129 +1,94 @@ package main import ( + "encoding/json" "fmt" + "log" "os" - "path/filepath" - "regexp" "strings" -) - -const srcTpl = `#include "include/%s" - -#ifdef __cplusplus -extern "C" { -#endif - -%s - -#ifdef __cplusplus -} -#endif -` - -const funcTpl = `%s%s %s(%s) { -%s%sreturn call<%s>(%s); -%s}` - -// ^\s*([\w\s\*]+)\s+(\w+)\s*\(([^)]*)\)\s*; -var funcPrototypeRe = regexp.MustCompile(`(?m)` + - `^` + - `\s*` + - `([\w\s\*]+)` + // type - `\s+` + - `(\w+)` + // name - `\s*` + - `\(` + - `([^)]*)` + // arguments - `\)` + - `\s*` + - `;`, + "text/template" ) func main() { - genSrcFiles("include") -} - -func genSrcFiles(headersPath string) error { - headers, err := os.ReadDir(headersPath) + api, err := parseAPIDocs("capi/apidocs/api.json") if err != nil { - return err + log.Fatalf("Failed to parse API docs file: %s\n", err.Error()) } - for _, header := range headers { - if header.Name() == "omp.h" { - continue - } - - headerPath := filepath.Join(headersPath, header.Name()) - genSrcFile(headerPath) + err = genFromTemplate("include/wrappers.h", "wrappers.h.go.tmpl", api) + if err != nil { + log.Fatalf("Failed to generate header file: %s\n", err.Error()) } - return nil + err = genFromTemplate("wrappers.c", "wrappers.c.go.tmpl", api) + if err != nil { + log.Fatalf("Failed to generate source file: %s\n", err.Error()) + } } -func genSrcFile(headerPath string) error { - contents, err := os.ReadFile(headerPath) +func parseAPIDocs(path string) (*API, error) { + inf, err := os.Open(path) if err != nil { - return err + return nil, fmt.Errorf("failed to open API docs file: %w", err) } - matches := funcPrototypeRe.FindAllStringSubmatch(string(contents), -1) + var api *API - funcs := make([]string, 0, len(matches)) - - for _, match := range matches { - retType := match[1] - name := match[2] - args := match[3] - - funcs = append(funcs, newFunc(retType, name, args, " ")) + err = json.NewDecoder(inf).Decode(&api) + if err != nil { + return nil, fmt.Errorf("failed to decode API docs file: %w", err) } - header := filepath.Base(headerPath) - headerName := strings.TrimSuffix(header, filepath.Ext(header)) - - src := fmt.Sprintf(srcTpl, header, strings.Join(funcs, "\n\n")) - - // srcFile, _ := os.Create("test.cpp") - srcFile, _ := os.Create(fmt.Sprintf("%s.cpp", headerName)) - srcFile.WriteString(src) - - return nil + return api, nil } -func newFunc(retType, name, args, indent string) string { - callArgs := []string{ - fmt.Sprintf(`"%s"`, name), +func genFromTemplate(dstPath, tmplPath string, api *API) error { + tmpl, err := os.ReadFile(tmplPath) + if err != nil { + return fmt.Errorf("failed to read template file: %w", err) } - if args != "" { - callArgs = append(callArgs, removeArgTypes(args)...) + funcs := template.FuncMap{ + "split": strings.Split, + "join": strings.Join, } - return fmt.Sprintf( - funcTpl, - indent, - retType, - name, - args, - indent, indent, - retType, - strings.Join(callArgs, ", "), - indent, - ) -} - -func removeArgTypes(rawArgs string) []string { - args := strings.Split(rawArgs, ",") - result := make([]string, 0, len(args)) + t := template.Must(template.New("func").Funcs(funcs).Parse(string(tmpl))) - for _, arg := range args { - argWords := strings.Fields(strings.TrimSpace(arg)) - argName := argWords[len(argWords)-1] + dstFile, err := os.Create(dstPath) + if err != nil { + return fmt.Errorf("failed to create destination file: %w", err) + } - result = append(result, argName) + err = t.Execute(dstFile, []*Group{ + {Name: "Actor", Funcs: api.Actor}, + {Name: "Checkpoint", Funcs: api.Checkpoint}, + {Name: "RaceCheckpoint", Funcs: api.RaceCheckpoint}, + {Name: "Class", Funcs: api.Class}, + {Name: "Player", Funcs: api.Player}, + {Name: "Component", Funcs: api.Component}, + {Name: "Config", Funcs: api.Config}, + {Name: "Core", Funcs: api.Core}, + {Name: "NPC", Funcs: api.NPC}, + {Name: "CustomModel", Funcs: api.CustomModel}, + {Name: "Dialog", Funcs: api.Dialog}, + {Name: "Event", Funcs: api.Event}, + {Name: "GangZone", Funcs: api.GangZone}, + {Name: "Menu", Funcs: api.Menu}, + {Name: "Object", Funcs: api.Object}, + {Name: "PlayerObject", Funcs: api.PlayerObject}, + {Name: "Pickup", Funcs: api.Pickup}, + {Name: "All", Funcs: api.All}, + {Name: "Recording", Funcs: api.Recording}, + {Name: "TextDraw", Funcs: api.TextDraw}, + {Name: "PlayerTextDraw", Funcs: api.PlayerTextDraw}, + {Name: "TextLabel", Funcs: api.TextLabel}, + {Name: "PlayerTextLabel", Funcs: api.PlayerTextLabel}, + {Name: "Vehicle", Funcs: api.Vehicle}, + }) + if err != nil { + return fmt.Errorf("failed to execute template file: %w", err) } - return result + return nil } diff --git a/cmd/codegen/model.go b/cmd/codegen/model.go new file mode 100644 index 0000000..12a305e --- /dev/null +++ b/cmd/codegen/model.go @@ -0,0 +1,44 @@ +package main + +type API struct { + Actor []*Func `json:"Actor"` + Checkpoint []*Func `json:"Checkpoint"` + RaceCheckpoint []*Func `json:"RaceCheckpoint"` + Class []*Func `json:"Class"` + Player []*Func `json:"Player"` + Component []*Func `json:"Component"` + Config []*Func `json:"Config"` + Core []*Func `json:"Core"` + NPC []*Func `json:"NPC"` + CustomModel []*Func `json:"CustomModel"` + Dialog []*Func `json:"Dialog"` + Event []*Func `json:"Event"` + GangZone []*Func `json:"GangZone"` + Menu []*Func `json:"Menu"` + Object []*Func `json:"Object"` + PlayerObject []*Func `json:"PlayerObject"` + Pickup []*Func `json:"Pickup"` + All []*Func `json:"All"` + Recording []*Func `json:"Recording"` + TextDraw []*Func `json:"TextDraw"` + PlayerTextDraw []*Func `json:"PlayerTextDraw"` + TextLabel []*Func `json:"TextLabel"` + PlayerTextLabel []*Func `json:"PlayerTextLabel"` + Vehicle []*Func `json:"Vehicle"` +} + +type FuncParam struct { + Name string `json:"name"` + Type string `json:"type"` +} + +type Func struct { + Ret string `json:"ret"` + Name string `json:"name"` + Params []*FuncParam `json:"params"` +} + +type Group struct { + Name string + Funcs []*Func +} diff --git a/config.cpp b/config.cpp deleted file mode 100644 index 611797e..0000000 --- a/config.cpp +++ /dev/null @@ -1,35 +0,0 @@ -#include "include/config.h" - -extern "C" { - void config_setFloat(String key, float value) { - return call("config_setFloat", key, value); - } - - void config_setInt(String key, int value) { - return call("config_setInt", key, value); - } - - void config_setBool(String key, unsigned char value) { - return call("config_setBool", key, value); - } - - int config_getType(String key) { - return call("config_getType", key); - } - - float config_getFloat(String key) { - return call("config_getFloat", key); - } - - int config_getInt(String key) { - return call("config_getInt", key); - } - - unsigned char config_getBool(String key) { - return call("config_getBool", key); - } - - unsigned char config_isBanned(String ip) { - return call("config_isBanned", ip); - } -} diff --git a/console.cpp b/console.cpp deleted file mode 100644 index 69d5cb4..0000000 --- a/console.cpp +++ /dev/null @@ -1,7 +0,0 @@ -#include "include/console.h" - -extern "C" { - void console_send(String command) { - return call("console_send", command); - } -} diff --git a/dialog.go b/dialog.go index dbad1ea..f999534 100644 --- a/dialog.go +++ b/dialog.go @@ -1,9 +1,10 @@ package omp -// #include "include/player.h" +// #include "include/wrappers.h" import "C" import ( "strings" + "unsafe" "github.com/kodeyeen/event" ) @@ -19,13 +20,35 @@ const ( dialogStyleTablistHeaders ) -var activeDialogs = make(map[int]dialog, 1000) +const dialogID = 999 -type dialog interface { +var activeDialogs = make(map[int]Dialog, 1000) + +type Dialog interface { ShowFor(player *Player) HideFor(player *Player) } +func showDialog(plr *Player, style dialogStyle, title, body, button1, button2 string) { + cTitle := C.CString(title) + defer C.free(unsafe.Pointer(cTitle)) + + cBody := C.CString(body) + defer C.free(unsafe.Pointer(cBody)) + + cButton1 := C.CString(button1) + defer C.free(unsafe.Pointer(cButton1)) + + cButton2 := C.CString(button2) + defer C.free(unsafe.Pointer(cButton2)) + + C.Dialog_Show(plr.handle, dialogID, C.int(style), cTitle, cBody, cButton1, cButton2) +} + +func hideDialog(plr *Player) { + C.Dialog_Hide(plr.handle) +} + type MessageDialog struct { *event.Dispatcher Title, Body, Button1, Button2 string @@ -48,7 +71,7 @@ func (d *MessageDialog) ShowFor(player *Player) { Player: player, }) - player.showDialog(dialogStyleMsgBox, d.Title, d.Body, d.Button1, d.Button2) + showDialog(player, dialogStyleMsgBox, d.Title, d.Body, d.Button1, d.Button2) } func (d *MessageDialog) HideFor(player *Player) { @@ -58,7 +81,7 @@ func (d *MessageDialog) HideFor(player *Player) { delete(activeDialogs, player.ID()) - player.hideDialog() + hideDialog(player) } type InputDialog struct { @@ -101,7 +124,7 @@ func (d *InputDialog) ShowFor(player *Player) { Player: player, }) - player.showDialog(style, d.Title, d.Body, d.Button1, d.Button2) + showDialog(player, style, d.Title, d.Body, d.Button1, d.Button2) } func (d *InputDialog) HideFor(player *Player) { @@ -111,7 +134,7 @@ func (d *InputDialog) HideFor(player *Player) { delete(activeDialogs, player.ID()) - player.hideDialog() + hideDialog(player) } type ListDialog struct { @@ -146,7 +169,7 @@ func (d *ListDialog) ShowFor(player *Player) { Player: player, }) - player.showDialog(dialogStyleList, d.Title, body, d.Button1, d.Button2) + showDialog(player, dialogStyleList, d.Title, body, d.Button1, d.Button2) } func (d *ListDialog) HideFor(player *Player) { @@ -156,7 +179,7 @@ func (d *ListDialog) HideFor(player *Player) { delete(activeDialogs, player.ID()) - player.hideDialog() + hideDialog(player) } type TabListItem []string @@ -203,7 +226,7 @@ func (d *TabListDialog) ShowFor(player *Player) { Player: player, }) - player.showDialog(style, d.Title, body, d.Button1, d.Button2) + showDialog(player, style, d.Title, body, d.Button1, d.Button2) } func (d *TabListDialog) makeBody(style dialogStyle) string { @@ -227,5 +250,5 @@ func (d *TabListDialog) HideFor(player *Player) { delete(activeDialogs, player.ID()) - player.hideDialog() + hideDialog(player) } diff --git a/event.go b/event.go index 8959b5d..451d92b 100644 --- a/event.go +++ b/event.go @@ -59,13 +59,22 @@ const ( ObjectEditResponseUpdate ) +type DownloadRequestType int + +const ( + DownloadRequestTypeUnknown DownloadRequestType = iota - 1 + DownloadRequestTypeEmpty + DownloadRequestTypeModelFile + DownloadRequestTypeTextureFile +) + type PlayerBullet struct { - Origin Vector3 - HitPos Vector3 - Offset Vector3 - Weapon Weapon - HitType int - HitID int + Origin Vector3 + HitPosition Vector3 + Offset Vector3 + Weapon Weapon + HitType int + HitID int } type UnoccupiedVehicleUpdate struct { @@ -96,6 +105,9 @@ const ( EventTypeConsoleText event.Type = "consoleText" EventTypeRconLoginAttempt event.Type = "rconLoginAttempt" + // Core events + EventTypeTick event.Type = "tick" + // Custom model events EventTypePlayerFinishedDownloading event.Type = "playerFinishedDownloading" EventTypePlayerRequestDownload event.Type = "playerRequestDownload" @@ -208,11 +220,11 @@ type GameModeExitEvent struct { // Actor events type PlayerGiveDamageActorEvent struct { - Player *Player - Actor *Player - Amount float32 - Weapon uint - Part BodyPart + Player *Player + Actor *Player + Amount float32 + Weapon Weapon + BodyPart BodyPart } type ActorStreamInEvent struct { @@ -263,6 +275,11 @@ type RconLoginAttemptEvent struct { Success bool } +type TickEvent struct { + Elapsed time.Duration + Now time.Time +} + // Custom model events type PlayerFinishedDownloadingEvent struct { @@ -270,8 +287,9 @@ type PlayerFinishedDownloadingEvent struct { } type PlayerRequestDownloadEvent struct { - Player *Player - Type, Checksum int + Player *Player + Type DownloadRequestType + Checksum int } // Dialog events @@ -345,7 +363,7 @@ type PlayerClickPlayerTurfEvent struct { type PlayerSelectedMenuRowEvent struct { Player *Player - MenuRow uint8 + MenuRow int } type PlayerExitedMenuEvent struct { @@ -426,7 +444,7 @@ type PlayerSpawnEvent struct { type IncomingConnectionEvent struct { Player *Player - IPAddress string + ipAddress string Port int } @@ -507,8 +525,8 @@ type PlayerNameChangeEvent struct { type PlayerInteriorChangeEvent struct { Player *Player - NewInterior uint - OldInterior uint + NewInterior int + OldInterior int } type PlayerStateChangeEvent struct { @@ -519,8 +537,8 @@ type PlayerStateChangeEvent struct { type PlayerKeyStateChangeEvent struct { Player *Player - NewKeys uint - OldKeys uint + NewKeys int + OldKeys int } // Player damage events @@ -540,11 +558,11 @@ type PlayerTakeDamageEvent struct { } type PlayerGiveDamageEvent struct { - Player *Player - To *Player - Amount float32 - Weapon Weapon - Part BodyPart + Player *Player + To *Player + Amount float32 + Weapon Weapon + BodyPart BodyPart } // Player click events @@ -555,9 +573,9 @@ type PlayerClickMapEvent struct { } type PlayerClickPlayerEvent struct { - Player *Player - Clicked *Player - Source PlayerClickSource + Player *Player + Target *Player + Source PlayerClickSource } // Player check events @@ -665,7 +683,7 @@ type UnoccupiedVehicleUpdateEvent struct { type TrailerUpdateEvent struct { Player *Player - Vehicle *Vehicle + Trailer *Vehicle } type VehicleSirenStateChangeEvent struct { diff --git a/examples/rivershell/main.go b/examples/rivershell/main.go index fb9ad92..425d478 100644 --- a/examples/rivershell/main.go +++ b/examples/rivershell/main.go @@ -402,7 +402,7 @@ func onPlayerStateChange(e *omp.PlayerStateChangeEvent) bool { char.SetColor(ColorObjective) char.ShowGameText("~w~Take the ~y~boat ~w~back to the ~r~spawn!", 3*time.Second, 5) - cp := char.DefaultCheckpoint() + cp := char.Checkpoint() cp.SetPosition(omp.Vector3{X: 2135.7368, Y: -179.8811, Z: -0.5323}) cp.SetRadius(10.0) cp.Enable() @@ -413,7 +413,7 @@ func onPlayerStateChange(e *omp.PlayerStateChangeEvent) bool { char.SetColor(ColorObjective) char.ShowGameText("~w~Take the ~y~boat ~w~back to the ~r~spawn!", 3*time.Second, 5) - cp := char.DefaultCheckpoint() + cp := char.Checkpoint() cp.SetPosition(omp.Vector3{X: 2329.4226, Y: 532.7426, Z: 0.5862}) cp.SetRadius(10.0) cp.Enable() @@ -424,11 +424,11 @@ func onPlayerStateChange(e *omp.PlayerStateChangeEvent) bool { if *char == objectiveGreenChar { objectiveGreenChar = Character{} char.SetColorFromTeam() - char.DefaultCheckpoint().Disable() + char.Checkpoint().Disable() } else if *char == objectiveBlueChar { objectiveBlueChar = Character{} char.SetColorFromTeam() - char.DefaultCheckpoint().Disable() + char.Checkpoint().Disable() } } diff --git a/include/actor.h b/include/actor.h deleted file mode 100644 index 9d65dd6..0000000 --- a/include/actor.h +++ /dev/null @@ -1,46 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct { - float delta; - unsigned char loop; - unsigned char lockX; - unsigned char lockY; - unsigned char freeze; - uint32_t time; - String lib; - String name; - } CAnimationData; - - typedef struct { - Vector3 position; - float facingAngle; - int skin; - } ActorSpawnData; - - void* actor_create(int skin, float posX, float posY, float posZ, float angle); - void actor_release(void* actor); - void actor_setSkin(void* actor, int skin); - int actor_getSkin(void* actor); - void actor_applyAnimation(void* actor, float delta, unsigned char loop, unsigned char lockX, unsigned char lockY, unsigned char freeze, uint32_t time, String lib, String name); - CAnimationData actor_getAnimation(void* actor); - void actor_clearAnimations(void* actor); - void actor_setHealth(void* actor, float health); - float actor_getHealth(void* actor); - void actor_setInvulnerable(void* actor, unsigned char invuln); - unsigned char actor_isInvulnerable(void* actor); - unsigned char actor_isStreamedInForPlayer(void* actor, void* player); - ActorSpawnData actor_getSpawnData(void* actor); - void actor_setPosition(void* actor, float posX, float posY, float posZ); - Vector3 actor_getPosition(void* actor); - void actor_setVirtualWorld(void* actor, int vw); - int actor_getVirtualWorld(void* actor); - void actor_setFacingAngle(void* actor, float angle); - float actor_getFacingAngle(void* actor); - -#ifdef __cplusplus -} -#endif diff --git a/include/checkpoint.h b/include/checkpoint.h deleted file mode 100644 index 6df34d1..0000000 --- a/include/checkpoint.h +++ /dev/null @@ -1,33 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - void* checkpoint_setPosition(void* checkpoint, float posX, float posY, float posZ); - Vector3 checkpoint_getPosition(void* checkpoint); - void checkpoint_setRadius(void* checkpoint, float radius); - float checkpoint_getRadius(void* checkpoint); - unsigned char checkpoint_isPlayerInside(void* checkpoint); - void checkpoint_enable(void* checkpoint); - void checkpoint_disable(void* checkpoint); - unsigned char checkpoint_isEnabled(void* checkpoint); - - // race checkpoint - - void* raceCheckpoint_setPosition(void* checkpoint, float posX, float posY, float posZ); - Vector3 raceCheckpoint_getPosition(void* checkpoint); - void raceCheckpoint_setRadius(void* checkpoint, float radius); - float raceCheckpoint_getRadius(void* checkpoint); - unsigned char raceCheckpoint_isPlayerInside(void* checkpoint); - void raceCheckpoint_enable(void* checkpoint); - void raceCheckpoint_disable(void* checkpoint); - unsigned char raceCheckpoint_isEnabled(void* checkpoint); - void raceCheckpoint_setType(void* checkpoint, int type); - int raceCheckpoint_getType(void* checkpoint); - void raceCheckpoint_setNextPosition(void* checkpoint, float posX, float posY, float posZ); - Vector3 raceCheckpoint_getNextPosition(void* checkpoint); - -#ifdef __cplusplus -} -#endif diff --git a/include/class.h b/include/class.h deleted file mode 100644 index 071559c..0000000 --- a/include/class.h +++ /dev/null @@ -1,31 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct ClassData - { - int team; - int skin; - float spawnX; - float spawnY; - float spawnZ; - float angle; - uint8_t weapon1; - uint32_t ammo1; - uint8_t weapon2; - uint32_t ammo2; - uint8_t weapon3; - uint32_t ammo3; - } ClassData; - - void* class_create(ClassData* data); - void class_release(void* _class); - int class_getID(void* class_); - void class_setClass(void* class_, ClassData* data); - ClassData class_getClass(void* class_); - -#ifdef __cplusplus -} -#endif diff --git a/include/config.h b/include/config.h deleted file mode 100644 index a40c622..0000000 --- a/include/config.h +++ /dev/null @@ -1,18 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - void config_setFloat(String key, float value); - void config_setInt(String key, int value); - void config_setBool(String key, unsigned char value); - int config_getType(String key); - float config_getFloat(String key); - int config_getInt(String key); - unsigned char config_getBool(String key); - unsigned char config_isBanned(String ip); - -#ifdef __cplusplus -} -#endif diff --git a/include/console.h b/include/console.h deleted file mode 100644 index c8feb73..0000000 --- a/include/console.h +++ /dev/null @@ -1,11 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - void console_send(String command); - -#ifdef __cplusplus -} -#endif diff --git a/include/menu.h b/include/menu.h deleted file mode 100644 index 02cd287..0000000 --- a/include/menu.h +++ /dev/null @@ -1,26 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - void* menu_create(String title, float posX, float posY, uint8_t columns, float col1Width, float col2Width); - void menu_release(void* menu); - void menu_setColumnHeader(void* menu, String header, uint8_t column); - void menu_addCell(void* menu, String itemText, uint8_t column); - void menu_disableRow(void* menu, uint8_t row); - unsigned char menu_isRowEnabled(void* menu, uint8_t row); - void menu_disable(void* menu); - unsigned char menu_isEnabled(void* menu); - Vector2 menu_getPosition(void* menu); - int menu_getRowCount(void* menu, uint8_t column); - int menu_getColumnCount(void* menu); - Vector2 menu_getColumnWidths(void* menu); - String menu_getColumnHeader(void* menu, uint8_t column); - String menu_getCell(void* menu, uint8_t column, uint8_t row); - void menu_showForPlayer(void* menu, void* player); - void menu_hideForPlayer(void* menu, void* player); - -#ifdef __cplusplus -} -#endif diff --git a/include/model.h b/include/model.h deleted file mode 100644 index 65ac2f0..0000000 --- a/include/model.h +++ /dev/null @@ -1,14 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - unsigned char model_add(uint8_t type, int32_t id, int32_t baseId, String dffName, String txdName, int32_t virtualWorld, uint8_t timeOn, uint8_t timeOff); - String model_getNameFromCheckSum(uint32_t crc); - unsigned char model_isValid(int32_t modelId); - unsigned char model_getPath(int32_t modelId, String* dffPath, String* txdPath); - -#ifdef __cplusplus -} -#endif diff --git a/include/object.h b/include/object.h deleted file mode 100644 index fb22487..0000000 --- a/include/object.h +++ /dev/null @@ -1,127 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct { - Vector3 targetPos; - Vector3 targetRot; - float speed; - } ObjectMoveData; - - typedef struct { - uint8_t type; - unsigned char syncRotation; - int ID; - Vector3 offset; - Vector3 rotation; - } ObjectAttachmentData; - - typedef enum { - ObjectMaterialSize_32x32 = 10, - ObjectMaterialSize_64x32 = 20, - ObjectMaterialSize_64x64 = 30, - ObjectMaterialSize_128x32 = 40, - ObjectMaterialSize_128x64 = 50, - ObjectMaterialSize_128x128 = 60, - ObjectMaterialSize_256x32 = 70, - ObjectMaterialSize_256x64 = 80, - ObjectMaterialSize_256x128 = 90, - ObjectMaterialSize_256x256 = 100, - ObjectMaterialSize_512x64 = 110, - ObjectMaterialSize_512x128 = 120, - ObjectMaterialSize_512x256 = 130, - ObjectMaterialSize_512x512 = 140 - } ObjectMaterialSize; - - typedef enum { - ObjectMaterialTextAlign_Left, - ObjectMaterialTextAlign_Center, - ObjectMaterialTextAlign_Right - } ObjectMaterialTextAlign; - - typedef struct { - int model; - String textureLibrary; - String textureName; - uint32_t colour; - } ObjectMaterial; - - typedef struct { - String text; - uint8_t materialSize; - String fontFace; - uint8_t fontSize; - unsigned char bold; - uint32_t fontColour; - uint32_t backgroundColour; - uint8_t alignment; - } ObjectMaterialText; - - void* object_create(int modelId, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float drawDistance); - void object_release(void* object); - void* object_getByID(int id); - void object_setDefaultCameraCollision(unsigned char set); - void object_setDrawDistance(void* object, float drawDistance); - float object_getDrawDistance(void* object); - void object_setModel(void* object, int model); - int object_getModel(void* object); - void object_setCameraCollision(void* object, unsigned char set); - unsigned char object_getCameraCollision(void* object); - int object_move(void* object, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float speed); - unsigned char object_isMoving(void* object); - void object_stop(void* object); - ObjectMoveData object_getMovingData(void* object); - void object_attachToVehicle(void* object, void* vehicle, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ); - void object_resetAttachment(void* object); - ObjectAttachmentData object_getAttachmentData(void* object); - unsigned char object_isMaterialSlotUsed(void* object, uint32_t materialIndex); - unsigned char object_getMaterial(void* object, uint32_t materialIndex, const ObjectMaterial* out); - unsigned char object_getMaterialText(void* object, uint32_t materialIndex, const ObjectMaterialText* out); - void object_setMaterial(void* object, uint32_t materialIndex, int model, String textureLibrary, String textureName, uint32_t colour); - void object_setMaterialText(void* object, uint32_t materialIndex, String text, ObjectMaterialSize materialSize, String fontFace, int fontSize, unsigned char bold, uint32_t fontColour, uint32_t backgroundColour, ObjectMaterialTextAlign align); - void object_attachToPlayer(void* object, void* player, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ); - void object_attachToObject(void* object, void* other, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ, unsigned char syncRotation); - - // entity - void object_setPosition(void* object, float posX, float posY, float posZ); - Vector3 object_getPosition(void* object); - void object_setRotation(void* object, float rotX, float rotY, float rotZ); - Vector3 object_getRotation(void* object); - - // PlayerObject - void* playerObject_create(void* player, int modelId, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float drawDistance); - void playerObject_release(void* object, void* player); - void* playerObject_getByID(void* player, int id); - void playerObject_setDrawDistance(void* object, float drawDistance); - float playerObject_getDrawDistance(void* object); - void playerObject_setModel(void* object, int model); - int playerObject_getModel(void* object); - void playerObject_setCameraCollision(void* object, unsigned char set); - unsigned char playerObject_getCameraCollision(void* object); - int playerObject_move(void* object, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float speed); - unsigned char playerObject_isMoving(void* object); - void playerObject_stop(void* object); - ObjectMoveData playerObject_getMovingData(void* object); - void playerObject_attachToVehicle(void* object, void* vehicle, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ); - void playerObject_resetAttachment(void* object); - ObjectAttachmentData playerObject_getAttachmentData(void* object); - unsigned char playerObject_isMaterialSlotUsed(void* object, uint32_t materialIndex); - unsigned char playerObject_getMaterial(void* object, uint32_t materialIndex, ObjectMaterial* out); - unsigned char playerObject_getMaterialText(void* object, uint32_t materialIndex, ObjectMaterialText* out); - void playerObject_setMaterial(void* object, uint32_t materialIndex, int model, String textureLibrary, String textureName, uint32_t colour); - void playerObject_setMaterialText(void* object, uint32_t materialIndex, String text, ObjectMaterialSize materialSize, String fontFace, int fontSize, unsigned char bold, uint32_t fontColour, uint32_t backgroundColour, ObjectMaterialTextAlign align); - void playerObject_attachToPlayer(void* object, void* player, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ); - void playerObject_attachToObject(void* object, void* other, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ); - - // entity - - void playerObject_setPosition(void* object, float posX, float posY, float posZ); - Vector3 playerObject_getPosition(void* object); - void playerObject_setRotation(void* object, float rotX, float rotY, float rotZ); - Vector3 playerObject_getRotation(void* object); - -#ifdef __cplusplus -} -#endif diff --git a/include/omp.h b/include/omp.h index ad46b68..95eeb3c 100644 --- a/include/omp.h +++ b/include/omp.h @@ -1,112 +1,18 @@ -#ifndef GOMP_H -#define GOMP_H +#ifndef OMP_H +#define OMP_H -#include -#include - -typedef struct { - const char* buf; - size_t length; -} String; - -typedef struct { - void** buf; - size_t length; -} Array; - -typedef struct { - float x; - float y; - float z; - float w; -} Vector4; - -typedef struct { - float x; - float y; - float z; -} Vector3; - -typedef struct { - float x; - float y; -} Vector2; - -typedef struct { - int primary; - int secondary; -} VehicleColour; - -typedef struct { - int model; - int bone; - Vector3 offset; - Vector3 rotation; - Vector3 scale; - uint32_t colour1; - uint32_t colour2; -} PlayerAttachedObject; - -typedef struct { - Vector3 origin; - Vector3 hitPos; - Vector3 offset; - uint8_t weapon; - uint8_t hitType; - uint16_t hitID; -} PlayerBulletData; - -typedef struct { - uint8_t seat; - Vector3 position; - Vector3 velocity; -} UnoccupiedVehicleUpdate; +#include "capi/include/ompcapi.h" #ifdef __cplusplus extern "C" { #endif - void loadComponent(); - void unloadComponent(); - void* findFunc(const char* name); - - void freeArray(Array arr); - uint8_t getWeaponSlotIndex(uint8_t weapon); - unsigned char getVehicleModelInfo(int model, int type, Vector3* out); + bool onGameModeInit(); + bool onGameModeExit(); + bool onPlayerConnect(struct EventArgs_onPlayerConnect* args); #ifdef __cplusplus } - -#include -#include - -extern void* libHandle; -extern std::unordered_map funcs; - -template -R call(const std::string& funcName, Args... args) -{ - auto it = funcs.find(funcName); - void* funcAddr = nullptr; - - if (it == funcs.end()) { - funcAddr = findFunc(funcName.c_str()); - funcs.emplace(funcName, funcAddr); - } else { - funcAddr = it->second; - } - - // R ret; - // if funcAddr == nullptr { - // return ret; - // } - - typedef R (* FuncType)(Args...); - - FuncType func = (FuncType)funcAddr; - - return (*func)(std::forward(args)...); -} #endif -#endif // GOMP_H +#endif // OMP_H diff --git a/include/pickup.h b/include/pickup.h deleted file mode 100644 index 05c17ae..0000000 --- a/include/pickup.h +++ /dev/null @@ -1,30 +0,0 @@ -#include -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - void* pickup_create(int modelId, uint8_t type, float posX, float posY, float posZ, uint32_t virtualWorld, int isStatic); - void pickup_release(void* pickup); - int pickup_getID(void* pickup); - void pickup_setType(void* pickup, uint8_t type); - uint8_t pickup_getType(void* pickup); - void pickup_setModel(void* pickup, int model); - int pickup_getModel(void* pickup); - unsigned char pickup_isStreamedInForPlayer(void* pickup, void* player); - void pickup_setPickupHiddenForPlayer(void* pickup, void* player, unsigned char hidden); - unsigned char pickup_isPickupHiddenForPlayer(void* pickup, void* player); - - // entity - void pickup_setPosition(void* pickup, float posX, float posY, float posZ); - Vector3 pickup_getPosition(void* pickup); - void pickup_setVirtualWorld(void* pickup, int vw); - int pickup_getVirtualWorld(void* pickup); - - void* playerPickup_create(void* player, int modelId, uint8_t type, float posX, float posY, float posZ, uint32_t virtualWorld, int isStatic); - void playerPickup_release(void* pickup, void* player); - -#ifdef __cplusplus -} -#endif diff --git a/include/player.h b/include/player.h deleted file mode 100644 index e29de37..0000000 --- a/include/player.h +++ /dev/null @@ -1,243 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct { - Vector3 camFrontVector; - Vector3 camPos; - float aimZ; - float camZoom; - float aspectRatio; - int8_t weaponState; - uint8_t camMode; - } PlayerAimData; - - typedef struct { - uint8_t id; - uint32_t ammo; - } WeaponSlotData; - - typedef struct { - int hours; - int minutes; - } Time; - - typedef struct { - uint16_t ID; - uint16_t flags; - } PlayerAnimationData; - - typedef struct { - uint32_t keys; - int16_t upDown; - int16_t leftRight; - } PlayerKeyData; - - typedef struct { - unsigned char spectating; - int spectateID; - int type; - } CPlayerSpectateData; - - typedef enum { - PlayerAnimationSyncType_NoSync, - PlayerAnimationSyncType_Sync, - PlayerAnimationSyncType_SyncOthers - } PlayerAnimationSyncType; - - void* player_getByID(int id); - Array player_getAll(); - void player_sendDeathMessageToAll(void* killer, void* killee, int weapon); - void player_sendEmptyDeathMessageToAll(); - void player_sendGameTextToAll(String msg, int time, int style); - - int player_getID(void* player); - - void player_kick(void* player); - void player_ban(void* player, String reason); - int player_isBot(void* player); - unsigned player_getPing(void* player); - void player_spawn(void* player); - int player_isSpawned(void* player); - uint8_t player_getClientVersion(void* player); - String player_getClientVersionName(void* player); - void player_setPositionFindZ(void* player, float x, float y, float z); - void player_setCameraPosition(void* player, float x, float y, float z); - Vector3 player_getCameraPosition(void* player); - void player_setCameraLookAt(void* player, float x, float y, float z, int cutType); - Vector3 player_getCameraLookAt(void* player); - void player_setCameraBehind(void* player); - void player_interpolateCameraPosition(void* player, float fromX, float fromY, float fromZ, float toX, float toY, float toZ, int time, int cutType); - void player_interpolateCameraLookAt(void* player, float fromX, float fromY, float fromZ, float toX, float toY, float toZ, int time, int cutType); - void player_attachCameraToObject(void* player, void* object); - int player_setName(void* player, String name); - String player_getName(void* player); - String player_getSerial(void* player); - void player_giveWeapon(void* player, uint8_t id, uint32_t ammo); - void player_removeWeapon(void* player, uint8_t weapon); - void player_setWeaponAmmo(void* player, uint8_t id, uint32_t ammo); - Array* player_getWeapons(void* player); - WeaponSlotData player_getWeaponSlot(void* player, int slot); - void player_resetWeapons(void* player); - void player_setArmedWeapon(void* player, uint32_t weapon); - uint32_t player_getArmedWeapon(void* player); - uint32_t player_getArmedWeaponAmmo(void* player); - void player_setShopName(void* player, String name); - String player_getShopName(void* player); - void player_setDrunkLevel(void* player, int level); - int player_getDrunkLevel(void* player); - void player_setColour(void* player, uint32_t colour); - uint32_t player_getColour(void* player); - void player_setOtherColour(void* player, void* other, uint32_t colour); - int player_getOtherColour(void* player, void* other, uint32_t* colour); - void player_setControllable(void* player, int controllable); - int player_getControllable(void* player); - void player_setSpectating(void* player, int spectating); - void player_setWantedLevel(void* player, unsigned level); - unsigned player_getWantedLevel(void* player); - void player_playSound(void* player, uint32_t sound, float posX, float posY, float posZ); - uint32_t player_lastPlayedSound(void* player); - void player_playAudio(void* player, String url, unsigned char usePos, float posX, float posY, float posZ, float distance); - int player_playerCrimeReport(void* player, void* suspect, int crime); - void player_stopAudio(void* player); - String player_lastPlayedAudio(void* player); - void player_createExplosion(void* player, float vecX, float vecY, float vecZ, int type, float radius); - void player_sendDeathMessage(void* player, void* killee, void* killer, int weapon); - void player_sendEmptyDeathMessage(void* player); - void player_removeDefaultObjects(void* player, unsigned model, float posX, float posY, float posZ, float radius); - void player_forceClassSelection(void* player); - void player_setMoney(void* player, int money); - void player_giveMoney(void* player, int money); - void player_resetMoney(void* player); - int player_getMoney(void* player); - void player_setMapIcon(void* player, int id, float posX, float posY, float posZ, int type, uint32_t colour, int style); - void player_unsetMapIcon(void* player, int id); - void player_useStuntBonuses(void* player, int enable); - void player_toggleOtherNameTag(void* player, void* other, int toggle); - void player_setTime(void* player, int hr, int min); - Time player_getTime(void* player); - void player_useClock(void* player, int enable); - int player_hasClock(void* player); - void player_useWidescreen(void* player, int enable); - int player_hasWidescreen(void* player); - void player_setHealth(void* player, float health); - float player_getHealth(void* player); - void player_setScore(void* player, int score); - int player_getScore(void* player); - void player_setArmour(void* player, float armour); - float player_getArmour(void* player); - void player_setGravity(void* player, float gravity); - float player_getGravity(void* player); - void player_setWorldTime(void* player, int time); - void player_applyAnimation(void* player, float delta, unsigned char loop, unsigned char lockX, unsigned char lockY, unsigned char freeze, uint32_t time, String lib, String name, int syncType); - void player_clearAnimations(void* player, int syncType); - PlayerAnimationData player_getAnimationData(void* player); - int player_isStreamedInForPlayer(void* player, void* other); - int player_getState(void* player); - void player_setTeam(void* player, int team); - int player_getTeam(void* player); - void player_setSkin(void* player, int skin, int send); - int player_getSkin(void* player); - void player_setChatBubble(void* player, String text, uint32_t colour, float drawDist, int expire); - void player_sendClientMessage(void* player, uint32_t colour, String message); - void player_sendChatMessage(void* player, void* sender, String message); - void player_sendGameText(void* player, String message, int time, int style); - void player_hideGameText(void* player, int style); - int player_hasGameText(void* player, int style); - int player_getGameText(void* player, int style, String* message, int* time, int* remaining); - void player_setWeather(void* player, int weatherID); - int player_getWeather(void* player); - void player_setWorldBounds(void* player, float x, float y, float z, float w); - Vector4 player_getWorldBounds(void* player); - void player_setFightingStyle(void* player, int style); - int player_getFightingStyle(void* player); - void player_setSkillLevel(void* player, int skill, int level); - void player_setAction(void* player, int action); - int player_getAction(void* player); - void player_setVelocity(void* player, float velX, float velY, float velZ); - Vector3 player_getVelocity(void* player); - void player_setInterior(void* player, unsigned interior); - unsigned player_getInterior(void* player); - PlayerKeyData player_getKeyData(void* player); - const PlayerAimData* player_getAimData(void* player); - const PlayerBulletData* player_getBulletData(void* player); - void player_useCameraTargeting(void* player, int enable); - unsigned char player_hasCameraTargeting(void* player); - void player_removeFromVehicle(void* player, unsigned char force); - void* player_getCameraTargetPlayer(void* player); - void* player_getCameraTargetVehicle(void* player); - void* player_getCameraTargetObject(void* player); - void* player_getCameraTargetActor(void* player); - void* player_getTargetPlayer(void* player); - void* player_getTargetActor(void* player); - void player_setRemoteVehicleCollisions(void* player, int collide); - void player_spectatePlayer(void* player, void* target, int mode); - void player_spectateVehicle(void* player, void* target, int mode); - CPlayerSpectateData player_getSpectateData(void* player); - void player_sendClientCheck(void* player, int actionType, int address, int offset, int count); - void player_toggleGhostMode(void* player, int toggle); - int player_isGhostModeEnabled(void* player); - int player_getDefaultObjectsRemoved(void* player); - void player_clearTasks(void* player, PlayerAnimationSyncType syncType); - void player_allowWeapons(void* player, int allow); - int player_areWeaponsAllowed(void* player); - void player_allowTeleport(void* player, int allow); - int player_isTeleportAllowed(void* player); - int player_isUsingOfficialClient(void* player); - - // entity - void player_setPosition(void* player, float posX, float posY, float posZ); - Vector3 player_getPosition(void* player); - Vector4 player_getRotation(void* player); - void player_setVirtualWorld(void* player, int vw); - int player_getVirtualWorld(void* player); - - // console data - void player_setConsoleAccessibility(void* player, int set); - int player_hasConsoleAccess(void* player); - - // checkpoint data - void* player_getCheckpoint(void* player); - void* player_getRaceCheckpoint(void* player); - - // custom models data - int player_getCustomSkin(void* player); - unsigned char player_redirectDownload(void* player, String url); - - // dialog data - void player_showDialog(void* player, int id, int style, String title, String body, String button1, String button2); - void player_hideDialog(void* player); - - // network data - String player_getIp(void* player); - uint32_t player_getRawIp(void* player); - - // vehicle data - void* player_getVehicle(void* player); - int player_getSeat(void* player); - int player_isInModShop(void* player); - - // object data - void player_beginObjectEditing(void* player, void* object); - void player_endObjectEditing(void* player); - unsigned char player_isEditingObject(void* player); - void player_beginObjectSelecting(void* player); - unsigned char player_isSelectingObject(void* player); - void player_setAttachedObject(void* player, int index, int modelId, int bone, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ, float scaleX, float scaleY, float scaleZ, uint32_t colour1, uint32_t colour2); - PlayerAttachedObject player_getAttachedObject(void* player, int index); - void player_removeAttachedObject(void* player, int index); - void player_editAttachedObject(void* player, int index); - unsigned char player_hasAttachedObject(void* player, int index); - - // misc - - float player_getDistanceFromPoint(void* player, float pX, float pY, float pZ); - void player_setFacingAngle(void* player, float angle); - float player_getFacingAngle(void* player); - unsigned char player_isInRangeOfPoint(void* player, float range, float pX, float pY, float pZ); - -#ifdef __cplusplus -} -#endif diff --git a/include/server.h b/include/server.h deleted file mode 100644 index 1cf9669..0000000 --- a/include/server.h +++ /dev/null @@ -1,18 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - void server_printLnU8(const char* fmt); - void server_logLnU8(int logLevel, const char* fmt); - - void server_setWeather(int weather); - void server_setWorldTime(int hours); - void server_enableStuntBonuses(); - - void server_setData(int type, String data); - -#ifdef __cplusplus -} -#endif diff --git a/include/textdraw.h b/include/textdraw.h deleted file mode 100644 index a2aa00b..0000000 --- a/include/textdraw.h +++ /dev/null @@ -1,97 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - void* textDraw_create(float posX, float posY, String text); - void textDraw_release(void* textdraw); - int textDraw_getID(void* textdraw); - void textDraw_setPosition(void* textdraw, float posX, float posY); - Vector2 textDraw_getPosition(void* textdraw); - void textDraw_setText(void* textdraw, String text); - String textDraw_getText(void* textdraw); - void textDraw_setLetterSize(void* textdraw, float sizeX, float sizeY); - Vector2 textDraw_getLetterSize(void* textdraw); - void textDraw_setTextSize(void* textdraw, float sizeX, float sizeY); - Vector2 textDraw_getTextSize(void* textdraw); - void textDraw_setAlignment(void* textdraw, int alignment); - int textDraw_getAlignment(void* textdraw); - void textDraw_setColour(void* textdraw, uint32_t colour); - int textDraw_getLetterColour(void* textdraw); - void textDraw_useBox(void* textdraw, int use); - int textDraw_hasBox(void* textdraw); - void textDraw_setBoxColour(void* textdraw, uint32_t colour); - int textDraw_getBoxColour(void* textdraw); - void textDraw_setShadow(void* textdraw, int size); - int textDraw_getShadow(void* textdraw); - void textDraw_setOutline(void* textdraw, int size); - int textDraw_getOutline(void* textdraw); - void textDraw_setBackgroundColour(void* textdraw, uint32_t colour); - int textDraw_getBackgroundColour(void* textdraw); - void textDraw_setStyle(void* textdraw, int style); - int textDraw_getStyle(void* textdraw); - void textDraw_setProportional(void* textdraw, int set); - int textDraw_isProportional(void* textdraw); - void textDraw_setSelectable(void* textdraw, int set); - int textDraw_isSelectable(void* textdraw); - void textDraw_setPreviewModel(void* textdraw, int model); - int textDraw_getPreviewModel(void* textdraw); - void textDraw_setPreviewRotation(void* textdraw, float rotX, float rotY, float rotZ); - Vector3 textDraw_getPreviewRotation(void* textdraw); - void textDraw_setPreviewVehicleColour(void* textdraw, int col1, int col2); - VehicleColour textDraw_getPreviewVehicleColour(void* textdraw); - void textDraw_setPreviewZoom(void* textdraw, float zoom); - float textDraw_getPreviewZoom(void* textdraw); - void textDraw_showForPlayer(void* textdraw, void* player); - void textDraw_hideForPlayer(void* textdraw, void* player); - int textDraw_isShownForPlayer(void* textdraw, void* player); - void textDraw_setTextForPlayer(void* textdraw, void* player, String text); - - // PlayerTextDraw - void* playerTextDraw_create(void* player, float posX, float posY, String text); - void playerTextDraw_release(void* textdraw, void* player); - int playerTextDraw_getID(void* textdraw); - void playerTextDraw_setPosition(void* textdraw, float posX, float posY); - Vector2 playerTextDraw_getPosition(void* textdraw); - void playerTextDraw_setText(void* textdraw, String text); - String playerTextDraw_getText(void* textdraw); - void playerTextDraw_setLetterSize(void* textdraw, float sizeX, float sizeY); - Vector2 playerTextDraw_getLetterSize(void* textdraw); - void playerTextDraw_setTextSize(void* textdraw, float sizeX, float sizeY); - Vector2 playerTextDraw_getTextSize(void* textdraw); - void playerTextDraw_setAlignment(void* textdraw, int alignment); - int playerTextDraw_getAlignment(void* textdraw); - void playerTextDraw_setColour(void* textdraw, uint32_t colour); - int playerTextDraw_getLetterColour(void* textdraw); - void playerTextDraw_useBox(void* textdraw, int use); - int playerTextDraw_hasBox(void* textdraw); - void playerTextDraw_setBoxColour(void* textdraw, uint32_t colour); - int playerTextDraw_getBoxColour(void* textdraw); - void playerTextDraw_setShadow(void* textdraw, int size); - int playerTextDraw_getShadow(void* textdraw); - void playerTextDraw_setOutline(void* textdraw, int size); - int playerTextDraw_getOutline(void* textdraw); - void playerTextDraw_setBackgroundColour(void* textdraw, uint32_t colour); - int playerTextDraw_getBackgroundColour(void* textdraw); - void playerTextDraw_setStyle(void* textdraw, int style); - int playerTextDraw_getStyle(void* textdraw); - void playerTextDraw_setProportional(void* textdraw, int set); - int playerTextDraw_isProportional(void* textdraw); - void playerTextDraw_setSelectable(void* textdraw, int set); - int playerTextDraw_isSelectable(void* textdraw); - void playerTextDraw_setPreviewModel(void* textdraw, int model); - int playerTextDraw_getPreviewModel(void* textdraw); - void playerTextDraw_setPreviewRotation(void* textdraw, float rotX, float rotY, float rotZ); - Vector3 playerTextDraw_getPreviewRotation(void* textdraw); - void playerTextDraw_setPreviewVehicleColour(void* textdraw, int col1, int col2); - VehicleColour playerTextDraw_getPreviewVehicleColour(void* textdraw); - void playerTextDraw_setPreviewZoom(void* textdraw, float zoom); - float playerTextDraw_getPreviewZoom(void* textdraw); - void playerTextDraw_show(void* textdraw); - void playerTextDraw_hide(void* textdraw); - int playerTextDraw_isShown(void* textdraw); - -#ifdef __cplusplus -} -#endif diff --git a/include/textlabel.h b/include/textlabel.h deleted file mode 100644 index 4319016..0000000 --- a/include/textlabel.h +++ /dev/null @@ -1,60 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct { - int playerID; - int vehicleID; - } TextLabelAttachmentData; - - void* textLabel_create(String text, uint32_t colour, float posX, float posY, float posZ, float drawDist, int vw, unsigned char los); - void textLabel_release(void* textLabel); - void textLabel_setText(void* textLabel, String text); - String textLabel_getText(void* textLabel); - void textLabel_setColour(void* textLabel, uint32_t colour); - uint32_t textLabel_getColour(void* textLabel); - void textLabel_setDrawDistance(void* textLabel, float drawDist); - float textLabel_getDrawDistance(void* textLabel); - void textLabel_attachToPlayer(void* textLabel, void* player, float offsetX, float offsetY, float offsetZ); - void textLabel_attachToVehicle(void* textLabel, void* vehicle, float offsetX, float offsetY, float offsetZ); - TextLabelAttachmentData textLabel_getAttachmentData(void* textLabel); - void textLabel_detachFromPlayer(void* textLabel, float posX, float posY, float posZ); - void textLabel_detachFromVehicle(void* textLabel, float posX, float posY, float posZ); - void textLabel_setTestLOS(void* textLabel, unsigned char status); - unsigned char textLabel_getTestLOS(void* textLabel); - unsigned char textLabel_isStreamedInForPlayer(void* textLabel, void* player); - void textLabel_setPosition(void* textLabel, float posX, float posY, float posZ); - Vector3 textLabel_getPosition(void* textLabel); - void textLabel_setVirtualWorld(void* textLabel, int vw); - int textLabel_getVirtualWorld(void* textLabel); - - // PlayerTextLabel - - void* playerTextLabel_create(void* player, String text, uint32_t colour, float posX, float posY, float posZ, float drawDistance, unsigned char los); - void playerTextLabel_release(void* textLabel, void* player); - void playerTextLabel_setText(void* textLabel, String text); - String playerTextLabel_getText(void* textLabel); - void playerTextLabel_setColour(void* textLabel, uint32_t colour); - uint32_t playerTextLabel_getColour(void* textLabel); - void playerTextLabel_setDrawDistance(void* textLabel, float drawDist); - float playerTextLabel_getDrawDistance(void* textLabel); - void playerTextLabel_attachToPlayer(void* textLabel, void* player, float offsetX, float offsetY, float offsetZ); - void playerTextLabel_attachToVehicle(void* textLabel, void* vehicle, float offsetX, float offsetY, float offsetZ); - TextLabelAttachmentData playerTextLabel_getAttachmentData(void* textLabel); - void playerTextLabel_detachFromPlayer(void* textLabel, float posX, float posY, float posZ); - void playerTextLabel_detachFromVehicle(void* textLabel, float posX, float posY, float posZ); - void playerTextLabel_setTestLOS(void* textLabel, unsigned char status); - unsigned char playerTextLabel_getTestLOS(void* textLabel); - - // entity - - void playerTextLabel_setPosition(void* textLabel, float posX, float posY, float posZ); - Vector3 playerTextLabel_getPosition(void* textLabel); - void playerTextLabel_setVirtualWorld(void* textLabel, int vw); - int playerTextLabel_getVirtualWorld(void* textLabel); - -#ifdef __cplusplus -} -#endif diff --git a/include/turf.h b/include/turf.h deleted file mode 100644 index 6abd687..0000000 --- a/include/turf.h +++ /dev/null @@ -1,36 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct { - Vector2 min; - Vector2 max; - } TurfPos; - - void* turf_create(float minX, float minY, float maxX, float maxY); - void turf_release(void* turf); - void turf_useCheck(void* turf, unsigned char use); - unsigned char turf_isShownForPlayer(void* turf, void* player); - unsigned char turf_isFlashingForPlayer(void* turf, void* player); - void turf_showForPlayer(void* turf, void* player, uint32_t colour); - void turf_showForAll(void* turf, uint32_t colour); - void turf_hideForPlayer(void* turf, void* player); - void turf_hideForAll(void* turf); - void turf_flashForPlayer(void* turf, void* player, uint32_t colour); - void turf_flashForAll(void* turf, uint32_t colour); - void turf_stopFlashForPlayer(void* turf, void* player); - void turf_stopFlashForAll(void* turf); - TurfPos turf_getPosition(void* turf); - void turf_setPosition(void* turf, float minX, float minY, float maxX, float maxY); - unsigned char turf_isPlayerInside(void* turf, void* player); - uint32_t turf_getFlashingColourForPlayer(void* turf, void* player); - uint32_t turf_getColourForPlayer(void* turf, void* player); - - void* playerTurf_create(void* player, float minX, float minY, float maxX, float maxY); - void playerTurf_release(void* gangZone, void* player); - -#ifdef __cplusplus -} -#endif diff --git a/include/vehicle.h b/include/vehicle.h deleted file mode 100644 index bbdf819..0000000 --- a/include/vehicle.h +++ /dev/null @@ -1,91 +0,0 @@ -#include "omp.h" - -#ifdef __cplusplus -extern "C" { -#endif - - typedef struct { - int8_t engine; - int8_t lights; - int8_t alarm; - int8_t doors; - int8_t bonnet; - int8_t boot; - int8_t objective; - int8_t siren; - int8_t doorDriver; - int8_t doorPassenger; - int8_t doorBackLeft; - int8_t doorBackRight; - int8_t windowDriver; - int8_t windowPassenger; - int8_t windowBackLeft; - int8_t windowBackRight; - } VehicleParams; - - void* vehicle_create(int isStatic, int modelId, float x, float y, float z, float angle, int colour1, int colour2, int respawnDelay, unsigned char addSiren); - void vehicle_release(void* vehicle); - void* vehicle_getByID(int id); - int vehicle_isStreamedInForPlayer(void* vehicle, void* player); - void vehicle_setColour(void* vehicle, int col1, int col2); - VehicleColour vehicle_getColour(void* vehicle); - void vehicle_setHealth(void* vehicle, float health); - float vehicle_getHealth(void* vehicle); - void* vehicle_getDriver(void* vehicle); - Array vehicle_getPassengers(void* vehicle); - void vehicle_setPlate(void* vehicle, String plate); - String vehicle_getPlate(void* vehicle); - void vehicle_setDamageStatus(void* vehicle, int PanelStatus, int DoorStatus, uint8_t LightStatus, uint8_t TyreStatus, void* vehicleUpdater); - void vehicle_getDamageStatus(void* vehicle, int* PanelStatus, int* DoorStatus, int* LightStatus, int* TyreStatus); - void vehicle_setPaintjob(void* vehicle, int paintjob); - int vehicle_getPaintjob(void* vehicle); - void vehicle_addComponent(void* vehicle, int component); - int vehicle_getComponentInSlot(void* vehicle, int slot); - void vehicle_removeComponent(void* vehicle, int component); - void vehicle_putPlayer(void* vehicle, void* player, int seatID); - void vehicle_setZAngle(void* vehicle, float angle); - float vehicle_getZAngle(void* vehicle); - void vehicle_setParams(void* vehicle, VehicleParams* params); - void vehicle_setParamsForPlayer(void* vehicle, void* player, VehicleParams* params); - VehicleParams vehicle_getParams(void* vehicle); - int vehicle_isDead(void* vehicle); - void vehicle_respawn(void* vehicle); - void vehicle_setRespawnDelay(void* vehicle, int delay); - long long vehicle_getRespawnDelay(void* vehicle); - int vehicle_isRespawning(void* vehicle); - void vehicle_setInterior(void* vehicle, int interiorID); - int vehicle_getInterior(void* vehicle); - void vehicle_attachTrailer(void* vehicle, void* trailer); - void vehicle_detachTrailer(void* vehicle); - int vehicle_isTrailer(void* vehicle); - void* vehicle_getTrailer(void* vehicle); - void* vehicle_getCab(void* vehicle); - void vehicle_repair(void* vehicle); - void vehicle_setVelocity(void* vehicle, float x, float y, float z); - Vector3 vehicle_getVelocity(void* vehicle); - void vehicle_setAngularVelocity(void* vehicle, float x, float y, float z); - Vector3 vehicle_getAngularVelocity(void* vehicle); - int vehicle_getModel(void* vehicle); - uint8_t vehicle_getLandingGearState(void* vehicle); - int vehicle_hasBeenOccupied(void* vehicle); - long vehicle_getLastOccupiedTime(void* vehicle); - long vehicle_getLastSpawnTime(void* vehicle); - int vehicle_isOccupied(void* vehicle); - void vehicle_setSiren(void* vehicle, int status); - uint8_t vehicle_getSirenState(void* vehicle); - uint32_t vehicle_getHydraThrustAngle(void* vehicle); - float vehicle_getTrainSpeed(void* vehicle); - int vehicle_getLastDriverPoolID(void* vehicle); - - Vector3 vehicle_getPosition(void* vehicle); - void vehicle_setPosition(void* vehicle, float x, float y, float z); - Vector4 vehicle_getRotation(void* vehicle); - void vehicle_setVirtualWorld(void* vehicle, int vw); - int vehicle_getVirtualWorld(void* vehicle); - - float vehicle_getDistanceFromPoint(void* vehicle, float pX, float pY, float pZ); - int vehicle_isInRangeOfPoint(void* vehicle, float range, float pX, float pY, float pZ); - -#ifdef __cplusplus -} -#endif diff --git a/include/wrappers.h b/include/wrappers.h new file mode 100644 index 0000000..8f56aab --- /dev/null +++ b/include/wrappers.h @@ -0,0 +1,737 @@ +// This code is generated by codegen command. Do not edit. +// +// As we cannot directly call a C function pointer from Go code +// we need to create C wrapper functions around ompcapi pointers +// which will be used by Go code. + +#ifndef WRAPPERS_H +#define WRAPPERS_H + +#include +#include "capi/include/ompcapi.h" + +typedef struct CAPIStringView CAPIStringView; +typedef struct ComponentVersion ComponentVersion; + +extern struct OMPAPI_t ompapi; + +// Actor functions + +void* Actor_Create(int model, float x, float y, float z, float rot, int* id); +bool Actor_Destroy(void* actor); +void* Actor_FromID(int actorid); +int Actor_GetID(void* actor); +bool Actor_IsStreamedInFor(void* actor, void* player); +bool Actor_SetVirtualWorld(void* actor, int vw); +int Actor_GetVirtualWorld(void* actor); +bool Actor_ApplyAnimation(void* actor, const char* name, const char* library, float delta, bool loop, bool lockX, bool lockY, bool freeze, int time); +bool Actor_ClearAnimations(void* actor); +bool Actor_SetPos(void* actor, float x, float y, float z); +bool Actor_GetPos(void* actor, float* x, float* y, float* z); +bool Actor_SetFacingAngle(void* actor, float angle); +float Actor_GetFacingAngle(void* actor); +bool Actor_SetHealth(void* actor, float hp); +float Actor_GetHealth(void* actor); +bool Actor_SetInvulnerable(void* actor, bool toggle); +bool Actor_IsInvulnerable(void* actor); +bool Actor_IsValid(void* actor); +bool Actor_SetSkin(void* actor, int skin); +int Actor_GetSkin(void* actor); +bool Actor_GetAnimation(void* actor, CAPIStringView* library, CAPIStringView* name, float* delta, bool* loop, bool* lockX, bool* lockY, bool* freeze, int* time); +bool Actor_GetSpawnInfo(void* actor, float* x, float* y, float* z, float* angle, int* skin); + + +// Checkpoint functions + +bool Checkpoint_Set(void* player, float x, float y, float z, float radius); +bool Checkpoint_Disable(void* player); +bool Checkpoint_IsPlayerIn(void* player); +bool Checkpoint_IsActive(void* player); +bool Checkpoint_Get(void* player, float* x, float* y, float* z, float* radius); + + +// RaceCheckpoint functions + +bool RaceCheckpoint_Set(void* player, int type, float x, float y, float z, float nextX, float nextY, float nextZ, float radius); +bool RaceCheckpoint_Disable(void* player); +bool RaceCheckpoint_IsPlayerIn(void* player); +bool RaceCheckpoint_IsActive(void* player); +bool RaceCheckpoint_Get(void* player, float* x, float* y, float* z, float* nextX, float* nextY, float* nextZ, float* radius); + + +// Class functions + +void* Class_Add(uint8_t team, int skin, float x, float y, float z, float angle, uint8_t weapon1, uint32_t ammo1, uint8_t weapon2, uint32_t ammo2, uint8_t weapon3, uint32_t ammo3, int* id); +void* Class_FromID(int classid); +int Class_GetID(void* cls); +int Class_Count(); +bool Class_GetData(void* classptr, uint8_t* teamid, int* skin, float* x, float* y, float* z, float* angle, uint8_t* weapon1, uint32_t* weapon1_ammo, uint8_t* weapon2, uint32_t* weapon2_ammo, uint8_t* weapon3, uint32_t* weapon3_ammo); +bool Class_Edit(void* classptr, uint8_t teamid, int skin, float x, float y, float z, float angle, uint8_t weapon1, uint32_t ammo1, uint8_t weapon2, uint32_t ammo2, uint8_t weapon3, uint32_t ammo3); + + +// Player functions + +bool Player_SetSpawnInfo(void* player, uint8_t team, int skin, float x, float y, float z, float angle, uint8_t weapon1, uint32_t ammo1, uint8_t weapon2, uint32_t ammo2, uint8_t weapon3, uint32_t ammo3); +bool Player_GetSpawnInfo(void* player, uint8_t* team, int* skin, float* x, float* y, float* z, float* angle, uint8_t* weapon1, uint32_t* ammo1, uint8_t* weapon2, uint32_t* ammo2, uint8_t* weapon3, uint32_t* ammo3); +int Player_GetNetworkStats(void* player, CAPIStringView* output); +int Player_NetStatsBytesReceived(void* player); +int Player_NetStatsBytesSent(void* player); +int Player_NetStatsConnectionStatus(void* player); +int Player_NetStatsGetConnectedTime(void* player); +bool Player_NetStatsGetIpPort(void* player, CAPIStringView* output); +int Player_NetStatsMessagesReceived(void* player); +int Player_NetStatsMessagesRecvPerSecond(void* player); +int Player_NetStatsMessagesSent(void* player); +float Player_NetStatsPacketLossPercent(void* player); +int Player_GetCustomSkin(void* player); +int Player_GetDialog(void* player); +bool Player_GetDialogData(void* player, int* dialogid, int* style, CAPIStringView* title, CAPIStringView* body, CAPIStringView* button1, CAPIStringView* button2); +void* Player_GetMenu(void* player); +void* Player_GetSurfingPlayerObject(void* player); +void* Player_GetCameraTargetPlayerObject(void* player); +void* Player_FromID(int playerid); +int Player_GetID(void* player); +bool Player_SendClientMessage(void* player, uint32_t color, const char* text); +bool Player_SetCameraPos(void* player, float x, float y, float z); +bool Player_SetDrunkLevel(void* player, int level); +bool Player_SetInterior(void* player, int interior); +bool Player_SetWantedLevel(void* player, int level); +bool Player_SetWeather(void* player, int weather); +int Player_GetWeather(void* player); +bool Player_SetSkin(void* player, int skin); +bool Player_SetShopName(void* player, const char* name); +bool Player_GiveMoney(void* player, int amount); +bool Player_SetCameraLookAt(void* player, float x, float y, float z, int cutType); +bool Player_SetCameraBehind(void* player); +bool Player_CreateExplosion(void* player, float x, float y, float z, int type, float radius); +bool Player_PlayAudioStream(void* player, const char* url, float x, float y, float z, float distance, bool usePos); +bool Player_StopAudioStream(void* player); +bool Player_ToggleWidescreen(void* player, bool enable); +bool Player_IsWidescreenToggled(void* player); +bool Player_SetHealth(void* player, float health); +float Player_GetHealth(void* player); +bool Player_SetArmor(void* player, float armor); +float Player_GetArmor(void* player); +bool Player_SetTeam(void* player, int team); +int Player_GetTeam(void* player); +bool Player_SetScore(void* player, int score); +int Player_GetScore(void* player); +int Player_GetSkin(void* player); +bool Player_SetColor(void* player, uint32_t color); +uint32_t Player_GetColor(void* player); +uint32_t Player_GetDefaultColor(void* player); +int Player_GetDrunkLevel(void* player); +bool Player_GiveWeapon(void* player, int weapon, int ammo); +bool Player_RemoveWeapon(void* player, int weapon); +int Player_GetMoney(void* player); +bool Player_ResetMoney(void* player); +int Player_SetName(void* player, const char* name); +int Player_GetName(void* player, CAPIStringView* name); +int Player_GetState(void* player); +int Player_GetPing(void* player); +int Player_GetWeapon(void* player); +bool Player_SetTime(void* player, int hour, int minute); +bool Player_GetTime(void* player, int* hour, int* minute); +bool Player_ToggleClock(void* player, bool enable); +bool Player_HasClock(void* player); +bool Player_ForceClassSelection(void* player); +int Player_GetWantedLevel(void* player); +bool Player_SetFightingStyle(void* player, int style); +int Player_GetFightingStyle(void* player); +bool Player_SetVelocity(void* player, float x, float y, float z); +bool Player_GetVelocity(void* player, float* x, float* y, float* z); +bool Player_GetCameraPos(void* player, float* x, float* y, float* z); +float Player_GetDistanceFromPoint(void* player, float x, float y, float z); +int Player_GetInterior(void* player); +bool Player_SetPos(void* player, float x, float y, float z); +bool Player_GetPos(void* player, float* x, float* y, float* z); +int Player_GetVirtualWorld(void* player); +bool Player_IsNPC(void* player); +bool Player_IsStreamedIn(void* player, void* other); +bool Player_PlayGameSound(void* player, int sound, float x, float y, float z); +bool Player_SpectatePlayer(void* player, void* target, int mode); +bool Player_SpectateVehicle(void* player, void* target, int mode); +bool Player_SetVirtualWorld(void* player, int vw); +bool Player_SetWorldBounds(void* player, float xMax, float xMin, float yMax, float yMin); +bool Player_ClearWorldBounds(void* player); +bool Player_GetWorldBounds(void* player, float* xmax, float* xmin, float* ymax, float* ymin); +bool Player_ClearAnimations(void* player, int syncType); +bool Player_GetLastShotVectors(void* player, float* origin_x, float* origin_y, float* origin_z, float* hit_x, float* hit_y, float* hit_z); +void* Player_GetCameraTargetPlayer(void* player); +void* Player_GetCameraTargetActor(void* player); +void* Player_GetCameraTargetObject(void* player); +void* Player_GetCameraTargetVehicle(void* player); +bool Player_PutInVehicle(void* player, void* vehicle, int seat); +bool Player_RemoveBuilding(void* player, int model, float x, float y, float z, float radius); +int Player_GetBuildingsRemoved(void* player); +bool Player_RemoveFromVehicle(void* player, bool force); +bool Player_RemoveMapIcon(void* player, int icon); +bool Player_SetMapIcon(void* player, int iconID, float x, float y, float z, int type, uint32_t color, int style); +bool Player_ResetWeapons(void* player); +bool Player_SetAmmo(void* player, uint8_t id, uint32_t ammo); +bool Player_SetArmedWeapon(void* player, uint8_t weapon); +bool Player_SetChatBubble(void* player, const char* text, uint32_t color, float drawdistance, int expiretime); +bool Player_SetPosFindZ(void* player, float x, float y, float z); +bool Player_SetSkillLevel(void* player, uint8_t weapon, int level); +bool Player_SetSpecialAction(void* player, uint32_t action); +bool Player_ShowNameTagForPlayer(void* player, void* other, bool enable); +bool Player_ToggleControllable(void* player, bool enable); +bool Player_ToggleSpectating(void* player, bool enable); +bool Player_ApplyAnimation(void* player, const char* animlib, const char* animname, float delta, bool loop, bool lockX, bool lockY, bool freeze, uint32_t time, int sync); +bool Player_GetAnimationName(int index, CAPIStringView* lib, CAPIStringView* name); +bool Player_EditAttachedObject(void* player, int index); +bool Player_EnableCameraTarget(void* player, bool enable); +bool Player_EnableStuntBonus(void* player, bool enable); +int Player_GetPlayerAmmo(void* player); +int Player_GetAnimationIndex(void* player); +float Player_GetFacingAngle(void* player); +int Player_GetIp(void* player, CAPIStringView* ip); +int Player_GetSpecialAction(void* player); +int Player_GetVehicleID(void* player); +int Player_GetVehicleSeat(void* player); +bool Player_GetWeaponData(void* player, int slot, int* weaponid, int* ammo); +int Player_GetWeaponState(void* player); +bool Player_InterpolateCameraPos(void* player, float from_x, float from_y, float from_z, float to_x, float to_y, float to_z, int time, int cut); +bool Player_InterpolateCameraLookAt(void* player, float from_x, float from_y, float from_z, float to_x, float to_y, float to_z, int time, int cut); +bool Player_IsPlayerAttachedObjectSlotUsed(void* player, int index); +bool Player_AttachCameraToObject(void* player, void* object); +bool Player_AttachCameraToPlayerObject(void* player, void* object); +float Player_GetCameraAspectRatio(void* player); +bool Player_GetCameraFrontVector(void* player, float* x, float* y, float* z); +int Player_GetCameraMode(void* player); +bool Player_GetKeys(void* player, int* keys, int* updown, int* leftright); +void* Player_GetSurfingVehicle(void* player); +void* Player_GetSurfingObject(void* player); +void* Player_GetTargetPlayer(void* player); +void* Player_GetTargetActor(void* player); +bool Player_IsInVehicle(void* player, void* targetVehicle); +bool Player_IsInAnyVehicle(void* player); +bool Player_IsInRangeOfPoint(void* player, float range, float x, float y, float z); +bool Player_PlayCrimeReport(void* player, void* suspect, int crime); +bool Player_RemoveAttachedObject(void* player, int index); +bool Player_SetAttachedObject(void* player, int index, int modelid, int bone, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ, float scaleX, float scaleY, float scaleZ, uint32_t materialcolor1, uint32_t materialcolor2); +bool Player_GetAttachedObject(void* player, int index, int* modelid, int* bone, float* offsetX, float* offsetY, float* offsetZ, float* rotationX, float* rotationY, float* rotationZ, float* scaleX, float* scaleY, float* scaleZ, int* materialcolor1, int* materialcolor2); +bool Player_SetFacingAngle(void* player, float angle); +bool Player_SetMarkerForPlayer(void* player, void* other, uint32_t color); +uint32_t Player_GetMarkerForPlayer(void* player, void* other); +bool Player_AllowTeleport(void* player, bool allow); +bool Player_IsTeleportAllowed(void* player); +bool Player_DisableRemoteVehicleCollisions(void* player, bool disable); +float Player_GetCameraZoom(void* player); +bool Player_SelectTextDraw(void* player, uint32_t hoverColour); +bool Player_CancelSelectTextDraw(void* player); +bool Player_SendClientCheck(void* player, int actionType, int address, int offset, int count); +bool Player_Spawn(void* player); +bool Player_GPCI(void* player, CAPIStringView* gpci); +bool Player_IsAdmin(void* player); +bool Player_Kick(void* player); +bool Player_ShowGameText(void* player, const char* text, int time, int style); +bool Player_HideGameText(void* player, int style); +bool Player_HasGameText(void* player, int style); +bool Player_GetGameText(void* player, int style, CAPIStringView* message, int* time, int* remaining); +bool Player_Ban(void* player); +bool Player_BanEx(void* player, const char* reason); +bool Player_SendDeathMessage(void* player, void* killer, void* killee, int weapon); +bool Player_SendMessageToPlayer(void* player, void* sender, const char* message); +int Player_GetVersion(void* player, CAPIStringView* version); +int Player_GetSkillLevel(void* player, int skill); +float Player_GetZAim(void* player); +bool Player_GetSurfingOffsets(void* player, float* offsetX, float* offsetY, float* offsetZ); +bool Player_GetRotationQuat(void* player, float* x, float* y, float* z, float* w); +int Player_GetPlayerSpectateID(void* player); +int Player_GetSpectateType(void* player); +uint32_t Player_GetRawIp(void* player); +bool Player_SetGravity(void* player, float gravity); +float Player_GetGravity(void* player); +bool Player_SetAdmin(void* player, bool set); +bool Player_IsSpawned(void* player); +bool Player_IsControllable(void* player); +bool Player_IsCameraTargetEnabled(void* player); +bool Player_ToggleGhostMode(void* player, bool toggle); +bool Player_GetGhostMode(void* player); +bool Player_AllowWeapons(void* player, bool allow); +bool Player_AreWeaponsAllowed(void* player); +bool Player_IsPlayerUsingOfficialClient(void* player); +int Player_GetAnimationFlags(void* player); +bool Player_IsInDriveByMode(void* player); +bool Player_IsCuffed(void* player); +bool Player_IsInModShop(void* player); +int Player_GetSirenState(void* player); +int Player_GetLandingGearState(void* player); +uint32_t Player_GetHydraReactorAngle(void* player); +float Player_GetTrainSpeed(void* player); + + +// Component functions + +void* Component_Create(uint64_t uid, const char* name, ComponentVersion version, void* onReadyCB, void* onResetCB, void* onFreeCB); + + +// Config functions + +bool Config_GetAsBool(const char* cvar); +int Config_GetAsInt(const char* cvar); +float Config_GetAsFloat(const char* cvar); +int Config_GetAsString(const char* cvar, CAPIStringView* output); + + +// Core functions + +uint32_t Core_TickCount(); +int Core_MaxPlayers(); +bool Core_Log(const char* text); +bool Core_IsAdminTeleportAllowed(); +bool Core_AllowAdminTeleport(bool allow); +bool Core_AreAllAnimationsEnabled(); +bool Core_EnableAllAnimations(bool allow); +bool Core_IsAnimationLibraryValid(const char* name); +bool Core_AreInteriorWeaponsAllowed(); +bool Core_AllowInteriorWeapons(bool allow); +bool Core_BlockIpAddress(const char* ipAddress, int timeMS); +bool Core_UnBlockIpAddress(const char* ipAddress); +bool Core_DisableEntryExitMarkers(); +bool Core_DisableNameTagsLOS(); +bool Core_EnableZoneNames(bool enable); +bool Core_ShowGameTextForAll(const char* msg, int time, int style); +bool Core_HideGameTextForAll(int style); +int Core_NetworkStats(CAPIStringView* output); +int Core_ServerTickRate(); +bool Core_GetWeaponName(int weaponid, CAPIStringView* output); +bool Core_SetChatRadius(float globalChatRadius); +bool Core_SetMarkerRadius(float playerMarkerRadius); +bool Core_SendRconCommand(const char* command); +bool Core_SetDeathDropAmount(int amount); +bool Core_GameMode_SetText(const char* string); +bool Core_SetGravity(float gravity); +float Core_GetGravity(); +bool Core_SetNameTagsDrawDistance(float distance); +bool Core_SetWeather(int weatherid); +bool Core_SetWorldTime(int hour); +bool Core_ShowNameTags(bool show); +bool Core_ShowPlayerMarkers(int mode); +bool Core_UsePedAnims(); +int Core_GetWeather(); +int Core_GetWorldTime(); +bool Core_ToggleChatTextReplacement(bool enable); +bool Core_IsChatTextReplacementToggled(); +bool Core_IsNickNameValid(const char* name); +bool Core_AllowNickNameCharacter(int character, bool allow); +bool Core_IsNickNameCharacterAllowed(int character); +bool Core_ClearBanList(); +bool Core_IsIpAddressBanned(const char* ip); +int Core_GetWeaponSlot(uint8_t weapon); +bool Core_AddRule(const char* name, const char* value); +bool Core_IsValidRule(const char* name); +bool Core_RemoveRule(const char* name); + + +// NPC functions + +bool NPC_Connect(const char* name, const char* script); + + +// CustomModel functions + +bool CustomModel_AddCharModel(int baseid, int newid, const char* dff, const char* textureLibrary); +bool CustomModel_AddSimpleModel(int virtualWorld, int baseid, int newid, const char* dff, const char* textureLibrary); +bool CustomModel_AddSimpleModelTimed(int virtualWorld, int baseid, int newid, const char* dff, const char* textureLibrary, int timeOn, int timeOff); +bool CustomModel_RedirectDownload(void* player, const char* url); +int CustomModel_FindModelFileNameFromCRC(int crc, CAPIStringView* output); +bool CustomModel_IsValid(int modelId); +bool CustomModel_GetPath(int modelId, CAPIStringView* dffPath, CAPIStringView* txdPath); + + +// Dialog functions + +bool Dialog_Show(void* player, int dialog, int style, const char* title, const char* body, const char* button1, const char* button2); +bool Dialog_Hide(void* player); + + +// Event functions + +bool Event_AddHandler(const char* name, int priority, void* callback); +bool Event_RemoveHandler(const char* name, int priority, void* callback); +bool Event_RemoveAllHandlers(const char* name, int priority); + + +// GangZone functions + +void* GangZone_Create(float minx, float miny, float maxx, float maxy, int* id); +bool GangZone_Destroy(void* gangzone); +void* GangZone_FromID(int gangzoneid); +int GangZone_GetID(void* gangzone); +bool GangZone_ShowForPlayer(void* player, void* gangzone, uint32_t color); +bool GangZone_ShowForAll(void* gangzone, uint32_t color); +bool GangZone_HideForPlayer(void* player, void* gangzone); +bool GangZone_HideForAll(void* gangzone); +bool GangZone_FlashForPlayer(void* player, void* gangzone, uint32_t color); +bool GangZone_FlashForAll(void* gangzone, uint32_t color); +bool GangZone_StopFlashForPlayer(void* player, void* gangzone); +bool GangZone_StopFlashForAll(void* gangzone); +bool GangZone_IsValid(void* gangzone); +bool GangZone_IsPlayerIn(void* player, void* gangzone); +bool GangZone_IsVisibleForPlayer(void* player, void* gangzone); +int GangZone_GetColorForPlayer(void* player, void* gangzone); +int GangZone_GetFlashColorForPlayer(void* player, void* gangzone); +bool GangZone_IsFlashingForPlayer(void* player, void* gangzone); +bool GangZone_GetPos(void* gangzone, float* minx, float* miny, float* maxx, float* maxy); +bool GangZone_UseCheck(void* gangzone, bool enable); + + +// Menu functions + +void* Menu_Create(const char* title, uint32_t columns, float x, float y, float column1Width, float column2Width, int* id); +bool Menu_Destroy(void* menu); +void* Menu_FromID(int menuid); +int Menu_GetID(void* menu); +int Menu_AddItem(void* menu, uint8_t column, const char* text); +bool Menu_SetColumnHeader(void* menu, uint8_t column, const char* headerTitle); +bool Menu_ShowForPlayer(void* menu, void* player); +bool Menu_HideForPlayer(void* menu, void* player); +bool Menu_Disable(void* menu); +bool Menu_DisableRow(void* menu, uint8_t row); +bool Menu_IsValid(void* menu); +bool Menu_IsDisabled(void* menu); +bool Menu_IsRowDisabled(void* menu, int row); +int Menu_GetColumns(void* menu); +int Menu_GetItems(void* menu, int column); +bool Menu_GetPos(void* menu, float* x, float* y); +bool Menu_GetColumnWidth(void* menu, float* column1Width, float* column2Width); +bool Menu_GetColumnHeader(void* menu, int column, CAPIStringView* header); +bool Menu_GetItem(void* menu, int column, int row, CAPIStringView* item); + + +// Object functions + +void* Object_Create(int modelid, float x, float y, float z, float rotationX, float rotationY, float rotationZ, float drawDistance, int* id); +bool Object_Destroy(void* object); +void* Object_FromID(int objectid); +int Object_GetID(void* object); +bool Object_AttachToVehicle(void* object, void* vehicle, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ); +bool Object_AttachToObject(void* object, void* objAttachedTo, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ, bool syncRotation); +bool Object_AttachToPlayer(void* object, void* player, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ); +bool Object_SetPos(void* object, float x, float y, float z); +bool Object_GetPos(void* object, float* x, float* y, float* z); +bool Object_SetRot(void* object, float rotationX, float rotationY, float rotationZ); +bool Object_GetRot(void* object, float* rotationX, float* rotationY, float* rotationZ); +int Object_GetModel(void* object); +bool Object_SetNoCameraCollision(void* object); +bool Object_IsValid(void* object); +int Object_Move(void* object, float x, float y, float z, float speed, float rotationX, float rotationY, float rotationZ); +bool Object_Stop(void* object); +bool Object_IsMoving(void* object); +bool Object_BeginEditing(void* player, void* object); +bool Object_BeginSelecting(void* player); +bool Object_EndEditing(void* player); +bool Object_SetMaterial(void* object, int materialIndex, int modelId, const char* textureLibrary, const char* textureName, uint32_t materialColor); +bool Object_SetMaterialText(void* object, const char* text, int materialIndex, int materialSize, const char* fontface, int fontsize, bool bold, uint32_t fontColor, uint32_t backgroundColor, int textalignment); +bool Object_SetDefaultCameraCollision(bool disable); +float Object_GetDrawDistance(void* object); +float Object_GetMoveSpeed(void* object); +bool Object_GetMovingTargetPos(void* object, float* targetX, float* targetY, float* targetZ); +bool Object_GetMovingTargetRot(void* object, float* rotationX, float* rotationY, float* rotationZ); +bool Object_GetAttachedData(void* object, int* parentVehicle, int* parentObject, int* parentPlayer); +bool Object_GetAttachedOffset(void* object, float* offsetX, float* offsetY, float* offsetZ, float* rotationX, float* rotationY, float* rotationZ); +bool Object_GetSyncRotation(void* object); +bool Object_IsMaterialSlotUsed(void* object, int materialIndex); +bool Object_GetMaterial(void* object, int materialIndex, int* modelid, CAPIStringView* textureLibrary, CAPIStringView* textureName, int* materialColor); +bool Object_GetMaterialText(void* object, int materialIndex, CAPIStringView* text, int* materialSize, CAPIStringView* fontFace, int* fontSize, bool* bold, int* fontColor, int* backgroundColor, int* textAlignment); +bool Object_IsObjectNoCameraCollision(void* object); +uint8_t Object_GetType(void* player, int objectid); + + +// PlayerObject functions + +void* PlayerObject_Create(void* player, int modelid, float x, float y, float z, float rotationX, float rotationY, float rotationZ, float drawDistance, int* id); +bool PlayerObject_Destroy(void* player, void* object); +void* PlayerObject_FromID(void* player, int objectid); +int PlayerObject_GetID(void* player, void* object); +bool PlayerObject_AttachToVehicle(void* player, void* object, void* vehicle, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ); +bool PlayerObject_AttachToPlayer(void* player, void* object, void* playerAttachedTo, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ); +bool PlayerObject_AttachToObject(void* player, void* object, void* attachedTo, float offsetX, float offsetY, float offsetZ, float rotationX, float rotationY, float rotationZ); +bool PlayerObject_SetPos(void* player, void* object, float x, float y, float z); +bool PlayerObject_GetPos(void* player, void* object, float* x, float* y, float* z); +bool PlayerObject_SetRot(void* player, void* object, float rotationX, float rotationY, float rotationZ); +bool PlayerObject_GetRot(void* player, void* object, float* rotationX, float* rotationY, float* rotationZ); +int PlayerObject_GetModel(void* player, void* object); +bool PlayerObject_SetNoCameraCollision(void* player, void* object); +bool PlayerObject_IsValid(void* player, void* object); +int PlayerObject_Move(void* player, void* object, float x, float y, float z, float speed, float rotationX, float rotationY, float rotationZ); +bool PlayerObject_Stop(void* player, void* object); +bool PlayerObject_IsMoving(void* player, void* object); +bool PlayerObject_BeginEditing(void* player, void* object); +bool PlayerObject_SetMaterial(void* player, void* object, int materialIndex, int modelId, const char* textureLibrary, const char* textureName, uint32_t materialColor); +bool PlayerObject_SetMaterialText(void* player, void* object, const char* text, int materialIndex, int materialSize, const char* fontface, int fontsize, bool bold, uint32_t fontColor, uint32_t backgroundColor, int textalignment); +float PlayerObject_GetDrawDistance(void* player, void* object); +float PlayerObject_GetMoveSpeed(void* player, void* object); +bool PlayerObject_GetMovingTargetPos(void* player, void* object, float* targetX, float* targetY, float* targetZ); +bool PlayerObject_GetMovingTargetRot(void* player, void* object, float* rotationX, float* rotationY, float* rotationZ); +bool PlayerObject_GetAttachedData(void* player, void* object, int* parentVehicle, int* parentObject, int* parentPlayer); +bool PlayerObject_GetAttachedOffset(void* player, void* object, float* offsetX, float* offsetY, float* offsetZ, float* rotationX, float* rotationY, float* rotationZ); +bool PlayerObject_GetSyncRotation(void* player, void* object); +bool PlayerObject_IsMaterialSlotUsed(void* player, void* object, int materialIndex); +bool PlayerObject_GetMaterial(void* player, void* object, int materialIndex, int* modelid, CAPIStringView* textureLibrary, CAPIStringView* textureName, int* materialColor); +bool PlayerObject_GetMaterialText(void* player, void* object, int materialIndex, CAPIStringView* text, int* materialSize, CAPIStringView* fontFace, int* fontSize, bool* bold, int* fontColor, int* backgroundColor, int* textAlignment); +bool PlayerObject_IsNoCameraCollision(void* player, void* object); + + +// Pickup functions + +void* Pickup_Create(int model, int type, float x, float y, float z, int virtualWorld, int* id); +bool Pickup_AddStatic(int model, int type, float x, float y, float z, int virtualWorld); +bool Pickup_Destroy(void* pickup); +void* Pickup_FromID(int pickupid); +int Pickup_GetID(void* pickup); +bool Pickup_IsValid(void* pickup); +bool Pickup_IsStreamedIn(void* player, void* pickup); +bool Pickup_GetPos(void* pickup, float* x, float* y, float* z); +int Pickup_GetModel(void* pickup); +int Pickup_GetType(void* pickup); +int Pickup_GetVirtualWorld(void* pickup); +bool Pickup_SetPos(void* pickup, float x, float y, float z, bool update); +bool Pickup_SetModel(void* pickup, int model, bool update); +bool Pickup_SetType(void* pickup, int type, bool update); +bool Pickup_SetVirtualWorld(void* pickup, int virtualworld); +bool Pickup_ShowForPlayer(void* player, void* pickup); +bool Pickup_HideForPlayer(void* player, void* pickup); +bool Pickup_IsHiddenForPlayer(void* player, void* pickup); + + +// All functions + +bool All_SendClientMessage(uint32_t color, const char* text); +bool All_CreateExplosion(float x, float y, float z, int type, float radius); +bool All_SendDeathMessage(void* killer, void* killee, int weapon); +bool All_EnableStuntBonus(bool enable); + + +// Recording functions + +bool Recording_Start(void* player, int type, const char* file); +bool Recording_Stop(void* player); + + +// TextDraw functions + +void* TextDraw_Create(float x, float y, const char* text, int* id); +bool TextDraw_Destroy(void* textdraw); +void* TextDraw_FromID(int textdrawid); +int TextDraw_GetID(void* textdraw); +bool TextDraw_IsValid(void* textdraw); +bool TextDraw_IsVisibleForPlayer(void* player, void* textdraw); +bool TextDraw_SetLetterSize(void* textdraw, float sizeX, float sizeY); +bool TextDraw_SetTextSize(void* textdraw, float sizeX, float sizeY); +bool TextDraw_SetAlignment(void* textdraw, int alignment); +bool TextDraw_SetColor(void* textdraw, uint32_t color); +bool TextDraw_SetUseBox(void* textdraw, bool use); +bool TextDraw_SetBoxColor(void* textdraw, uint32_t color); +bool TextDraw_SetShadow(void* textdraw, int size); +bool TextDraw_SetOutline(void* textdraw, int size); +bool TextDraw_SetBackgroundColor(void* textdraw, uint32_t color); +bool TextDraw_SetFont(void* textdraw, int font); +bool TextDraw_SetSetProportional(void* textdraw, bool set); +bool TextDraw_SetSelectable(void* textdraw, bool set); +bool TextDraw_ShowForPlayer(void* player, void* textdraw); +bool TextDraw_HideForPlayer(void* player, void* textdraw); +bool TextDraw_ShowForAll(void* textdraw); +bool TextDraw_HideForAll(void* textdraw); +bool TextDraw_SetString(void* textdraw, const char* text); +bool TextDraw_SetPreviewModel(void* textdraw, int model); +bool TextDraw_SetPreviewRot(void* textdraw, float rotationX, float rotationY, float rotationZ, float zoom); +bool TextDraw_SetPreviewVehCol(void* textdraw, int color1, int color2); +bool TextDraw_SetPos(void* textdraw, float x, float y); +bool TextDraw_GetString(void* textdraw, CAPIStringView* text); +bool TextDraw_GetLetterSize(void* textdraw, float* sizeX, float* sizeY); +bool TextDraw_GetTextSize(void* textdraw, float* sizeX, float* sizeY); +bool TextDraw_GetPos(void* textdraw, float* x, float* y); +int TextDraw_GetColor(void* textdraw); +int TextDraw_GetBoxColor(void* textdraw); +int TextDraw_GetBackgroundColor(void* textdraw); +int TextDraw_GetShadow(void* textdraw); +int TextDraw_GetOutline(void* textdraw); +int TextDraw_GetFont(void* textdraw); +bool TextDraw_IsBox(void* textdraw); +bool TextDraw_IsProportional(void* textdraw); +bool TextDraw_IsSelectable(void* textdraw); +int TextDraw_GetAlignment(void* textdraw); +int TextDraw_GetPreviewModel(void* textdraw); +bool TextDraw_GetPreviewRot(void* textdraw, float* x, float* y, float* z, float* zoom); +bool TextDraw_GetPreviewVehColor(void* textdraw, int* color1, int* color2); +bool TextDraw_SetStringForPlayer(void* textdraw, void* player, const char* text); + + +// PlayerTextDraw functions + +void* PlayerTextDraw_Create(void* player, float x, float y, const char* text, int* id); +bool PlayerTextDraw_Destroy(void* player, void* textdraw); +void* PlayerTextDraw_FromID(void* player, int textdrawid); +int PlayerTextDraw_GetID(void* player, void* textdraw); +bool PlayerTextDraw_IsValid(void* player, void* textdraw); +bool PlayerTextDraw_IsVisible(void* player, void* textdraw); +bool PlayerTextDraw_SetLetterSize(void* player, void* textdraw, float x, float y); +bool PlayerTextDraw_SetTextSize(void* player, void* textdraw, float x, float y); +bool PlayerTextDraw_SetAlignment(void* player, void* textdraw, int alignment); +bool PlayerTextDraw_SetColor(void* player, void* textdraw, uint32_t color); +bool PlayerTextDraw_UseBox(void* player, void* textdraw, bool use); +bool PlayerTextDraw_SetBoxColor(void* player, void* textdraw, uint32_t color); +bool PlayerTextDraw_SetShadow(void* player, void* textdraw, int size); +bool PlayerTextDraw_SetOutline(void* player, void* textdraw, int size); +bool PlayerTextDraw_SetBackgroundColor(void* player, void* textdraw, uint32_t color); +bool PlayerTextDraw_SetFont(void* player, void* textdraw, int font); +bool PlayerTextDraw_SetProportional(void* player, void* textdraw, bool set); +bool PlayerTextDraw_SetSelectable(void* player, void* textdraw, bool set); +bool PlayerTextDraw_Show(void* player, void* textdraw); +bool PlayerTextDraw_Hide(void* player, void* textdraw); +bool PlayerTextDraw_SetString(void* player, void* textdraw, const char* text); +bool PlayerTextDraw_SetPreviewModel(void* player, void* textdraw, int model); +bool PlayerTextDraw_SetPreviewRot(void* player, void* textdraw, float rx, float ry, float rz, float zoom); +bool PlayerTextDraw_SetPreviewVehCol(void* player, void* textdraw, int color1, int color2); +bool PlayerTextDraw_SetPos(void* player, void* textdraw, float x, float y); +bool PlayerTextDraw_GetString(void* player, void* textdraw, CAPIStringView* text); +bool PlayerTextDraw_GetLetterSize(void* player, void* textdraw, float* x, float* y); +bool PlayerTextDraw_GetTextSize(void* player, void* textdraw, float* x, float* y); +bool PlayerTextDraw_GetPos(void* player, void* textdraw, float* x, float* y); +int PlayerTextDraw_GetColor(void* player, void* textdraw); +int PlayerTextDraw_GetBoxColor(void* player, void* textdraw); +int PlayerTextDraw_GetBackgroundColor(void* player, void* textdraw); +int PlayerTextDraw_GetShadow(void* player, void* textdraw); +int PlayerTextDraw_GetOutline(void* player, void* textdraw); +int PlayerTextDraw_GetFont(void* player, void* textdraw); +bool PlayerTextDraw_IsBox(void* player, void* textdraw); +bool PlayerTextDraw_IsProportional(void* player, void* textdraw); +bool PlayerTextDraw_IsSelectable(void* player, void* textdraw); +int PlayerTextDraw_GetAlignment(void* player, void* textdraw); +int PlayerTextDraw_GetPreviewModel(void* player, void* textdraw); +bool PlayerTextDraw_GetPreviewRot(void* player, void* textdraw, float* rx, float* ry, float* rz, float* zoom); +bool PlayerTextDraw_GetPreviewVehColor(void* player, void* textdraw, int* color1, int* color2); + + +// TextLabel functions + +void* TextLabel_Create(const char* text, uint32_t color, float x, float y, float z, float drawDistance, int virtualWorld, bool los, int* id); +bool TextLabel_Destroy(void* textlabel); +void* TextLabel_FromID(int textlabelid); +int TextLabel_GetID(void* textlabel); +bool TextLabel_AttachToPlayer(void* textlabel, void* player, float offsetX, float offsetY, float offsetZ); +bool TextLabel_AttachToVehicle(void* textlabel, void* vehicle, float offsetX, float offsetY, float offsetZ); +bool TextLabel_UpdateText(void* textlabel, uint32_t color, const char* text); +bool TextLabel_IsValid(void* textlabel); +bool TextLabel_IsStreamedIn(void* player, void* textlabel); +bool TextLabel_GetText(void* textlabel, CAPIStringView* output); +uint32_t TextLabel_GetColor(void* textlabel); +bool TextLabel_GetPos(void* textlabel, float* x, float* y, float* z); +bool TextLabel_SetDrawDistance(void* textlabel, float distance); +float TextLabel_GetDrawDistance(void* textlabel); +bool TextLabel_GetLOS(void* textlabel); +bool TextLabel_SetLOS(void* textlabel, bool status); +int TextLabel_GetVirtualWorld(void* textlabel); +bool TextLabel_SetVirtualWorld(void* textlabel, int world); +bool TextLabel_GetAttachedData(void* textlabel, int* attached_player, int* attached_vehicle); + + +// PlayerTextLabel functions + +void* PlayerTextLabel_Create(void* player, const char* text, uint32_t color, float x, float y, float z, float drawDistance, void* attachedPlayer, void* attachedVehicle, bool los, int* id); +bool PlayerTextLabel_Destroy(void* player, void* textlabel); +void* PlayerTextLabel_FromID(void* player, int textlabelid); +int PlayerTextLabel_GetID(void* player, void* textlabel); +bool PlayerTextLabel_UpdateText(void* player, void* textlabel, uint32_t color, const char* text); +bool PlayerTextLabel_IsValid(void* player, void* textlabel, bool* valid); +bool PlayerTextLabel_GetText(void* player, void* textlabel, CAPIStringView* output); +bool PlayerTextLabel_GetColor(void* player, void* textlabel, uint32_t* color); +bool PlayerTextLabel_GetPos(void* player, void* textlabel, float* x, float* y, float* z); +bool PlayerTextLabel_SetDrawDistance(void* player, void* textlabel, float distance); +float PlayerTextLabel_GetDrawDistance(void* player, void* textlabel); +bool PlayerTextLabel_GetLOS(void* player, void* textlabel); +bool PlayerTextLabel_SetLOS(void* player, void* textlabel, bool status); +int PlayerTextLabel_GetVirtualWorld(void* player); +bool PlayerTextLabel_GetAttachedData(void* player, void* textlabel, int* attached_player, int* attached_vehicle); + + +// Vehicle functions + +void* Vehicle_Create(int modelid, float x, float y, float z, float rotation, int color1, int color2, int respawnDelay, bool addSiren, int* id); +bool Vehicle_Destroy(void* vehicle); +void* Vehicle_FromID(int vehicleid); +int Vehicle_GetID(void* vehicle); +int Vehicle_GetMaxPassengerSeats(int modelid); +bool Vehicle_IsStreamedIn(void* vehicle, void* player); +bool Vehicle_GetPos(void* vehicle, float* x, float* y, float* z); +bool Vehicle_SetPos(void* vehicle, float x, float y, float z); +float Vehicle_GetZAngle(void* vehicle); +bool Vehicle_GetRotationQuat(void* vehicle, float* w, float* x, float* y, float* z); +float Vehicle_GetDistanceFromPoint(void* vehicle, float x, float y, float z); +bool Vehicle_SetZAngle(void* vehicle, float angle); +bool Vehicle_SetParamsForPlayer(void* vehicle, void* player, int objective, int doors); +bool Vehicle_UseManualEngineAndLights(); +bool Vehicle_SetParamsEx(void* vehicle, int engine, int lights, int alarm, int doors, int bonnet, int boot, int objective); +bool Vehicle_GetParamsEx(void* vehicle, int* engine, int* lights, int* alarm, int* doors, int* bonnet, int* boot, int* objective); +int Vehicle_GetParamsSirenState(void* vehicle); +bool Vehicle_SetParamsCarDoors(void* vehicle, int frontLeft, int frontRight, int rearLeft, int rearRight); +bool Vehicle_GetParamsCarDoors(void* vehicle, int* frontLeft, int* frontRight, int* rearLeft, int* rearRight); +bool Vehicle_SetParamsCarWindows(void* vehicle, int frontLeft, int frontRight, int rearLeft, int rearRight); +bool Vehicle_GetParamsCarWindows(void* vehicle, int* frontLeft, int* frontRight, int* rearLeft, int* rearRight); +bool Vehicle_SetToRespawn(void* vehicle); +bool Vehicle_LinkToInterior(void* vehicle, int interiorid); +bool Vehicle_AddComponent(void* vehicle, int componentid); +bool Vehicle_RemoveComponent(void* vehicle, int componentid); +bool Vehicle_ChangeColor(void* vehicle, int color1, int color2); +bool Vehicle_ChangePaintjob(void* vehicle, int paintjobid); +bool Vehicle_SetHealth(void* vehicle, float health); +float Vehicle_GetHealth(void* vehicle); +bool Vehicle_AttachTrailer(void* trailer, void* vehicle); +bool Vehicle_DetachTrailer(void* vehicle); +bool Vehicle_IsTrailerAttached(void* vehicle); +void* Vehicle_GetTrailer(void* vehicle); +bool Vehicle_SetNumberPlate(void* vehicle, const char* numberPlate); +int Vehicle_GetModel(void* vehicle); +int Vehicle_GetComponentInSlot(void* vehicle, int slot); +int Vehicle_GetComponentType(int componentid); +bool Vehicle_CanHaveComponent(int modelid, int componentid); +bool Vehicle_GetRandomColorPair(int modelid, int* color1, int* color2, int* color3, int* color4); +int Vehicle_ColorIndexToColor(int colorIndex, int alpha); +bool Vehicle_Repair(void* vehicle); +bool Vehicle_GetVelocity(void* vehicle, float* x, float* y, float* z); +bool Vehicle_SetVelocity(void* vehicle, float x, float y, float z); +bool Vehicle_SetAngularVelocity(void* vehicle, float x, float y, float z); +bool Vehicle_GetDamageStatus(void* vehicle, int* panels, int* doors, int* lights, int* tires); +bool Vehicle_UpdateDamageStatus(void* vehicle, int panels, int doors, int lights, int tires); +bool Vehicle_GetModelInfo(int vehiclemodel, int infotype, float* x, float* y, float* z); +bool Vehicle_SetVirtualWorld(void* vehicle, int virtualWorld); +int Vehicle_GetVirtualWorld(void* vehicle); +int Vehicle_GetLandingGearState(void* vehicle); +bool Vehicle_IsValid(void* vehicle); +void* Vehicle_AddStatic(int modelid, float x, float y, float z, float angle, int color1, int color2, int* id); +void* Vehicle_AddStaticEx(int modelid, float x, float y, float z, float angle, int color1, int color2, int respawnDelay, bool addSiren, int* id); +bool Vehicle_EnableFriendlyFire(); +bool Vehicle_GetSpawnInfo(void* vehicle, float* x, float* y, float* z, float* rotation, int* color1, int* color2); +bool Vehicle_SetSpawnInfo(void* vehicle, int modelid, float x, float y, float z, float rotation, int color1, int color2, int respawn_time, int interior); +int Vehicle_GetModelCount(int modelid); +int Vehicle_GetModelsUsed(); +int Vehicle_GetPaintjob(void* vehicle); +bool Vehicle_GetColor(void* vehicle, int* color1, int* color2); +int Vehicle_GetInterior(void* vehicle); +bool Vehicle_GetNumberPlate(void* vehicle, CAPIStringView* numberPlate); +bool Vehicle_SetRespawnDelay(void* vehicle, int respawn_delay); +int Vehicle_GetRespawnDelay(void* vehicle); +void* Vehicle_GetCab(void* vehicle); +void* Vehicle_GetTower(void* vehicle); +int Vehicle_GetOccupiedTick(void* vehicle); +int Vehicle_GetRespawnTick(void* vehicle); +bool Vehicle_HasBeenOccupied(void* vehicle); +bool Vehicle_IsOccupied(void* vehicle); +bool Vehicle_IsDead(void* vehicle); +bool Vehicle_SetParamsSirenState(void* vehicle, bool siren_state); +bool Vehicle_ToggleSirenEnabled(void* vehicle, bool status); +bool Vehicle_IsSirenEnabled(void* vehicle); +void* Vehicle_GetLastDriver(void* vehicle); +void* Vehicle_GetDriver(void* vehicle); +int Vehicle_GetSirenState(void* vehicle); +uint32_t Vehicle_GetHydraReactorAngle(void* vehicle); +float Vehicle_GetTrainSpeed(void* vehicle); +bool Vehicle_GetMatrix(void* vehicle, float* rightX, float* rightY, float* rightZ, float* upX, float* upY, float* upZ, float* atX, float* atY, float* atZ); +void* Vehicle_GetOccupant(void* vehicle, int seat); +int Vehicle_CountOccupants(void* vehicle); + + +#endif // WRAPPERS_H diff --git a/menu.cpp b/menu.cpp deleted file mode 100644 index 2b03ce2..0000000 --- a/menu.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "include/menu.h" - -extern "C" { - void* menu_create(String title, float posX, float posY, uint8_t columns, float col1Width, float col2Width) { - return call("menu_create", title, posX, posY, columns, col1Width, col2Width); - } - - void menu_release(void* menu) { - return call("menu_release", menu); - } - - void menu_setColumnHeader(void* menu, String header, uint8_t column) { - return call("menu_setColumnHeader", menu, header, column); - } - - void menu_addCell(void* menu, String itemText, uint8_t column) { - return call("menu_addCell", menu, itemText, column); - } - - void menu_disableRow(void* menu, uint8_t row) { - return call("menu_disableRow", menu, row); - } - - unsigned char menu_isRowEnabled(void* menu, uint8_t row) { - return call("menu_isRowEnabled", menu, row); - } - - void menu_disable(void* menu) { - return call("menu_disable", menu); - } - - unsigned char menu_isEnabled(void* menu) { - return call("menu_isEnabled", menu); - } - - Vector2 menu_getPosition(void* menu) { - return call("menu_getPosition", menu); - } - - int menu_getRowCount(void* menu, uint8_t column) { - return call("menu_getRowCount", menu, column); - } - - int menu_getColumnCount(void* menu) { - return call("menu_getColumnCount", menu); - } - - Vector2 menu_getColumnWidths(void* menu) { - return call("menu_getColumnWidths", menu); - } - - String menu_getColumnHeader(void* menu, uint8_t column) { - return call("menu_getColumnHeader", menu, column); - } - - String menu_getCell(void* menu, uint8_t column, uint8_t row) { - return call("menu_getCell", menu, column, row); - } - - void menu_showForPlayer(void* menu, void* player) { - return call("menu_showForPlayer", menu, player); - } - - void menu_hideForPlayer(void* menu, void* player) { - return call("menu_hideForPlayer", menu, player); - } -} diff --git a/model.cpp b/model.cpp deleted file mode 100644 index 727d39b..0000000 --- a/model.cpp +++ /dev/null @@ -1,19 +0,0 @@ -#include "include/model.h" - -extern "C" { - unsigned char model_add(uint8_t type, int32_t id, int32_t baseId, String dffName, String txdName, int32_t virtualWorld, uint8_t timeOn, uint8_t timeOff) { - return call("customModel_add", type, id, baseId, dffName, txdName, virtualWorld, timeOn, timeOff); - } - - String model_getNameFromCheckSum(uint32_t checksum) { - return call("customModel_getNameFromCheckSum", checksum); - } - - unsigned char model_isValid(int32_t modelId) { - return call("customModel_isValid", modelId); - } - - unsigned char model_getPath(int32_t modelId, String* dffPath, String* txdPath) { - return call("customModel_getPath", modelId, dffPath, txdPath); - } -} diff --git a/object.cpp b/object.cpp deleted file mode 100644 index 7b141fb..0000000 --- a/object.cpp +++ /dev/null @@ -1,223 +0,0 @@ -#include "include/object.h" - -extern "C" { - void* object_create(int modelId, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float drawDistance) { - return call("object_create", modelId, posX, posY, posZ, rotX, rotY, rotZ, drawDistance); - } - - void object_release(void* object) { - return call("object_release", object); - } - - void* object_getByID(int id) { - return call("object_getByID", id); - } - - void object_setDefaultCameraCollision(unsigned char set) { - return call("object_setDefaultCameraCollision", set); - } - - void object_setDrawDistance(void* object, float drawDistance) { - return call("object_setDrawDistance", object, drawDistance); - } - - float object_getDrawDistance(void* object) { - return call("object_getDrawDistance", object); - } - - void object_setModel(void* object, int model) { - return call("object_setModel", object, model); - } - - int object_getModel(void* object) { - return call("object_getModel", object); - } - - void object_setCameraCollision(void* object, unsigned char set) { - return call("object_setCameraCollision", object, set); - } - - unsigned char object_getCameraCollision(void* object) { - return call("object_getCameraCollision", object); - } - - int object_move(void* object, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float speed) { - return call("object_move", object, posX, posY, posZ, rotX, rotY, rotZ, speed); - } - - unsigned char object_isMoving(void* object) { - return call("object_isMoving", object); - } - - void object_stop(void* object) { - return call("object_stop", object); - } - - ObjectMoveData object_getMovingData(void* object) { - return call("object_getMovingData", object); - } - - void object_attachToVehicle(void* object, void* vehicle, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ) { - return call("object_attachToVehicle", object, vehicle, offsetX, offsetY, offsetZ, rotX, rotY, rotZ); - } - - void object_resetAttachment(void* object) { - return call("object_resetAttachment", object); - } - - ObjectAttachmentData object_getAttachmentData(void* object) { - return call("object_getAttachmentData", object); - } - - unsigned char object_isMaterialSlotUsed(void* object, uint32_t materialIndex) { - return call("object_isMaterialSlotUsed", object, materialIndex); - } - - unsigned char object_getMaterial(void* object, uint32_t materialIndex, const ObjectMaterial* out) { - return call("object_getMaterial", object, materialIndex, out); - } - - unsigned char object_getMaterialText(void* object, uint32_t materialIndex, const ObjectMaterialText* out) { - return call("object_getMaterialText", object, materialIndex, out); - } - - void object_setMaterial(void* object, uint32_t materialIndex, int model, String textureLibrary, String textureName, uint32_t colour) { - return call("object_setMaterial", object, materialIndex, model, textureLibrary, textureName, colour); - } - - void object_setMaterialText(void* object, uint32_t materialIndex, String text, ObjectMaterialSize materialSize, String fontFace, int fontSize, unsigned char bold, uint32_t fontColour, uint32_t backgroundColour, ObjectMaterialTextAlign align) { - return call("object_setMaterialText", object, materialIndex, text, materialSize, fontFace, fontSize, bold, fontColour, backgroundColour, align); - } - - void object_attachToPlayer(void* object, void* player, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ) { - return call("object_attachToPlayer", object, player, offsetX, offsetY, offsetZ, rotX, rotY, rotZ); - } - - void object_attachToObject(void* object, void* other, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ, unsigned char syncRotation) { - return call("object_attachToObject", object, other, offsetX, offsetY, offsetZ, rotX, rotY, rotZ, syncRotation); - } - - void object_setPosition(void* object, float posX, float posY, float posZ) { - return call("object_setPosition", object, posX, posY, posZ); - } - - Vector3 object_getPosition(void* object) { - return call("object_getPosition", object); - } - - void object_setRotation(void* object, float rotX, float rotY, float rotZ) { - return call("object_setRotation", object, rotX, rotY, rotZ); - } - - Vector3 object_getRotation(void* object) { - return call("object_getRotation", object); - } - - void* playerObject_create(void* player, int modelId, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float drawDistance) { - return call("playerObject_create", player, modelId, posX, posY, posZ, rotX, rotY, rotZ, drawDistance); - } - - void playerObject_release(void* object, void* player) { - return call("playerObject_release", object, player); - } - - void* playerObject_getByID(void* player, int id) { - return call("playerObject_getByID", player, id); - } - - void playerObject_setDrawDistance(void* object, float drawDistance) { - return call("playerObject_setDrawDistance", object, drawDistance); - } - - float playerObject_getDrawDistance(void* object) { - return call("playerObject_getDrawDistance", object); - } - - void playerObject_setModel(void* object, int model) { - return call("playerObject_setModel", object, model); - } - - int playerObject_getModel(void* object) { - return call("playerObject_getModel", object); - } - - void playerObject_setCameraCollision(void* object, unsigned char set) { - return call("playerObject_setCameraCollision", object, set); - } - - unsigned char playerObject_getCameraCollision(void* object) { - return call("playerObject_getCameraCollision", object); - } - - int playerObject_move(void* object, float posX, float posY, float posZ, float rotX, float rotY, float rotZ, float speed) { - return call("playerObject_move", object, posX, posY, posZ, rotX, rotY, rotZ, speed); - } - - unsigned char playerObject_isMoving(void* object) { - return call("playerObject_isMoving", object); - } - - void playerObject_stop(void* object) { - return call("playerObject_stop", object); - } - - ObjectMoveData playerObject_getMovingData(void* object) { - return call("playerObject_getMovingData", object); - } - - void playerObject_attachToVehicle(void* object, void* vehicle, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ) { - return call("playerObject_attachToVehicle", object, vehicle, offsetX, offsetY, offsetZ, rotX, rotY, rotZ); - } - - void playerObject_resetAttachment(void* object) { - return call("playerObject_resetAttachment", object); - } - - ObjectAttachmentData playerObject_getAttachmentData(void* object) { - return call("playerObject_getAttachmentData", object); - } - - unsigned char playerObject_isMaterialSlotUsed(void* object, uint32_t materialIndex) { - return call("playerObject_isMaterialSlotUsed", object, materialIndex); - } - - unsigned char playerObject_getMaterial(void* object, uint32_t materialIndex, ObjectMaterial* out) { - return call("playerObject_getMaterial", object, materialIndex, out); - } - - unsigned char playerObject_getMaterialText(void* object, uint32_t materialIndex, ObjectMaterialText* out) { - return call("playerObject_getMaterialText", object, materialIndex, out); - } - - void playerObject_setMaterial(void* object, uint32_t materialIndex, int model, String textureLibrary, String textureName, uint32_t colour) { - return call("playerObject_setMaterial", object, materialIndex, model, textureLibrary, textureName, colour); - } - - void playerObject_setMaterialText(void* object, uint32_t materialIndex, String text, ObjectMaterialSize materialSize, String fontFace, int fontSize, unsigned char bold, uint32_t fontColour, uint32_t backgroundColour, ObjectMaterialTextAlign align) { - return call("playerObject_setMaterialText", object, materialIndex, text, materialSize, fontFace, fontSize, bold, fontColour, backgroundColour, align); - } - - void playerObject_attachToPlayer(void* object, void* player, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ) { - return call("playerObject_attachToPlayer", object, player, offsetX, offsetY, offsetZ, rotX, rotY, rotZ); - } - - void playerObject_attachToObject(void* object, void* other, float offsetX, float offsetY, float offsetZ, float rotX, float rotY, float rotZ) { - return call("playerObject_attachToObject", object, other, offsetX, offsetY, offsetZ, rotX, rotY, rotZ); - } - - void playerObject_setPosition(void* object, float posX, float posY, float posZ) { - return call("playerObject_setPosition", object, posX, posY, posZ); - } - - Vector3 playerObject_getPosition(void* object) { - return call("playerObject_getPosition", object); - } - - void playerObject_setRotation(void* object, float rotX, float rotY, float rotZ) { - return call("playerObject_setRotation", object, rotX, rotY, rotZ); - } - - Vector3 playerObject_getRotation(void* object) { - return call("playerObject_getRotation", object); - } -} diff --git a/omp.cpp b/omp.cpp deleted file mode 100644 index 8bf0a7d..0000000 --- a/omp.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - #include -#else - #include -#endif - -#include "include/omp.h" - -void* libHandle; -std::unordered_map funcs; - -extern "C" { - void loadComponent() { -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - libHandle = LoadLibrary("./components/Go.dll"); -#else - libHandle = dlopen("./components/Go.so", RTLD_GLOBAL | RTLD_NOW); -#endif - } - - void unloadComponent() { -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - FreeLibrary((HMODULE)libHandle); -#else - dlclose(libHandle); -#endif - } - - void* findFunc(const char* name) { -#if defined(WIN32) || defined(_WIN32) || defined(__WIN32__) - return (void*)GetProcAddress((HMODULE)libHandle, name); -#else - return dlsym(libHandle, name); -#endif - } - - void freeArray(Array arr) { - return call("freeArray", arr); - } - - uint8_t getWeaponSlotIndex(uint8_t weapon) { - return call("getWeaponSlotIndex", weapon); - } - - unsigned char getVehicleModelInfo(int model, int type, Vector3* out) { - return call("getVehicleModelInfo", model, type, out); - } -} diff --git a/omp.go b/omp.go index 606a070..3fd8119 100644 --- a/omp.go +++ b/omp.go @@ -2,6 +2,7 @@ package omp // #include // #include "include/omp.h" +// #include "include/class.h" import "C" import ( "fmt" @@ -52,158 +53,226 @@ func handlePanic() { } } +//export ComponentEntryPoint +func ComponentEntryPoint() unsafe.Pointer { + cName := C.CString("OmpGo") + defer C.free(unsafe.Pointer(cName)) + + cVer := C.struct_ComponentVersion{ + major: 0, + minor: 0, + patch: 0, + prerel: 0, + } + + return C.Component_Create(C.ulonglong(uid), cName, cVer, onReady, onReset, onFree) +} + //export onGameModeInit -func onGameModeInit() { +func onGameModeInit() C.bool { defer handlePanic() C.loadComponent() - event.Dispatch(Events, EventTypeGameModeInit, &GameModeInitEvent{}) + result := event.Dispatch(Events, EventTypeGameModeInit, &GameModeInitEvent{}) + + return C.bool(result) } //export onGameModeExit -func onGameModeExit() { +func onGameModeExit() C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeGameModeExit, &GameModeExitEvent{}) + result := event.Dispatch(Events, EventTypeGameModeExit, &GameModeExitEvent{}) + + return C.bool(result) } // Actor events //export onPlayerGiveDamageActor -func onPlayerGiveDamageActor(player, actor unsafe.Pointer, amount float32, weapon uint, part int) { +func onPlayerGiveDamageActor(args *C.struct_EventArgs_onPlayerGiveDamageActor) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerGiveDamageActor, &PlayerGiveDamageActorEvent{ - Player: &Player{handle: player}, - Actor: &Player{handle: actor}, - Amount: amount, - Weapon: weapon, - Part: BodyPart(part), + result := event.Dispatch(Events, EventTypePlayerGiveDamageActor, &PlayerGiveDamageActorEvent{ + Player: &Player{handle: *args.list.player}, + Actor: &Player{handle: *args.list.actor}, + Amount: float32(*args.list.amount), + Weapon: Weapon(*args.list.weapon), + BodyPart: BodyPart(*args.list.part), }) + + return C.bool(result) } //export onActorStreamOut -func onActorStreamOut(actor, forPlayer unsafe.Pointer) { +func onActorStreamOut(args *C.struct_EventArgs_onActorStreamOut) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeActorStreamOut, &ActorStreamOutEvent{ - Actor: &Player{handle: actor}, - ForPlayer: &Player{handle: forPlayer}, + result := event.Dispatch(Events, EventTypeActorStreamOut, &ActorStreamOutEvent{ + Actor: &Player{handle: *args.list.actor}, + ForPlayer: &Player{handle: *args.list.forPlayer}, }) + + return C.bool(result) } //export onActorStreamIn -func onActorStreamIn(actor, forPlayer unsafe.Pointer) { +func onActorStreamIn(args *C.struct_EventArgs_onActorStreamIn) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeActorStreamIn, &ActorStreamInEvent{ - Actor: &Player{handle: actor}, - ForPlayer: &Player{handle: forPlayer}, + result := event.Dispatch(Events, EventTypeActorStreamIn, &ActorStreamInEvent{ + Actor: &Player{handle: *args.list.actor}, + ForPlayer: &Player{handle: *args.list.forPlayer}, }) + + return C.bool(result) } // Checkpoint events //export onPlayerEnterCheckpoint -func onPlayerEnterCheckpoint(player unsafe.Pointer) { +func onPlayerEnterCheckpoint(args *C.struct_EventArgs_onPlayerEnterCheckpoint) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerEnterCheckpoint, &PlayerEnterCheckpointEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerEnterCheckpoint, &PlayerEnterCheckpointEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onPlayerLeaveCheckpoint -func onPlayerLeaveCheckpoint(player unsafe.Pointer) { +func onPlayerLeaveCheckpoint(args *C.struct_EventArgs_onPlayerLeaveCheckpoint) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerLeaveCheckpoint, &PlayerLeaveCheckpointEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerLeaveCheckpoint, &PlayerLeaveCheckpointEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onPlayerEnterRaceCheckpoint -func onPlayerEnterRaceCheckpoint(player unsafe.Pointer) { +func onPlayerEnterRaceCheckpoint(args *C.struct_EventArgs_onPlayerEnterRaceCheckpoint) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerEnterRaceCheckpoint, &PlayerEnterRaceCheckpointEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerEnterRaceCheckpoint, &PlayerEnterRaceCheckpointEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onPlayerLeaveRaceCheckpoint -func onPlayerLeaveRaceCheckpoint(player unsafe.Pointer) { +func onPlayerLeaveRaceCheckpoint(args *C.struct_EventArgs_onPlayerLeaveRaceCheckpoint) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerLeaveRaceCheckpoint, &PlayerLeaveRaceCheckpointEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerLeaveRaceCheckpoint, &PlayerLeaveRaceCheckpointEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } // Class events //export onPlayerRequestClass -func onPlayerRequestClass(player, class unsafe.Pointer) bool { +func onPlayerRequestClass(args *C.struct_EventArgs_onPlayerRequestClass) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypePlayerRequestClass, &PlayerRequestClassEvent{ - Player: &Player{handle: player}, + class := C.Class_FromID(*args.list.classId) + + result := event.Dispatch(Events, EventTypePlayerRequestClass, &PlayerRequestClassEvent{ + Player: &Player{handle: *args.list.player}, Class: &Class{handle: class}, }) + + return C.bool(result) } // Console events. TODO //export onConsoleText -func onConsoleText(command C.String, parameters C.String) bool { +func onConsoleText(args *C.struct_EventArgs_onConsoleText) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypeConsoleText, &ConsoleTextEvent{ - Command: C.GoStringN(command.buf, C.int(command.length)), - Parameters: C.GoStringN(parameters.buf, C.int(parameters.length)), + cmd := *args.list.command + params := *args.list.parameters + + result := event.Dispatch(Events, EventTypeConsoleText, &ConsoleTextEvent{ + Command: C.GoStringN(cmd.data, C.int(cmd.len)), + Parameters: C.GoStringN(params.data, C.int(params.len)), }) + + return C.bool(result) } -//export onRconLoginAttempt -func onRconLoginAttempt(player unsafe.Pointer, password C.String, success bool) { - defer handlePanic() +// //export onRconLoginAttempt +// func onRconLoginAttempt(args *C.struct_EventArgs_onRconLoginAttempt) C.bool { +// defer handlePanic() - event.Dispatch(Events, EventTypeRconLoginAttempt, &RconLoginAttemptEvent{ - Player: &Player{handle: player}, - Password: C.GoStringN(password.buf, C.int(password.length)), - Success: success, - }) -} +// password := *args.list.password + +// result := event.Dispatch(Events, EventTypeRconLoginAttempt, &RconLoginAttemptEvent{ +// Player: &Player{handle: *args.list.player}, +// Password: C.GoStringN(password.data, C.int(password.len)), +// Success: bool(*args.list.success), +// }) + +// return C.bool(result) +// } + +// //export onTick +// func onTick(args *C.struct_EventArgs_onTick) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypeTick, &TickEvent{ +// Elapsed: time.Duration(*args.list.elapsed) * time.Microsecond, +// Now: time.Unix(int64(*args.list.now), 0), +// }) + +// return C.bool(result) +// } // Custom model events //export onPlayerFinishedDownloading -func onPlayerFinishedDownloading(player unsafe.Pointer) { +func onPlayerFinishedDownloading(args *C.struct_EventArgs_onPlayerFinishedDownloading) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerFinishedDownloading, &PlayerFinishedDownloadingEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerFinishedDownloading, &PlayerFinishedDownloadingEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onPlayerRequestDownload -func onPlayerRequestDownload(player unsafe.Pointer, _type uint8, checksum uint32) bool { +func onPlayerRequestDownload(args *C.struct_EventArgs_onPlayerRequestDownload) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypePlayerRequestDownload, &PlayerRequestDownloadEvent{ - Player: &Player{handle: player}, - Type: int(_type), - Checksum: int(checksum), + result := event.Dispatch(Events, EventTypePlayerRequestDownload, &PlayerRequestDownloadEvent{ + Player: &Player{handle: *args.list.player}, + Type: DownloadRequestType(*args.list._type), + Checksum: int(*args.list.checksum), }) + + return C.bool(result) } // Dialog events //export onDialogResponse -func onDialogResponse(player unsafe.Pointer, dialogID, response, listItem int, inputText C.String) { +func onDialogResponse(args *C.struct_EventArgs_onDialogResponse) C.bool { defer handlePanic() + player := *args.list.player + // dialogID := *args.list.dialogId + response := DialogResponse(*args.list.response) + listItem := int(*args.list.listItem) + inputText := *args.list.inputText + eventPlayer := &Player{handle: player} playerID := eventPlayer.ID() @@ -213,41 +282,43 @@ func onDialogResponse(player unsafe.Pointer, dialogID, response, listItem int, i } delete(activeDialogs, playerID) + var result bool + switch dialog := dialog.(type) { case *MessageDialog: - event.Dispatch(dialog.Dispatcher, EventTypeDialogResponse, &MessageDialogResponseEvent{ + result = event.Dispatch(dialog.Dispatcher, EventTypeDialogResponse, &MessageDialogResponseEvent{ Player: eventPlayer, - Response: DialogResponse(response), + Response: response, }) event.Dispatch(dialog.Dispatcher, EventTypeDialogHide, &DialogHideEvent{ Player: eventPlayer, }) case *InputDialog: - event.Dispatch(dialog.Dispatcher, EventTypeDialogResponse, &InputDialogResponseEvent{ + result = event.Dispatch(dialog.Dispatcher, EventTypeDialogResponse, &InputDialogResponseEvent{ Player: eventPlayer, - Response: DialogResponse(response), - InputText: C.GoStringN(inputText.buf, C.int(inputText.length)), + Response: response, + InputText: C.GoStringN(inputText.data, C.int(inputText.len)), }) event.Dispatch(dialog.Dispatcher, EventTypeDialogHide, &DialogHideEvent{ Player: eventPlayer, }) case *ListDialog: - event.Dispatch(dialog.Dispatcher, EventTypeDialogResponse, &ListDialogResponseEvent{ + result = event.Dispatch(dialog.Dispatcher, EventTypeDialogResponse, &ListDialogResponseEvent{ Player: eventPlayer, - Response: DialogResponse(response), + Response: response, ItemNumber: listItem, - Item: C.GoStringN(inputText.buf, C.int(inputText.length)), + Item: C.GoStringN(inputText.data, C.int(inputText.len)), }) event.Dispatch(dialog.Dispatcher, EventTypeDialogHide, &DialogHideEvent{ Player: eventPlayer, }) case *TabListDialog: - event.Dispatch(dialog.Dispatcher, EventTypeDialogResponse, &TabListDialogResponseEvent{ + result = event.Dispatch(dialog.Dispatcher, EventTypeDialogResponse, &TabListDialogResponseEvent{ Player: eventPlayer, - Response: DialogResponse(response), + Response: response, ItemNumber: listItem, Item: dialog.items[listItem], }) @@ -258,358 +329,456 @@ func onDialogResponse(player unsafe.Pointer, dialogID, response, listItem int, i default: panic("unknown dialog type") } + + return C.bool(result) } // GangZone events //export onPlayerEnterGangZone -func onPlayerEnterGangZone(player, gangzone unsafe.Pointer) { +func onPlayerEnterGangZone(args *C.struct_EventArgs_onPlayerEnterGangZone) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerEnterTurf, &PlayerEnterTurfEvent{ - Player: &Player{handle: player}, - Turf: &Turf{handle: gangzone}, + result := event.Dispatch(Events, EventTypePlayerEnterTurf, &PlayerEnterTurfEvent{ + Player: &Player{handle: *args.list.player}, + Turf: &Turf{handle: *args.list.zone}, }) -} - -//export onPlayerEnterPlayerGangZone -func onPlayerEnterPlayerGangZone(player, gangzone unsafe.Pointer) { - defer handlePanic() - event.Dispatch(Events, EventTypePlayerEnterPlayerTurf, &PlayerEnterPlayerTurfEvent{ - Player: &Player{handle: player}, - Turf: &PlayerTurf{handle: gangzone}, - }) + return C.bool(result) } -//export onPlayerLeaveGangZone -func onPlayerLeaveGangZone(player, gangzone unsafe.Pointer) { - defer handlePanic() +// //export onPlayerEnterPlayerGangZone +// func onPlayerEnterPlayerGangZone(args *C.struct_EventArgs_onPlayerEnterPlayerGangZone) C.bool { +// defer handlePanic() - event.Dispatch(Events, EventTypePlayerLeaveTurf, &PlayerLeaveTurfEvent{ - Player: &Player{handle: player}, - Turf: &Turf{handle: gangzone}, - }) -} +// eventPlayer := &Player{handle: *args.list.player} -//export onPlayerLeavePlayerGangZone -func onPlayerLeavePlayerGangZone(player, gangzone unsafe.Pointer) { - defer handlePanic() +// result := event.Dispatch(Events, EventTypePlayerEnterPlayerTurf, &PlayerEnterPlayerTurfEvent{ +// Player: eventPlayer, +// Turf: &PlayerTurf{ +// handle: *args.list.zone, +// player: eventPlayer, +// }, +// }) - event.Dispatch(Events, EventTypePlayerLeavePlayerTurf, &PlayerLeavePlayerTurfEvent{ - Player: &Player{handle: player}, - Turf: &PlayerTurf{handle: gangzone}, - }) -} +// return C.bool(result) +// } -//export onPlayerClickGangZone -func onPlayerClickGangZone(player, gangzone unsafe.Pointer) { +//export onPlayerLeaveGangZone +func onPlayerLeaveGangZone(args *C.struct_EventArgs_onPlayerLeaveGangZone) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerClickTurf, &PlayerClickTurfEvent{ - Player: &Player{handle: player}, - Turf: &Turf{handle: gangzone}, + result := event.Dispatch(Events, EventTypePlayerLeaveTurf, &PlayerLeaveTurfEvent{ + Player: &Player{handle: *args.list.player}, + Turf: &Turf{handle: *args.list.zone}, }) -} -//export onPlayerClickPlayerGangZone -func onPlayerClickPlayerGangZone(player, gangzone unsafe.Pointer) { - defer handlePanic() - - event.Dispatch(Events, EventTypePlayerClickPlayerTurf, &PlayerClickPlayerTurfEvent{ - Player: &Player{handle: player}, - Turf: &PlayerTurf{handle: gangzone}, - }) + return C.bool(result) } -// Menu events +// //export onPlayerLeavePlayerGangZone +// func onPlayerLeavePlayerGangZone(args *C.struct_EventArgs_onPlayerLeavePlayerGangZone) C.bool { +// defer handlePanic() -//export onPlayerSelectedMenuRow -func onPlayerSelectedMenuRow(player unsafe.Pointer, menuRow uint8) { - defer handlePanic() +// eventPlayer := &Player{ +// handle: *args.list.player, +// } - event.Dispatch(Events, EventTypePlayerSelectedMenuRow, &PlayerSelectedMenuRowEvent{ - Player: &Player{handle: player}, - MenuRow: menuRow, - }) -} +// result := event.Dispatch(Events, EventTypePlayerLeavePlayerTurf, &PlayerLeavePlayerTurfEvent{ +// Player: eventPlayer, +// Turf: &PlayerTurf{ +// handle: *args.list.zone, +// player: eventPlayer, +// }, +// }) -//export onPlayerExitedMenu -func onPlayerExitedMenu(player unsafe.Pointer) { +// return C.bool(result) +// } + +//export onPlayerClickGangZone +func onPlayerClickGangZone(args *C.struct_EventArgs_onPlayerClickGangZone) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerExitedMenu, &PlayerExitedMenuEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerClickTurf, &PlayerClickTurfEvent{ + Player: &Player{handle: *args.list.player}, + Turf: &Turf{handle: *args.list.zone}, }) + + return C.bool(result) } -// Object events +// //export onPlayerClickPlayerGangZone +// func onPlayerClickPlayerGangZone(args *C.struct_EventArgs_onPlayerClickPlayerGangZone) C.bool { +// defer handlePanic() -//export onObjectMoved -func onObjectMoved(object unsafe.Pointer) { - defer handlePanic() +// eventPlayer := &Player{handle: *args.list.player} - event.Dispatch(Events, EventTypeObjectMoved, &ObjectMovedEvent{ - Object: &Object{handle: object}, - }) -} +// result := event.Dispatch(Events, EventTypePlayerClickPlayerTurf, &PlayerClickPlayerTurfEvent{ +// Player: eventPlayer, +// Turf: &PlayerTurf{ +// handle: *args.list.zone, +// player: eventPlayer, +// }, +// }) -//export onPlayerObjectMoved -func onPlayerObjectMoved(player, object unsafe.Pointer) { - defer handlePanic() +// return C.bool(result) +// } - event.Dispatch(Events, EventTypePlayerObjectMoved, &PlayerObjectMovedEvent{ - Player: &Player{handle: player}, - Object: &PlayerObject{handle: object}, - }) -} +// Menu events -//export onObjectSelected -func onObjectSelected(player, object unsafe.Pointer, model int, pos C.Vector3) { +//export onPlayerSelectedMenuRow +func onPlayerSelectedMenuRow(args *C.struct_EventArgs_onPlayerSelectedMenuRow) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeObjectSelected, &ObjectSelectedEvent{ - Player: &Player{handle: player}, - Object: &Object{handle: object}, - Model: model, - Position: Vector3{ - X: float32(pos.x), - Y: float32(pos.y), - Z: float32(pos.z), - }, + result := event.Dispatch(Events, EventTypePlayerSelectedMenuRow, &PlayerSelectedMenuRowEvent{ + Player: &Player{handle: *args.list.player}, + MenuRow: int(*args.list.row), }) -} - -//export onPlayerObjectSelected -func onPlayerObjectSelected(player, object unsafe.Pointer, model int, pos C.Vector3) { - defer handlePanic() - event.Dispatch(Events, EventTypePlayerObjectSelected, &PlayerObjectSelectedEvent{ - Player: &Player{handle: player}, - Object: &PlayerObject{handle: object}, - Model: model, - Position: Vector3{ - X: float32(pos.x), - Y: float32(pos.y), - Z: float32(pos.z), - }, - }) + return C.bool(result) } -//export onObjectEdited -func onObjectEdited(player, object unsafe.Pointer, response int, offset, rot C.Vector3) { +//export onPlayerExitedMenu +func onPlayerExitedMenu(args *C.struct_EventArgs_onPlayerExitedMenu) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeObjectEdited, &ObjectEditedEvent{ - Player: &Player{handle: player}, - Object: &Object{handle: object}, - Response: ObjectEditResponse(response), - Offset: Vector3{ - X: float32(offset.x), - Y: float32(offset.y), - Z: float32(offset.z), - }, - Rotation: Vector3{ - X: float32(rot.x), - Y: float32(rot.y), - Z: float32(rot.z), - }, + result := event.Dispatch(Events, EventTypePlayerExitedMenu, &PlayerExitedMenuEvent{ + Player: &Player{handle: *args.list.player}, }) -} -//export onPlayerObjectEdited -func onPlayerObjectEdited(player, object unsafe.Pointer, response int, offset, rot C.Vector3) { - defer handlePanic() - - event.Dispatch(Events, EventTypePlayerObjectEdited, &PlayerObjectEditedEvent{ - Player: &Player{handle: player}, - Object: &PlayerObject{handle: object}, - Response: ObjectEditResponse(response), - Offset: Vector3{ - X: float32(offset.x), - Y: float32(offset.y), - Z: float32(offset.z), - }, - Rotation: Vector3{ - X: float32(rot.x), - Y: float32(rot.y), - Z: float32(rot.z), - }, - }) + return C.bool(result) } -//export onPlayerAttachedObjectEdited -func onPlayerAttachedObjectEdited(player unsafe.Pointer, index int, saved bool, data C.PlayerAttachedObject) { - defer handlePanic() +// Object events - event.Dispatch(Events, EventTypePlayerAttachmentEdited, &PlayerAttachmentEdited{ - Player: &Player{handle: player}, - Index: index, - Saved: saved, - Attachment: PlayerAttachment{ - ModelID: int(data.model), - Bone: PlayerBone(data.bone), - Offset: Vector3{ - X: float32(data.offset.x), - Y: float32(data.offset.y), - Z: float32(data.offset.z), - }, - Rot: Vector3{ - X: float32(data.rotation.x), - Y: float32(data.rotation.y), - Z: float32(data.rotation.z), - }, - Scale: Vector3{ - X: float32(data.scale.x), - Y: float32(data.scale.y), - Z: float32(data.scale.z), - }, - Color1: Color(data.colour1), - Color2: Color(data.colour2), - }, - }) -} +// //export onObjectMoved +// func onObjectMoved(args *C.struct_EventArgs_onObjectMoved) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypeObjectMoved, &ObjectMovedEvent{ +// Object: &Object{handle: *args.list.object}, +// }) + +// return C.bool(result) +// } + +// //export onPlayerObjectMoved +// func onPlayerObjectMoved(args *C.struct_EventArgs_onPlayerObjectMoved) C.bool { +// defer handlePanic() + +// eventPlayer := &Player{handle: *args.list.player} + +// result := event.Dispatch(Events, EventTypePlayerObjectMoved, &PlayerObjectMovedEvent{ +// Player: eventPlayer, +// Object: &PlayerObject{ +// handle: *args.list.object, +// player: eventPlayer, +// }, +// }) + +// return C.bool(result) +// } + +// //export onObjectEdited +// func onObjectEdited(args *C.struct_EventArgs_onObjectEdited) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypeObjectEdited, &ObjectEditedEvent{ +// Player: &Player{handle: *args.list.player}, +// Object: &Object{handle: *args.list.object}, +// Response: ObjectEditResponse(*args.list.response), +// Offset: Vector3{ +// X: float32(*args.list.offsetX), +// Y: float32(*args.list.offsetY), +// Z: float32(*args.list.offsetZ), +// }, +// Rotation: Vector3{ +// X: float32(*args.list.rotationX), +// Y: float32(*args.list.rotationY), +// Z: float32(*args.list.rotationZ), +// }, +// }) + +// return C.bool(result) +// } + +// //export onPlayerObjectEdited +// func onPlayerObjectEdited(args *C.struct_EventArgs_onPlayerObjectEdited) C.bool { +// defer handlePanic() + +// eventPlayer := &Player{handle: *args.list.player} + +// result := event.Dispatch(Events, EventTypePlayerObjectEdited, &PlayerObjectEditedEvent{ +// Player: eventPlayer, +// Object: &PlayerObject{ +// handle: *args.list.object, +// player: eventPlayer, +// }, +// Response: ObjectEditResponse(*args.list.response), +// Offset: Vector3{ +// X: float32(*args.list.offsetX), +// Y: float32(*args.list.offsetY), +// Z: float32(*args.list.offsetZ), +// }, +// Rotation: Vector3{ +// X: float32(*args.list.rotationX), +// Y: float32(*args.list.rotationY), +// Z: float32(*args.list.rotationZ), +// }, +// }) + +// return C.bool(result) +// } + +// //export onPlayerAttachedObjectEdited +// func onPlayerAttachedObjectEdited(args *C.struct_EventArgs_onPlayerAttachedObjectEdited) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypePlayerAttachmentEdited, &PlayerAttachmentEdited{ +// Player: &Player{handle: *args.list.player}, +// Index: int(*args.list.index), +// Saved: bool(*args.list.saved), +// Attachment: PlayerAttachment{ +// ModelID: int(*args.list.model), +// Bone: PlayerBone(*args.list.bone), +// Offset: Vector3{ +// X: float32(*args.list.offsetX), +// Y: float32(*args.list.offsetY), +// Z: float32(*args.list.offsetZ), +// }, +// Rotation: Vector3{ +// X: float32(*args.list.rotationX), +// Y: float32(*args.list.rotationY), +// Z: float32(*args.list.rotationZ), +// }, +// Scale: Vector3{ +// X: float32(*args.list.scaleX), +// Y: float32(*args.list.scaleY), +// Z: float32(*args.list.scaleZ), +// }, +// Color1: Color(*args.list.color1), +// Color2: Color(*args.list.color2), +// }, +// }) + +// return C.bool(result) +// } + +// //export onObjectSelected +// func onObjectSelected(args *C.struct_EventArgs_onObjectSelected) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypeObjectSelected, &ObjectSelectedEvent{ +// Player: &Player{handle: *args.list.player}, +// Object: &Object{handle: *args.list.object}, +// Model: int(*args.list.model), +// Position: Vector3{ +// X: float32(*args.list.x), +// Y: float32(*args.list.y), +// Z: float32(*args.list.z), +// }, +// }) + +// return C.bool(result) +// } + +// //export onPlayerObjectSelected +// func onPlayerObjectSelected(args *C.struct_EventArgs_onPlayerObjectSelected) C.bool { +// defer handlePanic() + +// eventPlayer := &Player{handle: *args.list.player} + +// result := event.Dispatch(Events, EventTypePlayerObjectSelected, &PlayerObjectSelectedEvent{ +// Player: eventPlayer, +// Object: &PlayerObject{ +// handle: *args.list.object, +// player: eventPlayer, +// }, +// Model: int(*args.list.model), +// Position: Vector3{ +// X: float32(*args.list.x), +// Y: float32(*args.list.y), +// Z: float32(*args.list.z), +// }, +// }) + +// return C.bool(result) +// } // Pickup events //export onPlayerPickUpPickup -func onPlayerPickUpPickup(player, pickup unsafe.Pointer) { +func onPlayerPickUpPickup(args *C.struct_EventArgs_onPlayerPickUpPickup) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerPickUpPickup, &PlayerPickUpPickupEvent{ - Player: &Player{handle: player}, - Pickup: &Pickup{handle: pickup}, + result := event.Dispatch(Events, EventTypePlayerPickUpPickup, &PlayerPickUpPickupEvent{ + Player: &Player{handle: *args.list.player}, + Pickup: &Pickup{handle: *args.list.pickup}, }) + + return C.bool(result) } -//export onPlayerPickUpPlayerPickup -func onPlayerPickUpPlayerPickup(player, pickup unsafe.Pointer) { - defer handlePanic() +// //export onPlayerPickUpPlayerPickup +// func onPlayerPickUpPlayerPickup(args *C.struct_EventArgs_onPlayerPickUpPlayerPickup) C.bool { +// defer handlePanic() - event.Dispatch(Events, EventTypePlayerPickUpPlayerPickup, &PlayerPickUpPlayerPickupEvent{ - Player: &Player{handle: player}, - Pickup: &PlayerPickup{handle: pickup}, - }) -} +// eventPlayer := &Player{handle: *args.list.player} + +// result := event.Dispatch(Events, EventTypePlayerPickUpPlayerPickup, &PlayerPickUpPlayerPickupEvent{ +// Player: eventPlayer, +// Pickup: &PlayerPickup{ +// handle: *args.list.pickup, +// player: eventPlayer, +// }, +// }) + +// return C.bool(result) +// } // Player spawn events //export onPlayerRequestSpawn -func onPlayerRequestSpawn(player unsafe.Pointer) bool { +func onPlayerRequestSpawn(args *C.struct_EventArgs_onPlayerRequestSpawn) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypePlayerRequestSpawn, &PlayerRequestSpawnEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerRequestSpawn, &PlayerRequestSpawnEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onPlayerSpawn -func onPlayerSpawn(player unsafe.Pointer) { +func onPlayerSpawn(args *C.struct_EventArgs_onPlayerSpawn) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerSpawn, &PlayerSpawnEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerSpawn, &PlayerSpawnEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } // Player connect events //export onIncomingConnection -func onIncomingConnection(player unsafe.Pointer, ipAddress C.String, port C.ushort) { +func onIncomingConnection(args *C.struct_EventArgs_onIncomingConnection) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeIncomingConnection, &IncomingConnectionEvent{ - Player: &Player{handle: player}, - IPAddress: C.GoStringN(ipAddress.buf, C.int(ipAddress.length)), - Port: int(port), + ipAddress := *args.list.ipAddress + + result := event.Dispatch(Events, EventTypeIncomingConnection, &IncomingConnectionEvent{ + Player: &Player{handle: *args.list.player}, + ipAddress: C.GoStringN(ipAddress.data, C.int(ipAddress.len)), + Port: int(*args.list.port), }) + + return C.bool(result) } //export onPlayerConnect -func onPlayerConnect(player unsafe.Pointer) { +func onPlayerConnect(args *C.struct_EventArgs_onPlayerConnect) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerConnect, &PlayerConnectEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerConnect, &PlayerConnectEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onPlayerDisconnect -func onPlayerDisconnect(player unsafe.Pointer, reason int) { +func onPlayerDisconnect(args *C.struct_EventArgs_onPlayerDisconnect) C.bool { defer handlePanic() - eventPlayer := &Player{handle: player} + eventPlayer := &Player{handle: *args.list.player} - event.Dispatch(Events, EventTypePlayerDisconnect, &PlayerDisconnectEvent{ + result := event.Dispatch(Events, EventTypePlayerDisconnect, &PlayerDisconnectEvent{ Player: eventPlayer, - Reason: DisconnectReason(reason), + Reason: DisconnectReason(*args.list.reason), }) delete(activeDialogs, eventPlayer.ID()) + + return C.bool(result) } -//export onPlayerClientInit -func onPlayerClientInit(player unsafe.Pointer) { - defer handlePanic() +// //export onPlayerClientInit +// func onPlayerClientInit(args *C.struct_EventArgs_onPlayerClientInit) C.bool { +// defer handlePanic() - event.Dispatch(Events, EventTypePlayerClientInit, &PlayerClientInitEvent{ - Player: &Player{handle: player}, - }) -} +// result := event.Dispatch(Events, EventTypePlayerClientInit, &PlayerClientInitEvent{ +// Player: &Player{handle: *args.list.player}, +// }) + +// return C.bool(result) +// } // Player stream events //export onPlayerStreamIn -func onPlayerStreamIn(player, forPlayer unsafe.Pointer) { +func onPlayerStreamIn(args *C.struct_EventArgs_onPlayerStreamIn) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerStreamIn, &PlayerStreamInEvent{ - Player: &Player{handle: player}, - ForPlayer: &Player{handle: forPlayer}, + result := event.Dispatch(Events, EventTypePlayerStreamIn, &PlayerStreamInEvent{ + Player: &Player{handle: *args.list.player}, + ForPlayer: &Player{handle: *args.list.forPlayer}, }) + + return C.bool(result) } //export onPlayerStreamOut -func onPlayerStreamOut(player, forPlayer unsafe.Pointer) { +func onPlayerStreamOut(args *C.struct_EventArgs_onPlayerStreamOut) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerStreamOut, &PlayerStreamOutEvent{ - Player: &Player{handle: player}, - ForPlayer: &Player{handle: forPlayer}, + result := event.Dispatch(Events, EventTypePlayerStreamOut, &PlayerStreamOutEvent{ + Player: &Player{handle: *args.list.player}, + ForPlayer: &Player{handle: *args.list.forPlayer}, }) + + return C.bool(result) } // Player text events //export onPlayerText -func onPlayerText(player unsafe.Pointer, message *C.char) { +func onPlayerText(args *C.struct_EventArgs_onPlayerText) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerText, &PlayerTextEvent{ - Player: &Player{handle: player}, - Message: C.GoString(message), + text := *args.list.text + + result := event.Dispatch(Events, EventTypePlayerText, &PlayerTextEvent{ + Player: &Player{handle: *args.list.player}, + Message: C.GoStringN(text.data, C.int(text.len)), }) + + return C.bool(result) } //export onPlayerCommandText -func onPlayerCommandText(player unsafe.Pointer, message C.String) bool { +func onPlayerCommandText(args *C.struct_EventArgs_onPlayerCommandText) C.bool { defer handlePanic() - rawCmd := C.GoStringN(message.buf, C.int(message.length)) + player := *args.list.player + message := *args.list.command + + rawCmd := C.GoStringN(message.data, C.int(message.len)) tmp := strings.Fields(rawCmd) - name := strings.TrimPrefix(tmp[0], "/") - args := tmp[1:] + cmdName := strings.TrimPrefix(tmp[0], "/") + cmdArgs := tmp[1:] - exists := Commands.Has(name) + exists := Commands.Has(cmdName) if !exists { return false } - Commands.run(name, &Command{ + Commands.run(cmdName, &Command{ Sender: &Player{handle: player}, - Name: name, - Args: args, + Name: cmdName, + Args: cmdArgs, RawValue: rawCmd, }) @@ -618,498 +787,594 @@ func onPlayerCommandText(player unsafe.Pointer, message C.String) bool { // Player shot events -//export onPlayerShotMissed -func onPlayerShotMissed(player unsafe.Pointer, bulletData C.PlayerBulletData) bool { - defer handlePanic() +// //export onPlayerShotMissed +// func onPlayerShotMissed(args *C.struct_EventArgs_onPlayerShotMissed) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypePlayerShotMissed, &PlayerShotMissedEvent{ +// Player: &Player{handle: *args.list.player}, +// Bullet: PlayerBullet{ +// Origin: Vector3{ +// X: float32(*args.list.originX), +// Y: float32(*args.list.originY), +// Z: float32(*args.list.originZ), +// }, +// HitPosition: Vector3{ +// X: float32(*args.list.hitPosX), +// Y: float32(*args.list.hitPosY), +// Z: float32(*args.list.hitPosZ), +// }, +// Offset: Vector3{ +// X: float32(*args.list.offsetX), +// Y: float32(*args.list.offsetY), +// Z: float32(*args.list.offsetZ), +// }, +// Weapon: Weapon(*args.list.weapon), +// }, +// }) + +// return C.bool(result) +// } + +// //export onPlayerShotPlayer +// func onPlayerShotPlayer(args *C.struct_EventArgs_onPlayerShotPlayer) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypePlayerShotPlayer, &PlayerShotPlayerEvent{ +// Player: &Player{handle: *args.list.player}, +// Target: &Player{handle: *args.list.target}, +// Bullet: PlayerBullet{ +// Origin: Vector3{ +// X: float32(*args.list.originX), +// Y: float32(*args.list.originY), +// Z: float32(*args.list.originZ), +// }, +// HitPosition: Vector3{ +// X: float32(*args.list.hitPosX), +// Y: float32(*args.list.hitPosY), +// Z: float32(*args.list.hitPosZ), +// }, +// Offset: Vector3{ +// X: float32(*args.list.offsetX), +// Y: float32(*args.list.offsetY), +// Z: float32(*args.list.offsetZ), +// }, +// Weapon: Weapon(*args.list.weapon), +// }, +// }) + +// return C.bool(result) +// } + +// //export onPlayerShotVehicle +// func onPlayerShotVehicle(args *C.struct_EventArgs_onPlayerShotVehicle) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypePlayerShotVehicle, &PlayerShotVehicleEvent{ +// Player: &Player{handle: *args.list.player}, +// Target: &Vehicle{handle: *args.list.target}, +// Bullet: PlayerBullet{ +// Origin: Vector3{ +// X: float32(*args.list.originX), +// Y: float32(*args.list.originY), +// Z: float32(*args.list.originZ), +// }, +// HitPosition: Vector3{ +// X: float32(*args.list.hitPosX), +// Y: float32(*args.list.hitPosY), +// Z: float32(*args.list.hitPosZ), +// }, +// Offset: Vector3{ +// X: float32(*args.list.offsetX), +// Y: float32(*args.list.offsetY), +// Z: float32(*args.list.offsetZ), +// }, +// Weapon: Weapon(*args.list.weapon), +// }, +// }) + +// return C.bool(result) +// } + +// //export onPlayerShotObject +// func onPlayerShotObject(args *C.struct_EventArgs_onPlayerShotObject) C.bool { +// defer handlePanic() + +// result := event.Dispatch(Events, EventTypePlayerShotObject, &PlayerShotObjectEvent{ +// Player: &Player{handle: *args.list.player}, +// Target: &Object{handle: *args.list.target}, +// Bullet: PlayerBullet{ +// Origin: Vector3{ +// X: float32(*args.list.originX), +// Y: float32(*args.list.originY), +// Z: float32(*args.list.originZ), +// }, +// HitPosition: Vector3{ +// X: float32(*args.list.hitPosX), +// Y: float32(*args.list.hitPosY), +// Z: float32(*args.list.hitPosZ), +// }, +// Offset: Vector3{ +// X: float32(*args.list.offsetX), +// Y: float32(*args.list.offsetY), +// Z: float32(*args.list.offsetZ), +// }, +// Weapon: Weapon(*args.list.weapon), +// }, +// }) + +// return C.bool(result) +// } + +// //export onPlayerShotPlayerObject +// func onPlayerShotPlayerObject(args *C.struct_EventArgs_onPlayerShotPlayerObject) C.bool { +// defer handlePanic() + +// eventPlayer := &Player{handle: *args.list.player} + +// result := event.Dispatch(Events, EventTypePlayerShotPlayerObject, &PlayerShotPlayerObjectEvent{ +// Player: eventPlayer, +// Target: &PlayerObject{ +// handle: *args.list.target, +// player: eventPlayer, +// }, +// Bullet: PlayerBullet{ +// Origin: Vector3{ +// X: float32(*args.list.originX), +// Y: float32(*args.list.originY), +// Z: float32(*args.list.originZ), +// }, +// HitPosition: Vector3{ +// X: float32(*args.list.hitPosX), +// Y: float32(*args.list.hitPosY), +// Z: float32(*args.list.hitPosZ), +// }, +// Offset: Vector3{ +// X: float32(*args.list.offsetX), +// Y: float32(*args.list.offsetY), +// Z: float32(*args.list.offsetZ), +// }, +// Weapon: Weapon(*args.list.weapon), +// }, +// }) + +// return C.bool(result) +// } - return event.Dispatch(Events, EventTypePlayerShotMissed, &PlayerShotMissedEvent{ - Player: &Player{handle: player}, - Bullet: PlayerBullet{ - Origin: Vector3{ - X: float32(bulletData.origin.x), - Y: float32(bulletData.origin.y), - Z: float32(bulletData.origin.z), - }, - HitPos: Vector3{ - X: float32(bulletData.hitPos.x), - Y: float32(bulletData.hitPos.y), - Z: float32(bulletData.hitPos.z), - }, - Offset: Vector3{ - X: float32(bulletData.offset.x), - Y: float32(bulletData.offset.y), - Z: float32(bulletData.offset.z), - }, - Weapon: Weapon(bulletData.weapon), - }, - }) -} - -//export onPlayerShotPlayer -func onPlayerShotPlayer(player, target unsafe.Pointer, bulletData C.PlayerBulletData) bool { - defer handlePanic() - - return event.Dispatch(Events, EventTypePlayerShotPlayer, &PlayerShotPlayerEvent{ - Player: &Player{handle: player}, - Target: &Player{handle: target}, - Bullet: PlayerBullet{ - Origin: Vector3{ - X: float32(bulletData.origin.x), - Y: float32(bulletData.origin.y), - Z: float32(bulletData.origin.z), - }, - HitPos: Vector3{ - X: float32(bulletData.hitPos.x), - Y: float32(bulletData.hitPos.y), - Z: float32(bulletData.hitPos.z), - }, - Offset: Vector3{ - X: float32(bulletData.offset.x), - Y: float32(bulletData.offset.y), - Z: float32(bulletData.offset.z), - }, - Weapon: Weapon(bulletData.weapon), - }, - }) -} - -//export onPlayerShotVehicle -func onPlayerShotVehicle(player, target unsafe.Pointer, bulletData C.PlayerBulletData) bool { - defer handlePanic() - - return event.Dispatch(Events, EventTypePlayerShotVehicle, &PlayerShotVehicleEvent{ - Player: &Player{handle: player}, - Target: &Vehicle{handle: target}, - Bullet: PlayerBullet{ - Origin: Vector3{ - X: float32(bulletData.origin.x), - Y: float32(bulletData.origin.y), - Z: float32(bulletData.origin.z), - }, - HitPos: Vector3{ - X: float32(bulletData.hitPos.x), - Y: float32(bulletData.hitPos.y), - Z: float32(bulletData.hitPos.z), - }, - Offset: Vector3{ - X: float32(bulletData.offset.x), - Y: float32(bulletData.offset.y), - Z: float32(bulletData.offset.z), - }, - Weapon: Weapon(bulletData.weapon), - }, - }) -} - -//export onPlayerShotObject -func onPlayerShotObject(player, target unsafe.Pointer, bulletData C.PlayerBulletData) bool { - defer handlePanic() - - return event.Dispatch(Events, EventTypePlayerShotObject, &PlayerShotObjectEvent{ - Player: &Player{handle: player}, - Target: &Object{handle: target}, - Bullet: PlayerBullet{ - Origin: Vector3{ - X: float32(bulletData.origin.x), - Y: float32(bulletData.origin.y), - Z: float32(bulletData.origin.z), - }, - HitPos: Vector3{ - X: float32(bulletData.hitPos.x), - Y: float32(bulletData.hitPos.y), - Z: float32(bulletData.hitPos.z), - }, - Offset: Vector3{ - X: float32(bulletData.offset.x), - Y: float32(bulletData.offset.y), - Z: float32(bulletData.offset.z), - }, - Weapon: Weapon(bulletData.weapon), - }, - }) -} +// Player change events -//export onPlayerShotPlayerObject -func onPlayerShotPlayerObject(player, target unsafe.Pointer, bulletData C.PlayerBulletData) bool { - defer handlePanic() +// //export onPlayerScoreChange +// func onPlayerScoreChange(args *C.struct_EventArgs_onPlayerScoreChange) C.bool { +// defer handlePanic() - return event.Dispatch(Events, EventTypePlayerShotPlayerObject, &PlayerShotPlayerObjectEvent{ - Player: &Player{handle: player}, - Target: &PlayerObject{handle: target}, - Bullet: PlayerBullet{ - Origin: Vector3{ - X: float32(bulletData.origin.x), - Y: float32(bulletData.origin.y), - Z: float32(bulletData.origin.z), - }, - HitPos: Vector3{ - X: float32(bulletData.hitPos.x), - Y: float32(bulletData.hitPos.y), - Z: float32(bulletData.hitPos.z), - }, - Offset: Vector3{ - X: float32(bulletData.offset.x), - Y: float32(bulletData.offset.y), - Z: float32(bulletData.offset.z), - }, - Weapon: Weapon(bulletData.weapon), - }, - }) -} +// result := event.Dispatch(Events, EventTypePlayerScoreChange, &PlayerScoreChangeEvent{ +// Player: &Player{handle: *args.list.player}, +// Score: int(*args.list.score), +// }) -// Player change events +// return C.bool(result) +// } -//export onPlayerScoreChange -func onPlayerScoreChange(player unsafe.Pointer, score int) { - defer handlePanic() +// //export onPlayerNameChange +// func onPlayerNameChange(args *C.struct_EventArgs_onPlayerNameChange) C.bool { +// defer handlePanic() - event.Dispatch(Events, EventTypePlayerScoreChange, &PlayerScoreChangeEvent{ - Player: &Player{handle: player}, - Score: score, - }) -} +// oldName := *args.list.oldName -//export onPlayerNameChange -func onPlayerNameChange(player unsafe.Pointer, oldName C.String) { - defer handlePanic() +// result := event.Dispatch(Events, EventTypePlayerNameChange, &PlayerNameChangeEvent{ +// Player: &Player{handle: *args.list.player}, +// OldName: C.GoStringN(oldName.data, C.int(oldName.len)), +// }) - event.Dispatch(Events, EventTypePlayerNameChange, &PlayerNameChangeEvent{ - Player: &Player{handle: player}, - OldName: C.GoStringN(oldName.buf, C.int(oldName.length)), - }) -} +// return C.bool(result) +// } //export onPlayerInteriorChange -func onPlayerInteriorChange(player unsafe.Pointer, newInterior, oldInterior uint) { +func onPlayerInteriorChange(args *C.struct_EventArgs_onPlayerInteriorChange) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerInteriorChange, &PlayerInteriorChangeEvent{ - Player: &Player{handle: player}, - NewInterior: newInterior, - OldInterior: oldInterior, + result := event.Dispatch(Events, EventTypePlayerInteriorChange, &PlayerInteriorChangeEvent{ + Player: &Player{handle: *args.list.player}, + NewInterior: int(*args.list.newInterior), + OldInterior: int(*args.list.oldInterior), }) + + return C.bool(result) } //export onPlayerStateChange -func onPlayerStateChange(player unsafe.Pointer, newState, oldState int) { +func onPlayerStateChange(args *C.struct_EventArgs_onPlayerStateChange) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerStateChange, &PlayerStateChangeEvent{ - Player: &Player{handle: player}, - NewState: PlayerState(newState), - OldState: PlayerState(oldState), + result := event.Dispatch(Events, EventTypePlayerStateChange, &PlayerStateChangeEvent{ + Player: &Player{handle: *args.list.player}, + NewState: PlayerState(*args.list.newState), + OldState: PlayerState(*args.list.oldState), }) + + return C.bool(result) } //export onPlayerKeyStateChange -func onPlayerKeyStateChange(player unsafe.Pointer, newKeys, oldKeys uint) { +func onPlayerKeyStateChange(args *C.struct_EventArgs_onPlayerKeyStateChange) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerKeyStateChange, &PlayerKeyStateChangeEvent{ - Player: &Player{handle: player}, - NewKeys: newKeys, - OldKeys: oldKeys, + result := event.Dispatch(Events, EventTypePlayerKeyStateChange, &PlayerKeyStateChangeEvent{ + Player: &Player{handle: *args.list.player}, + NewKeys: int(*args.list.newKeys), + OldKeys: int(*args.list.oldKeys), }) + + return C.bool(result) } // Player damage events //export onPlayerDeath -func onPlayerDeath(player, killer unsafe.Pointer, reason int) { +func onPlayerDeath(args *C.struct_EventArgs_onPlayerDeath) C.bool { defer handlePanic() + player := *args.list.player + killer := *args.list.killer + reason := int(*args.list.reason) + eventKiller := &Player{handle: killer} + if killer == nil { eventKiller = nil } - event.Dispatch(Events, EventTypePlayerDeath, &PlayerDeathEvent{ + result := event.Dispatch(Events, EventTypePlayerDeath, &PlayerDeathEvent{ Player: &Player{handle: player}, Killer: eventKiller, Reason: reason, }) + + return C.bool(result) } //export onPlayerTakeDamage -func onPlayerTakeDamage(player, from unsafe.Pointer, amount float32, weapon uint, part int) { +func onPlayerTakeDamage(args *C.struct_EventArgs_onPlayerTakeDamage) C.bool { defer handlePanic() + player := *args.list.player + from := *args.list.from + amount := float32(*args.list.amount) + weapon := Weapon(*args.list.weapon) + bodyPart := BodyPart(*args.list.bodypart) + eventFrom := &Player{handle: from} if from == nil { eventFrom = nil } - event.Dispatch(Events, EventTypePlayerTakeDamage, &PlayerTakeDamageEvent{ + result := event.Dispatch(Events, EventTypePlayerTakeDamage, &PlayerTakeDamageEvent{ Player: &Player{handle: player}, From: eventFrom, Amount: amount, - Weapon: Weapon(weapon), - Part: BodyPart(part), + Weapon: weapon, + Part: bodyPart, }) + + return C.bool(result) } //export onPlayerGiveDamage -func onPlayerGiveDamage(player, to unsafe.Pointer, amount float32, weapon uint, part int) { +func onPlayerGiveDamage(args *C.struct_EventArgs_onPlayerGiveDamage) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerGiveDamage, &PlayerGiveDamageEvent{ - Player: &Player{handle: player}, - To: &Player{handle: to}, - Amount: amount, - Weapon: Weapon(weapon), - Part: BodyPart(part), + result := event.Dispatch(Events, EventTypePlayerGiveDamage, &PlayerGiveDamageEvent{ + Player: &Player{handle: *args.list.player}, + To: &Player{handle: *args.list.to}, + Amount: float32(*args.list.amount), + Weapon: Weapon(*args.list.weapon), + BodyPart: BodyPart(*args.list.bodypart), }) + + return C.bool(result) } // Player click events //export onPlayerClickMap -func onPlayerClickMap(player unsafe.Pointer, pos C.Vector3) { +func onPlayerClickMap(args *C.struct_EventArgs_onPlayerClickMap) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerClickMap, &PlayerClickMapEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerClickMap, &PlayerClickMapEvent{ + Player: &Player{handle: *args.list.player}, Position: Vector3{ - X: float32(pos.x), - Y: float32(pos.y), - Z: float32(pos.z), + X: float32(*args.list.x), + Y: float32(*args.list.y), + Z: float32(*args.list.z), }, }) + + return C.bool(result) } //export onPlayerClickPlayer -func onPlayerClickPlayer(player, clicked unsafe.Pointer, source int) { +func onPlayerClickPlayer(args *C.struct_EventArgs_onPlayerClickPlayer) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerClickPlayer, &PlayerClickPlayerEvent{ - Player: &Player{handle: player}, - Clicked: &Player{handle: clicked}, - Source: PlayerClickSource(source), + result := event.Dispatch(Events, EventTypePlayerClickPlayer, &PlayerClickPlayerEvent{ + Player: &Player{handle: *args.list.player}, + Target: &Player{handle: *args.list.clicked}, + Source: PlayerClickSource(*args.list.source), }) + + return C.bool(result) } // Player check events -//export onClientCheckResponse -func onClientCheckResponse(player unsafe.Pointer, actionType, address, results int) { - defer handlePanic() +// //export onClientCheckResponse +// func onClientCheckResponse(args *C.struct_EventArgs_onClientCheckResponse) C.bool { +// defer handlePanic() - event.Dispatch(Events, EventTypeClientCheckResponse, &ClientCheckResponseEvent{ - Player: &Player{handle: player}, - ActionType: actionType, - Address: address, - Results: results, - }) -} +// result := event.Dispatch(Events, EventTypeClientCheckResponse, &ClientCheckResponseEvent{ +// Player: &Player{handle: *args.list.player}, +// ActionType: int(*args.list.actionType), +// Address: int(*args.list.address), +// Results: int(*args.list.result), +// }) + +// return C.bool(result) +// } // Player update event -//export onPlayerUpdate -func onPlayerUpdate(player unsafe.Pointer, now C.longlong) bool { - defer handlePanic() +// //export onPlayerUpdate +// func onPlayerUpdate(args *C.struct_EventArgs_onPlayerUpdate) C.bool { +// defer handlePanic() - return event.Dispatch(Events, EventTypePlayerUpdate, &PlayerUpdateEvent{ - Player: &Player{handle: player}, - Now: time.Unix(0, int64(now)*int64(time.Millisecond)), - }) -} +// result := event.Dispatch(Events, EventTypePlayerUpdate, &PlayerUpdateEvent{ +// Player: &Player{handle: *args.list.player}, +// Now: time.Unix(int64(*args.list.now), 0), +// }) + +// return C.bool(result) +// } // Textdraw events //export onPlayerClickTextDraw -func onPlayerClickTextDraw(player, textdraw unsafe.Pointer) { +func onPlayerClickTextDraw(args *C.struct_EventArgs_onPlayerClickTextDraw) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerClickTextDraw, &PlayerClickTextDrawEvent{ - Player: &Player{handle: player}, - Textdraw: &Textdraw{handle: textdraw}, + result := event.Dispatch(Events, EventTypePlayerClickTextDraw, &PlayerClickTextDrawEvent{ + Player: &Player{handle: *args.list.player}, + Textdraw: &Textdraw{handle: *args.list.textdraw}, }) + + return C.bool(result) } //export onPlayerClickPlayerTextDraw -func onPlayerClickPlayerTextDraw(player, textdraw unsafe.Pointer) { +func onPlayerClickPlayerTextDraw(args *C.struct_EventArgs_onPlayerClickPlayerTextDraw) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerClickPlayerTextDraw, &PlayerClickPlayerTextDrawEvent{ - Player: &Player{handle: player}, - Textdraw: &PlayerTextdraw{handle: textdraw}, + eventPlayer := &Player{handle: *args.list.player} + + result := event.Dispatch(Events, EventTypePlayerClickPlayerTextDraw, &PlayerClickPlayerTextDrawEvent{ + Player: eventPlayer, + Textdraw: &PlayerTextdraw{ + handle: *args.list.textdraw, + player: eventPlayer, + }, }) + + return C.bool(result) } //export onPlayerCancelTextDrawSelection -func onPlayerCancelTextDrawSelection(player unsafe.Pointer) bool { +func onPlayerCancelTextDrawSelection(args *C.struct_EventArgs_onPlayerCancelTextDrawSelection) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypePlayerCancelTextDrawSelection, &PlayerCancelTextDrawSelectionEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerCancelTextDrawSelection, &PlayerCancelTextDrawSelectionEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onPlayerCancelPlayerTextDrawSelection -func onPlayerCancelPlayerTextDrawSelection(player unsafe.Pointer) bool { +func onPlayerCancelPlayerTextDrawSelection(args *C.struct_EventArgs_onPlayerCancelPlayerTextDrawSelection) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypePlayerCancelPlayerTextDrawSelection, &PlayerCancelPlayerTextDrawSelectionEvent{ - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypePlayerCancelPlayerTextDrawSelection, &PlayerCancelPlayerTextDrawSelectionEvent{ + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } // Vehicle events //export onVehicleStreamIn -func onVehicleStreamIn(vehicle, player unsafe.Pointer) { +func onVehicleStreamIn(args *C.struct_EventArgs_onVehicleStreamIn) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeVehicleStreamIn, &VehicleStreamInEvent{ - Vehicle: &Vehicle{handle: vehicle}, - ForPlayer: &Player{handle: player}, + result := event.Dispatch(Events, EventTypeVehicleStreamIn, &VehicleStreamInEvent{ + Vehicle: &Vehicle{handle: *args.list.vehicle}, + ForPlayer: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onVehicleStreamOut -func onVehicleStreamOut(vehicle, player unsafe.Pointer) { +func onVehicleStreamOut(args *C.struct_EventArgs_onVehicleStreamOut) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeVehicleStreamOut, &VehicleStreamOutEvent{ - Vehicle: &Vehicle{handle: vehicle}, - ForPlayer: &Player{handle: player}, + result := event.Dispatch(Events, EventTypeVehicleStreamOut, &VehicleStreamOutEvent{ + Vehicle: &Vehicle{handle: *args.list.vehicle}, + ForPlayer: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onVehicleDeath -func onVehicleDeath(vehicle, killer unsafe.Pointer) { +func onVehicleDeath(args *C.struct_EventArgs_onVehicleDeath) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeVehicleDeath, &VehicleDeathEvent{ - Vehicle: &Vehicle{handle: vehicle}, - Killer: &Player{handle: killer}, + result := event.Dispatch(Events, EventTypeVehicleDeath, &VehicleDeathEvent{ + Vehicle: &Vehicle{handle: *args.list.vehicle}, + Killer: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onPlayerEnterVehicle -func onPlayerEnterVehicle(player, vehicle unsafe.Pointer, isPassenger int) { +func onPlayerEnterVehicle(args *C.struct_EventArgs_onPlayerEnterVehicle) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerEnterVehicle, &PlayerEnterVehicleEvent{ - Player: &Player{handle: player}, - Vehicle: &Vehicle{handle: vehicle}, - IsPassenger: isPassenger != 0, + result := event.Dispatch(Events, EventTypePlayerEnterVehicle, &PlayerEnterVehicleEvent{ + Player: &Player{handle: *args.list.player}, + Vehicle: &Vehicle{handle: *args.list.vehicle}, + IsPassenger: bool(*args.list.passenger), }) + + return C.bool(result) } //export onPlayerExitVehicle -func onPlayerExitVehicle(player, vehicle unsafe.Pointer) { +func onPlayerExitVehicle(args *C.struct_EventArgs_onPlayerExitVehicle) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypePlayerExitVehicle, &PlayerExitVehicleEvent{ - Player: &Player{handle: player}, - Vehicle: &Vehicle{handle: vehicle}, + result := event.Dispatch(Events, EventTypePlayerExitVehicle, &PlayerExitVehicleEvent{ + Player: &Player{handle: *args.list.player}, + Vehicle: &Vehicle{handle: *args.list.vehicle}, }) + + return C.bool(result) } //export onVehicleDamageStatusUpdate -func onVehicleDamageStatusUpdate(vehicle, player unsafe.Pointer) { +func onVehicleDamageStatusUpdate(args *C.struct_EventArgs_onVehicleDamageStatusUpdate) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeVehicleDamageStatusUpdate, &VehicleDamageStatusUpdateEvent{ - Vehicle: &Vehicle{handle: vehicle}, - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypeVehicleDamageStatusUpdate, &VehicleDamageStatusUpdateEvent{ + Vehicle: &Vehicle{handle: *args.list.vehicle}, + Player: &Player{handle: *args.list.player}, }) + + return C.bool(result) } //export onVehiclePaintJob -func onVehiclePaintJob(player, vehicle unsafe.Pointer, paintJob int) { +func onVehiclePaintJob(args *C.struct_EventArgs_onVehiclePaintJob) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeVehiclePaintJob, &VehiclePaintJobEvent{ - Player: &Player{handle: player}, - Vehicle: &Vehicle{handle: vehicle}, - PaintJob: paintJob, + result := event.Dispatch(Events, EventTypeVehiclePaintJob, &VehiclePaintJobEvent{ + Player: &Player{handle: *args.list.player}, + Vehicle: &Vehicle{handle: *args.list.vehicle}, + PaintJob: int(*args.list.paintJob), }) + + return C.bool(result) } //export onVehicleMod -func onVehicleMod(player, vehicle unsafe.Pointer, component int) { +func onVehicleMod(args *C.struct_EventArgs_onVehicleMod) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeVehicleMod, &VehicleModEvent{ - Player: &Player{handle: player}, - Vehicle: &Vehicle{handle: vehicle}, - Component: component, + result := event.Dispatch(Events, EventTypeVehicleMod, &VehicleModEvent{ + Player: &Player{handle: *args.list.player}, + Vehicle: &Vehicle{handle: *args.list.vehicle}, + Component: int(*args.list.component), }) + + return C.bool(result) } //export onVehicleRespray -func onVehicleRespray(player, vehicle unsafe.Pointer, color1, color2 int) { +func onVehicleRespray(args *C.struct_EventArgs_onVehicleRespray) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeVehicleRespray, &VehicleResprayEvent{ - Player: &Player{handle: player}, - Vehicle: &Vehicle{handle: vehicle}, - Color: VehicleColor{Primary: color1, Secondary: color2}, + result := event.Dispatch(Events, EventTypeVehicleRespray, &VehicleResprayEvent{ + Player: &Player{handle: *args.list.player}, + Vehicle: &Vehicle{handle: *args.list.vehicle}, + Color: VehicleColor{ + Primary: int(*args.list.color1), + Secondary: int(*args.list.color2), + }, }) + + return C.bool(result) } -//export onEnterExitModShop -func onEnterExitModShop(player unsafe.Pointer, enterexit bool, interiorID int) { - defer handlePanic() +// //export onEnterExitModShop +// func onEnterExitModShop(args *C.struct_EventArgs_onEnterExitModShop) C.bool { +// defer handlePanic() - event.Dispatch(Events, EventTypeEnterExitModShop, &EnterExitModShopEvent{ - Player: &Player{handle: player}, - EnterExit: enterexit, - InteriorID: interiorID, - }) -} +// result := event.Dispatch(Events, EventTypeEnterExitModShop, &EnterExitModShopEvent{ +// Player: &Player{handle: *args.list.player}, +// EnterExit: bool(*args.list.enterexit), +// InteriorID: int(*args.list.interiorId), +// }) + +// return C.bool(result) +// } //export onVehicleSpawn -func onVehicleSpawn(vehicle unsafe.Pointer) { +func onVehicleSpawn(args *C.struct_EventArgs_onVehicleSpawn) C.bool { defer handlePanic() - event.Dispatch(Events, EventTypeVehicleSpawn, &VehicleSpawnEvent{ - Vehicle: &Vehicle{handle: vehicle}, + result := event.Dispatch(Events, EventTypeVehicleSpawn, &VehicleSpawnEvent{ + Vehicle: &Vehicle{handle: *args.list.vehicle}, }) + + return C.bool(result) } //export onUnoccupiedVehicleUpdate -func onUnoccupiedVehicleUpdate(vehicle, player unsafe.Pointer, updateData C.UnoccupiedVehicleUpdate) bool { +func onUnoccupiedVehicleUpdate(args *C.struct_EventArgs_onUnoccupiedVehicleUpdate) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypeUnoccupiedVehicleUpdate, &UnoccupiedVehicleUpdateEvent{ - Vehicle: &Vehicle{handle: vehicle}, - Player: &Player{handle: player}, + result := event.Dispatch(Events, EventTypeUnoccupiedVehicleUpdate, &UnoccupiedVehicleUpdateEvent{ + Vehicle: &Vehicle{handle: *args.list.vehicle}, + Player: &Player{handle: *args.list.player}, Update: UnoccupiedVehicleUpdate{ - Seat: int(updateData.seat), + Seat: int(*args.list.seat), Position: Vector3{ - X: float32(updateData.position.x), - Y: float32(updateData.position.y), - Z: float32(updateData.position.z), + X: float32(*args.list.posX), + Y: float32(*args.list.posY), + Z: float32(*args.list.posZ), }, Velocity: Vector3{ - X: float32(updateData.velocity.x), - Y: float32(updateData.velocity.y), - Z: float32(updateData.velocity.z), + X: float32(*args.list.velocityX), + Y: float32(*args.list.velocityY), + Z: float32(*args.list.velocityZ), }, }, }) + + return C.bool(result) } //export onTrailerUpdate -func onTrailerUpdate(player, vehicle unsafe.Pointer) bool { +func onTrailerUpdate(args *C.struct_EventArgs_onTrailerUpdate) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypeTrailerUpdate, &TrailerUpdateEvent{ - Player: &Player{handle: player}, - Vehicle: &Vehicle{handle: vehicle}, + result := event.Dispatch(Events, EventTypeTrailerUpdate, &TrailerUpdateEvent{ + Player: &Player{handle: *args.list.player}, + Trailer: &Vehicle{handle: *args.list.trailer}, }) + + return C.bool(result) } //export onVehicleSirenStateChange -func onVehicleSirenStateChange(player, vehicle unsafe.Pointer, sirenState uint8) bool { +func onVehicleSirenStateChange(args *C.struct_EventArgs_onVehicleSirenStateChange) C.bool { defer handlePanic() - return event.Dispatch(Events, EventTypeVehicleSirenStateChange, &VehicleSirenStateChangeEvent{ - Player: &Player{handle: player}, - Vehicle: &Vehicle{handle: vehicle}, - SirenState: int(sirenState), + result := event.Dispatch(Events, EventTypeVehicleSirenStateChange, &VehicleSirenStateChangeEvent{ + Player: &Player{handle: *args.list.player}, + Vehicle: &Vehicle{handle: *args.list.vehicle}, + SirenState: int(*args.list.sirenState), }) + + return C.bool(result) } diff --git a/pickup.cpp b/pickup.cpp deleted file mode 100644 index 313ee60..0000000 --- a/pickup.cpp +++ /dev/null @@ -1,67 +0,0 @@ -#include "include/pickup.h" - -extern "C" { - void* pickup_create(int modelId, uint8_t type, float posX, float posY, float posZ, uint32_t virtualWorld, int isStatic) { - return call("pickup_create", modelId, type, posX, posY, posZ, virtualWorld, isStatic); - } - - void pickup_release(void* pickup) { - return call("pickup_release", pickup); - } - - int pickup_getID(void* pickup) { - return call("pickup_getID", pickup); - } - - void pickup_setType(void* pickup, uint8_t type) { - return call("pickup_setType", pickup, type); - } - - uint8_t pickup_getType(void* pickup) { - return call("pickup_getType", pickup); - } - - void pickup_setModel(void* pickup, int model) { - return call("pickup_setModel", pickup, model); - } - - int pickup_getModel(void* pickup) { - return call("pickup_getModel", pickup); - } - - unsigned char pickup_isStreamedInForPlayer(void* pickup, void* player) { - return call("pickup_isStreamedInForPlayer", pickup, player); - } - - void pickup_setPickupHiddenForPlayer(void* pickup, void* player, unsigned char hidden) { - return call("pickup_setPickupHiddenForPlayer", pickup, player, hidden); - } - - unsigned char pickup_isPickupHiddenForPlayer(void* pickup, void* player) { - return call("pickup_isPickupHiddenForPlayer", pickup, player); - } - - void pickup_setPosition(void* pickup, float posX, float posY, float posZ) { - return call("pickup_setPosition", pickup, posX, posY, posZ); - } - - Vector3 pickup_getPosition(void* pickup) { - return call("pickup_getPosition", pickup); - } - - void pickup_setVirtualWorld(void* pickup, int vw) { - return call("pickup_setVirtualWorld", pickup, vw); - } - - int pickup_getVirtualWorld(void* pickup) { - return call("pickup_getVirtualWorld", pickup); - } - - void* playerPickup_create(void* player, int modelId, uint8_t type, float posX, float posY, float posZ, uint32_t virtualWorld, int isStatic) { - return call("playerPickup_create", player, modelId, type, posX, posY, posZ, virtualWorld, isStatic); - } - - void playerPickup_release(void* pickup, void* player) { - return call("playerPickup_release", pickup, player); - } -} diff --git a/player.cpp b/player.cpp deleted file mode 100644 index 56cb1a1..0000000 --- a/player.cpp +++ /dev/null @@ -1,679 +0,0 @@ -#include "include/player.h" - -extern "C" { - void* player_getByID(int id) { - return call("player_getByID", id); - } - - Array player_getAll() { - return call("player_getAll"); - } - - void player_sendDeathMessageToAll(void* killer, void* killee, int weapon) { - return call("player_sendDeathMessageToAll", killer, killee, weapon); - } - - void player_sendEmptyDeathMessageToAll() { - return call("player_sendEmptyDeathMessageToAll"); - } - - void player_sendGameTextToAll(String msg, int time, int style) { - return call("player_sendGameTextToAll", msg, time, style); - } - - int player_getID(void* player) { - return call("player_getID", player); - } - - void player_kick(void* player) { - return call("player_kick", player); - } - - void player_ban(void* player, String reason) { - return call("player_ban", player, reason); - } - - int player_isBot(void* player) { - return call("player_isBot", player); - } - - unsigned player_getPing(void* player) { - return call("player_getPing", player); - } - - void player_spawn(void* player) { - return call("player_spawn", player); - } - - int player_isSpawned(void* player) { - return call("player_isSpawned", player); - } - - uint8_t player_getClientVersion(void* player) { - return call("player_getClientVersion", player); - } - - String player_getClientVersionName(void* player) { - return call("player_getClientVersionName", player); - } - - void player_setPositionFindZ(void* player, float x, float y, float z) { - return call("player_setPositionFindZ", player, x, y, z); - } - - void player_setCameraPosition(void* player, float x, float y, float z) { - return call("player_setCameraPosition", player, x, y, z); - } - - Vector3 player_getCameraPosition(void* player) { - return call("player_getCameraPosition", player); - } - - void player_setCameraLookAt(void* player, float x, float y, float z, int cutType) { - return call("player_setCameraLookAt", player, x, y, z, cutType); - } - - Vector3 player_getCameraLookAt(void* player) { - return call("player_getCameraLookAt", player); - } - - void player_setCameraBehind(void* player) { - return call("player_setCameraBehind", player); - } - - void player_interpolateCameraPosition(void* player, float fromX, float fromY, float fromZ, float toX, float toY, float toZ, int time, int cutType) { - return call("player_interpolateCameraPosition", player, fromX, fromY, fromZ, toX, toY, toZ, time, cutType); - } - - void player_interpolateCameraLookAt(void* player, float fromX, float fromY, float fromZ, float toX, float toY, float toZ, int time, int cutType) { - return call("player_interpolateCameraLookAt", player, fromX, fromY, fromZ, toX, toY, toZ, time, cutType); - } - - void player_attachCameraToObject(void* player, void* object) { - return call("player_attachCameraToObject", player, object); - } - - int player_setName(void* player, String name) { - return call("player_setName", player, name); - } - - String player_getName(void* player) { - return call("player_getName", player); - } - - String player_getSerial(void* player) { - return call("player_getSerial", player); - } - - void player_giveWeapon(void* player, uint8_t id, uint32_t ammo) { - return call("player_giveWeapon", player, id, ammo); - } - - void player_removeWeapon(void* player, uint8_t weapon) { - return call("player_removeWeapon", player, weapon); - } - - void player_setWeaponAmmo(void* player, uint8_t id, uint32_t ammo) { - return call("player_setWeaponAmmo", player, id, ammo); - } - - Array* player_getWeapons(void* player) { - return call("player_getWeapons", player); - } - - WeaponSlotData player_getWeaponSlot(void* player, int slot) { - return call("player_getWeaponSlot", player, slot); - } - - void player_resetWeapons(void* player) { - return call("player_resetWeapons", player); - } - - void player_setArmedWeapon(void* player, uint32_t weapon) { - return call("player_setArmedWeapon", player, weapon); - } - - uint32_t player_getArmedWeapon(void* player) { - return call("player_getArmedWeapon", player); - } - - uint32_t player_getArmedWeaponAmmo(void* player) { - return call("player_getArmedWeaponAmmo", player); - } - - void player_setShopName(void* player, String name) { - return call("player_setShopName", player, name); - } - - String player_getShopName(void* player) { - return call("player_getShopName", player); - } - - void player_setDrunkLevel(void* player, int level) { - return call("player_setDrunkLevel", player, level); - } - - int player_getDrunkLevel(void* player) { - return call("player_getDrunkLevel", player); - } - - void player_setColour(void* player, uint32_t colour) { - return call("player_setColour", player, colour); - } - - uint32_t player_getColour(void* player) { - return call("player_getColour", player); - } - - void player_setOtherColour(void* player, void* other, uint32_t colour) { - return call("player_setOtherColour", player, other, colour); - } - - int player_getOtherColour(void* player, void* other, uint32_t* colour) { - return call("player_getOtherColour", player, other, colour); - } - - void player_setControllable(void* player, int controllable) { - return call("player_setControllable", player, controllable); - } - - int player_getControllable(void* player) { - return call("player_getControllable", player); - } - - void player_setSpectating(void* player, int spectating) { - return call("player_setSpectating", player, spectating); - } - - void player_setWantedLevel(void* player, unsigned level) { - return call("player_setWantedLevel", player, level); - } - - unsigned player_getWantedLevel(void* player) { - return call("player_getWantedLevel", player); - } - - void player_playSound(void* player, uint32_t sound, float posX, float posY, float posZ) { - return call("player_playSound", player, sound, posX, posY, posZ); - } - - uint32_t player_lastPlayedSound(void* player) { - return call("player_lastPlayedSound", player); - } - - void player_playAudio(void* player, String url, unsigned char usePos, float posX, float posY, float posZ, float distance) { - return call("player_playAudio", player, url, usePos, posX, posY, posZ, distance); - } - - int player_playerCrimeReport(void* player, void* suspect, int crime) { - return call("player_playerCrimeReport", player, suspect, crime); - } - - void player_stopAudio(void* player) { - return call("player_stopAudio", player); - } - - String player_lastPlayedAudio(void* player) { - return call("player_lastPlayedAudio", player); - } - - void player_createExplosion(void* player, float vecX, float vecY, float vecZ, int type, float radius) { - return call("player_createExplosion", player, vecX, vecY, vecZ, type, radius); - } - - void player_sendDeathMessage(void* player, void* killee, void* killer, int weapon) { - return call("player_sendDeathMessage", player, killee, killer, weapon); - } - - void player_sendEmptyDeathMessage(void* player) { - return call("player_sendEmptyDeathMessage", player); - } - - void player_removeDefaultObjects(void* player, unsigned model, float posX, float posY, float posZ, float radius) { - return call("player_removeDefaultObjects", player, model, posX, posY, posZ, radius); - } - - void player_forceClassSelection(void* player) { - return call("player_forceClassSelection", player); - } - - void player_setMoney(void* player, int money) { - return call("player_setMoney", player, money); - } - - void player_giveMoney(void* player, int money) { - return call("player_giveMoney", player, money); - } - - void player_resetMoney(void* player) { - return call("player_resetMoney", player); - } - - int player_getMoney(void* player) { - return call("player_getMoney", player); - } - - void player_setMapIcon(void* player, int id, float posX, float posY, float posZ, int type, uint32_t colour, int style) { - return call("player_setMapIcon", player, id, posX, posY, posZ, type, colour, style); - } - - void player_unsetMapIcon(void* player, int id) { - return call("player_unsetMapIcon", player, id); - } - - void player_useStuntBonuses(void* player, int enable) { - return call("player_useStuntBonuses", player, enable); - } - - void player_toggleOtherNameTag(void* player, void* other, int toggle) { - return call("player_toggleOtherNameTag", player, other, toggle); - } - - void player_setTime(void* player, int hr, int min) { - return call("player_setTime", player, hr, min); - } - - Time player_getTime(void* player) { - return call