mirror of
https://github.com/EQEmu/Server.git
synced 2025-12-15 16:41:29 +00:00
Add getnpcnamebyid(npc_id) to Perl/Lua.
This commit is contained in:
parent
4c348baabd
commit
02cac686b6
@ -941,6 +941,22 @@ const char* Database::GetCharNameByID(uint32 char_id) {
|
|||||||
return row[0];
|
return row[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char* Database::GetNPCNameByID(uint32 npc_id) {
|
||||||
|
std::string query = fmt::format("SELECT `name` FROM `npc_types` WHERE id = {}", npc_id);
|
||||||
|
auto results = QueryDatabase(query);
|
||||||
|
|
||||||
|
if (!results.Success()) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
if (results.RowCount() == 0) {
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
|
auto row = results.begin();
|
||||||
|
return row[0];
|
||||||
|
}
|
||||||
|
|
||||||
bool Database::LoadVariables() {
|
bool Database::LoadVariables() {
|
||||||
auto results = QueryDatabase(StringFormat("SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= %d", varcache.last_update));
|
auto results = QueryDatabase(StringFormat("SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= %d", varcache.last_update));
|
||||||
|
|
||||||
@ -2389,3 +2405,4 @@ int Database::GetInstanceID(uint32 char_id, uint32 zone_id) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -139,6 +139,7 @@ public:
|
|||||||
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
|
void GetAccountName(uint32 accountid, char* name, uint32* oLSAccountID = 0);
|
||||||
void GetCharName(uint32 char_id, char* name);
|
void GetCharName(uint32 char_id, char* name);
|
||||||
const char *GetCharNameByID(uint32 char_id);
|
const char *GetCharNameByID(uint32 char_id);
|
||||||
|
const char *GetNPCNameByID(uint32 npc_id);
|
||||||
void LoginIP(uint32 AccountID, const char* LoginIP);
|
void LoginIP(uint32 AccountID, const char* LoginIP);
|
||||||
|
|
||||||
/* Instancing */
|
/* Instancing */
|
||||||
|
|||||||
@ -2858,6 +2858,22 @@ XS(XS__getitemname) {
|
|||||||
XSRETURN(1);
|
XSRETURN(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
XS(XS__getnpcnamebyid);
|
||||||
|
XS(XS__getnpcnamebyid) {
|
||||||
|
dXSARGS;
|
||||||
|
if (items != 1)
|
||||||
|
Perl_croak(aTHX_ "Usage: quest::getnpcnamebyid(uint32 npc_id)");
|
||||||
|
|
||||||
|
dXSTARG;
|
||||||
|
uint32 npc_id = (int) SvIV(ST(0));
|
||||||
|
const char *npc_name = quest_manager.getnpcnamebyid(npc_id);
|
||||||
|
|
||||||
|
sv_setpv(TARG, npc_name);
|
||||||
|
XSprePUSH;
|
||||||
|
PUSHTARG;
|
||||||
|
XSRETURN(1);
|
||||||
|
}
|
||||||
|
|
||||||
XS(XS__UpdateSpawnTimer);
|
XS(XS__UpdateSpawnTimer);
|
||||||
XS(XS__UpdateSpawnTimer) {
|
XS(XS__UpdateSpawnTimer) {
|
||||||
dXSARGS;
|
dXSARGS;
|
||||||
@ -4110,6 +4126,7 @@ EXTERN_C XS(boot_quest) {
|
|||||||
newXS(strcpy(buf, "getinventoryslotid"), XS__getinventoryslotid, file);
|
newXS(strcpy(buf, "getinventoryslotid"), XS__getinventoryslotid, file);
|
||||||
newXS(strcpy(buf, "getitemname"), XS__getitemname, file);
|
newXS(strcpy(buf, "getitemname"), XS__getitemname, file);
|
||||||
newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file);
|
newXS(strcpy(buf, "getItemName"), XS_qc_getItemName, file);
|
||||||
|
newXS(strcpy(buf, "getnpcnamebyid"), XS__getnpcnamebyid, file);
|
||||||
newXS(strcpy(buf, "get_spawn_condition"), XS__get_spawn_condition, file);
|
newXS(strcpy(buf, "get_spawn_condition"), XS__get_spawn_condition, file);
|
||||||
newXS(strcpy(buf, "getcharnamebyid"), XS__getcharnamebyid, file);
|
newXS(strcpy(buf, "getcharnamebyid"), XS__getcharnamebyid, file);
|
||||||
newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file);
|
newXS(strcpy(buf, "getguildnamebyid"), XS__getguildnamebyid, file);
|
||||||
|
|||||||
@ -890,6 +890,10 @@ int lua_get_group_id_by_char_id(uint32 char_id) {
|
|||||||
return database.GetGroupIDByCharID(char_id);
|
return database.GetGroupIDByCharID(char_id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *lua_get_npc_name_by_id(uint32 npc_id) {
|
||||||
|
return quest_manager.getnpcnamebyid(npc_id);
|
||||||
|
}
|
||||||
|
|
||||||
int lua_get_raid_id_by_char_id(uint32 char_id) {
|
int lua_get_raid_id_by_char_id(uint32 char_id) {
|
||||||
return database.GetRaidIDByCharID(char_id);
|
return database.GetRaidIDByCharID(char_id);
|
||||||
}
|
}
|
||||||
@ -1776,6 +1780,7 @@ luabind::scope lua_register_general() {
|
|||||||
luabind::def("get_guild_name_by_id", &lua_get_guild_name_by_id),
|
luabind::def("get_guild_name_by_id", &lua_get_guild_name_by_id),
|
||||||
luabind::def("get_guild_id_by_char_id", &lua_get_guild_id_by_char_id),
|
luabind::def("get_guild_id_by_char_id", &lua_get_guild_id_by_char_id),
|
||||||
luabind::def("get_group_id_by_char_id", &lua_get_group_id_by_char_id),
|
luabind::def("get_group_id_by_char_id", &lua_get_group_id_by_char_id),
|
||||||
|
luabind::def("get_npc_name_by_id", &lua_get_npc_name_by_id),
|
||||||
luabind::def("get_raid_id_by_char_id", &lua_get_raid_id_by_char_id),
|
luabind::def("get_raid_id_by_char_id", &lua_get_raid_id_by_char_id),
|
||||||
luabind::def("create_instance", &lua_create_instance),
|
luabind::def("create_instance", &lua_create_instance),
|
||||||
luabind::def("destroy_instance", &lua_destroy_instance),
|
luabind::def("destroy_instance", &lua_destroy_instance),
|
||||||
|
|||||||
@ -2725,6 +2725,13 @@ std::string QuestManager::getitemname(uint32 item_id) {
|
|||||||
return item_name;
|
return item_name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const char *QuestManager::getnpcnamebyid(uint32 npc_id) {
|
||||||
|
if (npc_id > 0) {
|
||||||
|
return database.GetNPCNameByID(npc_id);
|
||||||
|
}
|
||||||
|
return "";
|
||||||
|
}
|
||||||
|
|
||||||
uint16 QuestManager::CreateInstance(const char *zone, int16 version, uint32 duration)
|
uint16 QuestManager::CreateInstance(const char *zone, int16 version, uint32 duration)
|
||||||
{
|
{
|
||||||
QuestManagerCurrentQuestVars();
|
QuestManagerCurrentQuestVars();
|
||||||
|
|||||||
@ -260,6 +260,7 @@ public:
|
|||||||
const char* getguildnamebyid(int guild_id);
|
const char* getguildnamebyid(int guild_id);
|
||||||
int getguildidbycharid(uint32 char_id);
|
int getguildidbycharid(uint32 char_id);
|
||||||
int getgroupidbycharid(uint32 char_id);
|
int getgroupidbycharid(uint32 char_id);
|
||||||
|
const char* getnpcnamebyid(uint32 npc_id);
|
||||||
int getraididbycharid(uint32 char_id);
|
int getraididbycharid(uint32 char_id);
|
||||||
void SetRunning(bool val);
|
void SetRunning(bool val);
|
||||||
bool IsRunning();
|
bool IsRunning();
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user