Johnson Posted January 11, 2024 Posted January 11, 2024 (edited) May I ask help on getting monster to display on mapmoblist command. Somehow, it is not showing any monster data when use on @mapmoblist atcommand.cpp static int count_mob(struct block_list *bl, va_list ap) // [FE] { struct mob_data *md = (struct mob_data*)bl; short id = va_arg(ap, short); if (md->mob_id == id) return 1; return 0; } ACMD_FUNC(mapmoblist) // [FE] { char temp[100]; bool mob_searched[MAX_MOB_DB]; bool mob_mvp[MAX_MOB_DB]; // Store mvp data.. struct s_mapiterator* it; unsigned short count = 0, i, mapindex = 0; int m = 0; memset(mob_searched, 0, MAX_MOB_DB); memset(mob_mvp, 0, MAX_MOB_DB); if (message && *message) { // Player input map name, search mob list for that map mapindex = mapindex_name2id(message); if (!mapindex) { clif_displaymessage(fd, "Map not found"); return -1; } m = map_mapindex2mapid(mapindex); } else { // Player doesn't input map name, search mob list in player current map mapindex = sd->mapindex; m = sd->bl.m; } clif_displaymessage(fd, "--------Monster List--------"); sprintf(temp, "Mapname: %s", mapindex_id2name(mapindex)); clif_displaymessage(fd, temp); clif_displaymessage(fd, "Monsters: "); //Looping and search for mobs it = mapit_geteachmob(); while (true) { TBL_MOB* md = (TBL_MOB*)mapit_next(it); uint16 mob_id; std::shared_ptr<s_mob_db> mob = mob_db.find(mob_id); if (md == NULL) break; if (md->bl.m != m || md->status.hp <= 0) continue; if (mob_searched[md->mob_id] == true) continue; // Already found, skip it if (md->db->mexp) { mob_searched[md->mob_id] = true; mob_mvp[md->mob_id] = true; // Save id for later continue; // It's MVP! } mob_searched[md->mob_id] = true; count = map_foreachinmap(count_mob, m, BL_MOB, md->mob_id); sprintf(temp, " %s[%d] : %d", mob->jname, md->mob_id, count); clif_displaymessage(fd, temp); } mapit_free(it); clif_displaymessage(fd, "MVP: "); // Looping again and search for mvp, not sure if this is the best way.. for (i = 1000; i < MAX_MOB_DB; i++) { //First monster start at 1001 (Scorpion) if (mob_mvp[i] == true) { TBL_MOB* md = (TBL_MOB*)mapit_next(it); count = map_foreachinmap(count_mob, m, BL_MOB, i); sprintf(temp, " %s[%d] : %d", md->db->jname, i, count); clif_displaymessage(fd, temp); } } return 0; } ACMD_DEF(mapmoblist), Reference & Credits to FatalError: Edited January 11, 2024 by khouuming21 Quote
0 Emistry Posted January 23, 2024 Posted January 23, 2024 also can try using npc script if you want. - script getmapmob_main -1,{ OnInit: bindatcmd "getmapmob", strnpcinfo(3) + "::OnAtcommand"; end; OnAtcommand: .@map$ = strcharinfo(3); if (.@atcmd_numparameters) { if (getmapusers(.@atcmd_parameters$) == -1) { dispbottom "Invalid map " + .@atcmd_parameters$+"."; end; } .@map$ = .@atcmd_parameters$; } .@size = getmapunits(BL_MOB, .@map$); for (.@i = 0; .@i < .@size; .@i++) { getunitdata .@array[.@i], .@array; if (!.@mobcount[.@array[UMOB_CLASS]]) { .@mob_id[.@mob_id_size] = .@array[UMOB_CLASS]; .@mob_id_size++; } .@mob[.@array[UMOB_CLASS]]++; } dispbottom "Found "+ .@mob_id_size + " monsters at " + strcharinfo(3); for (.@i = .@mob_id_size - 1; .@i >= 0; .@i--) { if (getmonsterinfo(.@mob_id[.@i], MOB_MVPEXP) > 0) continue; dispbottom sprintf(" %s[%d] : %d", getmonsterinfo(.@mob_id[.@i], MOB_NAME), .@mob_id[.@i], .@mob[.@mob_id[.@i]]); deletearray .@mob_id[.@i], 1; .@mob_id_size--; } dispbottom "Found "+ .@mob_id_size + " normal monsters at " + strcharinfo(3); for (.@i = 0; .@i < .@mob_id_size; .@i++) { dispbottom sprintf(" %s[%d] : %d", getmonsterinfo(.@mob_id[.@i], MOB_NAME), .@mob_id[.@i], .@mob[.@mob_id[.@i]]); } end; } but this may cause performance issue, use at your own risk. Quote
0 Johnson Posted January 26, 2024 Author Posted January 26, 2024 On 1/23/2024 at 10:56 PM, Emistry said: also can try using npc script if you want. - script getmapmob_main -1,{ OnInit: bindatcmd "getmapmob", strnpcinfo(3) + "::OnAtcommand"; end; OnAtcommand: .@map$ = strcharinfo(3); if (.@atcmd_numparameters) { if (getmapusers(.@atcmd_parameters$) == -1) { dispbottom "Invalid map " + .@atcmd_parameters$+"."; end; } .@map$ = .@atcmd_parameters$; } .@size = getmapunits(BL_MOB, .@map$); for (.@i = 0; .@i < .@size; .@i++) { getunitdata .@array[.@i], .@array; if (!.@mobcount[.@array[UMOB_CLASS]]) { .@mob_id[.@mob_id_size] = .@array[UMOB_CLASS]; .@mob_id_size++; } .@mob[.@array[UMOB_CLASS]]++; } dispbottom "Found "+ .@mob_id_size + " monsters at " + strcharinfo(3); for (.@i = .@mob_id_size - 1; .@i >= 0; .@i--) { if (getmonsterinfo(.@mob_id[.@i], MOB_MVPEXP) > 0) continue; dispbottom sprintf(" %s[%d] : %d", getmonsterinfo(.@mob_id[.@i], MOB_NAME), .@mob_id[.@i], .@mob[.@mob_id[.@i]]); deletearray .@mob_id[.@i], 1; .@mob_id_size--; } dispbottom "Found "+ .@mob_id_size + " normal monsters at " + strcharinfo(3); for (.@i = 0; .@i < .@mob_id_size; .@i++) { dispbottom sprintf(" %s[%d] : %d", getmonsterinfo(.@mob_id[.@i], MOB_NAME), .@mob_id[.@i], .@mob[.@mob_id[.@i]]); } end; } but this may cause performance issue, use at your own risk. Hi Emistry, Thanks for this i have managed to do it in src. Will still test this out tho thanks! Quote
0 Frost Diver Posted February 11, 2024 Posted February 11, 2024 On 1/26/2024 at 11:36 PM, khouuming21 said: Hi Emistry, Thanks for this i have managed to do it in src. Will still test this out tho thanks! hi, kindly share the solution to the community. thanks Quote
Question
Johnson
May I ask help on getting monster to display on mapmoblist command. Somehow, it is not showing any monster data when use on @mapmoblist

atcommand.cpp
Reference & Credits to FatalError:
3 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.