Skip to content

Commit

Permalink
Player Rotation method
Browse files Browse the repository at this point in the history
  • Loading branch information
kodeyeen committed Apr 6, 2024
1 parent cb1388a commit 85b519d
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 45 deletions.
5 changes: 2 additions & 3 deletions include/player.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ extern "C"
{
#endif

void* player_getByID(int id);
int player_getID(void* player);

void player_kick(void* player);
Expand Down Expand Up @@ -142,6 +143,7 @@ extern "C"
// 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);

Expand All @@ -163,15 +165,12 @@ extern "C"
void* player_getVehicle(void* player);
int player_getSeat(void* player);
int player_isInModShop(void* player);
int player_isInDriveByMode(void* player);
int player_isCuffed(void* player);

// misc

float player_getDistanceFromPoint(void* player, float pX, float pY, float pZ);
void player_setFacingAngle(void* player, float angle);
float player_getFacingAngle(void* player);
Vector4 player_getRotationQuat(void* player);
int player_isInRangeOfPoint(void* player, float range, float pX, float pY, float pZ);

#ifdef __cplusplus
Expand Down
25 changes: 10 additions & 15 deletions player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,11 @@ extern "C"
{
#endif

void* player_getByID(int id)
{
return call<void*>("player_getByID", id);
}

int player_getID(void* player)
{
return call<int>("player_getID", player);
Expand Down Expand Up @@ -678,6 +683,11 @@ extern "C"
return call<Vector3>("player_getPosition", player);
}

Vector4 player_getRotation(void* player)
{
return call<Vector4>("player_getRotation", player);
}

void player_setVirtualWorld(void* player, int vw)
{
return call<void>("player_setVirtualWorld", player, vw);
Expand Down Expand Up @@ -740,16 +750,6 @@ extern "C"
return call<int>("player_isInModShop", player);
}

int player_isInDriveByMode(void* player)
{
return call<int>("player_isInDriveByMode", player);
}

int player_isCuffed(void* player)
{
return call<int>("player_isCuffed", player);
}

// misc

float player_getDistanceFromPoint(void* player, float pX, float pY, float pZ)
Expand All @@ -767,11 +767,6 @@ extern "C"
return call<float>("player_getFacingAngle", player);
}

Vector4 player_getRotationQuat(void* player)
{
return call<Vector4>("player_getRotationQuat", player);
}

int player_isInRangeOfPoint(void* player, float range, float pX, float pY, float pZ)
{
return call<int>("player_isInRangeOfPoint", player, range, pX, pY, pZ);
Expand Down
46 changes: 19 additions & 27 deletions player.go
Original file line number Diff line number Diff line change
Expand Up @@ -622,7 +622,7 @@ func (p *Player) SetChatBubble(text string, color int, drawDist float32, expire
C.player_setChatBubble(p.handle, cstr, C.uint(color), C.float(drawDist), C.int(expire.Milliseconds()))
}

func (p *Player) SendMessage(color int, msg string) {
func (p *Player) SendMessage(msg string, color int) {
cmsg := C.CString(msg)
defer C.free(unsafe.Pointer(cmsg))

Expand Down Expand Up @@ -676,8 +676,8 @@ func (p *Player) GameText(style int) *PlayerGameText {
}
}

func (p *Player) SetWeather(weatherID int) {
C.player_setWeather(p.handle, C.int(weatherID))
func (p *Player) SetWeather(weather int) {
C.player_setWeather(p.handle, C.int(weather))
}

func (p *Player) Weather() int {
Expand Down Expand Up @@ -945,6 +945,17 @@ func (p *Player) Position() Vector3 {
}
}

func (p *Player) Rotation() Vector4 {
rquat := C.player_getRotation(p.handle)

return Vector4{
X: float32(rquat.x),
Y: float32(rquat.y),
Z: float32(rquat.z),
W: float32(rquat.w),
}
}

func (p *Player) SetVirtualWorld(vw int) {
C.player_setVirtualWorld(p.handle, C.int(vw))
}
Expand Down Expand Up @@ -1009,20 +1020,16 @@ func (p *Player) VehicleSeat() int {
return int(C.player_getSeat(p.handle))
}

func (p *Player) IsInDriveByMode() bool {
return C.player_isInDriveByMode(p.handle) != 0
}

func (p *Player) IsCuffed() bool {
return C.player_isCuffed(p.handle) != 0
}

// misc

func (p *Player) DistanceFromPoint(point Vector3) float32 {
func (p *Player) DistanceFrom(point Vector3) float32 {
return float32(C.player_getDistanceFromPoint(p.handle, C.float(point.X), C.float(point.Y), C.float(point.Z)))
}

func (p *Player) IsInRangeOf(point Vector3, _range float32) bool {
return C.player_isInRangeOfPoint(p.handle, C.float(_range), C.float(point.X), C.float(point.Y), C.float(point.Z)) != 0
}

func (p *Player) SetFacingAngle(angle float32) {
C.player_setFacingAngle(p.handle, C.float(angle))
}
Expand All @@ -1031,21 +1038,6 @@ func (p *Player) FacingAngle() float32 {
return float32(C.player_getFacingAngle(p.handle))
}

func (p *Player) RotationQuat() Vector4 {
rquat := C.player_getRotationQuat(p.handle)

return Vector4{
X: float32(rquat.x),
Y: float32(rquat.y),
Z: float32(rquat.z),
W: float32(rquat.w),
}
}

func (p *Player) IsInRangeOfPoint(_range float32, point Vector3) bool {
return C.player_isInRangeOfPoint(p.handle, C.float(_range), C.float(point.X), C.float(point.Y), C.float(point.Z)) != 0
}

func (p *Player) CheckPoint() {
panic("not implemented")
}
Expand Down

0 comments on commit 85b519d

Please sign in to comment.