Modcraft - The community dedicated to quality WoW modding!
Wrath of the Lich King Modding => Serverside Modding => Topic started by: XxXGenesisXxX on December 13, 2012, 02:38:27 am
-
I'm trying to get this gossip script to get the players characters GUID and a creatures Entry (not GUID) then INSERT them into a table. But I can't seem to have these in the same line:
plr->GetGUID(), pCreature->GetEntry()
Which came from this:
CharacterDatabase.Execute("INSERT INTO player_shop (ownerguid, vendor) VALUES(%u, %u)", plr->GetGUID(), pCreature->GetEntry());
However all that did is insert the GUID into the ownerguid column, and then set a 0 for the vendor ID. So then I tried this:
CharacterDatabase.Execute("INSERT INTO player_shop (ownerguid, vendor) VALUES(%u, %u)", plr->GetGUID(), pCreature->GetGUID());
And it worked as it should. But I don't want the GUID I want the "entry" from the creature table. So then I tried this:
CharacterDatabase.Execute("INSERT INTO player_shop (ownerguid, vendor) VALUES(%u, %u)", plr->GetGUID(), pCreature->GetEntry());
CharacterDatabase.Execute("INSERT INTO player_shop (vendor) VALUES(%u)", pCreature->GetEntry());
Which sort of worked, it got both the player character GUID and the creatures entry ID absolutely fine, but as expected it puts it into 2 individual rows.
Also, while the creature_proto and creature_names table use "entry" and I am using "Entry" if I use "entry" in the C++ script it comes says the class hasn't got it as a member. However I fail to see it as important since when on seperate lines it still successfully pulls the "entry" and inserts it into the table.
So can someone please correct this for me and explain why it's screwing up? Is it simply that I can't have the "Get" command twice in one query?
-
Just look if the class pCreature is made form
have a method called GetEntry()
-
As I said this works:
CharacterDatabase.Execute("INSERT INTO player_shop (vendor) VALUES(%u)", pCreature->GetEntry());
It's only when they are both in the same .Execture they don't seem to.
-
Perhaps try to use stringstream to build the query and give it to the CharacterDatabase.Execute Method
I personaly only use them. Don´t like the old string stuff;)
#include <sstream>
#include <string>
.....
stringstream myQuery;
myQuery << "INSERT INTO player_shop (ownerguid, vendor) VALUES(" << plr->GetGUID() << "," << pCreature->GetGUID() << ")";
CharacterDatabase.Execute( myQuery.toString() );
Perhaps you have to do some
plr->GetGUID().toString() and pCreature->GetGUID().toString() inside the stringstream build if you get type errors there.
-
Thanks for the reply again Steff. Tried as you said with the stringsstream method, and I do indeed need to add a class for toString to the sstream. I don't suppose you could please elaborate on that, I haven't done much work editing standard library files before.
-
I am also no c++ crack. I am fare away from this ;)
Often I jump dump bewtween the code parts and find solutions with luck.
But perhaps I can have a look at your compiler to see what the problem could be. Just chat me on this weekend.
-
Hehe, that's alright. I'll take annother shot at it tomorrow (been awake for far too long), perhaps I'll figure it out tomorrow. If not I'll come back to this thread.
-
CharacterDatabase.PQuery("INSERT INTO player_shop VALUES ( '%u', '%u')", plr->GetGUID(), pCreature->GetEntry());
You can also try with PExecute.
CharacterDatabase.PExecute("INSERT INTO player_shop VALUES ( '%u', '%u')", plr->GetGUID(), pCreature->GetEntry());
-
CharacterDatabase.PQuery("INSERT INTO player_shop VALUES ( '%u', '%u')", plr->GetGUID(), pCreature->GetEntry());
You can also try with PExecute.
CharacterDatabase.PExecute("INSERT INTO player_shop VALUES ( '%u', '%u')", plr->GetGUID(), pCreature->GetEntry());
Thanks for the reply Eatos, however i'm using ArcEmu unfortunately. I have no class members for either of those. Besides even on Trinity would that really make a difference? Aren't they just different definitions with basically the same effects?
I will try this though:
CharacterDatabase.Query("INSERT INTO player_shop VALUES ( '%u', '%u')", plr->GetGUID(), pCreature->GetEntry());