This repository has been archived on 2024-10-30. You can view files and clone it, but cannot push or open issues or pull requests.
rage-framework-rpc/src/util.js
2018-11-01 15:05:48 -04:00

26 lines
642 B
JavaScript

const util = {};
util.uid = () => {
let firstPart = (Math.random() * 46656) | 0;
let secondPart = (Math.random() * 46656) | 0;
firstPart = ('000' + firstPart.toString(36)).slice(-3);
secondPart = ('000' + secondPart.toString(36)).slice(-3);
return firstPart + secondPart;
};
util.getEnvironment = () => {
if(!mp) return undefined;
if(mp.joaat) return 'server';
else if(mp.game && mp.game.joaat) return 'client';
else if(mp.trigger) return 'cef';
};
util.stringifyData = (data) => {
return JSON.stringify(data);
};
util.parseData = (data) => {
return JSON.parse(data);
};
module.exports = util;