Hi there everybody, at the moment im releasing my typescript instruments that i used to be utilizing for a few month

Be aware that this isn’t a roleplay framework!

contributions are welcome, bug stories with repro steps too

Core bundle
source code
npm package

Core bundle offers some helpful instruments and can be utilized each on shopper and server

Be aware: all the tactic decorators will be utilized to any class, however it should work solely with a category that’s embellished with Controller decorator.

Examples

Chat instructions

// utilizing instruments from core bundle
import { Command } from "./command.decorator";
import { Controller } from "./controller.decorator";

@Controller('T')
class T {
  @Command('chatCommand1', false)
  non-public chatCommandHandler1(...args: unknown[]): void {
  }

  // 2nd param is elective, false by default
  @Command('chatCommand2', true)
  non-public chatCommandHandler2(...args: unknown[]): void {
  }
}

// NOT utilizing the core bundle instruments
class T {
  constructor() {
    RegisterCommand('chatCommand1', this.chatCommandHandler1.bind(this), false)
    RegisterCommand('chatCommand2', this.chatCommandHandler2.bind(this), true)
  }

  non-public chatCommandHandler1(...args: unknown[]): void {}
  non-public chatCommandHandler2(...args: unknown[]): void {}
}

Exports

//  utilizing this bundle
import { Export } from "./export.decorator";
import { Controller } from "./controller.decorator";

@Controller('T')
class T {
  // exportName is elective, controllerName_methodName by default
  @Export('exportName')
  non-public export1(...args: unknown[]): void {}

  @Export()
  non-public export2(...args: unknown[]): void {}
}

// not utilizing this bundle
class T {
  constructor() {
    international.exports('exportName', this.export1.bind(this))
    international.exports('T_export2', this.export2.bind(this))
  }

  non-public export1(...args: unknown[]): void {}

  non-public export2(...args: unknown[]): void {}
}

Native and Web occasions

// utilizing this bundle
import { Controller } from "./controller.decorator";
import { LocalEvent } from "./local-event.decorator";
import { NetEvent } from "./net-event.decorator";

@Controller('T')
class T {
  @LocalEvent('occasion')
  non-public eventHandler(...args: unknown[]): void {}
  
  @NetEvent('netEvent')
  non-public netEventHandler(...args: unknown[]): void { }
}

// not utilizing this bundle
class T {
  constructor() {
    on('occasion', this.eventHandler.bind(this))
    onNet('netEvent', this.netEventHandler.bind(this))
  }

  non-public eventHandler(...args: unknown[]): void {}
  non-public netEventHandler(...args: unknown[]): void { }
}

Ticks

// utilizing this bundle
import { Controller } from "./controller.decorator";
import { OnTick } from "./tick.decorator";

@Controller('T')
class T {
  // interval is elective, default 0
  @OnTick(100)
  non-public tick1(...args: unknown[]): void {}

  @OnTick()
  non-public tick2(...args: unknown[]): void {}
}

// not utilizing this bundle
class T {
  constructor() {
    setInterval(this.tick1.bind(this), 100)
    setTick(this.tick2.bind(this))
  }

  non-public tick1(...args: unknown[]): void {}

  non-public tick2(...args: unknown[]): void {}
}

// Tick class
import { Tick } from "./tick";

const tick = new Tick(() => {
  console.log('in automobile')
});

on('enterVehicleEvent', () => tick.begin());

on('leaveVehicleEvent', () => tick.cease());


// You can too pause a tick for some period of time
// The instance bellow waits for 1000ms after which begins once more
tick.pause(1000)

Shopper bundle
source code
npm

This bundle offers some helpful instruments for Shopper facet solely
It makes simpler listetning to nui callbacks and dealing with keys
Examples

// key dealing with
import {Controller, Vertex} from "@vxf/core";
import {OnKeyDown} from "./key-down.decorator";
import {OnKeyUp} from "./key-up.decorator";
import {KeyBindReader} from "./key-bind.reader";

@Controller('T')
class T {
  @OnKeyUp('keyboard', 'f1', 'Description')
  non-public onKeyUp(): void {
    // triggered when key's up after urgent
  }

  @OnKeyDown('keyboard', 'f1', 'Description')
  non-public onKeyDown(): void {
    // triggered when key's down
  }
}

(() => {
  const app = new Vertex({
    controllers: [T],
    metadataReaders: [KeyBindReader],
  });

  app.begin();
})();

// That is just about the identical
class T2 {
  constructor() {
    RegisterKeyMapping('+keyup', 'Description', 'keyboard', 'f1')
    RegisterCommand('+keyup', this.onKeyUp.bind(this))
    RegisterCommand('-keyup', this.onKeyDown.bind(this))
  }

  non-public onKeyUp(): void {
    // triggered when key's up after urgent
  }

  non-public onKeyDown(): void {
    // triggered when key's down
  }
}
// nui callbacks
import {Controller, Vertex} from "@vxf/core";
import {NuiCallback} from "./nui-callback.decorator";
import {NuiReader} from "./nui.reader";

@Controller('T')
class T {
  @NuiCallback()
  non-public nuiCallback(information: unknown): quantity {
    return 228;
  }
}

(() => {
  const app = new Vertex({
    controllers: [T],
    metadataReaders: [NuiReader],
  });

  app.begin();
})();


// with out this bundle
class T2 {
  constructor() {
    // must be lowercase
    const cbName="controllerName/methodName".toLowerCase();
    international.RegisterNuiCallbackType(cbName);
    international.on?.(
      `__cfx_nui:${cbName}`,
      (information: unknown, cb: (r: unknown) => void) => {
        const end result = this.nuiCallback(information);
        if (end result instanceof Promise) {
          return end result.then(cb)
        }
        cb(end result);
      },
    );
  }


  non-public nuiCallback(information: unknown): quantity {
    return 228;
  }
}

Distant packages

There is no such thing as a readme for shopper facet, however its much like server facet distant

Server
npm
github

Shopper
npm
github

I’ve added examples to svremote bundle, it’s possible you’ll discover it helpful



Looking for paid scripts? Click here