Commit d2e2bb48 authored by Chris's avatar Chris

initial commit

parents
{
"extends": [
"airbnb",
"prettier",
"prettier/react"
],
"plugins": [
"prettier"
],
"env": {
"browser": true,
"node": true
},
"rules":{
"linebreak-style": 0,
"no-console":0,
"no-shadow": [2, {"allow": ["done", "query"]}],
"no-param-reassign": 0,
"no-plusplus": 0,
"no-new": 0,
"class-methods-use-this": 0,
"no-unused-vars": 0,
"consistent-return": 0,
"no-restricted-syntax": 0,
"no-else-return": 0,
"func-names": 0,
"no-use-before-define": 0,
"one-var": 0,
"prefer-destructuring": 0,
"no-continue": 0
},
"globals": {
"mp": true,
"player": true,
"console": true
}
}
\ No newline at end of file
/node_modules/*
/bridge/*
.listcache
server.exe
node.dll
conf.json
bt.dat
*.log
/plugins/*
/packages/*
/client_packages/*
/app/server/sMysql.js
/app/server/sMailer.js
\ No newline at end of file
# rageserver
Open source rage mp role play server
Hello!
All about this server you can read at:
https://rage.mp/forums/topic/1559-open-source-role-play-server/
# Installation guide:
1. Install Ragemp server.
2. Put all files in your project.
3. Run `npm i` by cmd in main directory with "server.exe" excutable script.
4. Server using MySQL as a database. So you have to import sql file in to your database. In database management make one like "ragerp".
Import sql structure file (rpserver.sql) into it.
5. Rename sMailer.js.example and sMysql.js.example to sMailer.js and sMysql.js in ./app/server/,then modify the settings.(More sMailer instructions
see https://nodemailer.com/usage/)
6. Modify files in `app` directory (if you need).
7. Do `npm run build` by cmd in main directory (BESURE DO THIS every time after some improvements in 'app' directory).
8. Start a server
THEN ENJOY.
mp.events.add({
"cGPS-CreateRoute" : (x, y) => {
mp.game.ui.setNewWaypoint(x, y);
},
});
\ No newline at end of file
"use strict"
const player = mp.players.local;
const misc = require('../cMisc');
class loginClass {
constructor() {
mp.events.add({
"cLogin-ShowLoginWindow" : () => {
misc.prepareToCef(1);
misc.createCam(3223, 5349, 14, 0, 0, 218, 20);
misc.openCef("package://RP/Browsers/Login/login.html");
},
"cLogin-ShowRegWindow" : () => {
misc.prepareToCef(1);
misc.createCam(3223, 5349, 14, 0, 0, 218, 20);
misc.openCef("package://RP/Browsers/Login/register.html");
},
});
}
}
const login = new loginClass();
const misc = require('../cMisc');
mp.events.add({
"cMenu-Open" : (lang, inject) => {
misc.prepareToCef(1);
misc.openCef("package://RP/Browsers/Menu/Menu.html", lang);
misc.injectCef(inject);
},
});
\ No newline at end of file
const misc = require('../cMisc');
let money;
mp.events.add(
{
"cMoney-Update" : (value) => money = value,
"render" : () => {
if (money >= 0 && mp.gui.cursor.visible === false) {
mp.game.graphics.drawText(`$${misc.prettify(money)} `, [0.940, 0.050], {
font: 7,
color: [115, 186, 131, 255],
scale: [0.7, 0.7],
});
}
},
"cMoney-ShowATM" : (lang, execute) => {
misc.prepareToCef(1);
misc.openCef("package://RP/Browsers/ATM/atm.html", lang);
misc.injectCef(execute);
},
"cMoney-SendNotification" : (message) => {
const maxStringLength = 99;
mp.game.ui.setNotificationTextEntry("CELL_EMAIL_BCON");
for (let i = 0, msgLen = message.length; i < msgLen; i += maxStringLength) mp.game.ui.addTextComponentSubstringPlayerName(message.substr(i, Math.min(maxStringLength, message.length - i)));
mp.game.ui.setNotificationMessage("CHAR_BANK_FLEECA", "CHAR_BANK_FLEECA", false, 2, 'FLEECA BANK', `New message`);
mp.game.ui.drawNotification(false, true);
},
});
"use strict"
const misc = require('../cMisc');
const player = mp.players.local;
class cVehicle {
constructor() {
this.fuel = null;
this.fuelRate = 0;
this.speed = 0;
mp.events.add({
"cVehicle-setFuel" : (fuel, fuelRate) => this.setFuel(fuel, fuelRate),
"playerLeaveVehicle" : () => {
if (this.fuel !== null) mp.events.callRemote('sVehicle-SetFuel', player.vehicle, this.fuel);
},
"cVehicle-setLights" : (vehicle, state) => {
vehicle.setLights(state);
},
"cVehicle-rollUpWindow" : (vehicle, window) => vehicle.rollUpWindow(window),
"cVehicle-rollDownWindow" : (vehicle, window) => vehicle.rollDownWindow(window),
"render" : () => {
this.setLightMultiplier();
this.showSpeed();
this.showFuel();
this.showBrakeLights();
},
});
}
setFuel(fuel, fuelRate, showSpeed) {
if (typeof fuel !== "number") return this.fuel = null;
this.fuel = fuel;
this.fuelRate = fuelRate;
}
setLightMultiplier() {
if (player.vehicle) player.vehicle.setLightMultiplier(4);
}
showSpeed() {
const vehicle = player.vehicle;
if (!vehicle || mp.gui.cursor.visible) return;
this.speed = misc.roundNum(vehicle.getSpeed() * 4);
mp.game.graphics.drawText(" Speed: " + this.speed + " km/h", [0.920, 0.835], {
font: 1,
color: [255, 255, 255, 255],
scale: [0.6, 0.6],
});
}
showFuel() {
const vehicle = player.vehicle;
if (mp.gui.cursor.visible || !vehicle || this.fuel === null || !vehicle.getIsEngineRunning()) return;
mp.game.graphics.drawText(" Fuel: " + this.fuel.toFixed(1) + " L", [0.927, 0.80], {
font: 1,
color: [255, 255, 255, 255],
scale: [0.6, 0.6],
});
const rpm = misc.roundNum(vehicle.rpm * 5000);
let gear = vehicle.gear;
if (gear === 0) gear = 1;
this.fuel -= (rpm + (this.speed * 400)) / gear * this.fuelRate * Math.pow(5, -13);
if (this.fuel < 0.1) mp.events.callRemote('sVehicle-SetFuel', vehicle, this.fuel);
}
showBrakeLights() {
if (!player.vehicle || this.speed !== 0) return;
player.vehicle.setBrakeLights(true);
}
getIntoVehicleAsPassenger() {
if (mp.gui.cursor.visible || player.vehicle) return;
const pos = player.position;
const vehHandle = mp.game.vehicle.getClosestVehicle(pos.x, pos.y, pos.z, 5, 0, 70);
const vehicle = mp.vehicles.atHandle(vehHandle);
if (!vehicle || !vehicle.isAnySeatEmpty() || vehicle.getSpeed() > 5) return;
for (let i = 0; i < vehicle.getMaxNumberOfPassengers(); i++) {
if (!vehicle.isSeatFree(i)) continue;
player.taskEnterVehicle(vehicle.handle, 5000, i, 1, 1, 0);
break;
}
}
}
const veh = new cVehicle();
mp.keys.bind(71, false, function() { // G
veh.getIntoVehicleAsPassenger();
});
<html>
<meta charset="utf-8">
<link rel="stylesheet" href="style.css">
<script src="../vue.js"></script>
<body>
<div id="app">
<div class="b3-close" id="close-button" @click="exit">X</div>
<div class="b1-logo logoLoading" id="logo">
<div class="logo">
<img src="../fleeca.png" height="100vh">
</div>
</div>
<div class="b1-money">
<div>
<div class="b1-summ">{{ showCash() }}</div>
<div class="b1-summ-info">{{ cashText }}</div>
</div>
<div>
<div class="b1-summ">{{ showBMoney() }}</div>
<div class="b1-summ-info">{{ bankAccountText }}</div>
</div>
<div>
<div class="b1-summ">{{ showTMoney() }}</div>
<div class="b1-summ-info">{{ taxAccountText }}</div>
</div>
<div v-if="fine !== 0">
<div class="b1-summ">{{ showFMoney() }}</div>
<div class="b1-summ-info">{{ fineAccountText }}</div>
</div>
</div>
<div class="b2-buttons" v-if="!transactionBlockSeen && !finesBlockSeen">
<div class="b2-item" @click="openTransactionBlock('getCash')">{{ takeCashText }}</div>
<div class="b2-item" @click="openTransactionBlock('putCash')">{{ putCashText }}</div>
<div class="b2-item" @click="openTransactionBlock('getTaxMoney')">{{ takeTaxMoneyText }}</div>
<div class="b2-item" @click="openTransactionBlock('putTaxMoney')">{{ putCashToTaxText }}</div>
<div class="b2-item" v-if="fine !== 0" @click="openFinesBlock">{{ payFinesText }}</div>
</div>
<div class="b3" v-if="transactionBlockSeen">
<div class="b3-close" @click="closeTransactionBlock">X</div>
<div class="b3-vars">
<div class="b2-item b3-item" v-for="cash in cashTemplate" @click="addToInput(cash.amount)">{{ prettify(cash.amount) }}</div>
<div class="b2-item b3-item-input"><input class="submit-cash" type="text" v-model.number="inputValue"></div>
<div class="b2-item b3-item-done" @click="doTransaction">{{ doneText }}</div>
</div>
</div>
<div class="b3 b3-fine" v-if="finesBlockSeen">
<div class="b3-close" @click="closeFinesBlock">X</div>
<div class="fine">
<div class="fine-item" v-for="(finee, i) in fines" @click="payFine(i)">
<span class="fine-item_price">${{ prettify(finee.val) }}</span>
<div>{{ finee.txt }}</div>
<span>{{ finee.date }}</span>
</div>
</div>
</div>
</div>
</body>
</html>
<script>
const app = new Vue({
el: '#app',
data: {
cash: 0,
bank: 0,
tax: 0,
fine: 0,
fines: [],
transactionBlockSeen: false,
finesBlockSeen: false,
transactionType: null,
cashTemplate: [
{ amount: 1000 },
{ amount: 5000 },
{ amount: 10000 },
{ amount: 25000 },
{ amount: 50000 },
{ amount: 100000 },
],
inputValue: 0,
cashText: "cash",
bankAccountText: "bank account",
taxAccountText: "tax account",
fineAccountText: "fine account",
takeCashText: "Take cash",
putCashText: "Put cash",
takeTaxMoneyText: "Take cash from tax account",
putCashToTaxText: "Put cash in tax account",
payFinesText: "Pay Fines",
doneText: "Done",
},
methods: {
prettify: function(num) {
let n = num.toString();
const separator = " ";
return n.replace(/(\d{1,3}(?=(?:\d\d\d)+(?!\d)))/g, "$1" + separator);
},
showCash: function() {
return this.prettify(this.cash);
},
showBMoney: function() {
return this.prettify(this.bank);
},
showTMoney: function() {
return this.prettify(this.tax);
},
showFMoney: function() {
return this.prettify(this.fine);
},
openTransactionBlock: function(t) {
this.transactionType = t;
this.transactionBlockSeen = true;
},
closeTransactionBlock: function() {
this.transactionType = null;
this.transactionBlockSeen = false;
this.inputValue = 0;
},
addToInput: function(value) {
this.inputValue += value;
},
doTransaction: function() {
if (this.transactionType === "getCash") this.getCash();
else if (this.transactionType === "putCash") this.putCash();
else if (this.transactionType === "getTaxMoney") this.getTaxMoney();
else if (this.transactionType === "putTaxMoney") this.putTaxMoney();
this.inputValue = 0;
},
getCash: function() {
mp.trigger("cMisc-CallServerEvent", "sMoney-GetCash", this.inputValue);
},
putCash: function() {
mp.trigger("cMisc-CallServerEvent", "sMoney-PutCash", this.inputValue);
},
getTaxMoney: function() {
mp.trigger("cMisc-CallServerEvent", "sMoney-GetTaxMoney", this.inputValue);
},
putTaxMoney: function() {
mp.trigger("cMisc-CallServerEvent", "sMoney-PutTaxMoney", this.inputValue);
},
openFinesBlock: function() {
this.finesBlockSeen = true;
},
closeFinesBlock: function() {
this.finesBlockSeen = false;
},
loadFines: function(str) {
this.fines = JSON.parse(str);
},
payFine: function(i) {
mp.trigger("cMisc-CallServerEvent", "sMoney-PayFine", i);
},
exit: function() {
mp.trigger("cCloseCef");
},
}
});
function load() {
document.getElementById("logo").classList.remove("logoLoading");
}
function loadRusLang() {
app.cashText = "наличные";
app.bankAccountText = "сберегательный счет";
app.taxAccountText = "налоговый счет";
app.fineAccountText = "штрафной счет";
app.takeCashText = "Снять наличные";
app.putCashText = "Положить наличные";
app.takeTaxMoneyText = "Снять деньги с налогового счета";
app.putCashToTaxText = "Положить деньги на налоговый счет";
app.payFinesText = "Погасить штрафы";
app.doneText = "Готово";
}
function loadGerLang() {
app.cashText = "Bargeld";
app.bankAccountText = "Sparkonto";
app.taxAccountText = "Steuerkonto";
//app.fineAccountText = "";
app.takeCashText = "Bargeld abheben";
app.putCashText = "Bargeld einzahlen";
app.takeTaxMoneyText = "Geld von einem Steuerkonto abheben";
app.putCashToTaxText = "Geld auf ein Steuerkonto einzahlen";
//app.payFinesText = "";
app.doneText = "Erledigt";
}
function loadBrLang() {
app.cashText = "Dinheiro";
app.bankAccountText = "Conta bancária";
app.taxAccountText = "Impostos";
//app.fineAccountText = "";
app.takeCashText = "Sacar dinheiro";
app.putCashText = "Depósito em dinheiro";
app.takeTaxMoneyText = "Sacar dinheiro da conta de impostos";
app.putCashToTaxText = "Depositar dinheiro em conta de imposto";
app.payFinesText = "Pagar multa";
app.doneText = "Encerrar";
}
function loadZhsLang() {
app.cashText = "现金";
app.bankAccountText = "银行账户";
app.taxAccountText = "税务账户";
app.fineAccountText = "罚款账户";
app.takeCashText = "提现";
app.putCashText = "存款";
app.takeTaxMoneyText = "从税务账户提现";
app.putCashToTaxText = "存款到税务账户";
app.payFinesText = "缴纳罚款";
app.doneText = "完成";
}
function loadZhtLang() {
app.cashText = "現金";
app.bankAccountText = "銀行帳戶";
app.taxAccountText = "稅務帳戶";
app.fineAccountText = "罰金賬戶";
app.takeCashText = "提現";
app.putCashText = "存款";
app.takeTaxMoneyText = "從稅務帳戶提現";
app.putCashToTaxText = "存款到稅務帳戶";
app.payFinesText = "繳納罰金";
app.doneText = "完成";
}
</script>
\ No newline at end of file
html {
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
font-family: Segoe UI;
font-weight: 100;
color: #DDD;
text-align: center;
}
.b3-close {
background: coral;
position: absolute;
right: 0;
top: 0;
width: 6vh;
height: 3vh;
font-size: 2vh;
transition: 0.3s;
cursor: pointer;
z-index: 2;
}
.b3-close:hover {
background: tomato;
}
.b1-logo {
background: #268F3A;
width: 100%;
position: absolute;
left: 0;
top: 0;
height: 40vh;
z-index: 1;
display: flex;
flex-wrap: wrap;
position: fixed;
transition: 1s;
}
.logoLoading {
height: 100vh;
}
.logo {
margin: auto;
}
.b1-money {
width: 100%;
background: #DDD;
position: fixed;
left: 0;
top: 40vh;
display: flex;
padding: 2vh 0;
}
.b1-money > div {
width: 100%;
text-align: center;
border-left: 1px solid #777;
}
.b1-money > div:nth-child(1) {
border-left: 1px solid transparent;
}
.b1-summ {
font-size: 3vh;
color: green;
}
.b1-summ:before {
content: "$";
}
.b1-summ-info {
font-size: 1.5vh;
color: #777;
text-transform: uppercase;
}
.b2-buttons {
display: flex;
flex-wrap: wrap;
align-items: center;
align-content: center;
width: 100%;
position: absolute;
left: 0;
height: 50vh;
bottom: 0vh;
}
.b2-item {
width: 100%;
background: #268F3A;
text-align: center;
margin: 1vh 20vw;
color: #EEE;
font-size: 2vh;
padding: 2vh 0;
text-transform: uppercase;
transition: 0.3s;
cursor: pointer;
}
.b2-item:hover {
background: green;
color: #ddd;
}
.b3 {
background-color: rgba(0, 0, 0, 0.8);
width: 75vw;
height: 40vh;
position: absolute;
left: 50vw;
bottom: 5vh;
transform: translateX(-50%);
transition: 0.3s;
}
.b3-vars {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
margin: 3vh;
margin-top: 7vh;
}
.b3-item {
width: 30%;
margin: 0;
margin-bottom: 5vh;
}
.b3-item:before {
content: "$";
}
.b3-item-input {
width: 65%;
margin: 0;
cursor: default;
position: relative;
text-align: left;