summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
Diffstat (limited to 'src/map')
-rw-r--r--src/map/init.c1
-rw-r--r--src/map/script.c21
-rw-r--r--src/map/script.h1
-rw-r--r--src/map/send.c15
-rw-r--r--src/map/send.h1
5 files changed, 39 insertions, 0 deletions
diff --git a/src/map/init.c b/src/map/init.c
index 5327532..e19224a 100644
--- a/src/map/init.c
+++ b/src/map/init.c
@@ -109,6 +109,7 @@ HPExport void plugin_init (void)
addScriptCommand("areatimer", "siiiii*", areaTimer);
addScriptCommand("getareadropitem", "siiiiv*", getAreaDropItem);
addScriptCommand("setmount", "?", setMount);
+ addScriptCommand("clientcommand", "s", clientCommand);
do_init_langs();
diff --git a/src/map/script.c b/src/map/script.c
index b321541..fd54d5b 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -1097,3 +1097,24 @@ BUILDIN(setMount)
return true;
}
+
+BUILDIN(clientCommand)
+{
+ TBL_PC* sd = script->rid2sd(st);
+
+ if (sd == NULL)
+ {
+ ShowWarning("player not attached\n");
+ script->reportsrc(st);
+ return false;
+ }
+ const char *const command = script_getstr(st, 2);
+ if (!command)
+ {
+ ShowWarning("invalid client command\n");
+ script->reportsrc(st);
+ return false;
+ }
+ send_client_command(sd, command);
+ return true;
+}
diff --git a/src/map/script.h b/src/map/script.h
index b9247b3..24210a1 100644
--- a/src/map/script.h
+++ b/src/map/script.h
@@ -40,5 +40,6 @@ BUILDIN(isPcDead);
BUILDIN(areaTimer);
BUILDIN(getAreaDropItem);
BUILDIN(setMount);
+BUILDIN(clientCommand);
#endif // EVOL_MAP_SCRIPT
diff --git a/src/map/send.c b/src/map/send.c
index 6fa91fa..b9d826e 100644
--- a/src/map/send.c
+++ b/src/map/send.c
@@ -288,3 +288,18 @@ void send_online_list(int fd, const char *buf, unsigned size)
WFIFOB (fd, size + 4) = 0;
WFIFOSET (fd, len);
}
+
+void send_client_command(TBL_PC *sd, const char *const command)
+{
+ struct SessionExt *data = session_get_bysd(sd);
+ if (!data || data->clientVersion < 8)
+ return;
+
+ const unsigned int len = strlen(command);
+ const int fd = sd->fd;
+ WFIFOHEAD (fd, len);
+ WFIFOW (fd, 0) = 0xb16;
+ WFIFOW (fd, 2) = len + 4;
+ memcpy (WFIFOP (fd, 4), command, len);
+ WFIFOSET (fd, len + 4);
+}
diff --git a/src/map/send.h b/src/map/send.h
index ae9f305..efa89ad 100644
--- a/src/map/send.h
+++ b/src/map/send.h
@@ -26,5 +26,6 @@ void send_slave_say(TBL_PC *sd,
const char *const name,
const char *const message);
void send_online_list(int fd, const char *buf, unsigned size);
+void send_client_command(TBL_PC *sd, const char *const command);
#endif // EVOL_MAP_PC