Jump to content

Changing chat color by broadcast range


edikecske

Recommended Posts

Hey, I'm struggling with a roleplay server chat. I want to make it like if a player is close he can see the text full white, but if he's further away the text turns gray for him.

I use the original rageMP chat on my server and I'm trying to make something with /say command (I'm still looking for the solution that I don't have to use /say command to chat with other players).

I searched a lot about this thing, but I couldn't find any resource for it.

Please help me :(

 

mp.events.addCommand("say", (player, message) => {
        let pos = player.position;
        
            mp.players.broadcastInRange(pos, 15, `${player.name} says: ${message}`);
 
});
Link to comment
Share on other sites

That is pretty simple script, I'll show you just part of command and you do the rest yourself.

if (target.dist(player.position) < radius / 6) { target.outputChatBox(`!{${color_2}}${message}`); } 
else if (target.dist(player.position) < radius / 4) { target.outputChatBox(`!{${color_3}}${message}`); }

 

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

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