setpcblock script command (#4052)
* Added setpcblock and getpcblock script commands. 'setpcblock' command prevents/allows the player from doing the given type of action. 'getpcblock' command return the bit-mask value of the currently enabled block flags. The available type are: PCBLOCK_MOVE PCBLOCK_ATTACK PCBLOCK_SKILL PCBLOCK_USEITEM PCBLOCK_CHAT PCBLOCK_IMMUNE PCBLOCK_SITSTAND PCBLOCK_COMMANDS PCBLOCK_NPCCLICK PCBLOCK_EMOTION PCBLOCK_ALL Thanks to @sigtus, @secretdataz, @Lemongrass3110 and @aleos89 for the help and reviews ! Credit to https://github.com/HerculesWS/Hercules/pull/842 for the idea.
This commit is contained in:
@@ -3922,6 +3922,7 @@ ACMD_FUNC(reload) {
|
||||
for( pl_sd = (TBL_PC*)mapit_first(iter); mapit_exists(iter); pl_sd = (TBL_PC*)mapit_next(iter) ){
|
||||
pc_close_npc(pl_sd,1);
|
||||
clif_cutin(pl_sd, "", 255);
|
||||
pl_sd->state.block_action = 0;
|
||||
}
|
||||
mapit_free(iter);
|
||||
|
||||
@@ -5977,7 +5978,7 @@ ACMD_FUNC(autotrade) {
|
||||
|
||||
sd->state.autotrade = 1;
|
||||
if (battle_config.autotrade_monsterignore)
|
||||
sd->state.monster_ignore = 1;
|
||||
sd->state.block_action |= PCBLOCK_IMMUNE;
|
||||
|
||||
if( sd->state.vending ){
|
||||
if( Sql_Query( mmysql_handle, "UPDATE `%s` SET `autotrade` = 1 WHERE `id` = %d;", vendings_table, sd->vender_id ) != SQL_SUCCESS ){
|
||||
@@ -6634,7 +6635,7 @@ ACMD_FUNC(npctalk)
|
||||
bool ifcolor=(*(command + 8) != 'c' && *(command + 8) != 'C')?0:1;
|
||||
unsigned long color=0;
|
||||
|
||||
if (sd->sc.cant.chat)
|
||||
if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
|
||||
return -1; //no "chatting" while muted.
|
||||
|
||||
if(!ifcolor) {
|
||||
@@ -6683,7 +6684,7 @@ ACMD_FUNC(pettalk)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (sd->sc.cant.chat)
|
||||
if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
|
||||
return -1; //no "chatting" while muted.
|
||||
|
||||
if (!message || !*message || sscanf(message, "%99[^\n]", mes) < 1) {
|
||||
@@ -7567,7 +7568,7 @@ ACMD_FUNC(homtalk)
|
||||
sd->cantalk_tick = gettick() + battle_config.min_chat_delay;
|
||||
}
|
||||
|
||||
if (sd->sc.cant.chat)
|
||||
if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
|
||||
return -1; //no "chatting" while muted.
|
||||
|
||||
if ( !hom_is_active(sd->hd) ) {
|
||||
@@ -7975,7 +7976,7 @@ ACMD_FUNC(me)
|
||||
memset(tempmes, '\0', sizeof(tempmes));
|
||||
memset(atcmd_output, '\0', sizeof(atcmd_output));
|
||||
|
||||
if (sd->sc.cant.chat)
|
||||
if (sd->sc.cant.chat || (sd->state.block_action & PCBLOCK_CHAT))
|
||||
return -1; //no "chatting" while muted.
|
||||
|
||||
if (!message || !*message || sscanf(message, "%255[^\n]", tempmes) < 0) {
|
||||
@@ -8095,12 +8096,12 @@ ACMD_FUNC(monsterignore)
|
||||
{
|
||||
nullpo_retr(-1, sd);
|
||||
|
||||
if (!sd->state.monster_ignore) {
|
||||
sd->state.monster_ignore = 1;
|
||||
clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
|
||||
} else {
|
||||
sd->state.monster_ignore = 0;
|
||||
if (sd->state.block_action & PCBLOCK_IMMUNE) {
|
||||
sd->state.block_action &= ~PCBLOCK_IMMUNE;
|
||||
clif_displaymessage(sd->fd, msg_txt(sd,1306)); // Returned to normal state.
|
||||
} else {
|
||||
sd->state.block_action |= PCBLOCK_IMMUNE;
|
||||
clif_displaymessage(sd->fd, msg_txt(sd,1305)); // You are now immune to attacks.
|
||||
}
|
||||
|
||||
return 0;
|
||||
@@ -10564,6 +10565,12 @@ bool is_atcommand(const int fd, struct map_session_data* sd, const char* message
|
||||
if( sscanf(atcmd_msg, "%255s %255[^\n]", command, params) < 2 )
|
||||
params[0] = '\0';
|
||||
|
||||
if (type == 1 && (sd->state.block_action & PCBLOCK_COMMANDS)) {
|
||||
sprintf(output,msg_txt(sd,154), command); // %s failed.
|
||||
clif_displaymessage(fd, output);
|
||||
return true;
|
||||
}
|
||||
|
||||
// @commands (script based)
|
||||
if((type == 1 || type == 3) && atcmd_binding_count > 0) {
|
||||
struct atcmd_binding_data *binding = get_atcommandbind_byname(command);
|
||||
|
||||
Reference in New Issue
Block a user