|
You last visited: Today at 10:24
Advertisement
How to edit PK Mode System Message like Real Conquer Online .- TQ.Elgahed
Discussion on How to edit PK Mode System Message like Real Conquer Online .- TQ.Elgahed within the CO2 PServer Guides & Releases forum part of the CO2 Private Server category.
04/16/2012, 18:11
|
#1
|
elite*gold: 0
Join Date: Apr 2012
Posts: 4
Received Thanks: 0
|
How to edit PK Mode System Message like Real Conquer Online .- TQ.Elgahed
By the name of the god
========================
lets open PacketHandler.cs
and search this code :
PHP Code:
static void ChangePKMode(Data generalData, Client.GameState client)
{
client.Entity.AttackPacket = null;
client.Entity.PKMode = (Game.Enums.PKMode)(byte)generalData.dwParam;
client.Send(generalData);
}
Then replace it with this code
PHP Code:
#region ChangePKMode
static void ChangePKMode(Data generalData, Client.GameState client)
{
client.Entity.AttackPacket = null;
client.Entity.PKMode = (Game.Enums.PKMode)(byte)generalData.dwParam;
client.Send(generalData);
if (client.Entity.PKMode == Game.Enums.PKMode.PK)
{
client.Send(new Message("Free PK mode. You can attack monster and all players.", System.Drawing.Color.Red, Message.Talk));
}
if (client.Entity.PKMode == Game.Enums.PKMode.Capture)
{
client.Send(new Message("Capture PK mode. You can only attack monsters, black-name and blue-name players.", System.Drawing.Color.Red, Message.Talk));
}
if (client.Entity.PKMode == Game.Enums.PKMode.Peace)
{
client.Send(new Message("Peace mode. You can only attack monsters.", System.Drawing.Color.Red, Message.Talk));
}
if (client.Entity.PKMode == Game.Enums.PKMode.Team)
{
client.Send(new Message("Team PK mode. You can attack monster and all players except your teammates.", System.Drawing.Color.Red, Message.Talk));
}
}
#endregion
Done .
|
|
|
04/16/2012, 18:48
|
#2
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
This is definitely one of those times you use an if-else if (at least):
Code:
if (client.Entity.PKMode == Game.Enums.PKMode.PK)
{
client.Send(new Message("Free PK mode. You can attack monster and all players.", System.Drawing.Color.Red, Message.Talk));
}
else if (client.Entity.PKMode == Game.Enums.PKMode.Capture)
{
client.Send(new Message("Capture PK mode. You can only attack monsters, black-name and blue-name players.", System.Drawing.Color.Red, Message.Talk));
}
else if (client.Entity.PKMode == Game.Enums.PKMode.Peace)
{
client.Send(new Message("Peace mode. You can only attack monsters.", System.Drawing.Color.Red, Message.Talk));
}
else if (client.Entity.PKMode == Game.Enums.PKMode.Team)
{
client.Send(new Message("Team PK mode. You can attack monster and all players except your teammates.", System.Drawing.Color.Red, Message.Talk));
}
|
|
|
04/16/2012, 18:58
|
#3
|
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
|
Quote:
Originally Posted by nTL3fTy
This is definitely one of those times you use an if-else if (at least):
Code:
if (client.Entity.PKMode == Game.Enums.PKMode.PK)
{
client.Send(new Message("Free PK mode. You can attack monster and all players.", System.Drawing.Color.Red, Message.Talk));
}
else if (client.Entity.PKMode == Game.Enums.PKMode.Capture)
{
client.Send(new Message("Capture PK mode. You can only attack monsters, black-name and blue-name players.", System.Drawing.Color.Red, Message.Talk));
}
else if (client.Entity.PKMode == Game.Enums.PKMode.Peace)
{
client.Send(new Message("Peace mode. You can only attack monsters.", System.Drawing.Color.Red, Message.Talk));
}
else if (client.Entity.PKMode == Game.Enums.PKMode.Team)
{
client.Send(new Message("Team PK mode. You can attack monster and all players except your teammates.", System.Drawing.Color.Red, Message.Talk));
}
|
or switch() case{} ?
|
|
|
04/16/2012, 19:19
|
#4
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
was just gonna say...
USE SWITCH!
That being said, he did say at LEAST use if/elseif which makes him correct anyways :P
|
|
|
04/16/2012, 20:35
|
#5
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Don't use a switch, switches perform worse than if/else at lower iterations like this.
|
|
|
04/16/2012, 21:13
|
#6
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Or... just have one statement and use a string array to tell the client what message to display.
|
|
|
04/16/2012, 21:37
|
#7
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Quote:
Originally Posted by Korvacs
Don't use a switch, switches perform worse than if/else at lower iterations like this.
|
Interesting, at what point does switch become more efficient? or is it one of those things used more for aesthetic appeal then actual performance? I for some reason had it in my mind that switch became more efficient after a fairly low number of if/else if statements but I'm probably wrong.
|
|
|
04/16/2012, 22:37
|
#8
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by pro4never
Interesting, at what point does switch become more efficient? or is it one of those things used more for aesthetic appeal then actual performance? I for some reason had it in my mind that switch became more efficient after a fairly low number of if/else if statements but I'm probably wrong.
|
Here's my opinion on it:
I did a little research, and in the long run (depending on how many cases the statement is checking...) if else statements perform the worst. In situations where there are less than 5 cases being checked, an if-else structure performs the best. However, when you're dealing with that little of a switch, you should always consider how to write it as one statement.
This is how I'd do it:
client.Send(new ClientMessage(PkNotifications[generalAction.PrimaryAction], ChatTone.System).ToPointer());
|
|
|
04/16/2012, 22:53
|
#9
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
Quote:
Originally Posted by Fаng
This is how I'd do it:
client.Send(new ClientMessage(PkNotifications[generalAction.PrimaryAction], ChatTone.System).ToPointer());
|
What happens if I'm on a proxy and send PKMode 50?
|
|
|
04/16/2012, 23:13
|
#10
|
elite*gold: 21
Join Date: Jul 2005
Posts: 9,193
Received Thanks: 5,380
|
Quote:
Originally Posted by nTL3fTy
What happens if I'm on a proxy and send PKMode 50?
|
While I'm sure he'd account for this... it does make it a less elegant solution when you add in all sorts of error checking.
|
|
|
04/16/2012, 23:45
|
#11
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by nTL3fTy
What happens if I'm on a proxy and send PKMode 50?
|
I check the range before I even assign it. I'm showing you the message line, not how I assign everything.
|
|
|
04/17/2012, 00:01
|
#12
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
Quote:
Originally Posted by Fаng
I check the range before I even assign it. I'm showing you the message line, not how I assign everything.
|
I was going on the assumption that generalData was your packet instance and PrimaryAction was a field in the packet. Considering that, it seemed as though you were just taking the field from the packet with no range checks. If this isn't correct, I'm clearly confused.
|
|
|
04/17/2012, 00:08
|
#13
|
elite*gold: 0
Join Date: Apr 2008
Posts: 759
Received Thanks: 285
|
well use switch.
In the worst case the compiler will generate the same code as a if-else chain, so you don't lose anything. If in doubt put the most common cases first into the switch statement.
In the best case the optimizer may find a better way to generate the code. Common things a compiler does is to build a binary decision tree (saves compares and jumps in the average case) or simply build a jump-table (works without compares at all).
|
|
|
04/17/2012, 00:11
|
#14
|
elite*gold: 20
Join Date: Mar 2006
Posts: 6,126
Received Thanks: 2,518
|
Quote:
Originally Posted by pro4never
Interesting, at what point does switch become more efficient? or is it one of those things used more for aesthetic appeal then actual performance? I for some reason had it in my mind that switch became more efficient after a fairly low number of if/else if statements but I'm probably wrong.
|
Test i've read show that it varies under different circumstance, and your own benchmark will also show this most likely, the general rule of thumb is that if the number of conditions is 5 or more then use a switch as the switch will use a Hashtable which adds a reasonable amount of overhead (lookup + jump), otherwise in basically all cases if/else would be preferred.
|
|
|
04/17/2012, 00:31
|
#15
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,191
|
Quote:
Originally Posted by nTL3fTy
I was going on the assumption that generalData was your packet instance and PrimaryAction was a field in the packet. Considering that, it seemed as though you were just taking the field from the packet with no range checks. If this isn't correct, I'm clearly confused.
|
That's correct. I'm using the general packet like everyone else does ... I error check it BEFORE I handle it. If it's correct, I use the data in the packet. Problem?
|
|
|
 |
|
Similar Threads
|
Conquer Online BGM Edit
11/27/2012 - CO2 Guides & Templates - 3 Replies
Hello, this is my first guide. :D
In this guide I will show you how to change the BGM for conquer online.
(official co or private server)
The only program you need is notepad (or a other type of txt reader), lol.
FIRST: Go to your conquer folder.
Go to the folder named "ini".
Scroll down and open "MusicRegion".
This will be for the music configuration.
|
[Info KS4] Captain Mode|Map:Old Moon|Message System
12/12/2010 - S4 League - 50 Replies
Hallo lieber Epvpers-Community,
ich bin's Mal wieder =) Heute gibt's brisante News zur kommenden KS4 Update, ich glaube, dass es nicht lange dauern wird (Meine Prognose:Winter Set=99,9%, Map~75%, Mode~50%, Nachrichtensystem < 30%) bis es auch bei uns ankommt:
Neue Mode:Captain Mode
http://boardr.pmang.com/files/pm/attach3/cmboard/ 323/b6/24-/04-/53-/24045346./captain.jpg
http://boardr.pmang.com/files/pm/attach3/cmboard/ 323/b6/24-/04-/53-/24045346./mode_shot_2.jpg...
|
Conquer Ghost Mode edit.. need help.
08/04/2010 - Conquer Online 2 - 0 Replies
Alright so basically I'm trying to get into the oh so famous "ghost mode" of Conquer. Pretty much the Conquer realm is always in Enlightenment Mode but without the pointy finger. The reason I want to do this is to have the ability to log in more miners than my current limit. As I'm trying this I have 27 clients logged and mining.
The way I'm able to log in 27 is right click to start mining than press the Tab key however Enlightenment Mode gets rid of alot of other garbage. I would just right...
|
All times are GMT +1. The time now is 10:27.
|
|