Maintenance mode

AnnieRuru

~~Cute~Cute~Scripter~~
Messages
1,677
Points
0
Location
your next door ~
Discord
AnnieRuru#1609
Github
AnnieRuru
Emulator
Client Version
2019-05-30aRagexeRE
Download: 1.5

plugin

create table maintenance (
id int primary key auto_increment,
account_id int,
name varchar(23),
reason varchar(99),
minlv2connect tinyint,
order_time datetime,
start_time datetime,
end_time datetime
) engine = innodb;

 

.

remember to enable HPMHooking to enable this modification

Code:
plugins_list: [
	/* Enable HPMHooking when plugins in use rely on Hooking */
	"HPMHooking",
.

.

Note:

sometimes the server countdown jumps 1 second ahead

this is normal because the timetick from time->add is unstable

so I use unix_time to synchronize the countdown to server time

.

.

so, if you found some script/source code having bugs and you need to shut down your server for a short while

then you come to the right place

.

Code:
@maintenance <Group ID can stay 1~99> <duration to kick in minute> <maintenance duration in minute> <reason>
then a GM99 can commence the maintenance

Example : '@maintenance 40 5 10 need to fix announcer script'

every player with group ID 40 and below will be kick after 5 minutes

and the server will start counting down by an announcement,

during the maintenance of 10 minutes, group ID 40 and below will deny from login into the server

`maintenance` table will also generate a new line, with the `reason` field as 'need to fix announcer script'

which is useful to know when and how many times you did emergency server shutdown

though, the actual reason for using SQL is to persist the data after server shutdown

so the server will continue being in maintenance mode despite how many times you have shut down the server

until it times up ( `end_time` field ), or manually do `@maintenanceoff`

Note:

you can't generate a new line using 'INSERT INTO' Sql syntax when server is online

because I declare a bunch of variables to for them, for the purpose of saving memory consumption

you have to login the game and type `@maintenance` to initiate the maintenance mode, otherwise it wont work.

.

.

.

Code:
@maintenanceoff
if you have already finished fixing the script/source code, and there's still a lot of time left

you can type '@maintenanceoff' to immediately turn off the maintenance mode so players can login before the schedule.

.

.

.

.

-- Script commands --

.

*maintenance <Group ID can stay 1~99>, <duration to kick in minute>, <maintenance duration in minute> { , <reason> };


.

.

actually I have no idea why I wanna make a script command ... maybe just for fun ?

.

Code:
-	script	jsdfksdj	FAKE_NPC,{
OnMon0255:
	maintenance 40, 5, 60;
	end;
}
.

this will make an announcement on Monday, 2:55AM that the server will have a regular server maintenance starts from 3AM to 4AM

during that time, player with group ID 40 will be kicked and blocked from entering the server

the `reason` field in `maintenance` table will be defaulted to '*Regular server maintenance*'

.

maintenance 40, 5, 60, "系统保养";

this will overwrite the `reason` field in `maintenance` table to '系统保养' instead of regular maintenance

.

.

*maintenanceoff { <reason> };


uhh ... useless I think ...

.

.

*maintenancecheck( <type> );


use 'maintenance()' to check the server is currently in maintenance mode or not

return 0 if server is normal

return 1 if server is going to have maintenance

return 2 if server is having maintenance

all other types are meant to myself to debug this junk

1.0

plugin

patch

1.1

plugin

patch

--- change timer reset variable from 0 into INVALID_TIMER (-1)

--- fix plugin when GM type '@maintenance' blank, it mentioned group id 0, should be showing the correct syntax

--- also change 60-5-1 into 60-10-1 when announcing countdown

--- change maintainance into maintenance hahaha, 4 of them

1.2

plugin

patch

--- initialize all short/inf variable because of st*p*d compiler problem

--- change intif-broadcast into intif-broadcast2 to allow changing announcement color

1.3

plugin

patch

nothing much change other than increase readability

--- fix all misleading aaa[255] into output[CHAT_SIZE_MAX]

--- move the config value to battle folder for the patch

1.4

plugin

- nothing change much, other than fixing to the new format

1.5

plugin

- update to latest revision, but nothing else is change

 
Last edited by a moderator:
So sexy picture...
default_laugh.png


Can make the patch for rathena user too...?>_<

 
Last edited by a moderator:
Test it with Windows MSVC no problem., but when I tried with CentOS I get an error return while compiling:

Quote

CC maintenance.c

maintenance.c: In function ‘atcommand_maintenance’:

maintenance.c:237: warning: implicit declaration of function ‘aMalloc’

maintenance.c:237: warning: cast to pointer from integer of different size

maintenance.c:256: warning: implicit declaration of function ‘aFree’

maintenance.c: In function ‘plugin_init’:

maintenance.c:534: error: ‘iMalloc’ undeclared (first use in this function)

maintenance.c:534: error: (Each undeclared identifier is reported only once

maintenance.c:534: error: for each function it appears in.)

make[1]: *** [../../plugins/maintenance.so] Error 1

make[1]: Leaving directory `/home/nix/hercules/src/plugins'

make: *** [plugins] Error 2
Ok seems working now with centos I just added on include:

Quote

#include "../common/malloc.h"
with little warnings and could be ignored.

Thanks again AnnieRuru.

 
Last edited by a moderator:
@Darkpurple

nope, this modification took me 2 full days to write, very time consuming stuffs

go ahead and buy from roserver or cydh ... I don't care

seriously, you should consider switch to hercules because I noticed you always follow my posts

@THPO

fixed in 1.0a

 
Last edited by a moderator:
So sexy picture...
default_laugh.png


Can make the patch for rathena user too...?>_<
 for rAthena, u can do simply trick

[*]just do normal announcement "/b I gonna do maintenance bla bla bla"

[*]"@kickall"

[*]with a little modification on char & login server (see my PR on rA "server:reloadconf"

[*]edit the configs that have mean to "only this group level above can login"

[*]on your char & login server console, (make sure console:yes for both servers) just go type "server:reloadconf"

ehh, the proper sort is 3-1-4-5-2.
default_tongue.png


@Annie

instead of use 0 here, u should use INVALID_TIMER (and other lines)

Code:
+       if ( chrif->maintenance_countid > 0 ) {+               timer->delete( chrif->maintenance_countid, chrif->maintenance_countdown );+               chrif->maintenance_countid = 0; +       }
 
Last edited by a moderator:
@Annie

instead of use 0 here, u should use INVALID_TIMER (and other lines)

+       if ( chrif->maintenance_countid > 0 ) {+               timer->delete( chrif->maintenance_countid, chrif->maintenance_countdown );+               chrif->maintenance_countid = 0; +       }
are you sure about this ...

there is no problem with plugin with this, as I can initialize the value as -1 at the top of the file

but I am not able to change it inside chrif.h with the patch

how to reproduce :

1. type @maintenance 1 1 1 aaaaaa

2. immediately @maintenanceoff

[Error]: timer_do_delete error : function mismatch 005E9EE4(console_parse_timer) != 005E6E01(unknown timer function)
the chrif->maintenance_timerid was defaulted to 0, and INVALID_TIMER is -1
1. how do I initialize the value as -1 ?

2. or maybe I just change != operator into > ...?

because all I see the example inside src folder is always ( xxxx != INVALID_TIMER )

LOL I forgot I have execute the timer when server starts

so just have to initialize the value inside chrif_connectack function

up everything to version 1.1

 
Last edited by a moderator:
i think there's a problem, i tried to @maintenance 99 3 20 Testing Purposes , Everything goes well, the players got kick and i try to login with dual login using normal account (not GM99) , it still can login.

 
i think there's a problem, i tried to @maintenance 99 3 20 Testing Purposes , Everything goes well, the players got kick and i try to login with dual login using normal account (not GM99) , it still can login.
can't reproduce, tested with the plugin oneI do the same, KinoRuru not able to login, even with server restart

type @who to confirm it is normal player or not

or, try with the maintenancecheck() script command to debug type 1 value when maintenance is on

Code:
-	script	kjdfksjdf	-1,{OnInit:	for ( .@i = 0; .@i <= 5; .@i++ )		announce .@i +". "+ maintenancecheck(.@i), 0;	end;}
screenHercules024.jpg
 
Last edited by a moderator:
Here i tried what you said.

also use this

- script kjdfksjdf -1,{OnInit: for ( .@i = 0; .@i <= 5; .@i++ ) announce .@i +". "+ maintenancecheck(.@i), 0; end;} 

what do you think?

screenNewChaos009-1.jpg

 
try overwrite the pc_authok_pre function with this

bool pc_authok_pre( struct map_session_data *sd, int *login_id2, time_t *expiration_time, int *group_id, struct mmo_charstatus *st, bool *changing_mapservers ) { ShowDebug( "unix %dn", time(NULL) ); ShowDebug( "start %dn", maintenance_starttime ); ShowDebug( "end %dn", maintenance_endtime ); ShowDebug( "*group %dn", *group_id ); ShowDebug( "main_group %dn", maintenance_group ); if ( time(NULL) > maintenance_starttime && maintenance_endtime > time(NULL) && *group_id < maintenance_group ) { clif->authfail_fd( sd->fd, 1 ); hookStop(); return false; } return true;}AnnieRuru (GM99) login got this
Code:
[Debug]: unix 1410468793[Debug]: start 1410468711[Debug]: end 1410498711[Debug]: *group 99[Debug]: main_group 99[Info]: 'AnnieRuru' logged in. (AID/CID: '2000000/150000', IP: '127.0.0.1', Group '99').
KinoRuru (GM0) login got this
Code:
[Debug]: unix 1410468800[Debug]: start 1410468711[Debug]: end 1410498711[Debug]: *group 0[Debug]: main_group 99[Info]: Closed connection from '127.0.0.1'.
..

I got a feeling that your server doesn't hook the function ...

 
Last edited by a moderator:
i got the feeling too..

is this because of my revision is :

Last Changed Rev: 14293
Last Changed Date: 2014-06-08

got warning on make plugin.maintenance

Code:
maintenance.c: In function ‘atcommand_maintenance’:maintenance.c:222: warning: ‘group_id’ may be used uninitialized in this functionmaintenance.c:222: warning: ‘kick_duration’ may be used uninitialized in this functionmaintenance.c:222: warning: ‘maintenance_duration’ may be used uninitialized in this functionmaintenance.c:224: warning: ‘weekday’ may be used uninitialized in this functionmaintenance.c:224: warning: ‘hour’ may be used uninitialized in this functionmaintenance.c:224: warning: ‘minute’ may be used uninitialized in this functionmaintenance.c: In function ‘buildin_maintenance’:maintenance.c:401: warning: ‘weekday’ may be used uninitialized in this functionmaintenance.c:401: warning: ‘hour’ may be used uninitialized in this functionmaintenance.c:401: warning: ‘minute’ may be used uninitialized in this functionmaintenance.c: In function ‘server_online’:maintenance.c:145: warning: ‘weekday’ may be used uninitialized in this functionmaintenance.c:145: warning: ‘hour’ may be used uninitialized in this functionmaintenance.c:145: warning: ‘minute’ may be used uninitialized in this function 
 
Last edited by a moderator:
@Darkpurple

nope, this modification took me 2 full days to write, very time consuming stuffs

go ahead and buy from roserver or cydh ... I don't care

seriously, you should consider switch to hercules because I noticed you always follow my posts

@THPO

fixed in 1.0a
Yup, I am one of your super fans
default_smile.png
Like your script which are all so creative.

But I have so many personal COSTUMED SCR MOD (paid) in rathena.

If I changed to use hercules, it mean that I need to give up all of them...
default_sad.png


 
@annieruru

-at my makefile.in

When you add a plugin, add its name here:   ## Example: if you have a plugin named my_cool_plugin.c and another ## one named my_second_plugin.c, add them to the list like this:   ##   ## MYPLUGINS = my_cool_plugin my_second_plugin   ##   ## This is only needed if you want to build your plugin through ## 'make plugins' or 'make all'. If you don't add it to this list,  ## you will still be able to build your plugin through   ## 'make plugin.my_plugin'   ##   ## Note: DO NOT include the .c extension!!! #MYPLUGINS = GM_impersonate maintenance 



plugins.conf

plugins_list: [  /* Enable HPMHooking when plugins in use rely on Hooking */  //"HPMHooking",  //"db2sql",  //"sample",  //"other",  "GM_impersonate",  "maintenance",] 
Last Changed Rev: 14293

Last Changed Date: 2014-06-08

 
/* Enable HPMHooking when plugins in use rely on Hooking */ //"HPMHooking",
There's your problem. This plugin uses hooking.

 
i think there's a problem, i tried to @maintenance 99 3 20 Testing Purposes , Everything goes well, the players got kick and i try to login with dual login using normal account (not GM99) , it still can login.
I just tested with same settings no problem at all.

 
Back
Top