diff options
author | Haru <haru@dotalux.com> | 2016-06-18 00:19:39 +0200 |
---|---|---|
committer | Haru <haru@dotalux.com> | 2016-06-25 17:29:50 +0200 |
commit | 9164ea7ec938958245e1ceb75035f90500c8a7c8 (patch) | |
tree | ca80feaddfdcd859163e3977d4569d32a46feda1 /src/map/script.c | |
parent | 17f4709adeb4d9159359d901b1743de56348e7e4 (diff) | |
download | hercules-9164ea7ec938958245e1ceb75035f90500c8a7c8.tar.gz hercules-9164ea7ec938958245e1ceb75035f90500c8a7c8.tar.bz2 hercules-9164ea7ec938958245e1ceb75035f90500c8a7c8.tar.xz hercules-9164ea7ec938958245e1ceb75035f90500c8a7c8.zip |
Added mesf() command (combination of mes() and sprintf())
Signed-off-by: Haru <haru@dotalux.com>
Diffstat (limited to 'src/map/script.c')
-rw-r--r-- | src/map/script.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/map/script.c b/src/map/script.c index 926f19bf0..a6a9a9cf9 100644 --- a/src/map/script.c +++ b/src/map/script.c @@ -5487,6 +5487,37 @@ BUILDIN(mes) return true; } +/** + * Appends a message to the npc dialog, applying format string conversions (see + * sprintf). + * + * If a dialog doesn't exist yet, one is created. + * + * @code + * mes "<message>"; + * @endcode + */ +BUILDIN(mesf) +{ + struct map_session_data *sd = script->rid2sd(st); + struct StringBuf buf; + + if (sd == NULL) + return true; + + StrBuf->Init(&buf); + + if (!script_sprintf(st, 2, &buf)) { + StrBuf->Destroy(&buf); + return false; + } + + clif->scriptmes(sd, st->oid, StrBuf->Value(&buf)); + StrBuf->Destroy(&buf); + + return true; +} + /// Displays the button 'next' in the npc dialog. /// The dialog text is cleared and the script continues when the button is pressed. /// @@ -20275,6 +20306,7 @@ bool script_add_builtin(const struct script_function *buildin, bool override) { else if( strcmp(buildin->name, "callfunc") == 0 ) script->buildin_callfunc_ref = n; else if( strcmp(buildin->name, "getelementofarray") == 0 ) script->buildin_getelementofarray_ref = n; else if( strcmp(buildin->name, "mes") == 0 ) script->buildin_mes_offset = script->buildin_count; + else if( strcmp(buildin->name, "mesf") == 0 ) script->buildin_mesf_offset = script->buildin_count; else if( strcmp(buildin->name, "select") == 0 ) script->buildin_select_offset = script->buildin_count; else if( strcmp(buildin->name, "_") == 0 ) script->buildin_lang_macro_offset = script->buildin_count; else if( strcmp(buildin->name, "_$") == 0 ) script->buildin_lang_macro_fmtstring_offset = script->buildin_count; @@ -20372,6 +20404,7 @@ void script_parse_builtin(void) { // NPC interaction BUILDIN_DEF(mes,"s"), + BUILDIN_DEF(mesf,"s*"), BUILDIN_DEF(next,""), BUILDIN_DEF(close,""), BUILDIN_DEF(close2,""), |