diff --git a/npc/Test.txt b/npc/Test.txt new file mode 100644 index 0000000..c8255cc --- /dev/null +++ b/npc/Test.txt @@ -0,0 +1,9 @@ +prontera,150,150,0 script Postbox#Test 2_POSTBOX,{ +end; + +OnInit: +OnTimer5000: + mailemotion(); + initnpctimer; + end; +} \ No newline at end of file diff --git a/src/map/script.c b/src/map/script.c index e8dc978..7d37ae7 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -19772,6 +19772,37 @@ void script_hqueue_clear(int idx) { } #endif +int script_mailemotion_sub(struct block_list *bl, va_list ap) { + TBL_PC* sd; + int id = va_arg(ap, int); + + + nullpo_ret(bl); + + if( !bl ) + return 0; + + sd = (TBL_PC*)bl; + + if( !sd ) + return 0; + + if( sd->mail.inbox.unchecked || sd->mail.inbox.unread ) { + WFIFOHEAD(sd->fd,packet_len(0xc0)); + WFIFOW(sd->fd,0)=0xc0; + WFIFOL(sd->fd,2)=id; + WFIFOW(sd->fd,6)=69; + WFIFOSET(sd->fd,packet_len(0xc0)); + return 1; + } + return 0; +} + +BUILDIN(mailemotion) { + map->foreachinrange(script_mailemotion_sub, map->id2bl(st->oid), AREA_SIZE, BL_PC, st->oid); + return true; +} + /** * Adds a built-in script function. * @@ -20438,6 +20469,7 @@ void script_parse_builtin(void) { BUILDIN_DEF(showscript, "s?"), BUILDIN_DEF(mergeitem,""), BUILDIN_DEF(_,"s"), + BUILDIN_DEF(mailemotion,""), }; int i, len = ARRAYLENGTH(BUILDIN); RECREATE(script->buildin, char *, script->buildin_count + len); // Pre-alloc to speed up