72 lines
2.5 KiB
TypeScript
72 lines
2.5 KiB
TypeScript
import moneyFormat from '../moneyformat';
|
|
|
|
export default function handMoney(globalData: IGlobalData) {
|
|
var currentMoney = null;
|
|
var showMoneyChange = null;
|
|
var difference;
|
|
|
|
mp.events.add("SERVER:SET_HANDMONEY", (amount) => {
|
|
difference = currentMoney - amount;
|
|
if (difference != 0 && currentMoney != null) {
|
|
showMoneyChange = 600;
|
|
}
|
|
currentMoney = amount;
|
|
});
|
|
|
|
mp.events.add("render", () => {
|
|
if (globalData.HideGui) return;
|
|
if (currentMoney != null) {
|
|
var numberFormat = moneyFormat(Math.abs(currentMoney));
|
|
if (currentMoney >= 0) {
|
|
mp.game.graphics.drawText("$" + numberFormat, [0.95, 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.95, 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(Math.abs(difference)), [0.95, 0.145], {
|
|
font: 7,
|
|
color: [255, 0, 45, alpha],
|
|
scale: [0.65, 0.65],
|
|
outline: false,
|
|
centre: true
|
|
})
|
|
|
|
} else {
|
|
var alpha = 255;
|
|
if (showMoneyChange <= 70) {
|
|
alpha = (showMoneyChange * (255 / 70)) | 0;
|
|
}
|
|
mp.game.graphics.drawText("+$" + moneyFormat(Math.abs(difference)), [0.95, 0.145], {
|
|
font: 7,
|
|
color: [115, 186, 131, alpha],
|
|
scale: [0.65, 0.65],
|
|
outline: false,
|
|
centre: true
|
|
})
|
|
}
|
|
}
|
|
}
|
|
});
|
|
} |