convertpcinfo script command (#3924)
Implemented convertpcinfo script command * The command allows to convert more easily a player data to another. * It fails silently if the character is not found/online. Thanks to @aleos89, @Normynator, @cydh !
This commit is contained in:
parent
c1975d7ea3
commit
5fae7c26c1
@ -2338,6 +2338,22 @@ returned when requesting that information.
|
|||||||
|
|
||||||
---------------------------------------
|
---------------------------------------
|
||||||
|
|
||||||
|
*convertpcinfo(<char_id>,<type>)
|
||||||
|
*convertpcinfo(<account_id>,<type>)
|
||||||
|
*convertpcinfo(<player_name>,<type>)
|
||||||
|
|
||||||
|
This function will return the information <type> for the
|
||||||
|
specified character. Whatever it returns is determined by type.
|
||||||
|
|
||||||
|
CPC_NAME - Character's name.
|
||||||
|
CPC_CHAR - Character ID.
|
||||||
|
CPC_ACCOUNT - Account ID.
|
||||||
|
|
||||||
|
If a character is not found (or not online) when requesting that information,
|
||||||
|
an empty string will be returned for CPC_NAME, 0 for other <type>.
|
||||||
|
|
||||||
|
---------------------------------------
|
||||||
|
|
||||||
*strnpcinfo(<type>)
|
*strnpcinfo(<type>)
|
||||||
|
|
||||||
This function will return the various parts of the name of the calling NPC.
|
This function will return the various parts of the name of the calling NPC.
|
||||||
|
@ -24447,6 +24447,59 @@ BUILDIN_FUNC(getvariableofinstance)
|
|||||||
return SCRIPT_CMD_SUCCESS;
|
return SCRIPT_CMD_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
convertpcinfo(<char_id>,<type>)
|
||||||
|
convertpcinfo(<account_id>,<type>)
|
||||||
|
convertpcinfo(<player_name>,<type>)
|
||||||
|
*/
|
||||||
|
BUILDIN_FUNC(convertpcinfo) {
|
||||||
|
TBL_PC *sd;
|
||||||
|
|
||||||
|
if (script_isstring(st, 2))
|
||||||
|
sd = map_nick2sd(script_getstr(st, 2),false);
|
||||||
|
else {
|
||||||
|
int id = script_getnum(st, 2);
|
||||||
|
sd = map_id2sd(id);
|
||||||
|
if (!sd)
|
||||||
|
sd = map_charid2sd(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
int type = script_getnum(st, 3);
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case CPC_NAME:
|
||||||
|
case CPC_CHAR:
|
||||||
|
case CPC_ACCOUNT:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
ShowError("buildin_convertpcinfo: Unknown type %d.\n", type);
|
||||||
|
script_pushnil(st);
|
||||||
|
st->state = END;
|
||||||
|
return SCRIPT_CMD_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!sd) {
|
||||||
|
if (type == CPC_NAME)
|
||||||
|
script_pushstrcopy(st, "");
|
||||||
|
else
|
||||||
|
script_pushint(st, 0);
|
||||||
|
return SCRIPT_CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (type) {
|
||||||
|
case CPC_NAME:
|
||||||
|
script_pushstrcopy(st, sd->status.name);
|
||||||
|
break;
|
||||||
|
case CPC_CHAR:
|
||||||
|
script_pushint(st, sd->status.char_id);
|
||||||
|
break;
|
||||||
|
case CPC_ACCOUNT:
|
||||||
|
script_pushint(st, sd->status.account_id);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return SCRIPT_CMD_SUCCESS;
|
||||||
|
}
|
||||||
|
|
||||||
#include "../custom/script.inc"
|
#include "../custom/script.inc"
|
||||||
|
|
||||||
// declarations that were supposed to be exported from npc_chat.cpp
|
// declarations that were supposed to be exported from npc_chat.cpp
|
||||||
@ -25116,6 +25169,7 @@ struct script_function buildin_func[] = {
|
|||||||
|
|
||||||
BUILDIN_DEF(achievement_condition,"i"),
|
BUILDIN_DEF(achievement_condition,"i"),
|
||||||
BUILDIN_DEF(getvariableofinstance,"ri"),
|
BUILDIN_DEF(getvariableofinstance,"ri"),
|
||||||
|
BUILDIN_DEF(convertpcinfo,"vi"),
|
||||||
#include "../custom/script_def.inc"
|
#include "../custom/script_def.inc"
|
||||||
|
|
||||||
{NULL,NULL,NULL},
|
{NULL,NULL,NULL},
|
||||||
|
@ -1942,6 +1942,12 @@ enum e_hat_effects {
|
|||||||
HAT_EF_MAX
|
HAT_EF_MAX
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum e_convertpcinfo_type : uint8 {
|
||||||
|
CPC_NAME = 0,
|
||||||
|
CPC_CHAR = 1,
|
||||||
|
CPC_ACCOUNT = 2
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Player blocking actions related flags.
|
* Player blocking actions related flags.
|
||||||
*/
|
*/
|
||||||
|
@ -7281,6 +7281,11 @@
|
|||||||
export_constant(PCBLOCK_EMOTION);
|
export_constant(PCBLOCK_EMOTION);
|
||||||
export_constant(PCBLOCK_ALL);
|
export_constant(PCBLOCK_ALL);
|
||||||
|
|
||||||
|
/* convertpcinfo command */
|
||||||
|
export_constant(CPC_NAME);
|
||||||
|
export_constant(CPC_CHAR);
|
||||||
|
export_constant(CPC_ACCOUNT);
|
||||||
|
|
||||||
#undef export_constant
|
#undef export_constant
|
||||||
#undef export_constant2
|
#undef export_constant2
|
||||||
#undef export_parameter
|
#undef export_parameter
|
||||||
|
Loading…
x
Reference in New Issue
Block a user