Problem with offline shops

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Villy90
Posts: 26
Joined: Fri Jul 29, 2011 11:40 am

Problem with offline shops

Post by Villy90 »

If you want to receive support we need this info to help you properly.
» Find Revision
L2J Revision : 5513
L2JDP Revision : 8997

I am Trying to make a small change to the offline trade/craft shops, everything is almost perfect it works as it should it restart offline shops after server Restart but i want to be able to restart instead of closing the client to make the shop offline. Why? Simple because this will stop countless accounts being created for this purpose as someone can use the same account for playing on main char and a dwarf or whatever in shop offline mode from the same account. :mrgreen:
Also it is annoying to log back and always says account in use etc. this will stop this error happening.
Please can someone help me get this working. :?:
Thank you.
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: Problem with offline shops

Post by vampir »

Its quite a good idea, so first of all we need to make able to log on the ACCOUNT when character is in game, without kicking this char from game(this happends while u can see msg "Account is already in use. Unable to log in.").
So, we need to take care of tryAuthLogin in LoginController, if isAccountInAnyGameServer(account) will be false, then messsage will appear. Lets go to isAccountInAnyGameServer, the key method is hasAccountOnGameServer, so best thing we can do is remove our account name from _accountsOnGameServer in GameServerThread when guy with shop is closing client. Same thing we need to do with _loginServerClients in LoginController but thats piece of cake.

Now, player will probably(there can be more checks that are blocking us that i didnt find) be able to log in.
So it will be like this, guy is logging on account - field is added into login server, if he will log into any char, field will be added to gameserver, if guy will not choose server or 1 char will be offline shop and another will be real player then system will bug, what thoughts u have got? :)
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Problem with offline shops

Post by jurchiks »

I asked about this when I first came to this forum and the response was that enabling it creates many exploits. So I'd think twice before doing this.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: Problem with offline shops

Post by vampir »

every exploit can be neutralized(dunno if its the right word), it just depends how much effort u wanna put into this
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Problem with offline shops

Post by jurchiks »

good luck with finding them all.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: Problem with offline shops

Post by vampir »

if u are trying to add new feature or rework something big, u need to do the same, all the time watch if something can be exploited, if any exception can appear, and as i said, if u really care about doing that thing then whats the problem? :)
Villy90
Posts: 26
Joined: Fri Jul 29, 2011 11:40 am

Re: Problem with offline shops

Post by Villy90 »

I have seen this working before on a private server i played on, i would go on dwarf make shop, restart (back to char select) and play on main char class make level etc... I cannot remember the name of the server but it was working great and for a long time without problems. So it can be made and as posted above every exploit can be fixed.
So anyone have any ideas where to start :mrgreen:
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: Problem with offline shops

Post by vampir »

look at my first post in this topic.
first login server, i think best option would be creating list of all accounts that are using offline shoping system, if account will be on the list, it will not be added to _loginServerClients.
When player will log into offline character, it checks if any other offlne shop is on the account, if yes then do nothing, if not then remove account from list and add account to _loginServerClients and also _accountsOnGameServer.
Now if guy will log into not offline character then check if there is any offline shop in the account, if there is then do nothing, if not then add account to _accountsOnGameServer.

When player will log out as offline shop, then it have to check if there is any other offline shop in the account, if not then remove account from _loginServerClients and _accountsOnGameServer and add account to our list, and if there is then do nothing.
When player will log out as normal player, then it have to check if there is offline shop in the account, if not then remove from _loginServerClients and _accountsOnGameServer, if there is then do nothing.

Now we have got a little problem, there can be 2 active chars on the account, think what u can do about that and tell me :)
Villy90
Posts: 26
Joined: Fri Jul 29, 2011 11:40 am

Re: Problem with offline shops

Post by Villy90 »

Well what if you add a condition to check if more than one active character is online, for example
2 - chars in offline trade mode as there is option to check for this.
and
1- active char.

If active char > 1 then kick other active player or something like this? :mrgreen:
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: Problem with offline shops

Post by vampir »

jesus, i am stupid, i made such complicated thing from something that simple.
Do this: when somebody exit client as offline shop, remove account name from _accountsOnGameServer in GameServerThread and from _loginServerClients that is in LoginController.
Now if somebody logs in and account is already active, we need to kick only active Char, thats harder, we cannot use KickPlayer packet coz it kicks everybody, so go to RequestAuthLogin and replace gsi.getGameServerThread().kickPlayer(_user);
with
for(L2PcInstance player : L2World.getInstance().getAllPlayersArray())
if(player.getOfflineStartTime()==0)//dunno if its right way to check if player is this pack
if(player.getAccountName().equals(_user))
player.logout();

maybe its gonna work good, test it please and let me know
Last edited by vampir on Thu Jul 26, 2012 9:44 am, edited 2 times in total.
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Problem with offline shops

Post by jurchiks »

that'll log off all offline shops.
also, offline shop -> player.getClient().isDetached()
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
Villy90
Posts: 26
Joined: Fri Jul 29, 2011 11:40 am

Re: Problem with offline shops

Post by Villy90 »

Thank you Vampir for helping me with this :D
I will test more tomorrow as i spend all day getting the pvp-pk rank manager npc working, i did thanks to jurchiks, i hope i will be able to repay the favor someday :D

Now do you have any suggestions jurchiks about this, you said it will log out all offline shops so any idea how to log off only other active players on account, if there is more than the one logging in.
Thank you.
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: Problem with offline shops

Post by vampir »

it was small typo, i wrote > and not ==, also if player.getClient().isDatached() means player with offline shop, u can change line if(player.getOfflineStartTime()==0) to if(!player.getCliemt().isDatached())
and its gonna work fine :)
User avatar
jurchiks
Posts: 6769
Joined: Sat Sep 19, 2009 4:16 pm
Location: Eastern Europe

Re: Problem with offline shops

Post by jurchiks »

I don't know where you're trying to disconnect those players. Tell me the class and line, and I'll check, maybe I'll get it.
If you have problems, FIRST TRY SOLVING THEM YOURSELF, and if you get errors, TRY TO ANALYZE THEM, and ONLY if you can't help it, THEN ask here.
Otherwise you will never learn anything if all you do is copy-paste!
Discussion breeds innovation.
vampir
Posts: 113
Joined: Sun Mar 28, 2010 6:17 pm

Re: Problem with offline shops

Post by vampir »

Post Reply