Jump to content
  • 0

Help - how to add class restriction on @afk


Question

Posted

src/map/atcommand.c
add in line 1842:
/*==========================================
* @afk by Rad, built on by Tubby
* same as autotrade, but works without vending
*------------------------------------------*/
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 )
{

if (!message || !*message) {
chat_createpcchat(sd, "(@afk) mail me~", "", 1, 1);
trade_tradeack(sd,4);
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);
}

if((strlen(message) < 0)||(strlen(message) > 36)) {
chat_createpcchat(sd, "(@afk) mail me~", "", 1, 1);
trade_tradeack(sd,4);
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);
}
chat_createpcchat(sd, message, "", 1, 1);
trade_tradeack(sd,4);
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;
}
src/map/atcommand.c
add in line 8927:
{ "afk", 40,40, atcommand_afk },

I would like to ask on how to place a check like only this range of class can use @afk command

if ( class <= 6 )

mes "Not possible";

close;

10 answers to this question

Recommended Posts

Posted

You can check the players class with sd->class_&MAPID_UPPERMASK and this enumaration (taken from map.h):


enum {
MAPID_NOVICE = 0x0,
MAPID_SWORDMAN,
MAPID_MAGE,
MAPID_ARCHER,
MAPID_ACOLYTE,
MAPID_MERCHANT,
MAPID_THIEF,
MAPID_TAEKWON,
MAPID_WEDDING,
MAPID_GUNSLINGER,
MAPID_NINJA,
MAPID_XMAS,
MAPID_SUMMER,
//2_1 classes
MAPID_SUPER_NOVICE = JOBL_2_1|0x0,
MAPID_KNIGHT,
MAPID_WIZARD,
MAPID_HUNTER,
MAPID_PRIEST,
MAPID_BLACKSMITH,
MAPID_ASSASSIN,
MAPID_STAR_GLADIATOR,
//2_2 classes
MAPID_CRUSADER = JOBL_2_2|0x1,
MAPID_SAGE,
MAPID_BARDDANCER,
MAPID_MONK,
MAPID_ALCHEMIST,
MAPID_ROGUE,
MAPID_SOUL_LINKER,
//1-1, advanced
MAPID_NOVICE_HIGH = JOBL_UPPER|0x0,
MAPID_SWORDMAN_HIGH,
MAPID_MAGE_HIGH,
MAPID_ARCHER_HIGH,
MAPID_ACOLYTE_HIGH,
MAPID_MERCHANT_HIGH,
MAPID_THIEF_HIGH,
//2_1 advanced
MAPID_LORD_KNIGHT = JOBL_UPPER|JOBL_2_1|0x1,
MAPID_HIGH_WIZARD,
MAPID_SNIPER,
MAPID_HIGH_PRIEST,
MAPID_WHITESMITH,
MAPID_ASSASSIN_CROSS,
//2_2 advanced
MAPID_PALADIN = JOBL_UPPER|JOBL_2_2|0x1,
MAPID_PROFESSOR,
MAPID_CLOWNGYPSY,
MAPID_CHAMPION,
MAPID_CREATOR,
MAPID_STALKER,
//1-1 baby
MAPID_BABY = JOBL_BABY|0x0,
MAPID_BABY_SWORDMAN,
MAPID_BABY_MAGE,
MAPID_BABY_ARCHER,
MAPID_BABY_ACOLYTE,
MAPID_BABY_MERCHANT,
MAPID_BABY_THIEF,
MAPID_BABY_TAEKWON,
//2_1 baby
MAPID_SUPER_BABY = JOBL_BABY|JOBL_2_1|0x0,
MAPID_BABY_KNIGHT,
MAPID_BABY_WIZARD,
MAPID_BABY_HUNTER,
MAPID_BABY_PRIEST,
MAPID_BABY_BLACKSMITH,
MAPID_BABY_ASSASSIN,
MAPID_BABY_STAR_GLADIATOR,
//2_2 baby
MAPID_BABY_CRUSADER = JOBL_BABY|JOBL_2_2|0x1,
MAPID_BABY_SAGE,
MAPID_BABY_BARDDANCER,
MAPID_BABY_MONK,
MAPID_BABY_ALCHEMIST,
MAPID_BABY_ROGUE,
MAPID_BABY_SOUL_LINKER,
};
[/codeBOX]

Example:

[code]
if(sd->class_&MAPID_UPPERMASK == MAPID_NOVICE) clif_displaymessage(sd->fd, "You're a Novice.");
[/code]

//EDIT:

I think you want to disable @afk for Novices and 1st class characters.

Just add this:

[code]
if(sd->class_&MAPID_UPPERMASK < MAPID_TAEKWON)
{
clif_displaymessage(sd->fd, "You are not allowed to use @afk!");
return -1;
}
[/code]

below:

[code]
nullpo_retr(-1, sd);
[/code]

and recompile.

Posted

i also need this guide =)

i no understand here.(in map.h)

enum {

if(sd->class_&MAPID_UPPERMASK == MAPID_NOVICE) clif_displaymessage(sd->fd, "You're a Novice."); (edit MAPID_NOVICE = 0x0,

if i dun wan novice use @afk?)

if(sd->class_&MAPID_UPPERMASK < MAPID_TAEKWON)

{

clif_displaymessage(sd->fd, "You are not allowed to use @afk!");

return -1;

}

nullpo_retr(-1, sd);

MAPID_SWORDMAN,

MAPID_MAGE,

MAPID_ARCHER,

MAPID_ACOLYTE,

MAPID_MERCHANT,

MAPID_THIEF,

do the same for other like this on every job i dun wan they have ? (swordman,acolyte,merchant etc.)

Posted

Hi Kenpach!

I would like to restrict all jobs that are not transcendent and base level of 90 to do @afk , how will I do it ?

thanks

Just change the condition from
if(sd->class_&MAPID_UPPERMASK < MAPID_TAEKWON)

to

if(sd->class_&MAPID_UPPERMASK >= MAPID_NOVICE_HIGH && sd->class_&MAPID_UPPERMASK < MAPID_BABY && sd->status.base_level >= 90)

@manabeast:

Sorry, I don't understand your problem. :)

Posted (edited)

Hi Kenpachi,

Tried to do this to allow @afk only good for 90 or above.

		if( sd->status.base_level >= 90 )
	{
			clif_displaymessage(sd->fd, "Characters with base level 90 or above can use @afk!");
			return -1;
	}

but it did not work

help ...

Can I also ask how to do the same as with @autotrade

/*==========================================
* @autotrade by durf [Lupus] [Paradox924X]
* Turns on/off Autotrade for a specific player
*------------------------------------------*/
ACMD_FUNC(autotrade)
{
	nullpo_retr(-1, sd);

	if( sd->status.base_level >= 90 )
	{
			clif_displaymessage(sd->fd, "Characters with base level 90 or above can use @autotrade or @at!");
			return -1;
	}

	if( map[sd->bl.m].flag.autotrade != battle_config.autotrade_mapflag ) {
			clif_displaymessage(fd, "Autotrade is not allowed on this map.");
			return -1;
	}

	if( pc_isdead(sd) ) {
			clif_displaymessage(fd, "Cannot Autotrade if you are dead.");
			return -1;
	}

	if( !sd->state.vending && !sd->state.buyingstore ) { //check if player is vending or buying
			clif_displaymessage(fd, msg_txt(549)); // "You should have a shop open to use @autotrade."
			return -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) * 6000$
	}
	clif_authfail_fd(fd, 15);

	return 0;
}

Edited by MarcuZ
Posted

Hi Kenpachi,

Tried to do this to allow @afk only good for 90 or above.

		if( sd->status.base_level >= 90 )
	{
			clif_displaymessage(sd->fd, "Characters with base level 90 or above can use @afk!");
			return -1;
	}

but it did not work

The message will be shown if the characters base level is greater than 89. Change
>= 90

to

< 90

Now you'll see the message if your characters base level islower than 90.

Can I also ask how to do the same as with @autotrade

Same thing. just add a check like this below

nullpo_retr(-1, sd);

Posted (edited)

pls ignore previous question. becos i change my mind.

can i ask one thing? default is people who active vending skill can @afk / autotrade? because i just wan ppl vending only can @afk/autotrade include people using pushcart clips(any job)

Edited by manabeast
Posted

So your goal is to allow @afk only if the player is vending?

If yes add

if(!sd->state.vending)
{
 clif_displaymessage(fd, "@AFK is only allowed when vending!");
 return -1;
}

below

nullpo_retr(-1, sd);

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