Use squirrel for timestamp stuff (wtf GTAC)

This commit is contained in:
Vortrex
2022-06-27 16:39:52 -05:00
parent 91bfed4f8e
commit 5f687b7b01
3 changed files with 34 additions and 18 deletions

View File

@@ -129,6 +129,7 @@
<script src="scripts/client/netevents.js" type="client" language="javascript" />
<script src="scripts/client/skin-select.js" type="client" language="javascript" />
<script src="scripts/client/sync.js" type="client" language="javascript" />
<script src="scripts/client/time.nut" type="client" language="squirrel" />
<script src="scripts/client/utilities.js" type="client" language="javascript" />
<script src="scripts/client/vehicle.js" type="client" language="javascript" />

View File

@@ -55,24 +55,26 @@ function receiveChatBoxMessageFromServer(messageString, colour) {
// Just in case it's hidden by auto hide
//setChatWindowEnabled(true);
let colouredString = replaceColoursInMessage(messageString);
let timeStamp = getCurrentUnixTimeStampSquirrel();
let date = new Date();
let timeStampText = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
addToChatBoxHistory(messageString, colour, timeStamp);
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Changed colours in string: ${colouredString}`);
//let unixTimeStampMS = new Date().getTime();
//let timeStampDate = new Date(unixTimeStampMS);
//let timeStampDate = new Date(timeStamp);
//let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`;
addToChatBoxHistory(colouredString, colour, timeStampText);
//if(bottomMessageIndex >= chatBoxHistory.length-1) {
let outputText = colouredString;
if (chatBoxTimeStampsEnabled) {
outputText = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${colouredString}`;
let outputString = messageString;
let timeStampString = "";
if (chatBoxTimeStampsEnabled == true) {
timeStampString = `{TIMESTAMPCOLOUR}[${getTimeStampOutput(timeStamp)}]{MAINCOLOUR}`;
}
message(outputText, colour);
logToConsole(LOG_DEBUG, `[VRR.ChatBox]: Changed colours in string: ${outputString}`);
let colouredString = replaceColoursInMessage(`${timeStampString}${outputString}`);
message(colouredString, colour);
bottomMessageIndex = chatBoxHistory.length - 1;
//}
chatLastUse = getCurrentUnixTimestamp();
}
@@ -98,8 +100,8 @@ function setChatAutoHideDelay(delay) {
// ===========================================================================
function addToChatBoxHistory(messageString, colour) {
chatBoxHistory.push([messageString, colour]);
function addToChatBoxHistory(messageString, colour, timeStamp) {
chatBoxHistory.push([messageString, colour, timeStamp]);
}
// ===========================================================================
@@ -134,12 +136,17 @@ function updateChatBox() {
clearChatBox();
for (let i = bottomMessageIndex - maxChatBoxLines; i <= bottomMessageIndex; i++) {
if (typeof chatBoxHistory[i] != "undefined") {
let outputText = chatBoxHistory[i][0];
if (chatBoxTimeStampsEnabled) {
outputText = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${chatBoxHistory[i][0]}`;
let outputString = chatBoxHistory[i][0];
if (chatBoxTimeStampsEnabled == true) {
//let timeStampDate = new Date(chatBoxHistory[i][2]);
//let timeStampText = `${timeStampDate.getHours()}:${timeStampDate.getMinutes()}:${timeStampDate.getSeconds()}`;
let timeStampText = getTimeStampOutput(chatBoxHistory[i][2]);
outputString = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${chatBoxHistory[i][0]}`;
}
message(outputText, chatBoxHistory[i][1]);
replaceColoursInMessage(outputString);
message(outputString, chatBoxHistory[i][1]);
} else {
message("", COLOUR_WHITE);
}

8
scripts/client/time.nut Normal file
View File

@@ -0,0 +1,8 @@
function getCurrentUnixTimeStampSquirrel() {
return time();
}
function getTimeStampOutput(timeStamp) {
local dateObj = date(timeStamp);
return dateObj.hour + ":" + dateObj.minute + ":" + dateObj.second;
}