|
You last visited: Today at 15:43
Advertisement
[Request]Organized chat.cs?
Discussion on [Request]Organized chat.cs? within the CO2 Private Server forum part of the Conquer Online 2 category.
03/09/2013, 01:04
|
#31
|
elite*gold: 0
Join Date: Mar 2013
Posts: 44
Received Thanks: 2
|
Quote:
Originally Posted by lostsolder05
public static bool PmandGMCommand(Main.GameClient GC, string[] Msg)
{
string[] Cmd = Message.Split(' ');
Message is undeclared you're using Msg in your bool... 
|
I tried like this:
Code:
public static bool PmandGMCommand(Main.GameClient GC, string[] Msg)
{
if (GC.AuthInfo.Status != "[GM]" && GC.AuthInfo.Status != "[PM]") return false;
string[] Cmd = Msg;
switch (Msg[0])
{
case "/reborn":
{
GC.MyChar.Reborns = byte.Parse(Cmd[1]);
return true;
}
But it gives me error:
Code:
'NewestCOServer.PacketHandling.Chat.PmandGMCommand(NewestCOServer.Main.GameClient, string[])': not all code paths return a value
|
|
|
03/09/2013, 02:39
|
#32
|
elite*gold: 12
Join Date: Jul 2011
Posts: 8,282
Received Thanks: 4,190
|
Quote:
Originally Posted by xScylez
I tried like this:
Code:
public static bool PmandGMCommand(Main.GameClient GC, string[] Msg)
{
if (GC.AuthInfo.Status != "[GM]" && GC.AuthInfo.Status != "[PM]") return false;
string[] Cmd = Msg;
switch (Msg[0])
{
case "/reborn":
{
GC.MyChar.Reborns = byte.Parse(Cmd[1]);
return true;
}
But it gives me error:
Code:
'NewestCOServer.PacketHandling.Chat.PmandGMCommand(NewestCOServer.Main.GameClient, string[])': not all code paths return a value
|
You know absolutely rats-*** about programming... and you're trying to maintain a private server? That sounds like a really bad idea to me. Aren't there already private servers out there that you can join and support?
|
|
|
03/09/2013, 03:33
|
#33
|
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
|
Quote:
Originally Posted by Fаng
You know absolutely rats-*** about programming... and you're trying to maintain a private server?
|
You've done it, I've done it, everyone **** near has done it. It's just something you let people learn.
@OP
public static bool
should be a void, not a boolean.
And there will be no need to return values.
|
|
|
03/09/2013, 03:52
|
#34
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
|
Quote:
Originally Posted by Arco.
You've done it, I've done it, everyone **** near has done it. It's just something you let people learn.
@OP
public static bool
should be a void, not a boolean.
And there will be no need to return values.
|
there is always a need to return bool value
you always want to know if it worked out or not
say i made command for flags and i typed a flag which does not exist , the server will inform me with that bool if it exist and it does nothing or if it does not exist
it's in general for me and for what i've seen in trinity a really good programming practice to always add bool instead of voids but rarely any one use them , it definitely increase your source protection against all kinds of exploits
a better example would be taking cps method on trinity
at the very first i was doing this
check if client got the cps
{
bool method to take cps
bool method to give the items
}
later on after working and learning more i handle it that way
if(bool method to take cps)
{
if(bool method to give item)
else(give cps back)
}
else{}
|
|
|
03/09/2013, 03:54
|
#35
|
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
|
Quote:
Originally Posted by go for it
there is always a need to return bool value
you always want to know if it worked out or not
say i made command for flags and i typed a flag which does not exist , the server will inform me with that bool if it exist and it does nothing or if it does not exist
it's in general for me and for what i've seen in trinity a really good programming practice to always add bool instead of voids but rarely any one use them , it definitely increase your source protection against all kinds of exploits
a better example would be taking cps method on trinity
at the very first i was doing this
check if client got the cps
{
bool method to take cps
bool method to give the items
}
later on after working and learning more i handle it that way
if(bool method to take cps)
{
if(bool method to give item)
else(give cps back)
}
else{}
|
I'm referring to his command void. Why would that need to be a bool? If he wants to see if it works, try it, if it doesn't, breakpoint and find out why.
|
|
|
03/09/2013, 03:58
|
#36
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
|
Quote:
Originally Posted by Arco.
I'm referring to his command void. Why would that need to be a bool? If he wants to see if it works, try it, if it doesn't, breakpoint and find out why.
|
i maybe add up to 20 methods per day to nextco source and i don't have that time to break at all of them and test it
all i do is a bool , if returned false i write on the console values that may **** it up for me
it's always good to trace back your system on the run time
i find some logical bugs at the run time as i don't have full day to test systems im implementing
which to why that save my time of debugging and searching for bugs and errors
and in this case my command check method is bool too which send chat packet to me tellin me what is the problem with the command which is pretty helpful
|
|
|
03/09/2013, 04:00
|
#37
|
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
|
Quote:
Originally Posted by go for it
i maybe add up to 20 methods per day to nextco source and i don't have that time to break at all of them and test it
all i do is a bool , if returned false i write on the console values that may **** it up for me
it's always good to trace back your system on the run time
i find some logical bugs at the run time as i don't have full day to test systems im implementing
which to why that save my time of debugging and searching for bugs and errors
and in this case my command check method is bool too which send chat packet to me tellin me what is the problem with the command which is pretty helpful
|
so what,
if (Checkcommandshit) { ? }
else {?}
wut.
|
|
|
03/09/2013, 04:11
|
#38
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
|
**** chrome crashed after typing long ****
if (checkcommandshit )
{
don't send to players
}
else
{
send to players , do all checks
}
|
|
|
03/09/2013, 04:15
|
#39
|
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
|
but doing **** like
case "/reborn":
{
GC.MyChar.Reborns = byte.Parse(Cmd[1]);
return true;
}
It's gonna do one of two things, go through with the command, and return true.
Or NOT go through with the command, but return true anyways.
Eitherway return true, the ****?
|
|
|
03/09/2013, 04:25
|
#40
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
|
Quote:
Originally Posted by Arco.
but doing **** like
case "/reborn":
{
GC.MyChar.Reborns = byte.Parse(Cmd[1]);
return true;
}
It's gonna do one of two things, go through with the command, and return true.
Or NOT go through with the command, but return true anyways.
Eitherway return true, the ****?
|
it will when you try to set a value maybe of uint to ushort
aka reborn is max 2 ? it should be byte ? what if you simply did "@reborn 9999" ? it won't set it to true
but
you should do more checks
that's a poor example
a better version would check on command or even better to check while setting the object
but most of cases it does not return true and just break out of the try block to the catch block and not setting it to true (in case there was not check)
im not really flaming im just pointing out something , and it's not so useful at this example but it is indeed useful at some of that cases in this switch at my source
|
|
|
03/09/2013, 05:33
|
#41
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
In the end, it really doesn't matter how this code needs to be fixed. This guy needs to go learn the basics of programming before even attempting to write a server. He can't even solve these simple issues which the IDE is more than helpful in pointing out. Seriously, learn the C# language before trying to write a server.
Google is a wonderful resource and there are quite a few tutorials around here as well.
|
|
|
03/09/2013, 08:36
|
#42
|
elite*gold: 20
Join Date: Jan 2006
Posts: 890
Received Thanks: 241
|
Quote:
Originally Posted by Arco.
but doing **** like
case "/reborn":
{
GC.MyChar.Reborns = byte.Parse(Cmd[1]);
return true;
}
It's gonna do one of two things, go through with the command, and return true.
Or NOT go through with the command, but return true anyways.
Eitherway return true, the ****?
|
It would break out of the reborn case and return false...
static void Main(string[] args)
{
while (true)
LolWut();
}
public static bool LolWut()
{
try
{
string[] Message = Console.ReadLine().Split();
switch (Message[0])
{
case "/reborn":
byte Reborns = byte.Parse(Message[1]);
return true;
}
}
catch
{
}
return false;
}
|
|
|
03/09/2013, 08:47
|
#43
|
elite*gold: 0
Join Date: Feb 2011
Posts: 335
Received Thanks: 170
|
Quote:
Originally Posted by lostsolder05
It would break out of the reborn case and return false...
static void Main(string[] args)
{
while (true)
LolWut();
}
public static bool LolWut()
{
try
{
string[] Message = Console.ReadLine().Split();
switch (Message[0])
{
case "/test":
byte Reborns = byte.Parse(Message[1]);
return true;
}
}
catch
{
}
return false;
}
|
TRY CATCHES WHY
|
|
|
03/09/2013, 16:35
|
#44
|
elite*gold: 0
Join Date: Sep 2012
Posts: 775
Received Thanks: 329
|
Quote:
Originally Posted by Arco.
TRY CATCHES WHY
|
im not flaming but yes you need a try catch block not to check on each command
aka when i say "@bring someone" , if someone is not online it should give me an error , or maybe trying to get item which does not exist or get item with setting property from command to something which is outside the boundary of array/variable
but if you are doing something like
at setting property of maybe reborn you check for the value you are setting
Code:
public byte Reborn
{
get
{
this.SpawnPacket[108] = _reborn;
return _reborn;
}
set
{
if (value < 3)
{
if (EntityFlag == EntityFlag.Player)
{
Update(Network.GamePackets.Update.Reborn, value, true);
}
_reborn = value;
this.SpawnPacket[108] = value;
}
}
}
also you may add it at the command itself
Code:
#region reb
case "reb":
{
if (Convert.ToByte(Data[1]) < 3)
{
client.Entity.Reborn = Convert.ToByte(Data[1]);
return true;
}
else
{
return false;
}
}
#endregion
and yes it won't cause problem at < 255 but whenever you try to set it for a ushort , uint or ulong it will give an error
so incase you are not doing checks on all your commands then you need to do a try catch block
|
|
|
03/09/2013, 17:21
|
#45
|
elite*gold: 0
Join Date: Jun 2005
Posts: 692
Received Thanks: 353
|
Quote:
Originally Posted by go for it
and yes it won't cause problem at < 255 but whenever you try to set it for a ushort , uint or ulong it will give an error
so incase you are not doing checks on all your commands then you need to do a try catch block
|
 ?
 ?
 ?
 ?
 ?
 ?
 ?
 ?
 ?
 ?
|
|
|
 |
|
Similar Threads
|
Get the Section organized.
07/14/2013 - Need for Speed World - 37 Replies
Hello everyone.
I would like to ask you all, what do you think about getting the section divided in two; so that we could have a Main section, to discuss about the game, have general questions and so on, and a Hacks sub-section in which we can have just releases there?
I have been thinking about this, to get everything even more centralized, as well, we could avoid double posts/malware/spam in general.
So any comments, leave them below, and definitely, vote.
|
Elo boost service the best, fast and most organized
01/29/2013 - League of Legends Trading - 5 Replies
Hi, we are 3 players from 2.3 , 2.1, and 2,05k elo we are starting to boost we already boosted not for money, just a few friends it worked now they are at 1600 elo.
First of all this are our prices are all negociable
0 -1250 10 € per 100 elo
1250-1400 15 € per 100 elo
1400-1600 20 € per 100 elo
|
(request) chat filter
12/01/2009 - GunZ - 0 Replies
i've looked all over and all i want it just the chat filter. does anyone have just the chat filter?
|
All times are GMT +1. The time now is 15:44.
|
|