Welcome!

Join our community of MMO enthusiasts and game developers! By registering, you'll gain access to discussions on the latest developments in MMO server files and collaborate with like-minded individuals. Join us today and unlock the potential of MMO server development!

Join Today!

Fixed mute a player

Junior Spellweaver
Joined
Jun 27, 2008
Messages
148
Reaction score
0
NOTE: THIS IS NOT TESTED. IF YOU WANT TO BE SAFE, USE GOOFY'S ORIGINAL SCRIPT. THIS WAS MAINLY MADE TO FIX THE BUG WHERE
THE PLAYER CAN LOG OFF AND BE UNMUTED. I HAVEN'T TESTED IT AS I DO NOT HAVE THE COMMAND ADDED TO MY SERVER. IF ANYONE CAN
TEST IT, PLEASE REMEMBER TO BACK UP YOUR FILES FIRST, THEN MAKE THE FOLLOWING EDITS. I WILL NOT TAKE RESPONSIBILITY IN MESSING
UP YOUR FILES.

Execute this Query:
Code:
ALTER TABLE `characters` ADD COLUMN `muted` INTEGER UNSIGNED NOT NULL DEFAULT 0 AFTER `messengerposition`;

In client.MapleCharacter.java, Find:
Code:
private boolean canDoor = true;
Under, Place:
Code:
private boolean canTalk;

Underneath:
Code:
private MapleCharacter() {

Place:
Code:
canTalk = true;

Before the last closing bracket:
PHP:
        public boolean getCanTalk() {
            return this.canTalk;
        }
        
        public boolean canTalk(boolean talk) {
            return this.canTalk = talk;            
        }

Code:
	private int guildid;
	private int guildrank;
	private MapleGuildCharacter mgc = null;
Under Add:
Code:
private int muted;

Same file, find:
Code:
ret.jobRankMove = rs.getInt("jobRankMove");
Under add:
Code:
ret.muted = rs.getInt("muted");

Same file, find:
Code:
ret.buddylist = new BuddyList(25);
Under add:
Code:
ret.muted = 0;

Same file, find:
Code:
	public BuddyList getBuddylist() {
		return buddylist;
	}

Under add:
Code:
		public int getMuted() {
		return muted;
	}
			public void setMuted(int muted) {
            this.muted = muted; 
        }


Same file, Find and Replace:
Code:
	public void saveToDB(boolean update) {
		Connection con = DatabaseConnection.getConnection();
		try {
			// clients should not be able to log back before their old state is saved (see MapleClient#getLoginState) so we are save to switch to a very low isolation level here
			con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
			// connections are thread local now, no need to
			// synchronize anymore =)
			con.setAutoCommit(false);
			PreparedStatement ps;
			if (update) {
				ps = con.prepareStatement("UPDATE characters "
					+ "SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, "
					+ "exp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, "
					+ "gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, "
					+ "meso = ?, hpApUsed = ?, mpApUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, messengerposition = ? WHERE id = ?");
			} else {
				ps = con
					.prepareStatement("INSERT INTO characters ("
						+ "level, fame, str, dex, luk, `int`, exp, hp, mp, "
						+ "maxhp, maxmp, sp, ap, gm, skincolor, gender, job, hair, face, map, meso, hpApUsed, mpApUsed, spawnpoint, party, buddyCapacity, messengerid, messengerposition, accountid, name, world"
						+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
			}
With:
Code:
	public void saveToDB(boolean update) {
		Connection con = DatabaseConnection.getConnection();
		try {
			// clients should not be able to log back before their old state is saved (see MapleClient#getLoginState) so we are save to switch to a very low isolation level here
			con.setTransactionIsolation(Connection.TRANSACTION_READ_UNCOMMITTED);
			// connections are thread local now, no need to
			// synchronize anymore =)
			con.setAutoCommit(false);
			PreparedStatement ps;
			if (update) {
				ps = con.prepareStatement("UPDATE characters "
					+ "SET level = ?, fame = ?, str = ?, dex = ?, luk = ?, `int` = ?, "
					+ "exp = ?, hp = ?, mp = ?, maxhp = ?, maxmp = ?, sp = ?, ap = ?, "
					+ "gm = ?, skincolor = ?, gender = ?, job = ?, hair = ?, face = ?, map = ?, "
					+ "meso = ?, hpApUsed = ?, mpApUsed = ?, spawnpoint = ?, party = ?, buddyCapacity = ?, messengerid = ?, messengerposition = ?, muted = ? WHERE id = ?");
			} else {
				ps = con
					.prepareStatement("INSERT INTO characters ("
						+ "level, fame, str, dex, luk, `int`, exp, hp, mp, "
						+ "maxhp, maxmp, sp, ap, gm, skincolor, gender, job, hair, face, map, meso, hpApUsed, mpApUsed, spawnpoint, party, buddyCapacity, messengerid, messengerposition, muted, accountid, name, world"
						+ ") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)");
			}
In the same file, right under, find:
Code:
 else {
                                ps.setInt(27, 0);
                                ps.setInt(28, 4);                                
                        }
                        
			if (update) {
				ps.setInt(29, id);
			} else {
				ps.setInt(29, accountid);
                                ps.setString(30, name);
				ps.setInt(31, world); // TODO store world somewhere ;)
			}
Replace it with:
Code:
                        else {
                                ps.setInt(27, 0);
                                ps.setInt(28, 4);                                
                        }
                                ps.setInt(29, muted);
                        
			if (update) {
				ps.setInt(30, id);
			} else {
				ps.setInt(30, accountid);
                                ps.setString(31, name);
				ps.setInt(32, world); // TODO store world somewhere ;)
			}

Open channel.handler.GeneralchatHandler.java and replace all with:
Code:
     /*
              This file is part of the OdinMS Maple Story Server
          Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc>
                             Matthias Butz <matze@odinms.de>
                             Jan Christian Meyer <vimes@odinms.de>
          This program is free software: you can redistribute it and/or modify
          it under the terms of the GNU Affero General Public License version 3
          as published by the Free Software Foundation. You may not use, modify
          or distribute this program under any other version of the
          GNU Affero General Public License.
          This program is distributed in the hope that it will be useful,
          but WITHOUT ANY WARRANTY; without even the implied warranty of
          MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
          GNU Affero General Public License for more details.
          You should have received a copy of the GNU Affero General Public License
          along with this program.  If not, see <http://www.gnu.org/licenses/>.
      */

      package net.sf.odinms.net.channel.handler;

      import net.sf.odinms.client.MapleClient;
      import net.sf.odinms.client.messages.CommandProcessor;
      import net.sf.odinms.net.AbstractMaplePacketHandler;
      import net.sf.odinms.tools.MaplePacketCreator;
      import net.sf.odinms.tools.StringUtil;
      import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;

      public class GeneralchatHandler extends AbstractMaplePacketHandler {
              @Override
              public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
                      String text = slea.readMapleAsciiString();
                      boolean warning;
       
                      if (!CommandProcessor.getInstance().processCommand(c, text)) {
                              if (StringUtil.countCharacters(text, '@') > 4 || StringUtil.countCharacters(text, '%') > 4 ||
                                      StringUtil.countCharacters(text, '+') > 6 || StringUtil.countCharacters(text, '$') > 6 ||
                                      StringUtil.countCharacters(text, '&') > 6 || StringUtil.countCharacters(text, '~') > 6 ||
                                      StringUtil.countCharacters(text, 'W') > 6) {
                                      text = "DISREGARD THAT, MY SERVER OWNER IS A LEECHING NOOB IF THIS ISN'T CHANGED.";
                              }
                              if (c.getPlayer().getCanTalk() == true && c.getPlayer().getMuted() == 0) {
                                  c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getChatText(c.getPlayer().getId(), text));
                              } else {
                                  c.getPlayer().getClient().getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "You have been muted and are therefore unable to talk. :D"));
                              }
                      }
              }
      }


Now finally, open client.messages.CommandProcessor.java and add:
Code:
else if (splitted[0].equals("!stfu")) {
                    try {
                    int set = Integer.parseInt(splitted[2]);
                    MapleCharacter d = c.getPlayer().getClient().getChannelServer().getPlayerStorage().getCharacterByName(splitted[1]);
                    
                    if (set == 1) {
                        if (d.getCanTalk() == true) {
                            d.canTalk(false);
							d.setMuted(1);
                            d.getClient().getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "You have been muted."));
                            mc.dropMessage(d.getName() + " has been muted.");
                        } else {
                            mc.dropMessage(d.getName() + " has already been muted");
                        }
                    }
                    if (set == 0) {
                        if (d.getCanTalk() == false) {
                            d.canTalk(true);
							d.setMuted(0);
                            d.getClient().getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "You have been unmuted."));
                            mc.dropMessage(d.getName() + " has been unmuted");
                            
                        } else {
                            mc.dropMessage(d.getName() + " can already talk.");
                        }
                         }   
                    } catch 
                            (ArrayIndexOutOfBoundsException e) {
                                mc.dropMessage("Syntax helper: !mute <Victim's name> <1 or 0 | 1 = Mute, 0 = Unmute.>");
                    }
                    catch (NullPointerException e) {
                        mc.dropMessage("Could not find " + splitted[1] + ".");
                    }
                }


Credits to iGoofy for the original, and me for the bug fix, hope this works and helps. :3
Be sure to add Goofy's first. D; I stole Goofy's post and added it here.
 
Last edited:
Newbie Spellweaver
Joined
May 12, 2008
Messages
87
Reaction score
0
Re: [Release/Testing] Fixed mute a player

Thanks I wait for this

first post

edit: Nvm I will wait some1 to cheak it the last part of maplecharcters.java
don't sim right (sorry for my english I am Israel)
 
Skilled Illusionist
Joined
Apr 4, 2008
Messages
382
Reaction score
2
Re: [Release/Testing] Fixed mute a player

As usual he does it again...takes something and makes it sexy
 
Master Summoner
Loyal Member
Joined
Nov 30, 2007
Messages
511
Reaction score
0
Re: [Release/Testing] Fixed mute a player

As usual he does it again...takes something and makes it sexy
Sexier you mean.

It's not a bug, you know. There was just no way to know whether the player was muted or not after they logged out. <_<
 
Junior Spellweaver
Joined
Jun 25, 2008
Messages
118
Reaction score
0
Re: [Release/Testing] Fixed mute a player

Very Nice Goofy and V1ral .
 
Junior Spellweaver
Joined
Apr 7, 2008
Messages
100
Reaction score
0
Re: [Release/Testing] Fixed mute a player

Lol, good thing someone used my idea and made it a release. But I had the SQL in the command and never had to mess with the savetoDB crap.
 
Junior Spellweaver
Joined
Jun 27, 2008
Messages
148
Reaction score
0
Re: [Release/Testing] Fixed mute a player

Lol, good thing someone used my idea and made it a release. But I had the SQL in the command and never had to mess with the savetoDB crap.

Did it actually save?
 
Master Summoner
Loyal Member
Joined
Apr 27, 2008
Messages
596
Reaction score
0
Re: [Release/Testing] Fixed mute a player

Its a very good idea, but.. It doesn't work for me!
EDIT: I got the original Goofy's mute.
 
Junior Spellweaver
Joined
Jul 8, 2008
Messages
164
Reaction score
0
Re: [Release/Testing] Fixed mute a player

great release i cant test atm D:
 
Experienced Elementalist
Joined
Jun 22, 2008
Messages
264
Reaction score
0
Re: [Release/Testing] Fixed mute a player

same here, i cant test it. i hope it works, cus this would really make my fwend STFU lmao xD

and good job v1ral and goofy: )
we all look forward for your future releases, if this works, i promise 3 hugs from my dog :3

(i dont have a dog)

~dXm
 
Banned
Banned
Joined
Apr 10, 2008
Messages
1,295
Reaction score
113
Re: [Release/Testing] Fixed mute a player

Don't the things have to be tested before release? :p
 
Junior Spellweaver
Joined
Jan 15, 2007
Messages
181
Reaction score
0
Re: [Release/Testing] Fixed mute a player

I get loads of errors o-o

init:
deps-jar:
Compiling 1 source file to C:\Documents and Settings\kidsadmin\AmoraMS\build\classes
C:\Documents and Settings\kidsadmin\Desktop\Server\src\net\sf\odinms\net\channel\handler\GeneralchatHandler.java:34: cannot find symbol
symbol : method getInstance()
location: class net.sf.odinms.client.messages.CommandProcessor
if (!CommandProcessor.getInstance().processCommand(c, text)) {
C:\Documents and Settings\kidsadmin\Desktop\Server\src\net\sf\odinms\net\channel\handler\GeneralchatHandler.java:41: cannot find symbol
symbol : method getCanTalk()
location: class net.sf.odinms.client.MapleCharacter
if (c.getPlayer().getCanTalk() == true && c.getPlayer().getMuted() == 0) {
C:\Documents and Settings\kidsadmin\Desktop\Server\src\net\sf\odinms\net\channel\handler\GeneralchatHandler.java:42: getChatText(int,java.lang.String,int) in net.sf.odinms.tools.MaplePacketCreator cannot be applied to (int,java.lang.String)
c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getChatText(c.getPlayer().getId(), text));
3 errors
BUILD FAILED (total time: 0 seconds)
 
Junior Spellweaver
Joined
Jan 15, 2007
Messages
181
Reaction score
0
Re: [Release/Testing] Fixed mute a player

I added goofys then yours compilation error.

Then tried your compilations error.
 
Junior Spellweaver
Joined
Jun 27, 2008
Messages
148
Reaction score
0
Re: [Release/Testing] Fixed mute a player

Let me go add Goofy's and test it out. D: God.
 
Junior Spellweaver
Joined
May 3, 2007
Messages
135
Reaction score
3
Re: [Release/Testing] Fixed mute a player

aww man please fix this asap T.T I need it instead of jailing and banning people XD BTW. Good Job :D
 
Junior Spellweaver
Joined
Jun 27, 2008
Messages
148
Reaction score
0
Re: [Release/Testing] Fixed mute a player

PHP:
/*
	This file is part of the OdinMS Maple Story Server
    Copyright (C) 2008 Patrick Huy <patrick.huy@frz.cc> 
                       Matthias Butz <matze@odinms.de>
                       Jan Christian Meyer <vimes@odinms.de>

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License version 3
    as published by the Free Software Foundation. You may not use, modify
    or distribute this program under any other version of the
    GNU Affero General Public License.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Affero General Public License for more details.

    You should have received a copy of the GNU Affero General Public License
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
*/

package net.sf.odinms.net.channel.handler;

import net.sf.odinms.client.MapleClient;
import net.sf.odinms.client.messages.CommandProcessor;
import net.sf.odinms.net.AbstractMaplePacketHandler;
import net.sf.odinms.tools.MaplePacketCreator;
import net.sf.odinms.tools.StringUtil;
import net.sf.odinms.tools.data.input.SeekableLittleEndianAccessor;

public class GeneralchatHandler extends AbstractMaplePacketHandler {
	@Override
	public void handlePacket(SeekableLittleEndianAccessor slea, MapleClient c) {
		String text = slea.readMapleAsciiString();

		if (!CommandProcessor.processCommand(c, text)) {
			if (StringUtil.countCharacters(text, '@') > 4 || StringUtil.countCharacters(text, '%') > 4 ||
				StringUtil.countCharacters(text, '+') > 6 || StringUtil.countCharacters(text, '$') > 6 ||
				StringUtil.countCharacters(text, '&') > 6 || StringUtil.countCharacters(text, '~') > 6 ||
				StringUtil.countCharacters(text, 'W') > 6) {
				text = "DISREGARD THAT I SUCK penis";
			}
			if(!c.getPlayer().isHidden())
			c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.getChatText(c.getPlayer().getId(), text, c.getPlayer().isGM() ? 1 : 0));
                    else {
                         if (c.getPlayer().getMuted() == 0 || c.getPlayer().getCanTalk() == true) {
                            c.getPlayer().getMap().broadcastMessage(MaplePacketCreator.serverNotice(2, c.getPlayer().getName() + " : " + text));
                        } else {
                            c.getPlayer().getClient().getChannelServer().broadcastPacket(MaplePacketCreator.serverNotice(6, "You have been muted and are therefore unable to talk. :D"));
                        }
		}
	}
}
}
Use that as GeneralchatHandler.java, it should fix all the problems. :3
 
Skilled Illusionist
Joined
May 12, 2008
Messages
321
Reaction score
0
Re: [Release/Testing] Fixed mute a player

Nvm fixed, ily.
 
Back
Top