Use database queries in source code?
Hi, I need to know how to run database queries in my source code. I am trying to remove trade between characters who have different "expansion" values in my character_vars table as I made per here: http://www.eqemulator.net/wiki/wikka...mCharacterData
Here is my code: Code:
void Client::Handle_OP_TradeRequest(const EQApplicationPacket *app) |
Run this so someone can help further. (since it is a non default table)
Code:
DESCRIBE `character_vars`; Quick assumption Code:
MakeAnyLenString(&query, "SELECT expansion FROM character_vars WHERE character_id = %i", AccountID()); |
Code:
Field Type Null Key Default Extra |
I will try that and see how it goes, thanks
|
Still no luck, zone crashes on character to character trade once you click an item or plat on somebody else. but compiled fine
|
To make it easier here is the code that I added from the above:
Quote:
|
here is my newest code: doesnt crash zone, but trade wont initiate between players with same expansion number:
Quote:
|
Are the proper user ID's being grabbed?
could try: Code:
if (myExpansion != tradeeExpansion) |
I will try that out and report my findings, cant do any more testing til tonight, thank you i appreciate the help
|
Why don't you just use 'ClientVersion' as a comparison?
you shouldn't need to access the db for this info since it a Client class property already. Code:
if (tradee && tradee->IsClient() && (this.ClientVersion == tradee->CastToClient()->GetClientVersion())) |
This is going to be used on a progression server where there is no trade between characters in different expansions. I'm using the custom expansion variable so I can change the value per character in perl quests and get the value from the source to restrict trade(the part which i'm stuck on)
|
Change myID and tID at the end of the queries to %i, then add them post-quote.
EDIT: You are probably translating the id's to zero in those... |
I already have the custom char code and table from drajor, and I compiled your code into mine and it all works..
When trade is denied, the proper IDS are echoed.. I tried first with different expansion settings for both chars, and it gave me the Denied message as expected, then i made both chars expansion values equal in the db and trade went through, no crash.. Nice work on this... Code:
if (database.RunQuery(query, MakeAnyLenString(&query, "SELECT expansion FROM character_vars WHERE character_vars.character_id=%i", myID), errbuf, &result)) { |
This would be a little more involved, but you could add the expansion variable to the Client class, along with supporting code, and then access
the memory reference as needed instead of doing a db call each time a trade is initiated. The world->Client already has access to expansions, so you would need to write code to modify it in zone->Client..that way the only db call is when the value actually changes. |
I tested this out again and its still not working. Did you use Uleats changes?
|
All times are GMT -4. The time now is 06:53 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.