Jump to content
Samuel

@cashreload

Recommended Posts

Hello everyone!

 

This is a new command to reload the cashshop_db.conf

 

So you don't need to restart the server when you add or delete items in the cash shop or just simply changed the price of items :)

 

But due to a certain conflict wherein a player needs to relog in order for him to see the changes in Cash Shop, I added a 10 sec countdown and kick command.

 

Special Thanks to: @@AnnieRuru

 

Have a nice day!

 

Link

Share this post


Link to post
Share on other sites

LOL !!! you only asked me about how to kick players

if you really told me about cashshop, I know which function to hook

 

.....

#include "common/hercules.h"#include <stdio.h>#include <string.h>#include <stdlib.h>#include "map/pc.h"#include "map/clif.h"#include "common/HPMDataCheck.h"HPExport struct hplugin_info pinfo = {	"reloadcashshop",	SERVER_TYPE_MAP,	"1.0",	HPM_VERSION,};ACMD(reloadcashshop) {	clif->cashshop_load();	clif->pCashShopSchedule( sd->fd, sd );	return true;}HPExport void plugin_init (void) {	addAtcommand( "reloadcashshop", reloadcashshop );}
what the ...

post-4102-0-00221700-1451130164_thumb.jpg

the item appear twice in my window

 

http://herc.ws/board/topic/1247-adding-reloadcashshop/?p=9041

so Ind was right

it has to kick the player

this is a client side restriction, because the client can only receive and add additional items

but the client NEVER refresh or delete the cash item list

 

maybe Samuel you can do that one post in the topic,

only ask the player to relog when the server did @reloadcashshop

so don't have to kick innocent players

Share this post


Link to post
Share on other sites

@@AnnieRuru

 

yeah, it could be just ask the player to relog, the problem is when players who didn't relog can have problems like buying items wherein price has been changed, they'll see the old value but when they buy, the new value will be deducted

 

i see your point that it could be a problem for players who are doing instance i think, or in maps where the character can't stau upon relogging

Share this post


Link to post
Share on other sites

i see your point that it could be a problem for players who are doing instance i think, or in maps where the character can't stau upon relogging

isn't it still better than kick the whole server xD

well, if event maps, there are nocashshop mapflag,

but if instance map, no comment

 

 

just in case you don't know how to do this ...

every time some one do @reloadcashshop, it adds the server variable +1

then there is also a player variable initialize when they log in

if the player variable doesn't match the server variable, ask them to relog

 

I used this trick for reset txt style pvp ladder

Share this post


Link to post
Share on other sites

FYI, I've noticed that the use of this script causes memory leakage from the cash shop being reloaded.

I personally see around 763 bytes that fails to be released after a reload. Running the command twice left 1426 bytes that the Memory Manager had to clean up afterwards. 

Not that this is that much, but I imagine it could become an issue with extended use.

 

Not sure if there's much that can be done on this one. 

 

The code looks like it frees up the struct it creates, and deletes the timer. I'll look at it later on when I have some time to see if there's something that can be done.

 

Alternatively, is anyone else noticing this?

Share this post


Link to post
Share on other sites

FYI, I've noticed that the use of this script causes memory leakage from the cash shop being reloaded.

I personally see around 763 bytes that fails to be released after a reload. Running the command twice left 1426 bytes that the Memory Manager had to clean up afterwards. 

Not that this is that much, but I imagine it could become an issue with extended use.

 

Not sure if there's much that can be done on this one. 

 

The code looks like it frees up the struct it creates, and deletes the timer. I'll look at it later on when I have some time to see if there's something that can be done.

 

Alternatively, is anyone else noticing this?

I haven;t try this but i'm planning to add but i notice that you've posted something about it, so you want to make another code for this one?

Share this post


Link to post
Share on other sites
ACMD(cashreload) {
	int i, j;

	if ( countdown )
		return false;

	for(i = 0; i < CASHSHOP_TAB_MAX; i++) {
		for( j = 0; j < clif->cs.item_count[i]; j++ ) {
			aFree(clif->cs.data[i][j]);
		}
		aFree(clif->cs.data[i]);
	}

	clif->cashshop_load();
	cashreload_countid = timer->add( timer->gettick() + 1000, cashreload_countdown, 0, 0 );
	clif->message(fd, "Cash Shop Reloaded");
	countdown = 11;
	return true;
}

You forgot to free the CashShop array, and did cashshop_load, which recreated the memory while previous haven't been free'd

Share this post


Link to post
Share on other sites

actually, it should be possible to reload cashshop without need to kick player :)

will see if my workaround works when i go back work soon!

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...

×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.