summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2015-01-02 12:41:30 +0300
committerAndrei Karas <akaras@inbox.ru>2015-01-02 13:32:43 +0300
commit1d23256b629c02102f57b6262d261c6a4c986887 (patch)
tree5be656e8f0c4126ee8820c1d15f0d7134a211723
parent6091f2d963bdff2e62176d9a668943ee02f57043 (diff)
downloadplugin-1d23256b629c02102f57b6262d261c6a4c986887.tar.gz
plugin-1d23256b629c02102f57b6262d261c6a4c986887.tar.bz2
plugin-1d23256b629c02102f57b6262d261c6a4c986887.tar.xz
plugin-1d23256b629c02102f57b6262d261c6a4c986887.zip
Add script command to call timer on players in area.
New script command: areatimer map, x1, y1, x2, y2, tick, event
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/script.c37
-rw-r--r--src/map/script.h1
3 files changed, 39 insertions, 0 deletions
diff --git a/src/map/init.c b/src/map/init.c
index f53de01..cb8eece 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -95,6 +95,7 @@ HPExport void plugin_init (void)
addScriptCommand("getmapname", "", getMapName);
addScriptCommand("unequipbyid", "i", unequipById);
addScriptCommand("ispcdead", "", isPcDead);
+ addScriptCommand("areatimer", "siiiii*", areaTimer);
do_init_langs();
diff --git a/src/map/script.c b/src/map/script.c
index fcaf9cc..c38a377 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -747,3 +747,40 @@ BUILDIN(isPcDead)
script_pushint(st, pc_isdead(sd) ? 1 : 0);
return true;
}
+
+static int areatimer_sub(struct block_list *bl, va_list ap)
+{
+ int tick;
+ char *event;
+ TBL_PC *sd;
+
+ tick = va_arg(ap, int);
+ event = va_arg(ap, char*);
+
+ sd = (TBL_PC *)bl;
+ if (!pc->addeventtimer(sd, tick, event))
+ {
+ if (sd)
+ ShowWarning("buildin_addtimer: Event timer is full, can't add new event timer. (cid:%d timer:%s)\n", sd->status.char_id, event);
+ }
+ return 0;
+}
+
+BUILDIN(areaTimer)
+{
+ const char *const mapname = script_getstr(st, 2);
+ const int x1 = script_getnum(st, 3);
+ const int y1 = script_getnum(st, 4);
+ const int x2 = script_getnum(st, 5);
+ const int y2 = script_getnum(st, 6);
+ const int time = script_getnum(st, 7);
+ const char *const eventName = script_getstr(st, 8);
+ int m;
+
+ if ((m = map->mapname2mapid(mapname)) < 0)
+ return false;
+
+ map->foreachinarea(areatimer_sub, m, x1, y1, x2, y2, BL_PC, time, eventName);
+
+ return true;
+}
diff --git a/src/map/script.h b/src/map/script.h
index 617bd39..e82a57c 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -37,5 +37,6 @@ BUILDIN(setNpcDialogTitle);
BUILDIN(getMapName);
BUILDIN(unequipById);
BUILDIN(isPcDead);
+BUILDIN(areaTimer);
#endif // EVOL_MAP_SCRIPT