@cashreload

Samuel

New member
Messages
397
Points
0
Discord
Elijah#5798
Github
Samuel23
Emulator
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
default_smile.png


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

 
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 ...screenRuru_Server042.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

 
@@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

 
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 xDwell, 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

 
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?

 
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?

 
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; j++ ) {
aFree(clif->cs.data[j]);
}
aFree(clif->cs.data);
}

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

 
Last edited by a moderator:
actually, it should be possible to reload cashshop without need to kick player
default_smile.png


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

 
Back
Top