• You've discovered RedGuides, an EverQuest multi-boxing and scripting community 🧙‍♀️⚙️. We want you to play several EQ characters at once, come join us and say hello! 👋

  • A TLP without truebox has thawed (Very Vanilla ready)
    Frostreaver
Resource icon

Release MQ2PvPAlert

Naes

Member
Joined
Jan 15, 2006
RedCents
60¢
I wrote this plugin a couple years ago. Some others have popped up over the years but they were either too simple, or too complicated. When someone zones into you, this plugin can do the following:

  • Chat window message
  • LDoN/Task popup
  • Audio triggers

X2oDa.jpg


Now with military timestamps

coLR3.png


This plugin is clearly very useful on Zek, but I can see it being useful on PvE servers as well if you are doing stuff and need to know if someone else zones in.

Basic options:
PHP:
// MQ2PvPAlert.cpp : Defines the entry point for the DLL application.
// Author: Naes

#include <ctime>

#include "../MQ2Plugin.h"
PreSetup("MQ2PvPAlert");

int sounds = 0;
int popup = 0;
int message = 0;

bool CheckForPC(PSPAWNINFO pNewSpawn)
{
	// this seems dirty and redundant, but it's necessary to prevent a crash at the char select
	return (GetCharInfo() && GetCharInfo()->pSpawn && GetCharInfo()->pSpawn->Name && 
		GetSpawnType(pNewSpawn) == PC && 
		//strncmp(pNewSpawn->DisplayedName, "LD", 2) != 0 &&   // ignore VZ/TZ MQ crash mob
		strcmp(GetCharInfo()->pSpawn->Name, pNewSpawn->Name) != 0);
}

void EchoNewPlayer(PSPAWNINFO pNewSpawn, bool entered, DWORD color)
{
	char echomsg[MAX_STRING];
	const char* guild = (GetGuildByID(pNewSpawn->GuildID)) ? (GetGuildByID(pNewSpawn->GuildID)) : "";
	const char* came = (entered) ? "entered" : "left";

	time_t now = time(NULL);
	struct tm * ptm = localtime(&now);
	char timebuffer[32];
	strftime (timebuffer, 32, "%H:%M:%S", ptm);

	sprintf(echomsg, "[%s] [PvP] %s (%d %s) <%s> %s %s.", timebuffer, pNewSpawn->Name, 
						pNewSpawn->Level, pEverQuest->GetClassThreeLetterCode(pNewSpawn->Class),
						guild, came, ((PZONEINFO)pZoneInfo)->ShortName);

	WriteChatColor(echomsg, color);
}

void PopupNewPlayer(PSPAWNINFO pNewSpawn, int color, int seconds)
{
	char buffer[MAX_STRING];
	sprintf(buffer, "/popup %s (%d %s) has entered the zone.", pNewSpawn->Name, pNewSpawn->Level, 
						pEverQuest->GetClassThreeLetterCode(pNewSpawn->Class));
	//sprintf(buffer, "/popcustom %d %d %s has entered the zone.", color, seconds, pNewSpawn->Name);
	DoCommand(GetCharInfo()->pSpawn, buffer);
}

PLUGIN_API VOID OnAddSpawn(PSPAWNINFO pNewSpawn)
{
	if (CheckForPC(pNewSpawn))
	{
		DebugSpewAlways("MQ2PvPAlert::OnAddSpawn(%s) - PC DETECTED", pNewSpawn->Name);
		int seconds = 2;
		int color = 15;

		if (message)
			EchoNewPlayer(pNewSpawn, true, CONCOLOR_YELLOW);

		if (popup)
			PopupNewPlayer(pNewSpawn, color, seconds);		

		if (sounds)
			MacroBeep(GetCharInfo()->pSpawn, "AudioTriggers\\default\\alert4.wav");
	}
}

PLUGIN_API VOID OnRemoveSpawn(PSPAWNINFO pSpawn)
{
	if (CheckForPC(pSpawn))
	{
		DebugSpewAlways("MQ2PvPAlert::OnRemoveSpawn(%s) - PC DETECTED", pSpawn->Name);

		if (message)
			EchoNewPlayer(pSpawn, false, CONCOLOR_RED);	
	
		if (sounds)
			MacroBeep(GetCharInfo()->pSpawn, "AudioTriggers\\default\\alert2.wav");
	}
}

void PvPAlertExecuteCmd(PCHAR iniSetting, int &option, int activate)
{
	CHAR szMsg[MAX_STRING]={0};
	CHAR szTemp[MAX_STRING]={0};
	
	sprintf(szTemp, "%d", activate);

	option = activate;
	WritePrivateProfileString("MQ2PvPAlert", iniSetting, szTemp, INIFileName);

	sprintf(szMsg, "MQ2PvPAlert - %s: %d", iniSetting, activate);
	WriteChatColor(szMsg, USERCOLOR_DEFAULT);
}

void PvPAlertCmd(PSPAWNINFO pChar, PCHAR szLine)
{
	CHAR Arg1[MAX_STRING] = {0}; 
    CHAR Arg2[MAX_STRING] = {0};

    GetArg(Arg1, szLine, 1); 
    GetArg(Arg2, szLine, 2); 

	
	int activate = (!stricmp(Arg2, "on")) ? 1 : 0;

	
	DebugSpewAlways("sZLine: %d, Arg1: %s, Arg2: %s, activate: %d", szLine, Arg1, Arg2, activate);

	if (!stricmp(Arg1, "sounds"))
	{
		PvPAlertExecuteCmd("sounds", sounds, activate);
	}
	else if(!stricmp(Arg1, "popup"))
	{
		PvPAlertExecuteCmd("popup", popup, activate);
	}
	else if(!stricmp(Arg1, "message"))
	{
		PvPAlertExecuteCmd("message", message, activate);
	}
	else
	{
		WriteChatColor("MQ2PvPAlert Usage: /pvpalert [sounds/popup/message] [on/off]", USERCOLOR_DEFAULT);
	}
}

PLUGIN_API VOID InitializePlugin(VOID) 
{
	AddCommand("/pvpalert", PvPAlertCmd); 

	sounds = GetPrivateProfileInt("MQ2PvPAlert", "sounds", 1, INIFileName);
	popup = GetPrivateProfileInt("MQ2PvPAlert", "popup", 1, INIFileName);
	message = GetPrivateProfileInt("MQ2PvPAlert", "message", 1, INIFileName);
}

PLUGIN_API VOID ShutdownPlugin(VOID) 
{ 
    RemoveCommand("/pvpalert"); 
}

Known issues:
When you first zone in to a new zone, the message box will say they zoned into the old zone. (e.g. You zone to guildlobby, it'll say all the people in guildlobby just zoned into PoK). This is due to OnAddSpawn() being called before OnZoned(). It has no effect however if you are already in a zone and someone new zones into it (will display correctly).


I Hope you find this as useful as I do. Post if you have any ideas for features.
 
Last edited:
What iare sthe actual pvp rules on zek now?

Tallon Zek used to be light races vs Dark Races with a level 10 spread.
 
I'd really like this to be included with the compile. Can we get it added, please? Thank you!
 
I tried this tonight, and its awesome. Like Naes mentioned, just enough info while not being too busy. The only thing I would suggest is adding a timestamp to the output. But even without it, its exactly what i've been looking for. i'll redcent you.
 
/plugin mq2timestamp

Unless I'm setting it up completely incorrectly (which is actually quite likely), mq2timestamp doesnt appear to apply to messages from mq2pvpalert, even though it does append timestamps to normal eq chat.
 
Ah you are right I thought it added it to all windows.
 
Added military timestamps to the message box. Figured this was something overlooked and that everyone would leave on so didn't add an option for it. updated OP

coLR3.png


Rich (BB code):
// MQ2PvPAlert.cpp : Defines the entry point for the DLL application.
// Author: Naes

#include <ctime>

#include "../MQ2Plugin.h"
PreSetup("MQ2PvPAlert");

int sounds = 0;
int popup = 0;
int message = 0;

bool CheckForPC(PSPAWNINFO pNewSpawn)
{
	// this seems dirty and redundant, but it's necessary to prevent a crash at the char select
	return (GetCharInfo() && GetCharInfo()->pSpawn && GetCharInfo()->pSpawn->Name && 
		GetSpawnType(pNewSpawn) == PC && 
		//strncmp(pNewSpawn->DisplayedName, "LD", 2) != 0 &&   // ignore VZ/TZ MQ crash mob
		strcmp(GetCharInfo()->pSpawn->Name, pNewSpawn->Name) != 0);
}

void EchoNewPlayer(PSPAWNINFO pNewSpawn, bool entered, DWORD color)
{
	char echomsg[MAX_STRING];
	const char* guild = (GetGuildByID(pNewSpawn->GuildID)) ? (GetGuildByID(pNewSpawn->GuildID)) : "";
	const char* came = (entered) ? "entered" : "left";

	time_t now = time(NULL);
	struct tm * ptm = localtime(&now);
	char timebuffer[32];
	strftime (timebuffer, 32, "%H:%M:%S", ptm);

	sprintf(echomsg, "[%s] [PvP] %s (%d %s) <%s> %s %s.", timebuffer, pNewSpawn->Name, 
						pNewSpawn->Level, pEverQuest->GetClassThreeLetterCode(pNewSpawn->Class),
						guild, came, ((PZONEINFO)pZoneInfo)->ShortName);

	WriteChatColor(echomsg, color);
}

void PopupNewPlayer(PSPAWNINFO pNewSpawn, int color, int seconds)
{
	char buffer[MAX_STRING];
	sprintf(buffer, "/popup %s (%d %s) has entered the zone.", pNewSpawn->Name, pNewSpawn->Level, 
						pEverQuest->GetClassThreeLetterCode(pNewSpawn->Class));
	//sprintf(buffer, "/popcustom %d %d %s has entered the zone.", color, seconds, pNewSpawn->Name);
	DoCommand(GetCharInfo()->pSpawn, buffer);
}

PLUGIN_API VOID OnAddSpawn(PSPAWNINFO pNewSpawn)
{
	if (CheckForPC(pNewSpawn))
	{
		DebugSpewAlways("MQ2PvPAlert::OnAddSpawn(%s) - PC DETECTED", pNewSpawn->Name);
		int seconds = 2;
		int color = 15;

		if (message)
			EchoNewPlayer(pNewSpawn, true, CONCOLOR_YELLOW);

		if (popup)
			PopupNewPlayer(pNewSpawn, color, seconds);		

		if (sounds)
			MacroBeep(GetCharInfo()->pSpawn, "AudioTriggers\\default\\alert4.wav");
	}
}

PLUGIN_API VOID OnRemoveSpawn(PSPAWNINFO pSpawn)
{
	if (CheckForPC(pSpawn))
	{
		DebugSpewAlways("MQ2PvPAlert::OnRemoveSpawn(%s) - PC DETECTED", pSpawn->Name);

		if (message)
			EchoNewPlayer(pSpawn, false, CONCOLOR_RED);	
	
		if (sounds)
			MacroBeep(GetCharInfo()->pSpawn, "AudioTriggers\\default\\alert2.wav");
	}
}

void PvPAlertExecuteCmd(PCHAR iniSetting, int &option, int activate)
{
	CHAR szMsg[MAX_STRING]={0};
	CHAR szTemp[MAX_STRING]={0};
	
	sprintf(szTemp, "%d", activate);

	option = activate;
	WritePrivateProfileString("MQ2PvPAlert", iniSetting, szTemp, INIFileName);

	sprintf(szMsg, "MQ2PvPAlert - %s: %d", iniSetting, activate);
	WriteChatColor(szMsg, USERCOLOR_DEFAULT);
}

void PvPAlertCmd(PSPAWNINFO pChar, PCHAR szLine)
{
	CHAR Arg1[MAX_STRING] = {0}; 
    CHAR Arg2[MAX_STRING] = {0};

    GetArg(Arg1, szLine, 1); 
    GetArg(Arg2, szLine, 2); 

	
	int activate = (!stricmp(Arg2, "on")) ? 1 : 0;

	
	DebugSpewAlways("sZLine: %d, Arg1: %s, Arg2: %s, activate: %d", szLine, Arg1, Arg2, activate);

	if (!stricmp(Arg1, "sounds"))
	{
		PvPAlertExecuteCmd("sounds", sounds, activate);
	}
	else if(!stricmp(Arg1, "popup"))
	{
		PvPAlertExecuteCmd("popup", popup, activate);
	}
	else if(!stricmp(Arg1, "message"))
	{
		PvPAlertExecuteCmd("message", message, activate);
	}
	else
	{
		WriteChatColor("MQ2PvPAlert Usage: /pvpalert [sounds/popup/message] [on/off]", USERCOLOR_DEFAULT);
	}
}

PLUGIN_API VOID InitializePlugin(VOID) 
{
	AddCommand("/pvpalert", PvPAlertCmd); 

	sounds = GetPrivateProfileInt("MQ2PvPAlert", "sounds", 1, INIFileName);
	popup = GetPrivateProfileInt("MQ2PvPAlert", "popup", 1, INIFileName);
	message = GetPrivateProfileInt("MQ2PvPAlert", "message", 1, INIFileName);
}

PLUGIN_API VOID ShutdownPlugin(VOID) 
{ 
    RemoveCommand("/pvpalert"); 
}
 
Tallon/Vallon were +/-8 levels actually but since they'll never make another PVP server we'll never have to worry about things other than Zek.
 
MQ2PvPAlert

by Naes

When someone zones into you, this plugin can do the following:

  • Chat window message
  • LDoN/Task popup
  • Audio triggers

X2oDa.jpg


Now with military timestamps

coLR3.png


This plugin is clearly very useful on Zek, but I can see it being useful on PvE servers as well if you are doing stuff and need to know if someone else zones in.

Known issues:
When you first zone in to a new zone, the message box will say they zoned into the old zone. (e.g. You zone to guildlobby, it'll say all the people in guildlobby just zoned into PoK). This is due to OnAddSpawn() being called before OnZoned(). It has no effect however if you are already in a zone and someone new zones into it (will display correctly).
 
 
Release MQ2PvPAlert

Users who are viewing this thread

Back
Top
Cart