1.0.3 • Published 3 years ago

alt-rpc v1.0.3

Weekly downloads
4
License
ISC
Repository
github
Last release
3 years ago

alt-rpc

Lightweight RPC script for AltV Multiplayer, which allows you to make async requests with response data.


Installation

Install with npm

npm i alt-rpc --save

Examples

Client to Server

Client

import rpc from 'alt-rpc';

rpc.cts(alt, 'testRequest', 'foo') //cts -> client to server
.then(data => {
    alt.log(data); //bar
});

Server

import rpc from 'alt-rpc';

rpc.sRegister(alt, 'testRequest', (player, data)=>{ //sRegister -> server register
    alt.log(data); //foo
    return 'bar';
});

Server to Client

Server

import rpc from 'alt-rpc';

rpc.stc(alt, player, 'testRequest', 'foo') //stc -> server to client
.then(data => {
    alt.log(data); //bar
});

Client

import rpc from 'alt-rpc';

rpc.cRegister(alt, 'testRequest', (data)=>{ //cRegister -> client register
    alt.log(data); //foo
    return 'bar';
});

Web to Client

Web

import rpc from 'alt-rpc';

rpc.wtc(alt, 'testRequest', 'foo') //wtc -> web to client
.then(data => {
    alt.log(data); //bar
});

Client

import rpc from 'alt-rpc';

rpc.wcRegister(webview, 'testRequest', (data)=>{ //wcRegister -> web-client register
    alt.log(data); //foo
    return 'bar';
});

Changelog

1.0.3

  • FIX: Import file ES6 syntax error
  • FIX: Events are unsubscribed from handlers after the execution has done

To Do

  • Web to Server and Server to Web requests
1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago