mirror of
https://github.com/EQEmu/Server.git
synced 2026-05-19 05:08:26 +00:00
[Quest API] Add getcleannpcnamebyid(npc_id) to Perl/Lua. (#1383)
* [Quest API] Add optional clean name parameter to getnpcnamebyid in Perl/Lua. - Allows Server Operators to grab the clean name without having to clean it up in their Perl/Lua. * Convert from a parameter to a method. * Add safer method. * Convert to proper type.
This commit is contained in:
@@ -906,6 +906,26 @@ std::string Database::GetNPCNameByID(uint32 npc_id) {
|
||||
return res;
|
||||
}
|
||||
|
||||
std::string Database::GetCleanNPCNameByID(uint32 npc_id) {
|
||||
std::string query = fmt::format("SELECT `name` FROM `npc_types` WHERE id = {}", npc_id);
|
||||
auto results = QueryDatabase(query);
|
||||
std::string res;
|
||||
std::string mob_name;
|
||||
|
||||
if (!results.Success()) {
|
||||
return res;
|
||||
}
|
||||
|
||||
if (results.RowCount() == 0) {
|
||||
return res;
|
||||
}
|
||||
|
||||
auto row = results.begin();
|
||||
mob_name = row[0];
|
||||
CleanMobName(mob_name.begin(), mob_name.end(), std::back_inserter(res));
|
||||
return res;
|
||||
}
|
||||
|
||||
bool Database::LoadVariables() {
|
||||
auto results = QueryDatabase(StringFormat("SELECT varname, value, unix_timestamp() FROM variables where unix_timestamp(ts) >= %d", varcache.last_update));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user