Skip to content
This repository has been archived by the owner on Nov 7, 2023. It is now read-only.

panarama360/rager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

Releases

No releases published

Packages

No packages published