Fix for multiple logging in at one time

04/07/2010 09:10 Arcо#31
Quote:
Originally Posted by -impulse- View Post
Meh' you gotta add World.Spawns(GC.MyChar, false) somewhere and it will work just fine.
Tried that, didn't work.
04/07/2010 11:38 -NewDawn-#32
I see where you're getting at Impulse but that's not the problem. I've been busy coding the beginner's quest on my server (which is really complicated actually lol), but when I wake up tomorrow I'll take a deep look at this. It must be something we're deleting. Afk. Night all- good luck!
04/07/2010 15:09 kamote#33
try this one ...
Code:
                                    if (Game.World.H_Chars.Contains(GC.MyChar.EntityID))
                                    {
                                        Game.Character Old = (Game.Character)Game.World.H_Chars[GC.MyChar.EntityID];
                                        Old.MyClient.Disconnect(true);
                                        if (!Game.World.H_Chars.Contains(GC.MyChar.EntityID))
                                            Game.World.H_Chars.Add(GC.MyChar.EntityID, GC.MyChar);
                                        GC.MyChar = Database.LoadCharacter(GC.AuthInfo.Character, ref Acc);
                                        GC.MyChar.MyClient = GC;
                                        GC.AddSend(Packets.SystemMessage(GC.MessageID, "ANSWER_OK"));
                                        GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.VIPLevel, GC.MyChar.VipLevel));
                                        GC.AddSend(Packets.Time());
                                        GC.AddSend(Packets.Donators(GC.MyChar));
                                        GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, 0));
                                    }
                                    else
                                    {
                                        Game.World.H_Chars.Add(GC.MyChar.EntityID, GC.MyChar);
						    GC.AddSend(Packets.SystemMessage(GC.MessageID, "ANSWER_OK"));
                                        GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.VIPLevel, GC.MyChar.VipLevel));
                                        GC.AddSend(Packets.Time());
                                        GC.AddSend(Packets.Donators(GC.MyChar));
                                        GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, 0));
                                    }
04/07/2010 15:26 -impulse-#34
PHP Code:
if (Game.World.H_Chars.ContainsKey(GC.MyChar.EntityID))
                                {
                                    
Game.Character Old = (Game.Character)Game.World.H_Chars[GC.MyChar.EntityID];
                                    
Old.MyClient.Disconnect();
                                    if (
Game.World.H_Chars.ContainsKey(GC.MyChar.EntityID))
                                        
Game.World.H_Chars.Remove(GC.MyChar.EntityID);

                                    
GC.MyChar Database.LoadCharacter(GC.AuthInfo.Characterref Acc);
                                    
GC.MyChar.MyClient GC;
                                    
Game.World.H_Chars.Add(GC.MyChar.EntityIDGC.MyChar);
                                    
GC.AddSend(Packets.SystemMessage(GC.MessageID"ANSWER_OK"));
                                    
GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                    
GC.AddSend(Packets.Status(GC.MyChar.EntityIDGame.Status.VIPLevelGC.MyChar.VipLevel));
                                    
GC.AddSend(Packets.Time());
                                    
GC.AddSend(Packets.Donators(GC.MyChar));
                                    
GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                    
GC.AddSend(Packets.Status(GC.MyChar.EntityIDGame.Status.Effect0));
                                }
                                else
                                {
                                    
Game.World.H_Chars.Add(GC.MyChar.EntityIDGC.MyChar);
                                    
GC.AddSend(Packets.SystemMessage(GC.MessageID"ANSWER_OK"));
                                    
GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                    
GC.AddSend(Packets.Status(GC.MyChar.EntityIDGame.Status.VIPLevelGC.MyChar.VipLevel));
                                    
GC.AddSend(Packets.Time());
                                    
GC.AddSend(Packets.Donators(GC.MyChar));
                                    
GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                    
GC.AddSend(Packets.Status(GC.MyChar.EntityIDGame.Status.Effect0));
                                } 
Okay, made some tests and this is the perfect script. Works nice.

Quote:
Originally Posted by kamote View Post
try this one ...
Code:
                                    if (Game.World.H_Chars.Contains(GC.MyChar.EntityID))
                                    {
                                        Game.Character Old = (Game.Character)Game.World.H_Chars[GC.MyChar.EntityID];
                                        Old.MyClient.Disconnect(true);
                                        if (!Game.World.H_Chars.Contains(GC.MyChar.EntityID))
                                            Game.World.H_Chars.Add(GC.MyChar.EntityID, GC.MyChar);
                                        GC.MyChar = Database.LoadCharacter(GC.AuthInfo.Character, ref Acc);
                                        GC.MyChar.MyClient = GC;
                                        GC.AddSend(Packets.SystemMessage(GC.MessageID, "ANSWER_OK"));
                                        GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.VIPLevel, GC.MyChar.VipLevel));
                                        GC.AddSend(Packets.Time());
                                        GC.AddSend(Packets.Donators(GC.MyChar));
                                        GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, 0));
                                    }
                                    else
                                    {
                                        Game.World.H_Chars.Add(GC.MyChar.EntityID, GC.MyChar);
						    GC.AddSend(Packets.SystemMessage(GC.MessageID, "ANSWER_OK"));
                                        GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.VIPLevel, GC.MyChar.VipLevel));
                                        GC.AddSend(Packets.Time());
                                        GC.AddSend(Packets.Donators(GC.MyChar));
                                        GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, 0));
                                    }
Lol?
Copy machine.

Ah my bad actually no, you are not a copy machine... You was close...though.
Using your code you can't be seen by others.
04/07/2010 19:44 -NewDawn-#35
Both of you are wrong.
You still get the same error.
Hold on, I'll look into it too.

#EDIT: There's a problem with the original code, but not as you described it.

The Problem:

The server sees that once the 2nd client tries to connect that both the 1st and 2nd Client disconnect; however, the 2nd Client is still logged on. As a result, the server starts not saving the character. That's the error that we're facing.

[Only registered and activated users can see links. Click Here To Register...]

The first login is normal- the 1st Client.
The disconnect is normal- the 1st Client Disconnecting for the 2nd Client.
The 2nd Login is normal - the 2nd Client Logging in.
The 2nd disconnect is the problem.

Get it? =\
04/07/2010 23:08 -impulse-#36
Quote:
Originally Posted by -NewDawn- View Post
Both of you are wrong.
You still get the same error.
Hold on, I'll look into it too.

#EDIT: There's a problem with the original code, but not as you described it.

The Problem:

The server sees that once the 2nd client tries to connect that both the 1st and 2nd Client disconnect; however, the 2nd Client is still logged on. As a result, the server starts not saving the character. That's the error that we're facing.

[Only registered and activated users can see links. Click Here To Register...]

The first login is normal- the 1st Client.
The disconnect is normal- the 1st Client Disconnecting for the 2nd Client.
The 2nd Login is normal - the 2nd Client Logging in.
The 2nd disconnect is the problem.

Get it? =\
LOL. It works perfectly fine for me because I have switched to MySQL.
04/07/2010 23:19 PeTe Ninja#37
Quote:
Originally Posted by -impulse- View Post
LOL. It works perfectly fine for me because I have switched to MySQL.
OMFG GIVE ME UR PRETTY COLORS
04/07/2010 23:56 -impulse-#38
Quote:
Originally Posted by PeTe Ninja View Post
OMFG GIVE ME UR PRETTY COLORS
LOL?
04/08/2010 00:20 -NewDawn-#39
I agree with impulse. rofl
my what?? o.O
04/08/2010 03:31 kamote#40
Quote:
Originally Posted by -impulse- View Post
PHP Code:
if (Game.World.H_Chars.ContainsKey(GC.MyChar.EntityID))
                                {
                                    
Game.Character Old = (Game.Character)Game.World.H_Chars[GC.MyChar.EntityID];
                                    
Old.MyClient.Disconnect();
                                    if (
Game.World.H_Chars.ContainsKey(GC.MyChar.EntityID))
                                        
Game.World.H_Chars.Remove(GC.MyChar.EntityID);

                                    
GC.MyChar Database.LoadCharacter(GC.AuthInfo.Characterref Acc);
                                    
GC.MyChar.MyClient GC;
                                    
Game.World.H_Chars.Add(GC.MyChar.EntityIDGC.MyChar);
                                    
GC.AddSend(Packets.SystemMessage(GC.MessageID"ANSWER_OK"));
                                    
GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                    
GC.AddSend(Packets.Status(GC.MyChar.EntityIDGame.Status.VIPLevelGC.MyChar.VipLevel));
                                    
GC.AddSend(Packets.Time());
                                    
GC.AddSend(Packets.Donators(GC.MyChar));
                                    
GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                    
GC.AddSend(Packets.Status(GC.MyChar.EntityIDGame.Status.Effect0));
                                }
                                else
                                {
                                    
Game.World.H_Chars.Add(GC.MyChar.EntityIDGC.MyChar);
                                    
GC.AddSend(Packets.SystemMessage(GC.MessageID"ANSWER_OK"));
                                    
GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                    
GC.AddSend(Packets.Status(GC.MyChar.EntityIDGame.Status.VIPLevelGC.MyChar.VipLevel));
                                    
GC.AddSend(Packets.Time());
                                    
GC.AddSend(Packets.Donators(GC.MyChar));
                                    
GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                    
GC.AddSend(Packets.Status(GC.MyChar.EntityIDGame.Status.Effect0));
                                } 
Okay, made some tests and this is the perfect script. Works nice.



Lol?
Copy machine.

Ah my bad actually no, you are not a copy machine... You was close...though.
Using your code you can't be seen by others.
FYI, that was not my code... it came from the original one.. i only added some code which i believe are missing. I haven't tried it... if it wont work...then dont use it! SimplE!
04/08/2010 03:54 -NewDawn-#41
Quote:
Originally Posted by kamote View Post
FYI, that was not my code... it came from the original one.. i only added some code which i believe are missing. I haven't tried it... if it wont work...then dont use it! SimplE!
There's no need to get emotional about it.
You tried at least.
04/08/2010 12:35 kamote#42
try this code.. i tested it, and it worked fine! It look similar with the first one, but i added one single code(in color blue) to fix the bug. It will disconnect the first loggedIn client and let the later one get in.

Code:
                                    if (Game.World.H_Chars.Contains(GC.MyChar.EntityID))
                                    {
                                        Game.Character Old = (Game.Character)Game.World.H_Chars[GC.MyChar.EntityID];
                                        Old.MyClient.Disconnect();
                                        [COLOR="Blue"] Game.World.H_Chars.Remove(Old.EntityID);[/COLOR]
                                        if (!Game.World.H_Chars.Contains(GC.MyChar.EntityID))
                                            Game.World.H_Chars.Add(GC.MyChar.EntityID, GC.MyChar);
                                        GC.MyChar = Database.LoadCharacter(GC.AuthInfo.Character, ref Acc);
                                        GC.MyChar.MyClient = GC;
                                        GC.AddSend(Packets.SystemMessage(GC.MessageID, "ANSWER_OK"));
                                        GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.VIPLevel, GC.MyChar.VipLevel));
                                        GC.AddSend(Packets.Time());
                                        GC.AddSend(Packets.Donators(GC.MyChar));
                                        GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, 0));
                                    }
                                    else
                                    {
                                        [COLOR="#ff0000"]Game.World.H_Chars.Add(GC.MyChar.EntityID, GC.MyChar);[/COLOR]
                                        GC.AddSend(Packets.SystemMessage(GC.MessageID, "ANSWER_OK"));
                                        GC.AddSend(Packets.CharacterInfo(GC.MyChar));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.VIPLevel, GC.MyChar.VipLevel));
                                        GC.AddSend(Packets.Time());
                                        GC.AddSend(Packets.Donators(GC.MyChar));
                                        GC.AddSend(Packets.Packet1012(GC.MyChar.EntityID));
                                        GC.AddSend(Packets.Status(GC.MyChar.EntityID, Game.Status.Effect, 0));
                                    }
04/08/2010 13:00 Paralyzer[GM]#43
But then lets say someone was hacking your account they could get stright in I prefer it so they don't get to login 2x erm I would do lets say 1 character logged someone else trys to login BUT FROM A DIFF IP and it will alert the character that is trying to be logged saying something like "Somebody is trying to login to your account from the IP: x.xxx.xxx.xx if you do not know them please change your password before logging out, and alert the ServerCo staff otherwise the person could comprimise your account"
04/08/2010 19:37 pintser#44
Ore u can just pop up the message to say:

U are Already logged in

--------------------------

I saw this many codes at the thead, wich 1 does fix the CP/item problem(trade, Dc, and still have items?(problem).)

:)
04/08/2010 21:50 -NewDawn-#45
[Only registered and activated users can see links. Click Here To Register...]

I figured it out.
Works over and over again.
As it shows in the picture, I logged in over the 1st client with the 2nd Client... then logged in AGAIN over the 2nd client with the 1st client. It works 100% of the time, over and over again.
All mobs and NPCs spawn correctly too!
The character saves correctly on transfer.

You're welcome. Lol
Don't forget to hit [Only registered and activated users can see links. Click Here To Register...]!

Here's the solution:
#Removed: Response to the community and how it thinks I don't help.