Need a @sleep script for Hercules

The command worked great on our test server (windows) but when we went to put Hercules to our root (linux) we get the message:

file at_sleep.so can not be found. How to get this file?

Thank you in advance
default_smile.png


 
Tried that but somehow my Linux gets stuck at compiling HPMHooking.c. I waited almost 2 hrs but nothing happend. Not even an error message.

Mfg

Snowflake

 
Last edited by a moderator:
HPMHooking.c

I completely remove the one default in hercules and rebuilt it from clean

also this particular plugin doesn't need to have HPMHooking anyways

 
Its disabled in plugins.conf. So where to disable that ?

Maybe here ?

# Plugins that will be built through 'make plugins' or 'make all'PLUGINS = sample db2sql HPMHooking $(MYPLUGINS)
like that ?

# Plugins that will be built through 'make plugins' or 'make all'PLUGINS = $(MYPLUGINS)

Mfg

Snowflake

 
Last edited by a moderator:
Hello Annie, its me again
default_smile.png


I updated my server around the 10th of August 2014 and got this error messages from my compiler

3> at_sleep.c3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): warning C4013: 'DIFF_TICK' undefiniert; Annahme: extern mit Rückgabetyp int3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): error C2065: 'timer': nichtdeklarierter Bezeichner3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): error C2223: Der linke Teil von '->gettick' muss auf eine Struktur/Union zeigen3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(57): error C2065: 'timer': nichtdeklarierter Bezeichner3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(57): warning C4047: '=': Anzahl der Dereferenzierungen bei 'int' und 'void *' unterschiedlich
Sorry for the german text, its just what my compiler gives me, cause my computer has a german windows.

How can I fix this problem ?

I am using the plugin you gave me.

Thanks in advance

Snowflake

 
Hello Annie, its me again
default_smile.png


I updated my server around the 10th of August 2014 and got this error messages from my compiler

3> at_sleep.c3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): warning C4013: 'DIFF_TICK' undefiniert; Annahme: extern mit Rückgabetyp int3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): error C2065: 'timer': nichtdeklarierter Bezeichner3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): error C2223: Der linke Teil von '->gettick' muss auf eine Struktur/Union zeigen3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(57): error C2065: 'timer': nichtdeklarierter Bezeichner3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(57): warning C4047: '=': Anzahl der Dereferenzierungen bei 'int' und 'void *' unterschiedlich
Sorry for the german text, its just what my compiler gives me, cause my computer has a german windows.

How can I fix this problem ?

I am using the plugin you gave me.

Thanks in advance

Snowflake
try to add a line  #include "../common/timer.h"  on the header

 
Hello Annie, its me again
default_smile.png


I updated my server around the 10th of August 2014 and got this error messages from my compiler

3> at_sleep.c3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): warning C4013: 'DIFF_TICK' undefiniert; Annahme: extern mit Rückgabetyp int3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): error C2065: 'timer': nichtdeklarierter Bezeichner3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(30): error C2223: Der linke Teil von '->gettick' muss auf eine Struktur/Union zeigen3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(57): error C2065: 'timer': nichtdeklarierter Bezeichner3>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(57): warning C4047: '=': Anzahl der Dereferenzierungen bei 'int' und 'void *' unterschiedlich
Sorry for the german text, its just what my compiler gives me, cause my computer has a german windows.

How can I fix this problem ?

I am using the plugin you gave me.

Thanks in advance

Snowflake
try to add a line  #include "../common/timer.h"  on the header
Will try it and tell the result.

Thank You
default_biggrin.png


 
Here the result, sadly its an error again:

1>------ Neues Erstellen gestartet: Projekt: at_sleep, Konfiguration: Debug Win32 ------1> at_sleep.c1> Bibliothek "..pluginsat_sleep.lib" und Objekt "..pluginsat_sleep.exp" werden erstellt.1>at_sleep.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_battle_config".1>..pluginsat_sleep.dll : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ==========
I can not find _battle_config in the @sleep script. There is only a !battle_config. This confuses me a bit.

Thanks in advance

Snowflake
default_smile.png


 
Here the result, sadly its an error again:

1>------ Neues Erstellen gestartet: Projekt: at_sleep, Konfiguration: Debug Win32 ------1> at_sleep.c1> Bibliothek "..pluginsat_sleep.lib" und Objekt "..pluginsat_sleep.exp" werden erstellt.1>at_sleep.obj : error LNK2001: Nicht aufgelöstes externes Symbol "_battle_config".1>..pluginsat_sleep.dll : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ==========
I can not find _battle_config in the @sleep script. There is only a !battle_config. This confuses me a bit.

Thanks in advance

Snowflake
default_smile.png
coz  you had patched wrong file

here is the plugin file

plugin

http://upaste.me/6611107511ac763ee

 
Hello Angelmelody,

all I did was adding #include "../common/timer.h" to the existing C++ code for the plugin.

I will try the plugin you posted now. Results will follow.

Mfg

Snowflake


Hello Angelmelody,

here the result of the script you posted.

Code:
1>------ Neues Erstellen gestartet: Projekt: at_sleep, Konfiguration: Debug Win32 ------1>  at_sleep.c1>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(27): warning C4013: 'DIFF_TICK' undefiniert; Annahme: extern mit Rückgabetyp int1>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(27): error C2065: 'timer': nichtdeklarierter Bezeichner1>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(27): error C2223: Der linke Teil von '->gettick' muss auf eine Struktur/Union zeigen1>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(54): error C2065: 'timer': nichtdeklarierter Bezeichner1>c:transfersnowhercules serverhercules trunksrcpluginsat_sleep.c(54): warning C4047: '=': Anzahl der Dereferenzierungen bei 'int' und 'void *' unterschiedlich========== Alles neu erstellen: 0 erfolgreich, Fehler bei 1, 0 übersprungen ==========
Mfg

Snowflake


Hello
default_smile.png
,

added #include "../common/timer.h" to the script / plugin. => Compile was fine, no errors.

Server started without problems, but when using the command I get following message in the client:

Code:
Please refrain from trying to abuse this command@sleep failed
Mfg

Snowflake


Hello
default_smile.png
,

I tested a bit, as far as my knowledge goes, and got this script now:

Code:
#include <stdio.h>#include <stdlib.h>#include <string.h>#include "../map/pc.h"#include "../common/timer.h"#include "../common/HPMi.h"#include "../common/HPMDataCheck.h" // should always be the last file included! (if you don't make it last, it'll intentionally break compile time)HPExport struct hplugin_info pinfo = {	"sleep",		// Plugin name	SERVER_TYPE_MAP,// Which server types this plugin works with?	"0.1",			// Plugin version	HPM_VERSION,	// HPM Version (don't change, macro is automatically updated)};/**===================================* Sleep (@sleep)*-----------------------------------*/ACMD(sleep) {	if ( map->agit_flag || map->agit2_flag ) { // skill not useable in WOE [A17kaliva]		clif->message( fd, "Cannot use this command during WOE." );		return false;	}	if ( !battle->bc->prevent_logout || DIFF_TICK( timer->gettick(), sd->canlog_tick) < battle->bc->prevent_logout ) {		if ( sd->sc.opt1 != 0 && sd->sc.opt1 != OPT1_SLEEP ) {			clif->message( fd, msg_txt(807) ); // abuse ?			return false;		}		if ( sd->sc.opt1 != OPT1_SLEEP) {			status->change_start( NULL, &sd->bl, SC_TRICKDEAD, 10000, 1, 0, 0, 0, 1000, 0);			sd->sc.opt1 = OPT1_SLEEP;			clif->message( fd, msg_txt(805) ); // sleeping		} else {			sd->sc.opt1 = 0;			clif->emotion(&sd->bl,45);			status_change_end(&sd->bl, SC_TRICKDEAD, -1);			clif->message( fd, msg_txt(806) ); // awake					}		clif->changeoption( &sd->bl );		return true;	}	clif->message( fd, msg_txt(808) );	return false;}HPExport void plugin_init (void) {	atcommand = GET_SYMBOL("atcommand");	clif = GET_SYMBOL("clif");	map = GET_SYMBOL("map");	timer = GET_SYMBOL("timer");	status = GET_SYMBOL("status");	battle = GET_SYMBOL("battle");	addAtcommand("sleep",sleep);}
I also added a line ( 808 ) to msg_conf.txt to see in which case the scripts shows up the abuse message:

Code:
//------------------------------------// More atcommands message//------------------------------------//@sleep805: You went to sleep now.806: You are waking up now.807: Please refrain from trying to abuse this command.808: You can not sleep during a battle.
I assume message 808 is displayed while fighting a monster.

My problem now is:

The character is in town, NOT FIGHTING anything and standig. Typing @sleep gives back the new message.

Code:
You can not sleep during a battle.@sleep failed
Based on my knowledge from BASIC and PHP I think the bug is somwehere in the line:

Code:
if ( !battle->bc->prevent_logout || DIFF_TICK( timer->gettick(), sd->canlog_tick) < battle->bc->prevent_logout ) {
At this point I need help, cause I don't understand what !battle->bc->prevent_logout and battle->bc->prevent_logout mean or do. Special those " -> "

Maybe the actual code uses an other way to read or store a variable ??? so this plugin cannot read that variable ???

Or a different variable ???

Mfg

Snowflake

 
Last edited by a moderator:
srry, I dunno what happened..

Are there 2 sleep command existing at the same time(one in atcommand.c the other in plugin)?

 
probably

http://herc.ws/board/topic/4875-sleep/

I just added the line

#include "../common/timer.h"and it runs well
and .... don't multi post(within 24 hours) ... use the edit button

I'll merge your posts

 
Last edited by a moderator:
Hello Annie,

the new plugin work fine. No errors when compiling and it works. Great Job
default_no1.gif


BTW: I would like to know what is different between the two scripts. The one I created out of Angelmelody's and yours.

I am just curious and like to learn a bit more about C/C++.
default_smile.png


Is it really just the fact that this line

if ( battle->bc->prevent_logout && ( DIFF_TICK( timer->gettick(), sd->canlog_tick ) < battle->bc->prevent_logout ) ) ...
has 4 brackets more then Angelmelody's ? Is the logic really that "sensitive" ?

Mfg

Snowflake

 
srry, I dunno what happened..

Are there 2 sleep command existing at the same time(one in atcommand.c the other in plugin)?
Hello Angelmelody,

there is only one @sleep command and its in the plugin. IMO this plugin-thingy is really usefull. You don't have to mess with the original code in atcommand.c.

I think all this happened cause the code itself was changed. Maybe in Atcommand.c, maybe in an other file. All I know ( learned by comparing ) is that my old plugin was reading a variable called:

!battle_config.prevent_logout
and the new plugin ( yours and Annie's ) reads the variable:

battle->bc->prevent_logout

( If that are variable names
default_smile.png
)

Mfg

Snowflake

 
Last edited by a moderator:
battle->bc->prevent_logout and battle_config.prevent_logout issit ?

well ... I dunno how to really explain this either

I only know that 'battle_config.xxxxx' cannot be read in the plugin, always return 0

but then I noticed this line

https://github.com/HerculesWS/Hercules/blob/master/src/map/battle.c#L7107

battle->bc = &battle_config;'battle_config.xxxxx' cannot be used, so has to use 'battle->bc->xxxxx'
hahaha ... sry I don't really know C stuffs either,

I just try and error

 
Last edited by a moderator:
Back
Top