Files
reallife-gamemode/ReallifeGamemode.Client/Gui/handmoney.ts
2019-04-08 16:11:10 +02:00

73 lines
2.5 KiB
TypeScript

import moneyFormat from '../moneyformat';
export default function handMoney() {
var currentMoney = null;
var showMoneyChange = null;
var difference;
var screen = mp.game.graphics.getScreenResolution(0, 0);
var res_X = screen.x;
mp.events.add("SERVER:SET_HANDMONEY", (amount) => {
difference = currentMoney - amount;
if (difference != 0 && currentMoney != null) {
showMoneyChange = 1000;
}
currentMoney += amount;
});
mp.events.add("render", () => {
if (currentMoney != null) {
var numberFormat = moneyFormat(currentMoney);
if (currentMoney >= 0) {
mp.game.graphics.drawText("+$" + numberFormat, [0.96, 0.1],
{
font: 7,
color: [115, 186, 131, 255],
scale: [0.65, 0.65],
outline: false,
centre: true,
})
}
else {
mp.game.graphics.drawText("-$" + numberFormat, [0.96, 0.1],
{
font: 7,
color: [255, 0, 45, 255],
scale: [0.65, 0.65],
outline: false,
centre: true,
})
}
if (showMoneyChange > 0) {
showMoneyChange--;
if (difference > 0) {
var alpha = 255;
if (showMoneyChange <= 70) {
alpha = (showMoneyChange * (255 / 70)) | 0;
}
mp.game.graphics.drawText("- $" + moneyFormat(difference), [0.96, 0.145], {
font: 7,
color: [255, 0, 45, alpha],
scale: [0.65, 0.65],
outline: false,
centre: true
})
} else {
var nDef = difference * -1;
var alpha = 255;
if (showMoneyChange <= 70) {
alpha = (showMoneyChange * (255 / 70)) | 0;
}
mp.game.graphics.drawText("+ $" + moneyFormat(nDef), [0.96, 0.145], {
font: 7,
color: [115, 186, 131, alpha],
scale: [0.65, 0.65],
outline: false,
centre: true
})
}
}
}
});
}