Lately i been working to switch from eAthena server to Hercules.
with all the new functions Hercules has i started to build new scripts for my npcs.
i found myself searching a lot for lists:
1) Name of people on specific map.
2) Char ID of people on specific map.
3) Account ID of people on specific map.
BUILDIN(getmapusers) {
int16 m;
int type = 0;
int users = 0;
struct s_mapiterator* iter;
struct map_session_data *sd;
const char *str;
str = script_getstr(st,2);
if( (m=map->mapname2mapid(str))< 0) {
script_pushint(st,-1);
return true;
}
if (script_hasdata(st,3))
type = script_getnum(st,3);
else{
script_pushint(st,map->list[m].users);
return true;
}
iter = mapit_getallusers();
for (sd = BL_UCAST(BL_PC, mapit->first(iter)); mapit->exists(iter); sd = BL_UCAST(BL_PC, mapit->next(iter))) {
if (sd->bl.m == m){
switch (type)
{
case 1:
mapreg->setregstr(reference_uid(script->add_str("$@mapcharname$"), users), sd->status.name);
break;
case 2:
mapreg->setreg(reference_uid(script->add_str("$@mapcharid"), users), sd->status.char_id);
break;
case 3:
mapreg->setreg(reference_uid(script->add_str("$@mapaccountid"), users), sd->status.account_id);
break;
}
users++;
}
}
mapit->free(iter);
return true;
}
BUILDIN_DEF(getmapusers,"s?"),
I was wondering if you want to add it to Hercules as a new feature.
Regards,
Klutx