Thread: anyone have yellmute commands

Results 1 to 4 of 4
  1. #1 anyone have yellmute commands 
    RSPS SERVICES PROVIDER

    The Plateau's Avatar
    Join Date
    May 2015
    Posts
    999
    Thanks given
    592
    Thanks received
    191
    Rep Power
    129
    hello guys anyone have commands ::yellmute and ::unyellmute for 317?
    Reply With Quote  
     

  2. #2  
    Registered Member
    Join Date
    Feb 2015
    Posts
    97
    Thanks given
    8
    Thanks received
    0
    Rep Power
    11
    You're going to need to add the toggle for if the player can yell or not. Do you already have that toggle?

    If not you can either use a variable and save it to the character or create new methods in your connection class. If you are doing it with a variable then use the following:

    Code:
    if (playerCommand.startsWith("yell"))
    {
    	String message = playerCommand.substring(5);
    	
    	if (yellMuted)
    		return;
    		
    	for (int i = 0; i < PlayerHandler.players.length; i++)
    	{
    		if (PlayerHandler.players[i] != null)
    		{
    			Client announce = (Client) PlayerHandler.players[i];
    			switch (c.playerRights)
    			{
    			
    			case 1:
    				announce.sendMessage("[Moderator] " + Misc.formatPlayerName(c.playerName) + ": " + message);
    				break;
    
                            //TODO: Add other rights and stuff here.
    			}
    		}
    	}
    }
    Code:
    if (playerCommand.startsWith("yellmute"))
    {
    	String args[] = playerCommand.split(" ");
    	String yellMute = args[1];
    	for (int i = 0; i < PlayerHandler.players.length; i++)
    	{
    		if (PlayerHandler.players[i] != null)
    		{
    			if (PlayerHandler.players[i].playerName.equalsIgnoreCase(yellMute))
    			{
    				Client target = (Client) PlayerHandler.players[i];
    				target.yellMuted = true;
    				target.sendMessage("You can no longer yell as you have been yell muted!");
    				c.sendMessage("You have yell muted: " + Misc.formatPlayerName(c.playerName) + ".");
    			}
    		}
    	}
    }
    Code:
    if (playerCommand.startsWith("unyellmute"))
    {
    	String args[] = playerCommand.split(" ");
    	String unyellMute = args[1];
    	for (int i = 0; i < PlayerHandler.players.length; i++)
    	{
    		if (PlayerHandler.players[i] != null)
    		{
    			if (PlayerHandler.players[i].playerName.equalsIgnoreCase(unyellMute))
    			{
    				Client target = (Client) PlayerHandler.players[i];
    				target.yellMuted = false;
    				target.sendMessage("You can now yell again!");
    				c.sendMessage("You have unyell muted: " + Misc.formatPlayerName(c.playerName) + ".");
    			}
    		}
    	}
    }
    Add this in your Player class.

    Code:
    public boolean yellMuted;
    Add these in your PlayerSave class.

    Code:
    characterfile.write("yell-muted");
    characterfile.write(Boolean.toString(p.yellMuted), 0, Boolean.toString(p.yellMuted).length());
    characterfile.newLine();
    Code:
    if (token.equals("yell-muted"))
    {
    	p.yellMuted = Boolean.parseBoolean(token2);
    }
    Reply With Quote  
     

  3. Thankful user:


  4. #3  
    Donator

    Join Date
    Oct 2014
    Posts
    146
    Thanks given
    5
    Thanks received
    18
    Rep Power
    4
    Quote Originally Posted by Azuline View Post
    You're going to need to add the toggle for if the player can yell or not. Do you already have that toggle?

    If not you can either use a variable and save it to the character or create new methods in your connection class. If you are doing it with a variable then use the following:

    Code:
    if (playerCommand.startsWith("yell"))
    {
    	String message = playerCommand.substring(5);
    	
    	if (yellMuted)
    		return;
    		
    	for (int i = 0; i < PlayerHandler.players.length; i++)
    	{
    		if (PlayerHandler.players[i] != null)
    		{
    			Client announce = (Client) PlayerHandler.players[i];
    			switch (c.playerRights)
    			{
    			
    			case 1:
    				announce.sendMessage("[Moderator] " + Misc.formatPlayerName(c.playerName) + ": " + message);
    				break;
    
                            //TODO: Add other rights and stuff here.
    			}
    		}
    	}
    }
    Code:
    if (playerCommand.startsWith("yellmute"))
    {
    	String args[] = playerCommand.split(" ");
    	String yellMute = args[1];
    	for (int i = 0; i < PlayerHandler.players.length; i++)
    	{
    		if (PlayerHandler.players[i] != null)
    		{
    			if (PlayerHandler.players[i].playerName.equalsIgnoreCase(yellMute))
    			{
    				Client target = (Client) PlayerHandler.players[i];
    				target.yellMuted = true;
    				target.sendMessage("You can no longer yell as you have been yell muted!");
    				c.sendMessage("You have yell muted: " + Misc.formatPlayerName(c.playerName) + ".");
    			}
    		}
    	}
    }
    Code:
    if (playerCommand.startsWith("unyellmute"))
    {
    	String args[] = playerCommand.split(" ");
    	String unyellMute = args[1];
    	for (int i = 0; i < PlayerHandler.players.length; i++)
    	{
    		if (PlayerHandler.players[i] != null)
    		{
    			if (PlayerHandler.players[i].playerName.equalsIgnoreCase(unyellMute))
    			{
    				Client target = (Client) PlayerHandler.players[i];
    				target.yellMuted = false;
    				target.sendMessage("You can now yell again!");
    				c.sendMessage("You have unyell muted: " + Misc.formatPlayerName(c.playerName) + ".");
    			}
    		}
    	}
    }
    Add this in your Player class.

    Code:
    public boolean yellMuted;
    Add these in your PlayerSave class.

    Code:
    characterfile.write("yell-muted");
    characterfile.write(Boolean.toString(p.yellMuted), 0, Boolean.toString(p.yellMuted).length());
    characterfile.newLine();
    Code:
    if (token.equals("yell-muted"))
    {
    	p.yellMuted = Boolean.parseBoolean(token2);
    }
    You should use this method (which you can put in client.java) to handle the global message sent when using yell.
    Code:
    public void sendGlobalMessage(String message) {
         for(Player p : PlayerHandler.players) {
              if(p != null) {
                   ((Client)p).sendMessage(message);
              }
         }
    }
    Reply With Quote  
     

  5. Thankful user:


  6. #4  
    RSPS SERVICES PROVIDER

    The Plateau's Avatar
    Join Date
    May 2015
    Posts
    999
    Thanks given
    592
    Thanks received
    191
    Rep Power
    129
    thanks guys no error but not working players still can yell ?
    Reply With Quote  
     


Thread Information
Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)


User Tag List

Similar Threads

  1. Anyone have a command
    By chrisbrow in forum Help
    Replies: 5
    Last Post: 03-19-2015, 06:48 PM
  2. anyone have a ::giveitem command?
    By Scenemo in forum Help
    Replies: 3
    Last Post: 05-21-2011, 06:10 PM
  3. Replies: 7
    Last Post: 10-25-2010, 10:56 AM
  4. Anyone have PI yell command
    By HiImRusty in forum Help
    Replies: 1
    Last Post: 06-14-2010, 08:00 PM
  5. Anyone have good commands?
    By Philz in forum Help
    Replies: 5
    Last Post: 02-20-2009, 05:15 AM
Posting Permissions
  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •