Today I was thinking about making a cool script in chat, /id following the first 3 letters of a player’s name that is online, I would like this to result to print in chat that player’s ID, how many hours they have played, and how much money they have in hand.
I have attempted this but I’m not quite sure how to get the script to detect the first 3 letters and then compare them to all the online players and their names
Would appreciate it if anyone knows how to make this script and if they have time to help me out!
@codex24
I do something like this, actually it works with JS.
let players = []
let playersName = []
RegisterCommand('check', (rawCommands, args) => {
players = []
playersName = []
players = GetActivePlayers()
players.forEach(convertToObject)
let letters = args[0]
// if you type argument you will check all playerlist if not just print playerlist
if (letters)
{
let found = false
let i
// for each element i array check:
for( i = 0; i < playersName.length; i++) {
//1. if you write all name and it exist => true
if (playersName[i].name == letters) {
found = true
}
//2. when you type some letters and they exist in someone nickname => true
else if(playersName[i].name.includes(letters)) {
found = true
}
// If script find user print it to console
if (found) {
console.log(playersName[i])
break
}
}
// if not to find print to console
if (!found) console.log(`I don't find that player :v`)
}
}, false)
function convertToObject(element) {
id = element
name = GetPlayerName(element)
// transferm all nicks to lower case
name = name.toLowerCase()
const object = {'id': id, 'name': name }
playersName.push(object)
}