Skip to content

Commit

Permalink
Merge pull request #2876 from Helianthella/getcharid
Browse files Browse the repository at this point in the history
Allow to pass an account id to getcharid
  • Loading branch information
MishimaHaruna authored Oct 19, 2020
2 parents 847755f + 039b251 commit a775aeb
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 8 deletions.
11 changes: 6 additions & 5 deletions doc/script_commands.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2632,18 +2632,19 @@ bStr, bInt, bLuk
---------------------------------------

*getcharid(<type>{, "<character name>"})
*getcharid(<type>{, <account id>})

This function will return a unique ID number of the invoking character,
or, if a character name is specified, of that player.

Type is the kind of associated ID number required:

(0) CHAR_ID_CHAR - Character ID number.
(1) CHAR_ID_PARTY - Party ID number.
(2) CHAR_ID_GUILD - Guild ID number.
(0) CHAR_ID_CHAR - Character ID number.
(1) CHAR_ID_PARTY - Party ID number.
(2) CHAR_ID_GUILD - Guild ID number.
(3) CHAR_ID_ACCOUNT - Account ID number.
(4) CHAR_ID_BG - Battle ground ID
(5) CHAR_ID_CLAN - Clan ID number.
(4) CHAR_ID_BG - Battle ground ID
(5) CHAR_ID_CLAN - Clan ID number.

For most purposes other than printing it, a number is better to have than
a name (people do horrifying things to their character names).
Expand Down
11 changes: 8 additions & 3 deletions src/map/script.c
Original file line number Diff line number Diff line change
Expand Up @@ -9290,10 +9290,15 @@ static BUILDIN(getcharid)
int num = script_getnum(st, 2);
struct map_session_data *sd;

if (script_hasdata(st, 3))
sd = map->nick2sd(script_getstr(st, 3), false);
else
if (script_hasdata(st, 3)) {
if (script_isstringtype(st, 3)) {
sd = map->nick2sd(script_getstr(st, 3), false);
} else {
sd = map->id2sd(script_getnum(st, 3));
}
} else {
sd = script->rid2sd(st);
}

if (sd == NULL) {
script_pushint(st, 0); //return 0, according docs
Expand Down

0 comments on commit a775aeb

Please sign in to comment.