1.0.1 • Published 5 years ago

rager v1.0.1

Weekly downloads
10
License
-
Repository
github
Last release
5 years ago

Rager

This is a simple framework for RAGE MP based on typescript and decorators.

Install

npm i rager --save

Example

Create a controller

import {MyService} from "./MyService";
import {MpController, MpCommand, CurrentPlayer, Player, MpEvent} from "rager";

@MpController()
export class Controller {
    constructor(private service: MyService){}

    @MpEvent('playerJoin')
    startGame(@CurrentPlayer()player: Player){
        player.health = 100;
    }
    @MpCommand('command1')
    callCommand(@CurrentPlayer() player: Player){
        this.service.editUserSession(player);
    }
}

Create a service as needed, which will be injected into the controller (for this, you will have to set the dependency npm install typedi --save

import {Service} from "typedi";
import {Player} from 'rager'

@Service()
export class MyService {
    editUserSession(player: Player){
        player.clientSession.hello = Math.random();
    }
}

Build

import {build} from 'rager'
import {Controller} from "./Controller";
build([Controller])

Creating a decorator for a parameter

The function must be synchronous !!

export const MyDecoratorPlayer = createParamDecorator((player, args) => {
    return player;
})