Jump to content

Recommended Posts

Posted

Hello Dear RAGE MP Community,

how can i make Variable userID for players?

Right now i should write player name to do something.

for examlpe: /goto MikeAllen

i would like to use /goto 5

just using ID for players.

how can i do this?

  • 3 weeks later...
Posted
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

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
  • Recently Browsing   0 members

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