Pretty straightforward ... will accepts tasks/expeditions from people in your .ini files (similar to MQ2AutoGroup and MQ2AutoAcceptTrades).
Let me know of any issues/problems.
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();
}
}
Attachments
Last edited: