Vengeance Posted January 9, 2012 Posted January 9, 2012 (edited) Hi guys i made this simple modification to stop corruption in my server... This little snippet would allow you to stop GMs from abusing @monster command.. it will announce the Monster name, Amount and also the location with the GM name so its very easy to know if it was for an Purpose or just for abuse.... /*========================================== * *------------------------------------------*/ ACMD_FUNC(monster) { char name[NAME_LENGTH]; char monster[NAME_LENGTH]; int mob_id; int number = 0; int count; int i, k, range; short mx, my; nullpo_retr(-1, sd); memset(name, '0', sizeof(name)); memset(monster, '0', sizeof(monster)); memset(atcmd_output, '0', sizeof(atcmd_output)); if (!message || !*message) { clif_displaymessage(fd, msg_txt(80)); // Give the display name or monster name/id please. return -1; } if (sscanf(message, ""%23[^"]" %23s %d", name, monster, &number) > 1 || sscanf(message, "%23s "%23[^"]" %d", monster, name, &number) > 1) { //All data can be left as it is. } else if ((count=sscanf(message, "%23s %d %23s", monster, &number, name)) > 1) { //Here, it is possible name was not given and we are using monster for it. if (count < 3) //Blank mob's name. name[0] = '0'; } else if (sscanf(message, "%23s %23s %d", name, monster, &number) > 1) { //All data can be left as it is. } else if (sscanf(message, "%23s", monster) > 0) { //As before, name may be already filled. name[0] = '0'; } else { clif_displaymessage(fd, msg_txt(80)); // Give a display name and monster name/id please. return -1; } if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number) mob_id = mobdb_checkid(atoi(monster)); if (mob_id == 0) { clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name. return -1; } if (mob_id == MOBID_EMPERIUM) { clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned. return -1; } if (number <= 0) number = 1; if (strlen(name) < 1) strcpy(name, "--ja--"); // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive if (battle_config.atc_spawn_quantity_limit && number > battle_config.atc_spawn_quantity_limit) number = battle_config.atc_spawn_quantity_limit; if (battle_config.etc_log) ShowInfo("%s monster='%s' name='%s' id=%d count=%d (%d,%d)n", command, monster, name, mob_id, number, sd->bl.x, sd->bl.y); count = 0; range = (int)sqrt((float)number) +2; // calculation of an odd number (+ 4 area around) for (i = 0; i < number; i++) { map_search_freecell(&sd->bl, 0, &mx, &my, range, range, 0); k = mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, ""); count += (k != 0) ? 1 : 0; } if (count != 0) if (number == count){ if(pc_isGM(sd)==99){ // Checks if the GM level is below 99 Announcement is made [Vengeance] clif_displaymessage(fd, msg_txt(39)); // All monster summoned! } else { sprintf(atcmd_output, "%s summoned %d %s in %s,%d,%d", sd->status.name,number, monster, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y); intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); clif_displaymessage(fd, msg_txt(39)); // All monster summoned! } } else { sprintf(atcmd_output, "%s summoned %d %s in %s,%d,%d", sd->status.name,number, monster, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y); intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); sprintf(atcmd_output, msg_txt(240), count); // %d monster(s) summoned! clif_displaymessage(fd, atcmd_output); } else { clif_displaymessage(fd, msg_txt(40)); // Invalid monster ID or name. return -1; } return 0; } // small monster spawning [Valaris] ACMD_FUNC(monstersmall) { char name[NAME_LENGTH] = ""; char monster[NAME_LENGTH] = ""; int mob_id = 0; int number = 0; int x = 0; int y = 0; int count; int i; nullpo_retr(-1, sd); if (!message || !*message) { clif_displaymessage(fd, "Give a monster name/id please."); return -1; } if (sscanf(message, ""%23[^"]" %23s %d %d %d", name, monster, &number, &x, &y) < 2 && sscanf(message, "%23s "%23[^"]" %d %d %d", monster, name, &number, &x, &y) < 2 && sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) { clif_displaymessage(fd, "Give a monster name/id please."); return -1; } // If monster identifier/name argument is a name if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number) mob_id = atoi(monster); if (mob_id == 0) { clif_displaymessage(fd, msg_txt(40)); return -1; } if (mob_id == MOBID_EMPERIUM) { clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium return -1; } if (mobdb_checkid(mob_id) == 0) { clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID. return -1; } if (number <= 0) number = 1; if (strlen(name) < 1) strcpy(name, "--ja--"); // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit) number = battle_config.atc_spawn_quantity_limit; count = 0; for (i = 0; i < number; i++) { int mx, my; if (x <= 0) mx = sd->bl.x + (rand() % 11 - 5); else mx = x; if (y <= 0) my = sd->bl.y + (rand() % 11 - 5); else my = y; count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "2") != 0) ? 1 : 0; } if (count != 0) { if(pc_isGM(sd)==99){// Checks if the GM level is below 99 Announcement is made [Vengeance] clif_displaymessage(fd, msg_txt(39)); // All monster summoned! } else{ sprintf(atcmd_output, "%s summoned %d small %s in %s,%d,%d", sd->status.name, number, monster, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y); intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!! } } else clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID. return 0; } // big monster spawning [Valaris] ACMD_FUNC(monsterbig) { char name[NAME_LENGTH] = ""; char monster[NAME_LENGTH] = ""; int mob_id = 0; int number = 0; int x = 0; int y = 0; int count; int i; nullpo_retr(-1, sd); if (!message || !*message) { clif_displaymessage(fd, "Give a monster name/id please."); return -1; } if (sscanf(message, ""%23[^"]" %23s %d %d %d", name, monster, &number, &x, &y) < 2 && sscanf(message, "%23s "%23[^"]" %d %d %d", monster, name, &number, &x, &y) < 2 && sscanf(message, "%23s %d %23s %d %d", monster, &number, name, &x, &y) < 1) { clif_displaymessage(fd, "Give a monster name/id please."); return -1; } // If monster identifier/name argument is a name if ((mob_id = mobdb_searchname(monster)) == 0) // check name first (to avoid possible name begining by a number) mob_id = atoi(monster); if (mob_id == 0) { clif_displaymessage(fd, msg_txt(40)); return -1; } if (mob_id == MOBID_EMPERIUM) { clif_displaymessage(fd, msg_txt(83)); // Cannot spawn emperium return -1; } if (mobdb_checkid(mob_id) == 0) { clif_displaymessage(fd, "Invalid monster ID"); // Invalid Monster ID. return -1; } if (number <= 0) number = 1; if (strlen(name) < 1) strcpy(name, "--ja--"); // If value of atcommand_spawn_quantity_limit directive is greater than or equal to 1 and quantity of monsters is greater than value of the directive if (battle_config.atc_spawn_quantity_limit >= 1 && number > battle_config.atc_spawn_quantity_limit) number = battle_config.atc_spawn_quantity_limit; count = 0; for (i = 0; i < number; i++) { int mx, my; if (x <= 0) mx = sd->bl.x + (rand() % 11 - 5); else mx = x; if (y <= 0) my = sd->bl.y + (rand() % 11 - 5); else my = y; count += (mob_once_spawn(sd, sd->bl.m, mx, my, name, mob_id, 1, "4") != 0) ? 1 : 0; } if (count != 0) { if(pc_isGM(sd)==99){// Checks if the GM level is below 99 Announcement is made [Vengeance] clif_displaymessage(fd, msg_txt(39)); // All monster summoned! } else{ sprintf(atcmd_output, "%s summoned %d big %s in %s,%d,%d", sd->status.name, number, monster, mapindex_id2name(sd->mapindex), sd->bl.x, sd->bl.y); intif_broadcast(atcmd_output, strlen(atcmd_output) + 1, 0); clif_displaymessage(fd, msg_txt(39)); // Monster Summoned!! } } else clif_displaymessage(fd, msg_txt(40)); // Invalid Monster ID. return 0; } Just copy paste this Snippet. Download from here Edited January 9, 2012 by Vengeance 5 Quote
Vengeance Posted January 9, 2012 Author Posted January 9, 2012 thank you please give reviews about the mod to motivate so I release more useful mods to the community Quote
Igniz Posted January 9, 2012 Posted January 9, 2012 Pretty nice, but it will be better if you set a battle configuration to set the gm level that will broadcast the info and broadcast the spawner gm, would be better. Tnks in advance, good mod Quote
Vengeance Posted January 10, 2012 Author Posted January 10, 2012 Well thats possible but I just made it for a request so I thought that this much would be enough... Quote
Nigthscrawler Posted January 16, 2012 Posted January 16, 2012 Nice, but i have a question, how install this code in the server, i new in this xD and need help =) Quote
Vengeance Posted January 20, 2012 Author Posted January 20, 2012 You need to copy the code and edit the original monster code and then compile your server Quote
Syllabear Posted January 20, 2012 Posted January 20, 2012 Wow...this is cool.... Sir can u also make a source if a GM creates an item or @item command and only the lvl 99 GM only will see Quote
myieee Posted January 23, 2012 Posted January 23, 2012 where would i put that? map.h? src > map > atcommand.c Quote
Vengeance Posted January 25, 2012 Author Posted January 25, 2012 Wow...this is cool.... Sir can u also make a source if a GM creates an item or @item command and only the lvl 99 GM only will see I will try to do that... Quote
Innos Posted March 5, 2012 Posted March 5, 2012 Nice small Snippet. But i mean the most GM spawn with Monster ID. for normal Player looks this abnormal. A Broadcast with GM XX spawned 1002 100 on Map x,x isn't better to change all id's automatically in monster name? Quote
BuLaLaKaW Posted March 5, 2012 Posted March 5, 2012 Nice small Snippet. But i mean the most GM spawn with Monster ID. for normal Player looks this abnormal. A Broadcast with GM XX spawned 1002 100 on Map x,x isn't better to change all id's automatically in monster name? it is very simple, see script command below. *getmonsterinfo(<mob ID>,<type>) This function will look up the monster with the specified ID number in the mob database and return the info set by TYPE argument. It will return -1 if there is no such monster (or the type value is invalid), or "null" if you requested the monster's name. Valid types are listed in const.txt: MOB_NAME 0 MOB_LV 1 MOB_MAXHP 2 MOB_BASEEXP 3 MOB_JOBEXP 4 MOB_ATK1 5 MOB_ATK2 6 MOB_DEF 7 MOB_MDEF 8 MOB_STR 9 MOB_AGI 10 MOB_VIT 11 MOB_INT 12 JOB_DEX 13 MOB_LUK 14 MOB_RANGE 15 MOB_RANGE2 16 MOB_RANGE3 17 MOB_SIZE 18 MOB_RACE 19 MOB_ELEMENT 20 MOB_MODE 21 so you can just replace the part where it will announce the mob id into "+getmonsterinfo(<mob ID>,0)+" thanks for the share! another option is not to let your GM summon any monster at all. imagine summoning 1000 treasure chest Quote
Sharpienero Posted March 5, 2012 Posted March 5, 2012 Awesome! I think this should log it into cmd file though, instead of broadcasting it. Quote
Belkan Posted March 23, 2012 Posted March 23, 2012 can you update the @monster patch pls? it isn't compatible with new rathena svn change if(pc_isGM(sd)==99) to if(pc_get_group_level(sd)==99) Quote
Meister Posted May 13, 2012 Posted May 13, 2012 Nice small Snippet. But i mean the most GM spawn with Monster ID. for normal Player looks this abnormal. A Broadcast with GM XX spawned 1002 100 on Map x,x isn't better to change all id's automatically in monster name? it is very simple, see script command below. *getmonsterinfo(<mob ID>,<type>) This function will look up the monster with the specified ID number in the mob database and return the info set by TYPE argument. It will return -1 if there is no such monster (or the type value is invalid), or "null" if you requested the monster's name. Valid types are listed in const.txt: MOB_NAME 0 MOB_LV 1 MOB_MAXHP 2 MOB_BASEEXP 3 MOB_JOBEXP 4 MOB_ATK1 5 MOB_ATK2 6 MOB_DEF 7 MOB_MDEF 8 MOB_STR 9 MOB_AGI 10 MOB_VIT 11 MOB_INT 12 JOB_DEX 13 MOB_LUK 14 MOB_RANGE 15 MOB_RANGE2 16 MOB_RANGE3 17 MOB_SIZE 18 MOB_RACE 19 MOB_ELEMENT 20 MOB_MODE 21 so you can just replace the part where it will announce the mob id into "+getmonsterinfo(<mob ID>,0)+" thanks for the share! another option is not to let your GM summon any monster at all. imagine summoning 1000 treasure chest where can I see the "+getmonserinfo" Quote
Brynner Posted July 8, 2012 Posted July 8, 2012 the patch is now outdated to the latest revision. how to implement this on the latest revision? bump for this. is there anyone knows how to implement this on the latest version? Quote
Brynner Posted September 7, 2012 Posted September 7, 2012 nice. i think this is not working on the latest revision. Quote
Cydh Posted September 7, 2012 Posted September 7, 2012 nice. i think this is not working on the latest revision. i didnt try yet, i said "nice" for the share, I'll try this soon. and badly I dont use latest revision too. Quote
Brynner Posted September 7, 2012 Posted September 7, 2012 nice. i think this is not working on the latest revision. i didnt try yet, i said "nice" for the share, I'll try this soon. and badly I dont use latest revision too. oh ok. goodluck Quote
Cydh Posted September 7, 2012 Posted September 7, 2012 It's work bro . u just need patch ur mapserver or open the patch file an rewrite ur atcommand.c file based on @monster patch file. and edit inside ACMD_FUNC(monster), ACMD_FUNC(monstersmall), ACMD_FUNC(monsterbig) Quote
Belkan Posted August 25, 2013 Posted August 25, 2013 is there a new version compatible with the new update of rathena? Quote
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.