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/netevents.js" type="client" language="javascript" />
<script src="scripts/client/skin-select.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/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/utilities.js" type="client" language="javascript" />
<script src="scripts/client/vehicle.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 // Just in case it's hidden by auto hide
//setChatWindowEnabled(true); //setChatWindowEnabled(true);
let colouredString = replaceColoursInMessage(messageString); let timeStamp = getCurrentUnixTimeStampSquirrel();
let date = new Date(); addToChatBoxHistory(messageString, colour, timeStamp);
let timeStampText = `${date.getHours()}:${date.getMinutes()}:${date.getSeconds()}`;
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); let outputString = messageString;
//if(bottomMessageIndex >= chatBoxHistory.length-1) { let timeStampString = "";
if (chatBoxTimeStampsEnabled == true) {
let outputText = colouredString; timeStampString = `{TIMESTAMPCOLOUR}[${getTimeStampOutput(timeStamp)}]{MAINCOLOUR}`;
if (chatBoxTimeStampsEnabled) {
outputText = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${colouredString}`;
} }
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; bottomMessageIndex = chatBoxHistory.length - 1;
//}
chatLastUse = getCurrentUnixTimestamp(); chatLastUse = getCurrentUnixTimestamp();
} }
@@ -98,8 +100,8 @@ function setChatAutoHideDelay(delay) {
// =========================================================================== // ===========================================================================
function addToChatBoxHistory(messageString, colour) { function addToChatBoxHistory(messageString, colour, timeStamp) {
chatBoxHistory.push([messageString, colour]); chatBoxHistory.push([messageString, colour, timeStamp]);
} }
// =========================================================================== // ===========================================================================
@@ -134,12 +136,17 @@ function updateChatBox() {
clearChatBox(); clearChatBox();
for (let i = bottomMessageIndex - maxChatBoxLines; i <= bottomMessageIndex; i++) { for (let i = bottomMessageIndex - maxChatBoxLines; i <= bottomMessageIndex; i++) {
if (typeof chatBoxHistory[i] != "undefined") { if (typeof chatBoxHistory[i] != "undefined") {
let outputText = chatBoxHistory[i][0]; let outputString = chatBoxHistory[i][0];
if (chatBoxTimeStampsEnabled) { if (chatBoxTimeStampsEnabled == true) {
outputText = `{TIMESTAMPCOLOUR}[${timeStampText}]{MAINCOLOUR} ${chatBoxHistory[i][0]}`; //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 { } else {
message("", COLOUR_WHITE); 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;
}