Jump to content
  • 0

Modify @AFK


Question

Posted

erm...since i still too noob in SRC Modification, so i would like to ask some guideline on how to edit this command

/*==========================================
* @afk
* Turns on/off logout on player
*------------------------------------------*/
int atcommand_afk(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
   nullpo_retr(-1, sd);
   if( map[sd->bl.m].flag.autotrade == battle_config.autotrade_mapflag )
   {
    sd->state.monster_ignore = 0;
    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);
    }
    clif_authfail_fd(fd, 15);
   } else
    clif_displaymessage(fd, "AFK is not allowed on this map.");
   return 0;
}

this is the Origin @AFK Command i get from eA last time,

but i was wondering how to make it check on certain flag / cell

i can see that in the code there is a autotrade mapflag checking for allow and disallow using it..

but, i would like to modify it / add a check on

certain cell / coordinate cant use @AFK

by refering to this 2 cell

cell_novending	6
cell_nochat	7

Example :

if i have an area that already run with either cell_nochat / cell_novending then it will display a message to inform you cant use @AFK at this spot.

4 answers to this question

Recommended Posts

Posted
if( map[sd->bl.m].flag.vending_cell != map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) )
   {
       clif_displaymessage(fd, "You can't use @AFK on this spot.");
       return -1;
   }

Posted (edited)

just some question that i didnt understand very well here ~

if( map[sd->bl.m].flag.vending_cell != map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) )

why we still need to put

if( map[sd->bl.m].flag.vending_cell

but this part doesnt need in the check CELL_CHKNOCHAT part ?

if( map[sd->bl.m].flag.vending_cell )

if do like this it wont be able to work ?

if( map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOVENDING) || map_getcell(sd->bl.m,sd->bl.x,sd->bl.y,CELL_CHKNOCHAT) )

* LOL..the Colour Tag keep mess up my post when i posting....grrr.... O.O *

Edited by Emistry
Posted

but, i would like to modify it / add a check on

certain cell / coordinate cant use @AFK

by refering to this 2 cell

cell_novending	6
cell_nochat	7

Example :

if i have an area that already run with either cell_nochat / cell_novending then it will display a message to inform you cant use @AFK at this spot.

This is how its done /oh

/*==========================================
* @afk
* Turns on/off logout on player
*------------------------------------------*/
ACMD_FUNC(afk)
{
nullpo_retr(-1, sd);
// Map checks
if (
	   map[sd->bl.m].flag.novending // No vending on the whole map
	|| map[sd->bl.m].flag.nochat // No chats on the whole map
	|| map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag // Autotrade config dosnt match
) {
	clif_displaymessage(fd, "AFK is not allowed on this map.");
	return -1;
}

// Cell checks
if (
	   map_getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOVENDING) // No vending on the current cell
	|| map_getcell(sd->bl.m, sd->bl.x, sd->bl.y, CELL_CHKNOCHAT) // No chats on the current cell
) {
	clif_displaymessage(fd, "AFK is not allowed on this spot.");
	return -1;
}

// All checks passed
sd->state.monster_ignore = 0;
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);
}
clif_authfail_fd(fd, 15);

return 0;
}

  • Upvote 1
Posted

its not working on my server >.<

i tried 3 kind of @afk commands, but every time i type @afk or @at or @autotrade on my GM account its not working.. my character doesn't AFK..

please i need ur help... thank u in advanced.. hope u see my thread.

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