Skip to content

Commit

Permalink
feat(client): Add new pool methods from sdk and add new addVolumeEffe…
Browse files Browse the repository at this point in the history
…ct channel
  • Loading branch information
xLuxy committed Nov 27, 2023
1 parent 6a06423 commit 3bf3f66
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 2 deletions.
43 changes: 43 additions & 0 deletions client/src/modules/AltModule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,45 @@ static void IsPointOnScreen(js::FunctionContext& ctx)
ctx.Return(alt::ICore::Instance().IsPointOnScreen(point));
}

static void GetPoolSize(js::FunctionContext& ctx)
{
if (!ctx.CheckArgCount(1)) return;

std::string pool;
if (!ctx.GetArg(0, pool)) return;

ctx.Return(alt::ICore::Instance().GetPoolSize(pool));
}

static void GetPoolCount(js::FunctionContext& ctx)
{
if (!ctx.CheckArgCount(1)) return;

std::string pool;
if (!ctx.GetArg(0, pool)) return;

ctx.Return(alt::ICore::Instance().GetPoolCount(pool));
}

static void GetPoolEntities(js::FunctionContext& ctx)
{
if (!ctx.CheckArgCount(1)) return;

std::string pool;
if (!ctx.GetArg(0, pool)) return;

auto entities = alt::ICore::Instance().GetPoolEntities(pool);

js::Array arr(entities.size());
for (auto entity : entities)
{
arr.Push(entity);
}

ctx.Return(arr);
}


// clang-format off
extern js::Class playerClass, localPlayerClass, vehicleClass, pedClass, objectClass,
audioClass, audioFilterClass, blipClass, markerClass, textLabelClass, checkpointClass, webViewClass, fontClass,
Expand Down Expand Up @@ -508,6 +547,10 @@ static js::Module altModule("@altv/client", "@altv/shared",
module.StaticFunction("getPedBonePos", GetPedBonePos);
module.StaticFunction("isPointOnScreen", IsPointOnScreen);

module.StaticFunction("getPoolSize", GetPoolSize);
module.StaticFunction("getPoolCount", GetPoolCount);
module.StaticFunction("getPoolEntities", GetPoolEntities);

module.Namespace(eventsNamespace);
module.Namespace(discordNamespace);
module.Namespace(voiceNamespace);
Expand Down
6 changes: 5 additions & 1 deletion types/client/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ declare module "@altv/client" {
export function getPedBonePos(scriptId: number, boneId: number): altShared.Vector3;
export function isPointOnScreen(pos: altShared.IVector3): boolean;

export function getPoolSize(pool: string): number;
export function getPoolCount(pool: string): number;
export function getPoolEntities(pool: string): Array<number>;

export interface AudioCreateOptions {
source: string;
volume: number;
Expand Down Expand Up @@ -127,7 +131,7 @@ declare module "@altv/client" {
readonly hash: number;

addRotateEffect(rate: number, priority: number): number;
addVolumeEffect(volume: number, priority: number): number;
addVolumeEffect(volume: number, priority: number, channel?: number): number;
addPeakeqEffect(band: number, bandwidth: number, q: number, center: number, gain: number, priority: number): number;
addDampEffect(target: number, quiet: number, rate: number, gain: number, delay: number, priority: number): number;
addAutowahEffect(dryMix: number, wetMix: number, feedback: number, rate: number, range: number, freq: number, priority: number): number;
Expand Down
2 changes: 1 addition & 1 deletion types/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@altv/client",
"version": "0.0.11",
"version": "0.0.12",
"description": "This package contains the type definitions for the alt:V JS module v2 client types",
"types": "index.d.ts",
"files": [
Expand Down

0 comments on commit 3bf3f66

Please sign in to comment.