summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJesusaves <cpntb1@ymail.com>2020-09-26 10:39:17 -0300
committerJesusaves <cpntb1@ymail.com>2020-09-26 10:39:17 -0300
commit7bd8183936b5f01ef789822d1f114e85ac391d47 (patch)
tree0fe4d1f6227a642416c0c46ab405147d2ca801d2 /src
parent7fc3f47e2660ae5b88a4dcdc1c1ca2e6f41ecd9e (diff)
downloadplugin-7bd8183936b5f01ef789822d1f114e85ac391d47.tar.gz
plugin-7bd8183936b5f01ef789822d1f114e85ac391d47.tar.bz2
plugin-7bd8183936b5f01ef789822d1f114e85ac391d47.tar.xz
plugin-7bd8183936b5f01ef789822d1f114e85ac391d47.zip
changeplayermusic() script function
required for clientdata!174 Tested in Moubootaur Legends
Diffstat (limited to 'src')
-rw-r--r--src/emap/init.c1
-rw-r--r--src/emap/script_buildins.c24
-rw-r--r--src/emap/script_buildins.h1
-rw-r--r--src/emap/send.c18
-rw-r--r--src/emap/send.h1
5 files changed, 45 insertions, 0 deletions
diff --git a/src/emap/init.c b/src/emap/init.c
index f2e781a..5069ffe 100644
--- a/src/emap/init.c
+++ b/src/emap/init.c
@@ -169,6 +169,7 @@ HPExport void plugin_init (void)
addScriptCommand("setavataraction", "i", setAvatarAction);
addScriptCommand("clear", "", clear);
addScriptCommand("changemusic", "ss", changeMusic);
+ addScriptCommand("changeplayermusic", "s", changePlayerMusic);
addScriptCommand("setnpcdialogtitle", "s", setNpcDialogTitle);
addScriptCommand("getmapname", "", getMapName);
addScriptCommand("unequipbyid", "i", unequipById);
diff --git a/src/emap/script_buildins.c b/src/emap/script_buildins.c
index 85e81b2..263e3a6 100644
--- a/src/emap/script_buildins.c
+++ b/src/emap/script_buildins.c
@@ -921,6 +921,30 @@ BUILDIN(changeMusic)
return true;
}
+// changePlayerMusic(music)
+BUILDIN(changePlayerMusic)
+{
+ const char *const music = script_getstr(st, 2);
+ if (!music)
+ {
+ ShowWarning("invalid music file\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ struct map_session_data *sd = NULL;
+ sd = script->rid2sd(st);
+ if (sd == NULL)
+ {
+ ShowWarning("player not attached\n");
+ script->reportsrc(st);
+ return false;
+ }
+
+ send_changemusic(sd->fd, music);
+ return true;
+}
+
BUILDIN(setNpcDialogTitle)
{
const char *const name = script_getstr(st, 2);
diff --git a/src/emap/script_buildins.h b/src/emap/script_buildins.h
index bcffa7a..ea77fdb 100644
--- a/src/emap/script_buildins.h
+++ b/src/emap/script_buildins.h
@@ -39,6 +39,7 @@ BUILDIN(setAvatarDir);
BUILDIN(setAvatarAction);
BUILDIN(clear);
BUILDIN(changeMusic);
+BUILDIN(changePlayerMusic);
BUILDIN(setNpcDialogTitle);
BUILDIN(getMapName);
BUILDIN(unequipById);
diff --git a/src/emap/send.c b/src/emap/send.c
index 08c57b0..7938048 100644
--- a/src/emap/send.c
+++ b/src/emap/send.c
@@ -298,6 +298,24 @@ void send_advmoving(struct unit_data* ud, bool moving, struct block_list *tbl, e
aFree(buf);
}
+void send_changemusic(int fd, const char *music)
+{
+ if (!music)
+ return;
+
+ const int sz = (int)strlen(music) + 5;
+ char *buf;
+
+ CREATE(buf, char, sz);
+ WBUFW (buf, 0) = 0xb05 + evolPacketOffset;
+ WBUFW (buf, 2) = sz;
+ strcpy (WBUFP (buf, 4), music);
+ WFIFOHEAD(fd,sz);
+ memcpy(WFIFOP(fd,0), buf, sz);
+ WFIFOSET(fd,sz);
+ aFree(buf);
+}
+
void send_changemusic_brodcast(const int map, const char *music)
{
if (!music)
diff --git a/src/emap/send.h b/src/emap/send.h
index b89f1fc..880cdb7 100644
--- a/src/emap/send.h
+++ b/src/emap/send.h
@@ -22,6 +22,7 @@ void send_mapmask(int fd, int mask);
void send_mapmask_brodcast(const int map, const int mask);
void send_mob_info(struct block_list* bl1, struct block_list* bl2, enum send_target target);
void send_advmoving(struct unit_data* ud, bool moving, struct block_list *tbl, enum send_target target);
+void send_changemusic(int fd, const char *music);
void send_changemusic_brodcast(const int map, const char *music);
void send_changenpc_title (struct map_session_data *sd, const int npcId, const char *name);
void send_join_ack(int fd, const char *const name, int flag);