alt-rpc
v1.0.3
Published
Lightweight RPC script for AltV Multiplayer, which allows you to make async requests with response data.
Downloads
15
Maintainers
Readme
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