Jump to content

Question

15 answers to this question

Recommended Posts

Posted (edited)

In src/map/atcommand.c:

Find:

/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(monster)
{
char name[NAME_LENGTH];
char monster[NAME_LENGTH];
char eventname[EVENT_NAME_LENGTH] = "";
int mob_id;
int number = 0;

Before add:

static int monsterBlock(int compareid){
 FILE *fp;
char line[1024];
int ln=0;
int nameid;
char filename[255];
snprintf(filename, 255, "%s/"DBPATH"monster_block.txt", db_path);

if( (fp=fopen(filename,"r"))==NULL ){
  ShowError("can't read %s\n", filename);
 return -1;
}
while(fgets(line, sizeof(line), fp))
{
 if(line[0] == '\n' || line[0] == '\r' || line[0] == ' ' || (line[0]=='/' && line[1]=='/'))
  continue;
 nameid = atoi(line);
 if(compareid == nameid)
 {
  fclose(fp);
  return 1; // Monster Blocked
 }
}
fclose(fp);
return 0; // Monster Accepted

}

Within ACMD_FUNC(monster) find:

int mob_id;

Replace with:

int mob_id, mB = 0;

Find:

if (mob_id == MOBID_EMPERIUM) {
 clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
 return -1;
}

After add:

if(pc_get_group_level(sd) < 99 && (mB  = monsterBlock(mob_id)))
 if(mB == 1){
  clif_displaymessage(fd, "Acess_Restriction: Administrator restricted this monster from being called by @monster direct command.");
  return -1;
 }

Go to db path and create a file called: monster_block.txt

Put into it ID from monsters you want to block, like this:

//Comments

1001 //Scorpion

1002

1003 //etc

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

Admin level 99 can still summon any monster, if you don't want it change it:

if(pc_get_group_level(sd) < 99 && (mB  = monsterBlock(mob_id)))

To:

if((mB = monsterBlock(mob_id)))

Edit: fixed the fclose part which could lead to file descriptor staying opened "forever".

Edited by MarkZD
Posted

In src/map/atcommand.c:

Find:

/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(monster)
{
char name[NAME_LENGTH];
char monster[NAME_LENGTH];
char eventname[EVENT_NAME_LENGTH] = "";
int mob_id;
int number = 0;

Before add:

static int monsterBlock(int compareid){
 FILE *fp;
char line[1024];
int ln=0;
int nameid;
char filename[255];
snprintf(filename, 255, "%s/"DBPATH"monster_block.txt", db_path);

if( (fp=fopen(filename,"r"))==NULL ){
  ShowError("can't read %s\n", filename);
 return -1;
}
while(fgets(line, sizeof(line), fp))
{
 if(line[0] == '\n' || line[0] == '\r' || line[0] == ' ' || (line[0]=='/' && line[1]=='/'))
  continue;
 nameid = atoi(line);
 if(compareid == nameid)
  return 1; // Monster Blocked
}
fclose(fp);
return 0; // Monster Accepted

}

Within ACMD_FUNC(monster) find:

int mob_id;

Replace with:

int mob_id, mB = 0;

Find:

if (mob_id == MOBID_EMPERIUM) {
 clif_displaymessage(fd, msg_txt(83)); // Monster 'Emperium' cannot be spawned.
 return -1;
}

After add:

if(pc_get_group_level(sd) < 99 && (mB  = monsterBlock(mob_id)))
 if(mB == 1){
  clif_displaymessage(fd, "Acess_Restriction: Administrator restricted this monster from being called by @monster direct command.");
  return -1;
 }

Go to db path and create a file called: monster_block.txt

Put into it ID from monsters you want to block, like this:

//Comments

1001 //Scorpion

1002

1003 //etc

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

Admin level 99 can still summon any monster, if you don't want it change it:

if(pc_get_group_level(sd) < 99 && (mB  = monsterBlock(mob_id)))

To:

if((mB = monsterBlock(mob_id)))

Hi MarkZD

Pls adivse where i must pu Before add:

thanks

Posted (edited)

Before the found part:


HERE


/*==========================================
*
*------------------------------------------*/
ACMD_FUNC(monster)
{
char name[NAME_LENGTH];
char monster[NAME_LENGTH];
char eventname[EVENT_NAME_LENGTH] = "";
int mob_id;
int number = 0;

Edited by MarkZD
Posted

Change this line from the code I posted above:

snprintf(filename, 255, "%s/"DBPATH"monster_block.txt", db_path);

To this:

snprintf(filename, 255, "%s/monster_block.txt", db_path);

And recompile.

Join the conversation

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

Guest
Answer this question...

×   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...