Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

History

23 Commits

Repository files navigation


Runtime environment Node.js in SA-MP.

Documentation

Documentation is here.

Getting started

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

Getting Started with Docker

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

Example

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()exportclassModePlayerextendsPlayer.Context{publicreadonlyvehicles: Group<Vehicle>=newGroup;publiconConnect(): boolean{this.send(`Hello, ${this}!`);returntrue;}publiconRequestClass(): 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();}publiconDisconnect(): void{this.vehicles.destroy();}
@Key(Keys.YES)publichandleKeyYes(): void{this.spawn();}
@Key(Keys.NO)publichandleKeyNo(): void{this.vehicles.destroy();}
@Command("spawn")
@Alt("s")publicspawnPlayer(): void{this.spawn();}
@Command("pos")publicsetPosition(@Param()x: number, @Param()y: number, @Param()z: number): void{this.pos={x, y, z};}
@Command("veh")publiccreateVehicle(@ParamInt()model: number, @ParamInt()color1: number, @ParamInt()color2: number): void{const{x, y, z}: Position=this.pos;constrotation: number=this.angle;constvehicle: Vehicle=Vehicle.create({x, y, z, model,colors: [color1,color2], rotation});if(this.isInAnyVehicle())this.vehicle.destroy();this.put(vehicle);this.vehicles.push(vehicle);}}

Todo list

Supported plugins

PackagePlugin

Credits

License

MIT

About

Runtime environment Node.js in SA-MP

Topics

Resources

Stars

22 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors