Sign in to follow this  

String to PlayerMp

Recommended Posts


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.`givemoney`, (player, string) => {
	//Do Something with player	


Client Side:

let player = mp.players.local;


  • Like 1

Share this post

Link to post
Share on other sites

I was searching for the first one.

I thought about doing it with an foreach loop but i hoped there would be a better possibility.

But thank you :)

  • Like 1

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.