Skip to content

Commit

Permalink
feat: added streamer miscellaneous natives
Browse files Browse the repository at this point in the history
  • Loading branch information
dockfries committed Sep 20, 2022
1 parent f9dcffd commit b0f8c56
Show file tree
Hide file tree
Showing 4 changed files with 105 additions and 7 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "omp-node-lib",
"version": "0.1.1",
"version": "0.1.2",
"description": "Better with omp-node-ts",
"main": "dist/bundle.js",
"types": "dist/bundle.d.ts",
Expand Down Expand Up @@ -43,7 +43,7 @@
"iconv-lite": "^0.6.3",
"lodash": "^4.17.21",
"omp-wrapper": "latest",
"omp-wrapper-streamer": "latest",
"omp-wrapper-streamer": "^0.0.9",
"pino": "^8.4.2",
"pino-pretty": "^9.1.0"
}
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions src/controllers/player/basePlayer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ import {
SendClientCheck,
SelectTextDraw,
CancelSelectTextDraw,
SelectObject,
CancelEdit,
} from "@/wrapper/functions";
import { logger } from "@/logger";
import {
Expand Down Expand Up @@ -846,4 +848,10 @@ export abstract class BasePlayer {
public cancelSelectTextDraw(): void {
CancelSelectTextDraw(this.id);
}
public selectObject(): void {
SelectObject(this.id);
}
public cancelEdit() {
CancelEdit(this.id);
}
}
92 changes: 91 additions & 1 deletion src/controllers/streamer/common/index.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,35 @@
import { BasePlayer } from "@/main";
import { BasePlayer } from "@/controllers/player";
import {
StreamerItemTypes,
Streamer_AmxUnloadDestroyItems,
Streamer_CountItems,
Streamer_CountVisibleItems,
Streamer_DestroyAllItems,
Streamer_DestroyAllVisibleItems,
Streamer_GetAllVisibleItems,
Streamer_GetCellDistance,
Streamer_GetCellSize,
Streamer_GetChunkSize,
Streamer_GetChunkTickRate,
Streamer_GetDistanceToItem,
Streamer_GetItemInternalID,
Streamer_GetItemOffset,
Streamer_GetItemPos,
Streamer_GetItemStreamerID,
Streamer_GetLastUpdateTime,
Streamer_GetMaxItems,
Streamer_GetNearbyItems,
Streamer_GetPlayerTickRate,
Streamer_GetRadiusMultiplier,
Streamer_GetTickRate,
Streamer_GetTypePriority,
Streamer_GetVisibleItems,
Streamer_IsItemVisible,
Streamer_IsToggleCameraUpdate,
Streamer_IsToggleChunkStream,
Streamer_IsToggleErrorCallback,
Streamer_IsToggleIdleUpdate,
Streamer_IsToggleItem,
Streamer_IsToggleItemCallbacks,
Streamer_IsToggleItemInvAreas,
Streamer_IsToggleItemStatic,
Expand All @@ -29,16 +42,20 @@ import {
Streamer_SetCellSize,
Streamer_SetChunkSize,
Streamer_SetChunkTickRate,
Streamer_SetItemOffset,
Streamer_SetItemPos,
Streamer_SetMaxItems,
Streamer_SetPlayerTickRate,
Streamer_SetRadiusMultiplier,
Streamer_SetTickRate,
Streamer_SetTypePriority,
Streamer_SetVisibleItems,
Streamer_ToggleAllItems,
Streamer_ToggleCameraUpdate,
Streamer_ToggleChunkStream,
Streamer_ToggleErrorCallback,
Streamer_ToggleIdleUpdate,
Streamer_ToggleItem,
Streamer_ToggleItemCallbacks,
Streamer_ToggleItemInvAreas,
Streamer_ToggleItemStatic,
Expand Down Expand Up @@ -206,6 +223,79 @@ export abstract class Streamer {
freezeplayer
);
}
public static getDistanceToItem = Streamer_GetDistanceToItem;
public static toggleItem<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
id: number,
toggle: boolean
): number {
return Streamer_ToggleItem(player.id, type, id, toggle);
}
public static isToggleItem<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
id: number
): boolean {
return Streamer_IsToggleItem(player.id, type, id);
}
public static toggleAllItems<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
toggle: boolean,
exceptions: number[] = [-1]
): number {
return Streamer_ToggleAllItems(player.id, type, toggle, exceptions);
}
public static getItemInternalID<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
streamerid: number
): number {
return Streamer_GetItemInternalID(player.id, type, streamerid);
}
public static getItemStreamerID<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
internalid: number
): number {
return Streamer_GetItemStreamerID(player.id, type, internalid);
}
public static isItemVisible<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
id: number
): boolean {
return Streamer_IsItemVisible(player.id, type, id);
}
public static destroyAllVisibleItems<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
serverwide = 1
): number {
return Streamer_DestroyAllVisibleItems(player.id, type, serverwide);
}
public static countVisibleItems<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
serverwide = 1
): number {
return Streamer_CountVisibleItems(player.id, type, serverwide);
}
public static destroyAllItems = Streamer_DestroyAllItems;
public static countItems = Streamer_CountItems;
public static getNearbyItems = Streamer_GetNearbyItems;
public static getAllVisibleItems<P extends BasePlayer>(
player: P,
type: StreamerItemTypes,
items: number[]
): void {
Streamer_GetAllVisibleItems(player.id, type, items);
}
public static getItemPos = Streamer_GetItemPos;
public static setItemPos = Streamer_SetItemPos;
public static getItemOffset = Streamer_GetItemOffset;
public static setItemOffset = Streamer_SetItemOffset;
public abstract onItemStreamIn(
type: StreamerItemTypes,
id: number,
Expand Down

0 comments on commit b0f8c56

Please sign in to comment.