[Request]Organized chat.cs?

03/09/2013 01:04 xScylez#31
Quote:
Originally Posted by lostsolder05 View Post
public static bool PmandGMCommand(Main.GameClient GC, string[] Msg)
{
string[] Cmd = Message.Split(' ');

Message is undeclared you're using Msg in your bool... :rolleyes:
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 Spirited#32
Quote:
Originally Posted by xScylez View Post
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-ass 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 Arco.#33
Quote:
Originally Posted by Fаng View Post
You know absolutely rats-ass about programming... and you're trying to maintain a private server?
You've done it, I've done it, everyone damn 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 go for it#34
Quote:
Originally Posted by Arco. View Post
You've done it, I've done it, everyone damn 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 Arco.#35
Quote:
Originally Posted by go for it View Post
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 go for it#36
Quote:
Originally Posted by Arco. View Post
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 fuck 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 Arco.#37
Quote:
Originally Posted by go for it View Post
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 fuck 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 go for it#38
fuck chrome crashed after typing long shit
if (checkcommandshit )
{
don't send to players
}
else
{
send to players , do all checks
}
03/09/2013 04:15 Arco.#39
but doing shit 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 fuck?
03/09/2013 04:25 go for it#40
Quote:
Originally Posted by Arco. View Post
but doing shit 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 fuck?
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 nTL3fTy#41
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.

03/09/2013 08:36 lostsolder05#42
Quote:
Originally Posted by Arco. View Post
but doing shit 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 fuck?
It would break out of the reborn case and return false... :confused:


[Only registered and activated users can see links. Click Here To Register...]
03/09/2013 08:47 Arco.#43
Quote:
Originally Posted by lostsolder05 View Post
It would break out of the reborn case and return false... :confused:


[Only registered and activated users can see links. Click Here To Register...]
TRY CATCHES WHY
03/09/2013 16:35 go for it#44
Quote:
Originally Posted by Arco. View Post
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 nTL3fTy#45
Quote:
Originally Posted by go for it View Post
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
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?
[Only registered and activated users can see links. Click Here To Register...]?