Current collected state Current
Observed since 20 Oct, 20:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
5m-js
Helper package for FiveM JS
Helper package for FiveM.
npm i 5m-js
yarn add 5m-js
setImmediate to avoid freezing the main
thread. Refrequire("5m-js");
onNet("event-name", async () => {
const serverId = source;
const name = await I.GetPlayerName(serverId);
I.emitNet("event-name", name)
})
server.js
require("5m-js");
// calculate will be the rpc name
// when passing function, it will be registered as the rpc routine
rpc.calculate(function (playerServerId, op, x, y) {
// `playerServerId` will always passed to the rpc routine when registered in server side.
// And the rest will be the arguments passed to the rpc invocation from client.
switch (op) {
case "+":
return x + y;
case "-":
return x - y;
default:
return 0;
}
});
RegisterCommand("get-player-health", async function () {
const playerServerId = 1;
// invoking client registered rpc routine from server, playerServerId is the target player
const health = await rpc.getPlayerHealth(playerServerId)
console.log(health)
}, true);
client.js
require("5m-js");
RegisterCommand("calculate-from-server", async function () {
const r = await rpc.calculate("+", 2, 3);
console.log(r); // 5
}, false);
// registering rpc routine in clinet to be invoked from server side.
rpc.getPlayerHealth(function () {
return GetEntityHealth(PlayerPedId())
});
server.js
require("5m-js");
RegisterCommand("kill-all-players", async function() {
const players = getPlayers();
for (const p of players) {
// we need to pass the player server id (source) then the native arguments according to fivem natives.
const ped = await rpc.native.PlayerPedId(p);
await rpc.native.SetEntityHealth(p, ped, 0);
}
}, true)
let r = await httpRequest("https://httpbin.org/anything", {
method: "POST",
data: "name=5m-js",
headers: {
"Content-Type": "application/x-www-form-urlencoded"
}
})
console.log(
r.statusCode, r.body, r.headers,
)
r = await httpRequsetJson("https://httpbin.org/anything", {
method: "POST",
data: {name: "5m-js"},
headers: {
"X-Token": "123"
}
})
console.log(
r.statusCode, r.body, r.headers,
)
Download counts and popularity will appear here as the collector receives them.
| Package / target | Requirement | Relationship |
|---|---|---|
@types/nodeEnvironment{
"local_name": "@types/node",
"alias": false,
"peer_metadata": null
} | ^18.11.7 | development |
typescriptEnvironment{
"local_name": "typescript",
"alias": false,
"peer_metadata": null
} | ^4.8.4 | development |
Source distribution
{
"shasum": "1605b5b0d6763a5e124f7fb5fcf443f2382f00e5",
"integrity": "sha512-YBOyBW2ylNTVWELrmDyEdk0nOMeeEvvBvjUXcjapLCYZtdSnYaYdNJSPbCddwqiZSE7efSgs5RLo7IHvbu6QDA==",
"tarball": "https://registry.npmjs.org/5m-js/-/5m-js-0.1.1.tgz",
"fileCount": 7,
"unpackedSize": 1552,
"signatures": [
{
"keyid": "SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA",
"sig": "MEUCIESbIILRxxMAp/Gdr+zRSwcp97JQLoRdNoUMBXphhOu9AiEA9s3MEaZrgsc2IXvQ/rtep1+3jWxh4TpoNyHSmaJuM4g="
}
],
"npm-signature": "-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v4.10.10\r\nComment: https://openpgpjs.org\r\n\r\nwsFzBAEBCAAGBQJjXpDxACEJED1NWxICdlZqFiEECWMYAoorWMhJKdjhPU1b\r\nEgJ2VmrGcQ/8DLgfeJAYJHk69aAVXyT7ihG8LcEA6gDmBrfUX7BYpLttlr4v\r\nIUcIxSb+UmBdx1AOPFecAZzb/3wjSmLz61bVV92xy+dQR96CpNoaovJIVQVD\r\nR/Cz+lOC/hIV8fYimM94mLQAPoURwSMSEZcOdezGfqCNuh9QgmiRP2uBmqN9\r\nBvx6KhgTyh7iGohkrYb/mQb7UOCWykwvgdOvHkJWFTqQkNEftK3NPprUCOTq\r\njdr5usF2kRfdj/MaRhLx2ktHw8fBUU0Y1sz+doH4vZOr7C1pTKzQIDw51WYi\r\nHWagp4cP/lh4SOmk55O2GgqAVLrNuG7EYmQ//S5Zvpwh9fdzzehiOiZKUDri\r\nB4rj0aa6S4X2A5jx6OcbR079ArfVl5pQkPhZitpG7j+7xTHMhyDfA3gVSOLw\r\nBaxNMY6hycL0+Ucy51ijRk6j5UuQN7+wWQpCTnuWnS7pRL4YVC5TSuH/8PsJ\r\nPTvqAygEbZwhkb3ilvsPSlSnESNns14++TdSWOjE09NHnDvD52vangYLEX0x\r\ntfxIQj5CGQxeUh/diDYYDSYJ5hXEz5c2tCDyVsv3iScc250RU2g8XGMPq6sQ\r\nvZy+OpXmcH6zZ3TKEjgflyxP3fSOy7hL2xSZvTh2lZvNI0yqIvrl+pq+TrzG\r\nEMM7y4Q/vclPUiIi0rtDRWplD9ndcMEsre0=\r\n=JAq9\r\n-----END PGP SIGNATURE-----\r\n"
}Observed since 20 Oct, 20:37 UTC
No superseded metadata states collected. Unchanged observations do not create new revisions.
package_version:1926c318bb049168feb4e4c035338fe0292be151b2cadd4d25b0b6b25ae2dbe2