@autopots

- Mariel

New member
Messages
80
Points
0
Age
29
Location
Philippines
Emulator
CC autopots.c
autopots.c: In function 'autoatpots_timer':
autopots.c:79: warning: unused variable 'item'
autopots.c: In function 'atcommand_autopots':
autopots.c:133: warning: implicit declaration of function 'sscanf_s'
autopots.c: In function 'autoatpots_timer':
autopots.c:114: warning: array subscript is above array bounds
autopots.c:120: warning: array subscript is above array bounds
/tmp/ccqykVpt.o: In function `atcommand_autosp':
/home/xxx/trunk/src/plugins/autopots.c:231: undefined reference to `sscanf_s'
/home/xxx/trunk/src/plugins/autopots.c:232: undefined reference to `sscanf_s'
/home/xxx/trunk/src/plugins/autopots.c:228: undefined reference to `sscanf_s'
/tmp/ccqykVpt.o: In function `atcommand_autohp':
/home/xxx/trunk/src/plugins/autopots.c:189: undefined reference to `sscanf_s'
/home/xxx/trunk/src/plugins/autopots.c:190: undefined reference to `sscanf_s'
/tmp/ccqykVpt.o:/home/xxx/trunk/src/plugins/autopots.c:186: more undefined references to `sscanf_s' follow
collect2: ld returned 1 exit status
make[1]: *** [../../plugins/autopots.so] Error 1
make[1]: Leaving directory `/home/xxx/trunk/src/plugins'
make: *** [plugins] Error 2

Any one who knows how to fix this ? Thanks in advance. 

Edit : I tried using the fresh latest revision, and make plugins. Still the same error.

 
Last edited by a moderator:
can you share me your codes? i really can't reproduce your error
default_hmm.gif


 
can you share me your codes? i really can't reproduce your error
default_hmm.gif
#include

#include

#include

#include "../common/HPMi.h"

#include "../common/timer.h"

#include "../map/script.h"

#include "../map/pc.h"

#include "../map/map.h"

#include "../map/unit.h"

#include "../map/atcommand.h"

#include "../map/itemdb.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) */

#define OPTION_AUTOPOTS 0x40000000

/*

3.1 Plugins Release [Mhalicot]

3.2 Update to Latest Revision [Mhalicot]

4.0 Added autohp, autosp command Rev. 137* [Mhalicot]

4.1 Fixed Compilation error. Rev. 145*** [Mhalicot]

-----------------------------------------------------

Documentation

@autopots

@autohp

@autosp // Change autopots/hp/sp timer by replacing +500 in milisec

timer->add(timer->gettick()+500,autoatpots_timer,sd->bl.id,0);

*/

HPExport struct hplugin_info pinfo = {

"autopots", // Plugin name

SERVER_TYPE_MAP, // Which server types this plugin works with?

"4.0", // Plugin version

HPM_VERSION, // HPM Version (don't change, macro is automatically updated)

};

struct autopots {

unsigned int hp_rate, sp_rate, hp_nameid, sp_nameid;

};

struct autopots autopots;

void autoatpots_clean(struct map_session_data *sd)

{

if( sd )

{

sd->sc.option &= ~OPTION_AUTOPOTS;

autopots.hp_nameid = 0;

autopots.hp_rate = 0;

autopots.sp_nameid = 0;

autopots.sp_rate = 0;

clif->changeoption(&sd->bl);

}

return;

}

void autoathp_clean(struct map_session_data *sd)

{

if( sd )

{

sd->sc.option &= ~OPTION_AUTOPOTS;

autopots.hp_nameid = 0;

autopots.hp_rate = 0;

clif->changeoption(&sd->bl);

}

return;

}

void autoatsp_clean(struct map_session_data *sd)

{

if( sd )

{

sd->sc.option &= ~OPTION_AUTOPOTS;

autopots.sp_nameid = 0;

autopots.sp_rate = 0;

clif->changeoption(&sd->bl);

}

return;

}

int autoatpots_timer(int tid, int64 tick, int id, intptr_t data)

{

struct map_session_data *sd=NULL;

struct item_data* item = NULL;

int index;

sd=map->id2sd(id);

if( sd == NULL )

return 0;

if(sd->sc.option & OPTION_AUTOPOTS)

{

unsigned int hp_rate = autopots.hp_rate;

unsigned int sp_rate = autopots.sp_rate;

unsigned int hp_nameid = autopots.hp_nameid;

unsigned int sp_nameid = autopots.sp_nameid;

if( ( !sp_rate && !hp_rate ) || pc_isdead(sd) )

{

if( !hp_rate )

{

clif->message(sd->fd, "Auto-SP : OFF_");

autoatsp_clean(sd);

return 0;

}else

if( !sp_rate )

{

clif->message(sd->fd, "Auto-HP : OFF_");

autoathp_clean(sd);

return 0;

}

else{

clif->message(sd->fd, "Auto-pots : OFF_");

autoatpots_clean(sd);

return 0;

}

}

if( ( sd->battle_status.hp*100/sd->battle_status.max_hp ) < hp_rate && hp_nameid && hp_rate )

{

ARR_FIND(0, MAX_INVENTORY, index, sd->status.inventory[index].nameid == hp_nameid);

if( sd->status.inventory[index].nameid == hp_nameid )

pc->useitem(sd,index);

}

if( ( sd->battle_status.sp*100/sd->battle_status.max_sp ) < sp_rate && sp_nameid && sp_rate )

{

ARR_FIND(0, MAX_INVENTORY, index, sd->status.inventory[index].nameid == sp_nameid);

if( sd->status.inventory[index].nameid == sp_nameid )

pc->useitem(sd,index);

}

timer->add(timer->gettick()+500,autoatpots_timer,sd->bl.id,0);

}

return 0;

}

ACMD(autopots)

{

int hp_rate=0, hp_nameid=0, sp_rate=0, sp_nameid=0;

if( !sd ) return 0;

if ( !message || !*message || (

sscanf_s(message, "%d %d %d %d ", &hp_rate, &hp_nameid, &sp_rate, &sp_nameid) < 4) ||

( hp_rate < 0 || hp_rate > 99 ) ||

( sp_rate < 0 || sp_rate > 99 ) )

{

if ( sscanf_s(message, "%d %d %d %d ", &hp_rate, &hp_nameid, &sp_rate, &sp_nameid) < 4 &&

sscanf_s(message, "%d %d %d %d ", &hp_rate, &hp_nameid, &sp_rate, &sp_nameid) > 0)

{

clif->message(fd, "@autopots ");

return false;

}

clif->message(fd, "Auto-pots : OFF");

autoatpots_clean(sd);

return true;

}

if (sd->sc.option & OPTION_AUTOPOTS)

{

autoatpots_clean(sd);

}

if( hp_rate == 0 ) hp_nameid = 0;

if( sp_rate == 0 ) sp_nameid = 0;

if( hp_nameid == 0 ) hp_rate = 0;

if( sp_nameid == 0 ) sp_rate = 0;

if( itemdb->exists(hp_nameid) == NULL && hp_nameid )

{

hp_nameid = 0;

hp_rate = 0;

clif->message(fd, "Auto-pots : Invalid item for HP");

}

if( itemdb->exists(sp_nameid) == NULL && sp_nameid )

{

sp_nameid = 0;

sp_rate = 0;

clif->message(fd, "Auto-pots : Invalid item for SP");

return true;

}

clif->message(fd, "Auto-pots : ON");

sd->sc.option |= OPTION_AUTOPOTS;

autopots.hp_nameid = hp_nameid;

autopots.hp_rate = hp_rate;

autopots.sp_nameid = sp_nameid;

autopots.sp_rate = sp_rate;

timer->add(timer->gettick()+200,autoatpots_timer,sd->bl.id,0);

clif->changeoption(&sd->bl);

return true;

}

ACMD(autohp)

{

int hp_rate=0, hp_nameid=0;

if( !sd ) return 0;

if (!message || !*message || (

sscanf_s(message, "%d %d ", &hp_rate, &hp_nameid) < 2) ||

( hp_rate < 0 || hp_rate > 99 ) )

{

if ( sscanf_s(message, "%d %d ", &hp_rate, &hp_nameid) < 2 &&

sscanf_s(message, "%d %d ", &hp_rate, &hp_nameid) > 0)

{

clif->message(fd, "@autohp ");

return true;

}

clif->message(fd, "Auto-HP : OFF");

autoathp_clean(sd);

return true;

}

if (sd->sc.option & OPTION_AUTOPOTS)

{

autoathp_clean(sd);

}

if( hp_rate == 0 ) hp_nameid = 0;

if( hp_nameid == 0 ) hp_rate = 0;

if( itemdb->exists(hp_nameid) == NULL && hp_nameid )

{

hp_nameid = 0;

hp_rate = 0;

clif->message(fd, "Auto-HP : Invalid item for HP");

return true;

}

clif->message(fd, "Auto-HP : ON");

sd->sc.option |= OPTION_AUTOPOTS;

autopots.hp_nameid = hp_nameid;

autopots.hp_rate = hp_rate;

timer->add(timer->gettick()+200,autoatpots_timer,sd->bl.id,0);

clif->changeoption(&sd->bl);

return true;

}

ACMD(autosp)

{

int sp_rate=0, sp_nameid=0;

if( !sd ) return 0;

if (!message || !*message || (

sscanf_s(message, "%d %d ", &sp_rate, &sp_nameid) < 2) ||

( sp_rate < 0 || sp_rate > 99 ) )

{

if ( sscanf_s(message, "%d %d ", &sp_rate, &sp_nameid) < 2 &&

sscanf_s(message, "%d %d ", &sp_rate, &sp_nameid) > 0)

{

clif->message(fd, "@autosp ");

return true;

}

clif->message(fd, "Auto-SP : OFF");

autoatsp_clean(sd);

return true;

}

if (sd->sc.option & OPTION_AUTOPOTS)

{

autoatsp_clean(sd);

}

if( sp_rate == 0 ) sp_nameid = 0;

if( sp_nameid == 0 ) sp_rate = 0;

if( itemdb->exists(sp_nameid) == NULL && sp_nameid )

{

sp_nameid = 0;

sp_rate = 0;

clif->message(fd, "Auto-SP : Invalid item for SP");

return true;

}

clif->message(fd, "Auto-SP : ON");

sd->sc.option |= OPTION_AUTOPOTS;

autopots.sp_nameid = sp_nameid;

autopots.sp_rate = sp_rate;

timer->add(timer->gettick()+200,autoatpots_timer,sd->bl.id,0);

clif->changeoption(&sd->bl);

return true;

}

/* Server Startup */

HPExport void plugin_init (void)

{

clif = GET_SYMBOL("clif");

script = GET_SYMBOL("script");

pc = GET_SYMBOL("pc");

atcommand = GET_SYMBOL("atcommand");

map = GET_SYMBOL("map");

unit = GET_SYMBOL("unit");

timer = GET_SYMBOL("timer");

itemdb = GET_SYMBOL("itemdb");

addAtcommand("autopots",autopots);//link our '@autopots' command

addAtcommand("autohp",autohp);//link our '@autohp' command

addAtcommand("autosp",autosp);//link our '@autosp' command

}
More power to you Mhalicot. :> Thanks in advance.

 
can I ask? why there is an empty #include in there? is it typo error? can you remove it in your code and recompile @autopots check if still have error?

if theres error try to use autotpots

 
can I ask? why there is an empty #include in there? is it typo error? can you remove it in your code and recompile @autopots check if still have error?

if theres error try to use autotpots
still the same
default_sad.png
weird. sorry can't help its working my latest SVN.. is your server updated?
I'll try pulling a new hercules and try make plugins. If you upload autopots.so, will my server load that plugin ?

 
I dont have autopots,so because im using Windows, so i compile it using MSVS.

 
I dont have autopots,so because im using Windows, so i compile it using MSVS.
I don't know what to do. Thanks anyway! 
default_biggrin.png
Update first your hercules and let me know if still have problem.
I already did a fresh install of hercules using 'git clone https[color=rgb(102,102,0);:[/color]//github.com/HerculesWS/Hercules.git ~/Hercules']

then git pull

then ./configure

then make clean

pasted in src/plugins autopots.so

edited makefile.in

then make plugins

still the same errors

 
why you need to paste the autopots.so? when you compile autopots.so it will automatically generate autopots.so...

Make sure you know this guide

http://herc.ws/wiki/Building_HPM_Plugin_for_gcc
Oh it's a typo. I mean autopots.c
Is it errors or Warning? if, warning only you can ignore it.. check if it successfully build..
Error in building the plugin. Save as above, the only difference is that trunk folder is replaced by Hercules folder.

 
/home/xxx/trunk/src/plugins/autopots.c:231: undefined reference to `sscanf_s'
you need to include 'stdio.h'

default_ani_meow.gif
#include <stdio.h>

#include <stdlib.h>

#include <string.h>

#include "../common/HPMi.h"

#include "../common/timer.h"

#include "../map/script.h"

#include "../map/pc.h"

#include "../map/map.h"

#include "../map/unit.h"

#include "../map/atcommand.h"

#include "../map/itemdb.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) */

#define OPTION_AUTOPOTS 0x40000000

/*

3.1 Plugins Release [Mhalicot]

3.2 Update to Latest Revision [Mhalicot]

4.0 Added autohp, autosp command Rev. 137* [Mhalicot]

4.1 Fixed Compilation error. Rev. 145*** [Mhalicot]

-----------------------------------------------------

Documentation

@autopots

@autohp

@autosp // Change autopots/hp/sp timer by replacing +500 in milisec

timer->add(timer->gettick()+500,autoatpots_timer,sd->bl.id,0);

*/

HPExport struct hplugin_info pinfo = {

"autopots", // Plugin name

SERVER_TYPE_MAP, // Which server types this plugin works with?

"4.0", // Plugin version

HPM_VERSION, // HPM Version (don't change, macro is automatically updated)

};

struct autopots {

unsigned int hp_rate, sp_rate, hp_nameid, sp_nameid;

};

struct autopots autopots;

void autoatpots_clean(struct map_session_data *sd)

{

if( sd )

{

sd->sc.option &= ~OPTION_AUTOPOTS;

autopots.hp_nameid = 0;

autopots.hp_rate = 0;

autopots.sp_nameid = 0;

autopots.sp_rate = 0;

clif->changeoption(&sd->bl);

}

return;

}

void autoathp_clean(struct map_session_data *sd)

{

if( sd )

{

sd->sc.option &= ~OPTION_AUTOPOTS;

autopots.hp_nameid = 0;

autopots.hp_rate = 0;

clif->changeoption(&sd->bl);

}

return;

}

void autoatsp_clean(struct map_session_data *sd)

{

if( sd )

{

sd->sc.option &= ~OPTION_AUTOPOTS;

autopots.sp_nameid = 0;

autopots.sp_rate = 0;

clif->changeoption(&sd->bl);

}

return;

}

int autoatpots_timer(int tid, int64 tick, int id, intptr_t data)

{

struct map_session_data *sd=NULL;

struct item_data* item = NULL;

int index;

sd=map->id2sd(id);

if( sd == NULL )

return 0;

if(sd->sc.option & OPTION_AUTOPOTS)

{

unsigned int hp_rate = autopots.hp_rate;

unsigned int sp_rate = autopots.sp_rate;

unsigned int hp_nameid = autopots.hp_nameid;

unsigned int sp_nameid = autopots.sp_nameid;

if( ( !sp_rate && !hp_rate ) || pc_isdead(sd) )

{

if( !hp_rate )

{

clif->message(sd->fd, "Auto-SP : OFF_");

autoatsp_clean(sd);

return 0;

}else

if( !sp_rate )

{

clif->message(sd->fd, "Auto-HP : OFF_");

autoathp_clean(sd);

return 0;

}

else{

clif->message(sd->fd, "Auto-pots : OFF_");

autoatpots_clean(sd);

return 0;

}

}

if( ( sd->battle_status.hp*100/sd->battle_status.max_hp ) < hp_rate && hp_nameid && hp_rate )

{

ARR_FIND(0, MAX_INVENTORY, index, sd->status.inventory[index].nameid == hp_nameid);

if( sd->status.inventory[index].nameid == hp_nameid )

pc->useitem(sd,index);

}

if( ( sd->battle_status.sp*100/sd->battle_status.max_sp ) < sp_rate && sp_nameid && sp_rate )

{

ARR_FIND(0, MAX_INVENTORY, index, sd->status.inventory[index].nameid == sp_nameid);

if( sd->status.inventory[index].nameid == sp_nameid )

pc->useitem(sd,index);

}

timer->add(timer->gettick()+500,autoatpots_timer,sd->bl.id,0);

}

return 0;

}

ACMD(autopots)

{

int hp_rate=0, hp_nameid=0, sp_rate=0, sp_nameid=0;

if( !sd ) return 0;

if ( !message || !*message || (

sscanf_s(message, "%d %d %d %d ", &hp_rate, &hp_nameid, &sp_rate, &sp_nameid) < 4) ||

( hp_rate < 0 || hp_rate > 99 ) ||

( sp_rate < 0 || sp_rate > 99 ) )

{

if ( sscanf_s(message, "%d %d %d %d ", &hp_rate, &hp_nameid, &sp_rate, &sp_nameid) < 4 &&

sscanf_s(message, "%d %d %d %d ", &hp_rate, &hp_nameid, &sp_rate, &sp_nameid) > 0)

{

clif->message(fd, "@autopots ");

return false;

}

clif->message(fd, "Auto-pots : OFF");

autoatpots_clean(sd);

return true;

}

if (sd->sc.option & OPTION_AUTOPOTS)

{

autoatpots_clean(sd);

}

if( hp_rate == 0 ) hp_nameid = 0;

if( sp_rate == 0 ) sp_nameid = 0;

if( hp_nameid == 0 ) hp_rate = 0;

if( sp_nameid == 0 ) sp_rate = 0;

if( itemdb->exists(hp_nameid) == NULL && hp_nameid )

{

hp_nameid = 0;

hp_rate = 0;

clif->message(fd, "Auto-pots : Invalid item for HP");

}

if( itemdb->exists(sp_nameid) == NULL && sp_nameid )

{

sp_nameid = 0;

sp_rate = 0;

clif->message(fd, "Auto-pots : Invalid item for SP");

return true;

}

clif->message(fd, "Auto-pots : ON");

sd->sc.option |= OPTION_AUTOPOTS;

autopots.hp_nameid = hp_nameid;

autopots.hp_rate = hp_rate;

autopots.sp_nameid = sp_nameid;

autopots.sp_rate = sp_rate;

timer->add(timer->gettick()+200,autoatpots_timer,sd->bl.id,0);

clif->changeoption(&sd->bl);

return true;

}

ACMD(autohp)

{

int hp_rate=0, hp_nameid=0;

if( !sd ) return 0;

if (!message || !*message || (

sscanf_s(message, "%d %d ", &hp_rate, &hp_nameid) < 2) ||

( hp_rate < 0 || hp_rate > 99 ) )

{

if ( sscanf_s(message, "%d %d ", &hp_rate, &hp_nameid) < 2 &&

sscanf_s(message, "%d %d ", &hp_rate, &hp_nameid) > 0)

{

clif->message(fd, "@autohp ");

return true;

}

clif->message(fd, "Auto-HP : OFF");

autoathp_clean(sd);

return true;

}

if (sd->sc.option & OPTION_AUTOPOTS)

{

autoathp_clean(sd);

}

if( hp_rate == 0 ) hp_nameid = 0;

if( hp_nameid == 0 ) hp_rate = 0;

if( itemdb->exists(hp_nameid) == NULL && hp_nameid )

{

hp_nameid = 0;

hp_rate = 0;

clif->message(fd, "Auto-HP : Invalid item for HP");

return true;

}

clif->message(fd, "Auto-HP : ON");

sd->sc.option |= OPTION_AUTOPOTS;

autopots.hp_nameid = hp_nameid;

autopots.hp_rate = hp_rate;

timer->add(timer->gettick()+200,autoatpots_timer,sd->bl.id,0);

clif->changeoption(&sd->bl);

return true;

}

ACMD(autosp)

{

int sp_rate=0, sp_nameid=0;

if( !sd ) return 0;

if (!message || !*message || (

sscanf_s(message, "%d %d ", &sp_rate, &sp_nameid) < 2) ||

( sp_rate < 0 || sp_rate > 99 ) )

{

if ( sscanf_s(message, "%d %d ", &sp_rate, &sp_nameid) < 2 &&

sscanf_s(message, "%d %d ", &sp_rate, &sp_nameid) > 0)

{

clif->message(fd, "@autosp ");

return true;

}

clif->message(fd, "Auto-SP : OFF");

autoatsp_clean(sd);

return true;

}

if (sd->sc.option & OPTION_AUTOPOTS)

{

autoatsp_clean(sd);

}

if( sp_rate == 0 ) sp_nameid = 0;

if( sp_nameid == 0 ) sp_rate = 0;

if( itemdb->exists(sp_nameid) == NULL && sp_nameid )

{

sp_nameid = 0;

sp_rate = 0;

clif->message(fd, "Auto-SP : Invalid item for SP");

return true;

}

clif->message(fd, "Auto-SP : ON");

sd->sc.option |= OPTION_AUTOPOTS;

autopots.sp_nameid = sp_nameid;

autopots.sp_rate = sp_rate;

timer->add(timer->gettick()+200,autoatpots_timer,sd->bl.id,0);

clif->changeoption(&sd->bl);

return true;

}

/* Server Startup */

HPExport void plugin_init (void)

{

clif = GET_SYMBOL("clif");

script = GET_SYMBOL("script");

pc = GET_SYMBOL("pc");

atcommand = GET_SYMBOL("atcommand");

map = GET_SYMBOL("map");

unit = GET_SYMBOL("unit");

timer = GET_SYMBOL("timer");

itemdb = GET_SYMBOL("itemdb");

addAtcommand("autopots",autopots);//link our '@autopots' command

addAtcommand("autohp",autohp);//link our '@autohp' command

addAtcommand("autosp",autosp);//link our '@autosp' command

}

make[1]: Entering directory `/home/xxx/trunk/src/plugins'

CC autopots.c

autopots.c: In function 'autoatpots_timer':

autopots.c:79: warning: unused variable 'item'

autopots.c: In function 'atcommand_autopots':

autopots.c:133: warning: implicit declaration of function 'sscanf_s'

autopots.c: In function 'autoatpots_timer':

autopots.c:114: warning: array subscript is above array bounds

autopots.c:120: warning: array subscript is above array bounds

/tmp/cceKjLNC.o: In function `atcommand_autosp':

/home/xxx/trunk/src/plugins/autopots.c:231: undefined reference to `sscanf_s'

/home/xxx/trunk/src/plugins/autopots.c:232: undefined reference to `sscanf_s'

/home/xxx/trunk/src/plugins/autopots.c:228: undefined reference to `sscanf_s'

/tmp/cceKjLNC.o: In function `atcommand_autohp':

/home/xxx/trunk/src/plugins/autopots.c:189: undefined reference to `sscanf_s'

/home/xxx/trunk/src/plugins/autopots.c:190: undefined reference to `sscanf_s'

/tmp/cceKjLNC.o:/home/xxx/trunk/src/plugins/autopots.c:186: more undefined references to `sscanf_s' follow

collect2: ld returned 1 exit status

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

make[1]: Leaving directory `/home/xxx/trunk/src/plugins'

make: *** [plugin.autopots] Error 2
still no luck
default_sad.png
 
default_sad.png
 
default_sad.png
 
default_sad.png


using revision 16772

 
Last edited by a moderator:
Back
Top