[Request] Landro Longshot Codebox

Hi there.

I’ve tried for many times to code this npc to be blizzlike (items for code) but all my tries have failed.

I just wondering if some one will help me with requests from DB to check if entered code exists in DB and with gossip menus.

Why?

i’ve made php script to generate code and to add it to db, so it will be used to enter it in game.

Process:

  1. User opens page with script to add code

  2. User “buying” it with arena/honor of whatever point (if he has them)

  3. System showing him code to be entered ingame

Idea:

  1. after redeeming this code user logging in

  2. He speaks with Landro and code box appears

  3. He entering given code and redeem pet or something

  4. Entered code MUST be deleted from DB

So can you help me with core queries to DB to check and delete code if it was there?

After successful tests i will upload code to this thread

See https://github.com/TrinityCore/TrinityCore/blob/master/src/server/scripts/Examples/example_gossip_codebox.cpp

You can’t handle gossip codebox using DB only, you need cpp.

Thx, i’ve already done some work around this cpp file, but the question is:

how to get code from db and check if it correct or not, i know how to make DB request but dont know how to assign result to variable

QueryResult result = CharacterDatabase.PQuery(“SELECT GUID, FakeEntry FROM custom_transmogrification WHERE Owner = %u”, playerGUID);
if (result)
{
do
{
uint32 itemGUID = (*result)[0].GetUInt32();
uint32 fakeEntry = (*result)[1].GetUInt32();
} while (result->NextRow());
}

See ObjectMgr.cpp for more.

It contains pretty much all DB loading I guess.

Right … forgot the field isnt text… but a “bool”

thx you, i almost finished script, will upload it soon

Can any one help me to get text value from DB?

case GOSSIP_ACTION_INFO_DEF+1:
QueryResult result = WorldDatabase.PQuery(“SELECT code FROM landro_redeem_codes WHERE code = %u AND USED = 0”, code);
if (!result)
{
//Read comment in enum
creature->AI()->Talk(SAY_WRONG);
creature->CastSpell(player, SPELL_POLYMORPH, true);
sLog->outInfo(LOG_FILTER_SERVER_LOADING, “Player entered wrong redeem code! Entered code is: %u”, code);
}
else
And also, if in game i’ll enter something like 456, console returns random value (in sLog->outInfo)

uint32 codeUINT = (uint32)atol(code);
if(!codeINT)
return; // send error about invalid value inserted
QueryResult result = WorldDatabase.PQuery(“SELECT code FROM landro_redeem_codes WHERE code = %u AND USED = 0”, codeUINT);
if (!result)
{
//Read comment in enum
creature->AI()->Talk(SAY_WRONG);
creature->CastSpell(player, SPELL_POLYMORPH, true);
sLog->outInfo(LOG_FILTER_SERVER_LOADING, “Player entered wrong redeem code! Entered code is: %u”, codeUINT);
}
Did not test. I do not know C++.

Btw, I think the logic is wrong.

You can basically insert anything to the field (34782628374842) and if it is not found from DB, you get the buff …

and since we are talking about uint32, thats a lot of keys you can use …

You sure?

Buff in code is just for example, Landro will be awarding player who entered code with item like on official server