Jump to content

Recommended Posts

Posted (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 by Vengeance
  • Upvote 5
Posted

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 :(

  • 1 month later...
Posted

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? /ok

Posted

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? :D

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

  • 3 weeks later...
  • 1 month later...
Posted

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? :D

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"

  • 1 month later...
Posted

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?

  • 1 month later...
Posted

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. /hmm

Posted

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. /hmm

oh ok. goodluck /ic

Posted

It's work bro /no1 .

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)

  • 11 months later...

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...