Runtime environment Node.js in SA-MP.
Documentation is here.
Preliminary requirements:
Installation and start on TypeScript:
git clone https://github.com/dev2alert/node-samp-starter.git my-server
cd ./my-server
npm i
npm run compile
npm start
Installation and start on JavaScript:
git clone https://github.com/dev2alert/node-samp-javascript-starter.git my-server
cd ./my-server
npm i
npm start
Start in development mode:
npm run dev
Preliminary requirements:
Installation:
git clone https://github.com/dev2alert/node-samp-docker-starter.git my-server
cd ./my-server
npm i
Build and run:
npm run compile
make -B build
make run
Using Context API and TypeScript:
import {Group, Keys, Player, Position, Vehicle, Weapons} from "@sa-mp/core";
import {Alt, Command, Context, Key, Param, ParamInt} from "@sa-mp/decorators";
@Context()
export class ModePlayer extends Player.Context {
public readonly vehicles: Group<Vehicle> = new Group;
public onConnect(): boolean {
this.send(`Hello, ${this}!`);
return true;
}
public onRequestClass(): void {
this.spawnInfo({x: 1906.2207, y: -2429.4124, z: 13.5391, team: 0, skin: 68, rotation: 0, weapons: [{type: Weapons.AK47, ammo: 89}]});
this.spawn();
}
public onDisconnect(): void {
this.vehicles.destroy();
}
@Key(Keys.YES)
public handleKeyYes(): void {
this.spawn();
}
@Key(Keys.NO)
public handleKeyNo(): void {
this.vehicles.destroy();
}
@Command("spawn")
@Alt("s")
public spawnPlayer(): void {
this.spawn();
}
@Command("pos")
public setPosition(@Param() x: number, @Param() y: number, @Param() z: number): void {
this.pos = {x, y, z};
}
@Command("veh")
public createVehicle(@ParamInt() model: number, @ParamInt() color1: number, @ParamInt() color2: number): void {
const {x, y, z}: Position = this.pos;
const rotation: number = this.angle;
const vehicle: Vehicle = Vehicle.create({x, y, z, model, colors: [color1, color2], rotation});
if(this.isInAnyVehicle())
this.vehicle.destroy();
this.put(vehicle);
this.vehicles.push(vehicle);
}
}
- Updating Node.js up to version 16.13.2!
- Write documentation.
- Add Streamer plugin support.
- Add CrashDetect plugin support.
- Add FCNPC plugin support.
- Add Jest testing support.
- Add Typeorm support.
- Add SAMPVOICE plugin support.
- Add SAMP CEF plugin support.
- Create SA-MP Extension.
Package | Plugin |
---|---|