Jump to content
  • 0

Porting afk2 from eathena to rathena


mrlongshen

Question


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  1302
  • Reputation:   77
  • Joined:  12/04/12
  • Last Seen:  

Index: src/map/atcommand.c
===================================================================
--- src/map/atcommand.c (revision 15160)
+++ src/map/atcommand.c (working copy)
@@ -8847,6 +8847,48 @@
 return 0;
}

/*==========================================
* Cydh
* @afk2
* Turns on/off logout on player with aw message
*------------------------------------------*/
int atcommand_afk2(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
char temp_msg[CHAT_SIZE_MAX];

nullpo_retr(-1, sd);

memset(temp_msg, '\0', sizeof(temp_msg));

if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
{
 if (!message || !*message || sscanf(message, "%255[^\n]", temp_msg) < 1)
 {
  clif_displaymessage(sd->fd, "Please, enter at least an option (usage: @afk2 <away message>).");
  return -1;
 } else {
  sd->state.away = 1;
  sd->state.monster_ignore = 1;
  sd->state.autotrade = 1;
  if( battle_config.at_timeout )
  {
int timeout = atoi(message);
status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  }

  sscanf(message, "%255[^\n]", sd->state.away_msg);
  clif_authfail_fd(fd, 15);
  pc_setsit(sd);
  skill_sit(sd,1);
  clif_sitting(&sd->bl,1);
  clif_changelook(&sd->bl,LOOK_HEAD_TOP,471);
 }
} else
 clif_displaymessage(fd, "AFK is not allowed on this map.");
return 0;
}

/*==========================================
 * atcommand_info[] structure definition
@@ -9151,7 +9151,8 @@
 { "charcommands",	   1,1,	  atcommand_commands },
 { "font",			   1,1,	  atcommand_font },
{ "afk2",			   0,99,	 atcommand_afk2 },
};


/*==========================================
 * Command lookup functions
Index: src/map/clif.c
===================================================================
--- src/map/clif.c (revision 15160)
+++ src/map/clif.c (working copy)
@@ -9867,7 +9867,19 @@
  clif_wis_end(fd, 2); // 2: ignored by target
  return;
 }
+
+ // if player is @away. [Cydh]
+ if( dstsd->state.away == 1 )
+ {
+  char output_away[256];
+
+  clif_wis_end(fd, 0); // 0: success to send wisper
+  sprintf(output_away, "(away) \"%s\"", dstsd->state.away_msg);
+  clif_wis_message(fd, dstsd->status.name, output_away, strlen(output_away) + 1); // send @away message to sender
+  clif_wis_message(dstsd->fd, sd->status.name, message, messagelen); // show meesage from sender
+  return;
+ }

 // if player is autotrading
 if( dstsd->state.autotrade == 1 )
 {
Index: src/map/pc.h
===================================================================
--- src/map/pc.h (revision 15160)
+++ src/map/pc.h (working copy)
@@ -140,4 +140,7 @@
  struct guild *gmaster_flag;
  unsigned int warping : 1;//states whether you're in the middle of a warp processing
+
+  unsigned int away : 1; //@away auto message. [Cydh]
+  unsigned char away_msg[CHAT_SIZE_MAX]; //@away auto message. [Cydh]
 } state;
 struct {

can someone edit this src modification from eathena to rathena ?

I hope I can use it on rathena. Thanks :)

Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   6
  • Joined:  08/01/12
  • Last Seen:  

Try this (Dont tested, so i dont know if it works).

atcommand.c [i hope you know where you need to place this :) ]

/*==========================================
* Cydh [Edited by TxusToni to work on rAthena]
* @afk2
* Turns on/off logout on player with aw message
*------------------------------------------*/
ACMD_FUNC(afk2)
{
struct map_session_data* pl_sd;
char temp_msg[CHAT_SIZE_MAX];
nullpo_retr(-1, sd);
memset(temp_msg, '\0', sizeof(temp_msg));
if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
{
 if (!message || !*message || sscanf(message, "%255[^\n]", temp_msg) < 1)
 {
  clif_displaymessage(sd->fd, "Please, enter at least an option (usage: @afk2 <away message>).");
  return -1;
 } else {
  sd->state.away = 1;
  sd->state.monster_ignore = 1;
  sd->state.autotrade = 1;
  if( battle_config.at_timeout )
  {
int timeout = atoi(message);
status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  }

  sscanf(message, "%255[^\n]", sd->state.away_msg);
  clif_authfail_fd(fd, 15);
  pc_setsit(sd);
  skill_sit(sd,1);
  clif_sitting(&sd->bl,1);
  clif_changelook(&sd->bl,LOOK_HEAD_TOP,471);
 }
} else
 clif_displaymessage(fd, "AFK is not allowed on this map.");
return 0;
}

ACMD_DEF(afk2),

clif.c [ Search this - clif_wis_end(fd, 2); // 2: ignored by target and put, down:

// if player is @away. [Cydh] [Edited by TxusToni to work on rAthena]
if( dstsd->state.away == 1 )
{
char output_away[256];
clif_wis_end(fd, 0); // 0: success to send wisper
sprintf(output_away, "(away) \"%s\"", dstsd->state.away_msg);
clif_wis_message(fd, dstsd->status.name, output_away, strlen(output_away) + 1); // send @away message to sender
clif_wis_message(dstsd->fd, sd->status.name, message, messagelen); // show meesage from sender
return;
}

pc.h [ Search this : unsigned int warping : 1; and put down: ]

unsigned int away : 1; //@away auto message. [Cydh] [Edited by TxusToni to work on rAthena]
unsigned char away_msg[CHAT_SIZE_MAX]; //@away auto message. [Cydh] [Edited by TxusToni to work on rAthena]

As i said, dont know if it will work, try it.

Edited by TxusToni
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  1302
  • Reputation:   77
  • Joined:  12/04/12
  • Last Seen:  

bro, can u give me the guide. because i dont where to put :(

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  4
  • Topics Per Day:  0.00
  • Content Count:  27
  • Reputation:   6
  • Joined:  08/01/12
  • Last Seen:  

Seach this: [in atcommand.c]

		clif_displaymessage(fd, msg_txt(1188)); // Autoloot is now off.

return 0;
}

and put the code down of that.

/*==========================================
* Cydh [Edited by TxusToni to work on rAthena]
* @afk2
* Turns on/off logout on player with aw message
*------------------------------------------*/
ACMD_FUNC(afk2)
{
struct map_session_data* pl_sd;
char temp_msg[CHAT_SIZE_MAX];
nullpo_retr(-1, sd);
memset(temp_msg, '\0', sizeof(temp_msg));
if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
{
 if (!message || !*message || sscanf(message, "%255[^\n]", temp_msg) < 1)
 {
  clif_displaymessage(sd->fd, "Please, enter at least an option (usage: @afk2 <away message>).");
  return -1;
 } else {
  sd->state.away = 1;
  sd->state.monster_ignore = 1;
  sd->state.autotrade = 1;
  if( battle_config.at_timeout )
  {
int timeout = atoi(message);
status_change_start(&sd->bl, SC_AUTOTRADE, 10000, 0, 0, 0, 0, ((timeout > 0) ? min(timeout,battle_config.at_timeout) : battle_config.at_timeout) * 60000, 0);
  }

  sscanf(message, "%255[^\n]", sd->state.away_msg);
  clif_authfail_fd(fd, 15);
  pc_setsit(sd);
  skill_sit(sd,1);
  clif_sitting(&sd->bl,1);
  clif_changelook(&sd->bl,LOOK_HEAD_TOP,471);
 }
} else
 clif_displaymessage(fd, "AFK is not allowed on this map.");
return 0;
}

Search this:

ACMD_DEF(autoloot),

and put the code down of that.

ACMD_DEF(afk2),

Search this: [in clif.c]

clif_wis_end(fd, 2); // 2: ignored by target
 return;
}

And put the code down.

// if player is @away. [Cydh] [Edited by TxusToni to work on rAthena]
if( dstsd->state.away == 1 )
{
char output_away[256];
clif_wis_end(fd, 0); // 0: success to send wisper
sprintf(output_away, "(away) \"%s\"", dstsd->state.away_msg);
clif_wis_message(fd, dstsd->status.name, output_away, strlen(output_away) + 1); // send @away message to sender
clif_wis_message(dstsd->fd, sd->status.name, message, messagelen); // show meesage from sender
return;
}

Search this: [in pc.h]

unsigned int warping : 1;

and put the code down.

unsigned int away : 1; //@away auto message. [Cydh] [Edited by TxusToni to work on rAthena]
unsigned char away_msg[CHAT_SIZE_MAX]; //@away auto message. [Cydh] [Edited by TxusToni to work on rAthena]

As i said, dont know if it will work, try it.

Edited by TxusToni
Link to comment
Share on other sites


  • Group:  Developer
  • Topic Count:  153
  • Topics Per Day:  0.04
  • Content Count:  2285
  • Reputation:   745
  • Joined:  06/16/12
  • Last Seen:  

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  98
  • Topics Per Day:  0.02
  • Content Count:  1302
  • Reputation:   77
  • Joined:  12/04/12
  • Last Seen:  

 

thx alot bro. now using it :)

Link to comment
Share on other sites

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.

×
×
  • Create New...