Go Back   EQEmulator Home > EQEmulator Forums > Quests > Quests::LUA

Quests::LUA Section regarding LUA scripts, help, questions, answers

Thread Tools Display Modes
Old 09-10-2019, 03:24 AM
Hill Giant
Join Date: Aug 2008
Location: melbourne
Posts: 171
Default Deleteing Globals

I need to delete a player's quest global, but from an event timer so there is no player context in (e), instead I have a client using getrandomclient().

There's only one function I can find to delete quest globals, which is delete_global(char *name), this function doesn't include the player.

So I'm looking to add a function that lets you delete a global specifying a client id. Is this all I need to do?

1. Add the new function to the luabind register in lua_general.cpp.
2. Add a function to lua_general.cpp that calls the function in questmgr.cpp
3. Add a new function (delete_char_global) to questmgr.cpp and questmgr.h, that takes and uses uses an additional clientid parameter.

		luabind::def("delete_char_global", &lua_delete_char_global),
void lua_delete_char_global(const char *name, int charid) {
	quest_manager.delcharglobal(name, charid);
	void delcharglobal(const char * varname, int charid);
void QuestManager::delcharglobal(const char *varname, int charid) {
	int qgZoneid = zone->GetZoneID();
	int qgCharid = charid;
	int qgNpcid = owner ? owner->GetNPCTypeID() : 0; // encounter scripts don't have an owner

	/* QS: PlayerLogQGlobalUpdate */
	if (RuleB(QueryServ, PlayerLogQGlobalUpdate) && qgCharid && qgCharid > 0 && initiator && initiator->IsClient()) {
		std::string event_desc = StringFormat("Deleted :: qglobal:%s zoneid:%i instid:%i", varname, initiator->GetZoneID(), initiator->GetInstanceID());
		QServ->PlayerLogEvent(Player_Log_QGlobal_Update, qgCharid, event_desc);

	std::string query = StringFormat("DELETE FROM quest_globals "
		"WHERE name = '%s' "
		"&& (npcid=0 || npcid=%i) "
		"&& (charid=0 || charid=%i) "
		"&& (zoneid=%i || zoneid=0)",
		varname, qgNpcid, qgCharid, qgZoneid);
	auto results = database.QueryDatabase(query);
	if (!results.Success())
		std::cerr << "delglobal error deleting " << varname << " : " << results.ErrorMessage() << std::endl;

	if (!zone)

	auto pack = new ServerPacket(ServerOP_QGlobalDelete, sizeof(ServerQGlobalDelete_Struct));
	ServerQGlobalDelete_Struct *qgu = (ServerQGlobalDelete_Struct *)pack->pBuffer;

	qgu->npc_id = qgNpcid;
	qgu->char_id = qgCharid;
	qgu->zone_id = qgZoneid;
	strcpy(qgu->name, varname);

	entity_list.DeleteQGlobal(std::string((char *)qgu->name), qgu->npc_id, qgu->char_id, qgu->zone_id);
	zone->DeleteQGlobal(std::string((char *)qgu->name), qgu->npc_id, qgu->char_id, qgu->zone_id);

Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT -4. The time now is 09:18 PM.


Everquest is a registered trademark of Daybreak Game Company LLC.
EQEmulator is not associated or affiliated in any way with Daybreak Game Company LLC.
Except where otherwise noted, this site is licensed under a Creative Commons License.
Powered by vBulletin®, Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Template by Bluepearl Design and vBulletin Templates - Ver3.3