Jump to content

Recommended Posts

Posted

Hi forum i have a question!

Is there a way to set a distance limit to the chat.

For example: If Player1 is more then 64blocks away from Player2 then Player1 can not read the things that Player 2 wrote.

Without  effecting commands ore thing that the server says?

 

Thanks for everybody who can help me.

Posted

Just send a packet to any client within the range that does when received creates a client-only chat message.

Yes but he wishes to rework the system so that the vanilla chat is distance based.

OP, you can't do that without editing the base code, sorry.

[shadow=gray,left][glow=red,2,300]KEEGAN[/glow][/shadow]

Posted

To prevent chat messages to arrive, you can use ServerChatEvent and event.setCanceled(true)

Than send a chat message to every player that is close enough to that player.

Posted

How to i send the message to the players who are close enough, and that i can edit the distance with items.

For Example a megaphone which at 20 blocks more distance.

 

I got this(only with same coordinates):

import cpw.mods.fml.common.eventhandler.SubscribeEvent;
import net.minecraft.entity.player.EntityPlayerMP;
import net.minecraft.server.MinecraftServer;
import net.minecraft.util.ChatComponentText;
import net.minecraftforge.event.ServerChatEvent;
import java.util.List;

public class Shortchat {

    @SubscribeEvent
    public void onServerChatEvent(ServerChatEvent event)
    {
    event.setCanceled(true);
    EntityPlayerMP sender = event.player;

        List<EntityPlayerMP> players = MinecraftServer.getServer().getConfigurationManager().playerEntityList;
        for (EntityPlayerMP receiver : players){
            if (receiver.getPlayerCoordinates().equals(sender.getPlayerCoordinates()) ){

                receiver.addChatMessage(new ChatComponentText("["+event.username+"]"+event.message));

            }
        }
    }
}

Posted

found it, this one?

public void sendToAllNearExcept(EntityPlayer p_148543_1_, double p_148543_2_, double p_148543_4_, double p_148543_6_, double p_148543_8_, int p_148543_10_, Packet p_148543_11_)
    {
        for (int j = 0; j < this.playerEntityList.size(); ++j)
        {
            EntityPlayerMP entityplayermp = (EntityPlayerMP)this.playerEntityList.get(j);

            if (entityplayermp != p_148543_1_ && entityplayermp.dimension == p_148543_10_)
            {
                double d4 = p_148543_2_ - entityplayermp.posX;
                double d5 = p_148543_4_ - entityplayermp.posY;
                double d6 = p_148543_6_ - entityplayermp.posZ;

                if (d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_)
                {
                    entityplayermp.playerNetServerHandler.sendPacket(p_148543_11_);
                }
            }
        }
    }{

Posted

I tried this,because sendToAllNearExcept is nonstatic:

What goes in "X"?

ServerConfigurationManager send1 =new ServerConfigurationManager(X) {
    @Override
    public void sendToAllNearExcept(EntityPlayer p_148543_1_, double p_148543_2_, double p_148543_4_, double p_148543_6_, double p_148543_8_, int p_148543_10_, Packet p_148543_11_) {
        super.sendToAllNearExcept(p_148543_1_, p_148543_2_, p_148543_4_, p_148543_6_, p_148543_8_, p_148543_10_, p_148543_11_);
    }
};

I only tiped this ServerConfigurationManager send1 =new ServerConfigurationManager() IDEA added the rest.

And how can items modify the talking range.

Posted

Ups what do i have to fill in for these:

EntityPlayer p_148543_1_, double p_148543_2_, double p_148543_4_, double p_148543_6_, double p_148543_8_, int p_148543_10_, Packet p_148543_11

 

Posted

Well the first parameter is the player you're not sending the packet to (

entityplayermp != p_148543_1_

).  The last one is the packet to send.

The integer right before the packet is the dimension (

entityplayermp.dimension == p_148543_10_

).

The double right before that is the radius (

d4 * d4 + d5 * d5 + d6 * d6 < p_148543_8_ * p_148543_8_

-> the distance formula, minus the square root).

The remaining three parameters are the coordinates to send around (x, y, and z in order).

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

Make that parameter a variable that changes based on [whatever you want].

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

public void sendChatMsgImpl(IChatComponent p_148544_1_, boolean p_148544_2_)

    {

        this.mcServer.addChatMessage(p_148544_1_);

        this.sendPacketToAllPlayers(new S02PacketChat(p_148544_1_, p_148544_2_));

    }

 

p_148544_1_ ist the Mesage?

And what is p_148544_2_ ?

 

Posted

I feel stupid. What Please help me!

 

X = error

 String Message2 = new String("[" + event.username + "] " + event.message);
            MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent X Message2, true);

 

Posted

IChatComponent test = new ChatComponentText("test");
            Packet message = MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent test );

 

?

Posted

That function returns void.

Apparently I'm a complete and utter jerk and come to this forum just like to make fun of people, be confrontational, and make your personal life miserable.  If you think this is the case, JUST REPORT ME.  Otherwise you're just going to get reported when you reply to my posts and point it out, because odds are, I was trying to be nice.

 

Exception: If you do not understand Java, I WILL NOT HELP YOU and your thread will get locked.

 

DO NOT PM ME WITH PROBLEMS. No help will be given.

Posted

MinecraftServer.getServer().getConfigurationManager().sendToAllNear(event.player.serverPosX, event.player.serverPosY, event.player.serverPosZ, event.player.worldObj.provider.dimensionId, rar, MinecraftServer.getServer().getConfigurationManager().sendChatMsg(IChatComponent test ));

 

Don't kill me.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  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.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.