summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHaru <haru@dotalux.com>2017-06-03 18:41:29 +0200
committerGitHub <noreply@github.com>2017-06-03 18:41:29 +0200
commitf795a6df2766348d2a7f43f48e392b3cf3008781 (patch)
tree0bfee4f6fb230e14ff0ebd816c4f1a47c1345140
parentcaebdf44507fcd345b63211588fbe607fefd0d78 (diff)
parent0e30a97cb5629ee3c600fc2cdbc1ed9f0bc69636 (diff)
downloadhercules-f795a6df2766348d2a7f43f48e392b3cf3008781.tar.gz
hercules-f795a6df2766348d2a7f43f48e392b3cf3008781.tar.bz2
hercules-f795a6df2766348d2a7f43f48e392b3cf3008781.tar.xz
hercules-f795a6df2766348d2a7f43f48e392b3cf3008781.zip
Merge pull request #1747 from mekolat/param2
patch for readparam()
-rw-r--r--doc/script_commands.txt2
-rw-r--r--src/map/script.c22
2 files changed, 15 insertions, 9 deletions
diff --git a/doc/script_commands.txt b/doc/script_commands.txt
index e4f7e24a1..28e25679f 100644
--- a/doc/script_commands.txt
+++ b/doc/script_commands.txt
@@ -2466,7 +2466,7 @@ arrays:
---------------------------------------
-*readparam(<parameter number>)
+*readparam(<parameter number>{, "<player name>"})
This function will return the basic stats of an invoking character,
referred to by the parameter number. Instead of a number, you can use a
diff --git a/src/map/script.c b/src/map/script.c
index 5ef54ed2e..bd73fc021 100644
--- a/src/map/script.c
+++ b/src/map/script.c
@@ -8590,20 +8590,26 @@ BUILDIN(disableitemuse)
BUILDIN(readparam) {
int type;
struct map_session_data *sd;
+ struct script_data *data = script_getdata(st, 2);
- type=script_getnum(st,2);
- if (script_hasdata(st,3))
- sd = script->nick2sd(st, script_getstr(st,3));
- else
- sd=script->rid2sd(st);
+ if (reference_toparam(data)) {
+ type = reference_getparamtype(data);
+ } else {
+ type = script->conv_num(st, data);
+ }
+
+ if (script_hasdata(st, 3)) {
+ sd = script->nick2sd(st, script_getstr(st, 3));
+ } else {
+ sd = script->rid2sd(st);
+ }
if (sd == NULL) {
- script_pushint(st,-1);
+ script_pushint(st, -1);
return true;
}
- script_pushint(st,pc->readparam(sd,type));
-
+ script_pushint(st, pc->readparam(sd, type));
return true;
}