private static void Process_MakeGm(Player client, string[] command)
{
if (client.Account.Permission < PlayerPermission.GO)
return;
if (client.Account.Permission < PlayerPermission.GO)
return;
if (command.Length < 2)
client.SendMessage("Error: Proper format is /makegm PlayerName");
else
{
Player target = null;
foreach (var p in Managers.PlayerManager.Players.Values)
if (p.Name.ToLower() == command[1].ToLower() || p.Name.ToLower() + "[gm]" == command[1].ToLower())
{
target = p;
break;
}
if (target == null)
client.SendMessage(command[1] + " is not online or could not be found");
else
{
Managers.PlayerManager.SendToServer(new TalkPacket(ChatType.GM, client.Name + ": User " + target.Name + " has been promoted to GM"));
target.SendMessage("Congratulations! " + target.Name + " You have been made a GM by " + client.Name + "!", ChatType.System);
target.SendMessage("You are now being sent to his location", ChatType.System);
target.ChangeMap(client.MapID, client.X, client.Y);
client.SendMessage(target.Name + "is being sent to you location", ChatType.System);
target.Account.Permission = PlayerPermission.GM ;
using (var session = NHibernateHelper.OpenSession())
{
var t = session.CreateSQLQuery("UPDATE Accounts SET Permission=5 WHERE UID=" + target.UID);
t.ExecuteUpdate();
}
using (var session = NHibernateHelper.OpenSession())
{
var b = session.CreateSQLQuery("UPDATE Characters SET Name='" + target.Name +"[GM]' WHERE Name='" + target.Name+ "'");
b.ExecuteUpdate();
}
target.Name += "[GM] ";
target.Save();
}
}
}
under the
Code:
Process_Report
code ending
6) To use this command your account Permission must be set to 6
8) To use this command type /makegm PlayerName
private static void Process_Ban(Player client, string[] command)
{
if (client.Account.Permission < PlayerPermission.GM)
return;
if (client.Account.Permission < PlayerPermission.GM)
return;
if (command.Length < 2)
client.SendMessage("Error: Proper format is /ban PlayerName");
else
{
Player target = null;
foreach (var p in Managers.PlayerManager.Players.Values)
if (p.Name.ToLower() == command[1].ToLower() || p.Name.ToLower() + "[gm]" == command[1].ToLower())
{
target = p;
break;
}
if (target == null)
client.SendMessage(command[1] + " is not online or could not be found");
else
{
target.Disconnect();
client.SendMessage(target.Name + "has been banned");
target.Account.Permission = PlayerPermission.Banned;
Managers.PlayerManager.SendToServer(new TalkPacket(ChatType.GM, client.Name + ": User " + target.Name + " has been banned"));
using (var session = NHibernateHelper.OpenSession())
{
var t = session.CreateSQLQuery("UPDATE Accounts SET Permission=255 WHERE UID=" + target.UID);
t.ExecuteUpdate();
}
target.Save();
target.Disconnect();
}
}
}
private static void Process_UnBan(Player client, string[] command)
{
if (client.Account.Permission < PlayerPermission.GM)
return;
if (client.Account.Permission < PlayerPermission.GM)
return;
if (command.Length < 2)
client.SendMessage("Error: Proper format is /unban PlayerUID");
else
{
client.SendMessage(command + " has been unbanned");
Managers.PlayerManager.SendToServer(new TalkPacket(ChatType.GM, client.Name + ": User " + command[1] + " has been unbanned"));
using (var session = NHibernateHelper.OpenSession())
{
var t = session.CreateSQLQuery("UPDATE Accounts SET Permission=1 WHERE UID=" + command[1]);
t.ExecuteUpdate();
}
}
}
under the
Code:
Process_Report
code ending
5) To use this command you will need the players UID
6) To use the command type /unban PlayerUID
Random rnd = new Random();
int Valcp = rnd.Next(1, 100);
uint ConvVal = Convert.ToUInt32(Valcp);
killer.CP += ConvVal;
killer.SendSysMessage("You have gotten " + ConvVal + " cps from monster kill");
killer.Save()
4) To change the random values change the two numbers in the brackets rnd.Next(1, 100) e.g you want a drop from 200 to 250 so the numbers in the brackets are going to be like this rnd.Next(200, 250)
if (BaseMonster.ID == 0018)
{
var info = Database.ServerDatabase.Context.ItemInformation.GetById(1072048);
var item = new ConquerItem((uint)Common.ItemGenerator.Counter, info);
killer.AddItem(item);
killer.Send(ItemInformationPacket.Create(item));
killer.SendSysMessage("Item Dropped");
}
4) Next replace these codes (all of them in Monster.cs)
Code:
ClientStatus.ReviveProtection
with this :
Code:
Redux.Enum.ClientStatus.ReviveProtection
this is to avoid conflicts
5) To change which monster you want to drop the item change the id in the brackets (BaseMonster.ID == 0018)
6) To change the item that you want that monster to drop change the id from the brackets GetById(1072048)
7) You can use the itemtype.dat to find the item id and the Monster.dat to find the mob id (TypeID= MonsterID)
8) You can download both decrypted here : &
More will come soon if you have a cool codes post it here ill include it in the post lets make a redux code thread
Random rnd = new Random();
int Valcp = rnd.Next(1, 100);
killer.CP += ConvVal;
killer.SendSysMessage("You have gotten " + ConvVal + " cps from monster kill");
killer.Save()
You can just typecast ConvVal to to a uint.
killer.CP += (uint) ConvVal;
Instead of converting it to a uint. Just a friendly tip.
Keep on working on programming. Though this release may seem minimal to some, it's a start on the path to learning.
And here are some more tips.
Code:
Random rnd = new Random();
This is a very bad idea. The random generator in C# is horrible and using it like this will most likely produce invalid values and in worst cases the same value over and over.
Instead provide a static thread local random generator.
Code:
int Valcp = rnd.Next(1, 100);
You can use var.
Code:
killer.SendSysMessage("You have gotten " + ConvVal + " cps from monster kill");
"Why the **** is setting this integer crashing my ******* server?! Oh, it's not. This is a property that the debugger skips over, and it's actually the database save method crashing my **** because I changed the table structure. Wow do C# properties suck ***." Just another horrible Microsoftism.
"Why the **** is setting this integer crashing my ******* server?! Oh, it's not. This is a property that the debugger skips over, and it's actually the database save method crashing my **** because I changed the table structure. Wow do C# properties suck ***." Just another horrible Microsoftism.
What? Are you for real? I cannot decide if you're a bot or a troll.
This is a very bad idea. The random generator in C# is horrible and using it like this will most likely produce invalid values and in worst cases the same value over and over.
Instead provide a static thread local random generator.
Code:
int Valcp = rnd.Next(1, 100);
You can use var.
Code:
killer.SendSysMessage("You have gotten " + ConvVal + " cps from monster kill");
Interpolated strings anyone?
Code:
killer.Save()
Why is this not a part of the Killer.CP property?
the killer.save(); method is needed cause it will note save the cps to the database i tested before i used it dont worry xD, without it it will only save when the player exits so if the server crashes players cps will roll back also the random value will never produce an invalid value ! it will only produce values between 1 and 100 . Thanks for the post
"Why the fuck is setting this integer crashing my fucking server?! Oh, it's not. This is a property that the debugger skips over, and it's actually the database save method crashing my shit because I changed the table structure. Wow do C# properties suck ass." Just another horrible Microsoftism.
"Why the fuck is my database not updating with character information?! Oh, it's because I didn't make one billion manual calls to a database save that could have saved me tons of time debugging as well by having them in a property call."
Moron.
#Edit
On a side note. You're a shitty Go programmer anyway, so you don't know how to do anything remotely logical and smart anyway.
Quote:
Originally Posted by patcac-patcac
the killer.save(); method is needed cause it will note save the cps to the database i tested before i used it dont worry xD, without it it will only save when the player exits so if the server crashes players cps will roll back also the random value will never produce an invalid value ! it will only produce values between 1 and 100 . Thanks for the post
What I'm saying is that you should put it in the property so you don't need to call it.
... why would you even want to save stuff to the database EVERY time some property of a player changes? That's pretty bad, at least if you actually care about, you know, like performance and stuff.
What? Are you for real? I cannot decide if you're a bot or a troll.
I'm not into my programs doing things that even the debugger can't follow. Seems like a very bad practice or poor abstraction, almost like there's better design / software architecture out there than abstraction. Overloaded operators are in the same category.
... why would you even want to save stuff to the database EVERY time some property of a player changes? That's pretty bad, at least if you actually care about, you know, like performance and stuff.
No you want to bulk the records to insert/update, then perform them all at once to save performance, as well database speed.
But really it depends on what you want to achieve and how critical it is for you to have data loss.
Sometimes it may be better to sacrifice a little performance, over having critical data loss or possible bugs.
Also databases should be able to handle such type of updates anyway, if it gives you a significant performance loss, then the problem may lie somewhere else.
I think that you need to remove the killer.Save() after every kill. True it saves you from the server doing a rollback, but just do a main daily. If 30 archers are hunting monsters, each of them will kill 20,000-50,000 monsters(at least) in an hour, that is 3,500,000 saves. Also I think on every big scatter, he is going to spike a bit. I have tried this on a Redux code a few months back, if you save that many times that fast, the killer will lag as hell.