PLUGIN: MQ2TaskAddAccept

Sadge

Sexy Shoeless God of War
Joined
Nov 2, 2007
Messages
567
Reaction score
0
Points
16
Location
Washington, DC area
Pretty straightforward ... will accepts tasks/expeditions from people in your .ini files (similar to MQ2AutoGroup and MQ2AutoAcceptTrades).

Code:
/* MQ2TaskAddAccept.cpp v1.0000
	Plugin created by Sadge
	"TaskBox" function modified from code written by thez & Nightmare327
	Please do not distribute without my consent.

	This File Comes From MMOBugs and may not be distributed without consent of the author.

*************************************************************************************
| This is a simple plugin created to accept task invites.							|
| In the MQ2TaskAddAccept.ini file, you can change the option to accept tasks		|
| from everyone or just the toons you list in the ini file.							|
|																					|
| WARNING!!!! Although you can set this plugin to accept tasks from everyone, I do	|
| not recommend it.  There is no delay build into this program either.  Use at your	|
| risk!																				|
*************************************************************************************

*****Version 1.0000*****
-- Plugin creation.

*/

#include "../MQ2Plugin.h"

#define   PLUGIN_NAME	  "MQ2TaskAddAccept"	// Plugin Name
#define   PLUGIN_DATE				20080709	// Plugin Date
#define   PLUGIN_VERS				  1.0000	// Plugin Version

bool AutoAcceptEveryone;						//Check if you want to accept all task invited (true) or just from ini list (false)
int TotalNames = 0;								//Total names in ini list
char taskcommand[MAX_STRING];					//The actual command (used to accept task)
int MAXLIST = 30;								//Max names allowed in ini list
char Name[100][64];								//Array to contain each name from ini list

PreSetup("MQ2TaskAddAccept");

VOID Load_INI(VOID)	{	// Loads the ini settings or creates them if not available

	char szTemp[MAX_STRING];		// Local variable to receive and write settings from the ini
	TotalNames = 0;

	GetPrivateProfileString("Settings","AutoAcceptEveryone","TRUE",szTemp,MAX_STRING,INIFileName);
	if (!strnicmp(szTemp,"TRUE",4)) {
		WritePrivateProfileString("Settings","AutoAcceptEveryone","TRUE",INIFileName);
		AutoAcceptEveryone = true;
	}
	else {
		WritePrivateProfileString("Settings","AutoAcceptEveryone","FALSE",INIFileName);
		AutoAcceptEveryone = false;
	}

	for (int i = 0; i<(MAXLIST+1); i++)			// Loop to read names
	{
		sprintf(szTemp,"Name%i",i);
		if(!GetPrivateProfileString("Names",szTemp,"",Name[i],64,INIFileName))
			return;
		else
			TotalNames++;
	}
}	// end Load_INI function

void TaskAccept(VOID) {	// simply contains the command to accept the task
	sprintf(taskcommand,"/nomodkey /notify ConfirmationDialogBox Yes_Button leftmouseup ");
	DoCommand(NULL, taskcommand);
}	// end TaskAccept function

BOOL CheckNames(PCHAR szName) {						// Checks to see if person inviting is on your list

	for (int i = 0; i<(TotalNames+1); i++) {		// Loops until the total amount of names on list is reached
		if (!stricmp(szName,Name[i])) return true;	// if name is found on the list, then returns true
	}	// end for loop (names check)
	return false;									// if no name was found on list, then returns false
}	// end CheckNames function

VOID ShowHelp(VOID)
{
    WriteChatf("%s::Version [\ag%1.4f\ax] Loaded! Created by Sadge",PLUGIN_NAME,PLUGIN_VERS);
	WriteChatf("\ay====================\ax");
    WriteChatf("Status AutoAcceptEveryone is Currently: %s", AutoAcceptEveryone?"\agTRUE":"\arFALSE");
    WriteChatf("There are <%d> name(s) in your list of people to always accept tasks from", TotalNames);
	WriteChatf("\ay====================\ax");
    
    return;
}

VOID DoTaskAddSettings(PSPAWNINFO pChar, PCHAR szLine)	// This allows you to change settings
{
	char szTemp[MAX_STRING];

	if (gGameState == GAMESTATE_INGAME) {			// Checks to make sure we're in game
		if (szLine[0]==0) {							// if no parameter was passed then show the help (settings)
			ShowHelp();
			return;
		}	// end if statement (no parameters)
		if (!stricmp(szLine,"TRUE")) {				// if received "TRUE" turns autoaccepteveryone on
			AutoAcceptEveryone = true;
			WritePrivateProfileString("Settings","AutoAcceptEveryone",szLine,INIFileName);
			WriteChatf("AutoAcceptEveryone is now: %s", AutoAcceptEveryone?"\agTRUE":"\arFALSE");
		}	// end if statement (autoaccepteveryone true)
		else if (!stricmp(szLine,"FALSE")) {		// if received "FALSE" turns autoaccepteveryone off
			AutoAcceptEveryone = false;
			WritePrivateProfileString("Settings","AutoAcceptEveryone",szLine,INIFileName);
			WriteChatf("AutoAcceptEveryone is now: %s", AutoAcceptEveryone?"\agTRUE":"\arFALSE");
		}	// end if statement (autoaccepteveryone false)
		else {									// if anything else received, it's treated as a name to add to the list of acceptable trade names
			WriteChatf("Adding \ay< %s >\ax to list of people you'll always trade with",szLine);
			sprintf(szTemp,"Name%i",TotalNames);
			WritePrivateProfileString("Names",szTemp,szLine,INIFileName);
			TotalNames++;						// increases the total amount of names on our list
			Load_INI();
			return;
		}	// end else statement (it must be a name)
		Load_INI();								// reloads the ini
	}	// end if we're in game
}	// end function DoAutoTrade

// Called once, when the plugin is to initialize
PLUGIN_API VOID InitializePlugin(VOID)
{
	DebugSpewAlways("Initializing MQ2TaskAddAccept");

	Load_INI();
	AddCommand("/autotask", DoTaskAddSettings);

	WriteChatf("%s::Version [\ag%1.4f\ax] Loaded! Created by Sadge",PLUGIN_NAME,PLUGIN_VERS);
	WriteChatf("\ay====================\ax");
	WriteChatColor("You can view the current settings by typing /autotask", CONCOLOR_GREEN);
	WriteChatColor("You can toggle auto-accepting with everyone by typing /autotask TRUE (on) or FALSE (off)", CONCOLOR_GREEN);
	WriteChatColor("You can add someone to your list of people to always trade with by typing /autotask <CharName>", CONCOLOR_GREEN);
	WriteChatf("\ay====================\ax");
    WriteChatf("Status AutoAcceptEveryone is Currently: %s", AutoAcceptEveryone?"\agTRUE":"\arFALSE");
	WriteChatf("\ay====================\ax");

}	// end InitializePlugin function

// Called once, when the plugin is to shutdown
PLUGIN_API VOID ShutdownPlugin(VOID)
{
	DebugSpewAlways("Shutting down MQ2TaskAddAccept");
	RemoveCommand("/autotask");
}	// end ShutdownPlugin function

VOID TaskBox() {
   CXWnd *Child;
   CXWnd *pWnd;
   char InputCXStr[128],*p,InviterName[32];
   int i;

   pWnd=(CXWnd *)FindMQ2Window("ConfirmationDialogBox");
   if(pWnd) {
      if (((PCSIDLWND)(pWnd))->Show==0) return;
      Child=pWnd->GetChildItem("cd_textoutput");
      if(Child) {
         ZeroMemory(InputCXStr,sizeof(InputCXStr));
         GetCXStr(Child->SidlText,InputCXStr,sizeof(InputCXStr));
         p = strstr(InputCXStr,"has asked you to join");
		 if (p) {
			 for (i=0; i <= sizeof(InputCXStr); i++ ) {
				 if (InputCXStr[i] == ' ') break;
				 InviterName[i] = InputCXStr[i];
			 }
			if ((!AutoAcceptEveryone) && !(CheckNames(InviterName))) return;	// if you're not accepting all trades and the person trading is not on the always trade list...
			else {
			    WriteChatf("Accepting Task from \ay< %s >\ax",InviterName);
				TaskAccept();
				return;
			}
		 }
      }
   }
   return;
}
// This is called every time MQ pulses
PLUGIN_API VOID OnPulse(VOID)
{
	if (gGameState==GAMESTATE_INGAME) {							// are we in game?
		TaskBox();
	}
}
Let me know of any issues/problems.
 

Attachments

  • MQ2TaskAddAccept.dll
    134 KB · Views: 15
Last edited:
Man, if it wouldn't be queer I'd kiss you. Tounge kiss even. Thjis save my little fingers alot of work.



BB
 
Sorry about that -- it was a pretty weird and busy weekend.

I updated the post at the top to included the compiled version which should match the compile on the 20th.

If you guys want to add this to the standard compile, that's fine with me. Saves me the hassle of having to recompile it every patch. :D
 
If you don't want to accept from everyone, and you put False, how do format for the names you want to accept? And I have it loaded, but it doesn't accept tasks automatically, with Everyone true, so do I need to turn it on? It says I can't Load or unload the MQ2Taskaddaccept plugin as well.
 
Last edited:
what was another plugin that accepts task adds etc (not sure i had this plugin yet but been auto accepting taskadds.

great for these new tasks that lock as soon as mob dies:
/taskremov (toon u have in task)
/pause 02
/taskadd (gimptoon who couldnt do task)
not sure what the lvl spread max is for UF expansion but even gimps can get flagged (low aa low gear)
 
No, what I want is folks doing tasks that I need while I am at work could TA me and then remove me when done. This seemed to be the plugin that would do it, and it comes with the compile. I have it set to load in the setup, but it doesn't show as loaded, I can't /plugin mq2taskaddaccept load or /plugin mq2taskaddaccept unload. So I'm wondering if it's broken or if someone has something simiarl.
 
plugin works fine, if you cannt load it its on your end. Use this daily. Once it is loaded you need to turn on auto accept via name or just everyone.
 
Try logging in with just the standard plugins loaded and MQ2Taskaddaccept. I used this plugin yesterday, and it works fine. Failing that, post here, making sure you post everything that the first post asks for