Sorry quick update - the error was not your order of precedence brackets, but the conditional being the wrong way around. I had to reverse the options.
(sorry - dont have exact lines as I don't know how to work git :P )
Around line ~775
Original:
queryStream << i ? StringFormat("taskid = %i ", tasksDisabled[i]): StringFormat("OR taskid = %i ", tasksDisabled[i]);
This resulted in a query that looked like this with only a single task passed to it;
DELETE FROM character_enabledtasks WHERE charid = %i AND (OR taskid = %i " because of the conditional.
New:
queryStream << i ? StringFormat("OR taskid = %i ", tasksDisabled[i]) : StringFormat("taskid = %i ", tasksDisabled[i]);
This now results in the correct SQL statement;
DELETE FROM character_enabledtasks WHERE charid = %i AND (taskid = %i
or;
DELETE FROM character_enabledtasks WHERE charid = %i AND (taskid = %i OR taskid = %i - etc for multiple values.
So both these queries now work correctly and they replace and delete from the correct table. They still don't seem to function quite right though - I think it might be the enabled tasks list itself but I really don't have the skills to delve deeply into that.
Basically what happens is;
I enable 3 tasks, 302, 305 and 306 individually after doing a qglobal check for a daily qglobal.
Code:
if ($client->GetGlobal("daily_302") != 1 && $faction <= 7) { quest::enabletask(302); }
if ($client->GetGlobal("daily_305") != 1 && $faction <= 7) { quest::enabletask(305); }
if ($client->GetGlobal("daily_306") != 1 && $faction <= 7) { quest::enabletask(306); }
This results in correctly entering the entries into the character_enabledtasks db and then the task selector displays the 3 quests - so far so good. Task debugging shows the enabled task list has those 3 in it. I handled quest completion via perl as well, so I stay in zone and complete the task which then disables the task and sets the daily global as below.
Code:
if ($task_id == 302)
{
##Give rewards for completing task: Clear the Flooded Caves (Daily)
$client->AddAAPoints(5); ## 5 AA points
$client->AddMoneyToPP(0, 0, 0, 3333, 1); ## 3,333 platinum
quest::summonitem(quest::ChooseRandom(@rewards), 1); ## Give a random reward from @rewards
quest::summonitem(200175); ## Award charm increase token
quest::disabletask(302); ## Disable the task and set the daily global
$client->SetGlobal("daily_302", 1, 5, "H23"); ## 23 hours so people can do it basically at the same time each day
$client->Message(15, "You have been awarded 5 AA points, 3,333 platinum, a charm token and a random reward for completing this task.");
}
So all of that works fine, they get their rewards and the global is set. quest::disable tasks runs but here is where it gets weird. The logging shows that the task system removes 302 from the enabled task list correctly and tells me only 305 and 306 are enabled - the mysql logging shows me that the following statement runs;
DELETE FROM character_enabledtasks WHERE charid = 659774 AND (taskid = (0))
Now presumably that is the index of the task because if I do quest::disabletask(302, 305, 306) after zoning it shows taskid - (012)
The thing is - most of the time it says it runs the statement but 0 rows were affected and the 659774, 302 values are not removed from the enabledtasks table. I'm not sure if I can somehow see what is in index 0 but it seems like it isn't generating it quite right. After zoning however, if I write an EVENT_SAY script just to disable all 3 it will work perfect.
Not sure if that makes much sense, it's difficult to explain but I am happy to hook up some time and show you.
EDIT: Could it be because I am not using sequential task id's?