[Release] kick strikes

02/20/2010 00:38 hunterman01#1
THIS IS FOR COEMU!

Okay so what this does is Whenever someone gets kicked It will add a strike to that person

In me and pros server you get 3 strikes you get banned automatically

NOTE This is not tested but im pretty confident it works

Also This can be used for various things like i said we use it for automatic ban

I will not be releasing that this is where u the community come in to code that

Anyway here it is

This goes in Chat.cs


Code:
case "kick":
							{
								if(CSocket.Client.isGM || CSocket.Client.isPM)
								{
                                    
									if(Command.Length < 2)
									{
										CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Command example: /kick player", Struct.ChatType.Talk));
										break;
									}
									bool kicked = false;
									//lock(Nano.ClientPool)
									//{
									try
									{
										Monitor.Enter(Nano.ClientPool);
										foreach(KeyValuePair<int, ClientSocket> Player in Nano.ClientPool)
										{
                                            
											if(Player.Value.Client.Name.ToLower() == Command[1].ToLower())
											{
												if(Player.Value.Client.isPM && !CSocket.Client.isPM)
													CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "GMs cannot kick PMs, sorry!", Struct.ChatType.Top));
												else
												{
													ConquerPacket.ToServer(ConquerPacket.Chat(0, "SYSTEM", "ALLUSERS", Player.Value.Client.Name + " has been kicked from the server", Struct.ChatType.Center), 0);
													Player.Value.Disconnect();
													kicked = true;
                                                    Player.Value.Client.KickStrikes += 1;
												}
												break;
											}
										}
									//}
									}
									catch(Exception e)
									{
										Console.WriteLine(e.ToString());
									}
									finally
									{
										Monitor.Exit(Nano.ClientPool);
									}
									if(!kicked)
									{
										CSocket.Send(ConquerPacket.Chat(0, "SYSTEM", CSocket.Client.Name, "[ERROR] Cannot kick player.", Struct.ChatType.Talk));
									}
								}
								break;
							}

This goes in Character.cs

Code:
public int KickStrikes = 0;

Last but not least This goes in Database.cs

Code:
 public static void Strikes(Character Client)
        {
            MySqlCommand Cmd = new MySqlCommand("UPDATE `characters` SET `Strikes = " +Client.KickStrikes + DatabaseConnection.NewConnection());
            Cmd.ExecuteNonQuery();
            Cmd.Connection.Close();
            Cmd.Connection.Dispose();
            Cmd.Dispose();
        }
Search for GetCharacter in Database.cs and add this at the bottom

Code:
Client.KickStrikes = Convert.ToInt32(DR["Strikes"]);
Now Search for SaveCharacter in Database.cs and add this


Code:
", `Strikes`= " + Client.KickStrikes +
Note this has not been Tested

Also

Edit your character tables According to this

Name:Strikes
Type:int
Length:11
Decimals:0
Not Null

Have Fun And tell me if it doesnt work cause i havent tested it out yet

#edit saved and loaded from db
02/20/2010 00:44 Decker_#2
Good job Hunter!
02/20/2010 00:50 ArtOfWar#3
I think this is awesome
02/20/2010 00:55 hunterman01#4
Its just a way of keeping track of how many times a player gets kicked for this release but the one in Hellmouth we got it to ban ya if u get 3

But with the one i released you can see who the trouble makers are and perhaps ban them yourself
02/20/2010 01:30 PeTe Ninja#5
You could make this easier on the person who is kicking these people..

make it check lets say

strike += 1;
switch (strike)
{
case 1: You have recieved your first strike
case 2: You have two strikes. One more and you will be banned!
case 3: You are banned from the server.. Sorry :( Please appeal your ban at the forums! Bye
}
they press okay ( npc or w.e ) and it bans them..if they don't press okay.. do like a 30 second timer.

that way you don't have to check. it will automatically do it :))

good release though, if you want a more complete ban system idea just tell me and i will "write"( not code cuz no C# here ) up and give u it.. :D
02/20/2010 03:17 hunterman01#6
Quote:
Originally Posted by PeTe Ninja View Post
You could make this easier on the person who is kicking these people..

make it check lets say

strike += 1;
switch (strike)
{
case 1: You have recieved your first strike
case 2: You have two strikes. One more and you will be banned!
case 3: You are banned from the server.. Sorry :( Please appeal your ban at the forums! Bye
}
they press okay ( npc or w.e ) and it bans them..if they don't press okay.. do like a 30 second timer.

that way you don't have to check. it will automatically do it :))

good release though, if you want a more complete ban system idea just tell me and i will "write"( not code cuz no C# here ) up and give u it.. :D
This is just a way for me to see how my players are interacting with my gms
In my code i also put it to where i can see which gm kicked the person This way i can tell if its a staff problem or not

+

I dont like using timers that often makes server laggy :)