diff --git a/scripts/server/ban.js b/scripts/server/ban.js index a85ed259..6f42cd31 100644 --- a/scripts/server/ban.js +++ b/scripts/server/ban.js @@ -252,13 +252,9 @@ function unbanSubNet(ipAddressStart, ipAddressEnd, adminAccountId) { // =========================================================================== function isAccountBanned(accountId) { - let bans = getServerData().bans; - for(let i in bans) { - if(bans[i].type == VRR_BANTYPE_ACCOUNT) { - if(bans[i].detail == accountId) { - return true; - } - } + let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_ACCOUNT && ban.detail === accountId); + if(bans.length > 0) { + return true; } return false; @@ -267,13 +263,9 @@ function isAccountBanned(accountId) { // =========================================================================== function isSubAccountBanned(subAccountId) { - let bans = getServerData().bans; - for(let i in bans) { - if(bans[i].type == VRR_BANTYPE_SUBACCOUNT) { - if(bans[i].detail == subAccountId) { - return true; - } - } + let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_SUBACCOUNT && ban.detail === subAccountId); + if(bans.length > 0) { + return true; } return false; @@ -282,13 +274,9 @@ function isSubAccountBanned(subAccountId) { // =========================================================================== function isIpAddressBanned(ipAddress) { - let bans = getServerData().bans; - for(let i in bans) { - if(bans[i].type == VRR_BANTYPE_IPADDRESS) { - if(bans[i].detail == ipAddress) { - return true; - } - } + let bans = getServerData().bans.filter(ban => ban.type === VRR_BANTYPE_IPADDRESS && ban.detail === ipAddress); + if(bans.length > 0) { + return true; } return false; diff --git a/scripts/server/business.js b/scripts/server/business.js index 7fef45b0..c49eb913 100644 --- a/scripts/server/business.js +++ b/scripts/server/business.js @@ -2394,26 +2394,14 @@ function stockItemOnBusinessFloorCommand(command, params, client) { // Gets the first free slot in a business's storage items function getBusinessStorageFirstFreeItemSlot(businessId) { - for(let i in getBusinessData(businessId).storageItemCache) { - if(getBusinessData(businessId).storageItemCache[i] == -1) { - return i; - } - } - - return -1; + return getBusinessData(businessId).storageItemCache.findIndex(item => item == -1); } // =========================================================================== // Gets the first free slot in a business's floor items function getBusinessFloorFirstFreeItemSlot(businessId) { - for(let i in getBusinessData(businessId).floorItemCache) { - if(getBusinessData(businessId).floorItemCache[i] == -1) { - return i; - } - } - - return -1; + return getBusinessData(businessId).floorItemCache.findIndex(item => item == -1); } // =========================================================================== @@ -2449,13 +2437,7 @@ function cacheBusinessItems(businessId) { // Gets a business's data index from a business's databaseId function getBusinessIdFromDatabaseId(databaseId) { - for(let i in getServerData().businesses) { - if(getBusinessData(i).databaseId == databaseId) { - return i; - } - } - - return false; + return getServerData().businesses.findIndex(business => business.databaseId == databaseId); } // =========================================================================== diff --git a/scripts/server/item.js b/scripts/server/item.js index f76bad50..648a1763 100644 --- a/scripts/server/item.js +++ b/scripts/server/item.js @@ -995,10 +995,10 @@ function playerUseItem(client, hotBarSlot) { let clients = getClients(); for(let i in clients) { if(getDistance(getPlayerPosition(client), getPlayerPosition(clients[i])) <= 7) { - messagePlayerInfo(client, `{clanOrange}== {jobYellow}Badge {clanOrange}====================================`); - messagePlayerNormal(client, `{clanOrange}Name: {MAINCOLOUR}${getCharacterFullName(client)}`); - messagePlayerNormal(client, `{clanOrange}Type: {MAINCOLOUR}${getJobData(getPlayerJob(client)).name}`); - messagePlayerNormal(client, `{clanOrange}Rank: {MAINCOLOUR}${getJobRankName(getPlayerJob(client), getPlayerJobRank(client))}`); + makeChatBoxSectionHeader(clients[i], getLocaleString(client, "Badge", getCharacterFullName(client))); + messagePlayerNormal(client, `{clanOrange}Type:{MAINCOLOUR} ${getJobData(getPlayerJob(client)).name}`); + messagePlayerNormal(client, `{clanOrange}ID:{MAINCOLOUR} ${addPrefixNumberFill(getPlayerCurrentSubAccount(client).databaseId, 5)}`); + messagePlayerNormal(client, `{clanOrange}Rank:{MAINCOLOUR} ${getJobRankName(getPlayerJob(client), getPlayerJobRank(client))}`); } } break; diff --git a/scripts/server/utilities.js b/scripts/server/utilities.js index f9402b31..f145ecbc 100644 --- a/scripts/server/utilities.js +++ b/scripts/server/utilities.js @@ -509,3 +509,13 @@ function getPlayerConnectionsInLastMonthByName(name) { } // =========================================================================== + +function addPrefixNumberFill(number, amount) { + let numberString = toString(number); + while(numberString.length < amount) { + numberString = toString(`0${numberString}`); + } + return toString(numberString); +} + +// =========================================================================== \ No newline at end of file diff --git a/scripts/shared/utilities.js b/scripts/shared/utilities.js index af79a41c..a698e3c5 100644 --- a/scripts/shared/utilities.js +++ b/scripts/shared/utilities.js @@ -1389,9 +1389,7 @@ function Enum(constantsList) { // =========================================================================== function clearArray(array) { - if(array != null) { - array.splice(0, array.length); - } + array.length = 0; } // ===========================================================================