Jump to content
RAGE Multiplayer Community

How to create player ID?


LT.Steiner
 Share

Recommended Posts

  • 3 weeks later...
mp.events.addCommand('heal', (player, _, playerID, health) => {// ok admin
	if (playerID && playerID.trim().length > 0 && health)
	{
		const giveplayer = findRageMpPlayer(playerID);
		if (giveplayer)
		{
			if (health >= 0 || health <= 100)
			{
				giveplayer.health = health;
			}
			else return player.outputChatBox(`[Usage]: /heal [PlayerID/PartieDuNom] [Ammount]`);
		}
		else return player.notify(`Player not connected`);
	}
	else return player.outputChatBox(`[Usage]: /heal [PlayerID/PartieDuNom] [Ammount]`);
});

function findRageMpPlayer(playerNameOrPlayerId) {
  if (playerNameOrPlayerId == parseInt(playerNameOrPlayerId)) {
    return mp.players.at(playerNameOrPlayerId);
  }
  else
  {
    let foundPlayer = null;
    mp.players.forEach((rageMpPlayer) => {
        if (rageMpPlayer.name.toLowerCase().startsWith(playerNameOrPlayerId.toLowerCase())) {
          foundPlayer = rageMpPlayer;
          return;
        }
    });
    return foundPlayer;
  }
}

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...