Server-Side:
When you want to find a certain player, that didn't call the command, you could use that:
/**
* @author Paccoderpster
* @description With that function you can find a certain player
* @param {str} name The name of the player
* @returns {player}, if the player is found or null, if this player isn't logged in
*/
global.findPlayer = function findPlayer(name) {
let players = mp.players.toArray();
for(let p in players) {
if(players[p].name == name) {
return players[p];
}
}
return null;
}
Or, if you want the player object from the player that called the command, you don't have to do anything.
mp.events.addCommand(`givemoney`, (player, string) => {
//Do Something with player
});
Client Side:
let player = mp.players.local;