Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

The2Alert/node-samp

Open more actions menu

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()
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);
    }
}

Todo list

Supported plugins

Package Plugin

Credits

License

MIT

About

Runtime environment Node.js in SA-MP

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.