Give characters Boa on logon

Working on a custom script and I’ve ran into a little roadblock. Essentially as long as the script is in the core I want players to automatically receive boa items when they login for the first time. What I have currently is

#include “ScriptMgr.h”
#include “Player.h”
#include “Chat.h”

class Player_BoA : public PlayerScript
{

public:
Player_BoA() : PlayerScript(“Player_BoA”) { }

void OnLogin(Player* player, bool firstLogin)
{
	uint32 shoulders, chest, ring, trinkett, weapon;
	QueryResult classResult = CharacterDatabase.PQuery("SELECT class FROM characters WHERE guid = %u", player->GetGUID()); //Find the Player's Class'

	if(firstLogin) //Only Run script if it's their first login'
	{

	ring = 50255;
		switch(classResult) {
			case 1: //Warrior and the other class IDs
			shoulders = 42949;
			chest = 48685;
			trinkett = 42991;
			weapon = 42945;
			break;
			case 2:
			shoulders = 42949;
			chest = 48685;
			trinkett = 42991;
			weapon = 42945;
			break;
			case 3:
			break;
			case 4:
			break;
			case 5:
			break;
			case 6:
			shoulders = 42949;
			chest = 48685;
			trinkett = 42991;
			weapon = 42945;
			break;
			case 7:
			break;
			case 8:
			break;
			case 9:
			break;
			case 11:
			break;
			default:
			return;
		}
		player->AddItem(shoulders, false);
		player->AddItem(trinkett, 2);
		player->AddItem(ring, false);
		player->AddItem(chest, false);
		player->AddItem(weapon, false);

	}





}

};

void AddSC_Player_BoA()
{
new Player_BoA();
}
I only have that so far. I haven’t added for all the class, just the plate tanks, so my issue arrises at

switch quantity not an integer
switch(classResult) {But, classResult is a query to the database to find the class from the GUID which would be an integer. Does anyone know why it’s not returning correctly?

You are not using it correctly.
Here is a correct way, notice the changes to GetGUID and the IF statement checking the result and the use of fetch. Also the fields[0] means the class ‘column’ in the selection:

QueryResult result = CharacterDatabase.PQuery(“SELECT class FROM characters WHERE guid = %u”, player->GetGUID().GetCounter());
if (result)
{
Field* fields = result->Fetch();
uint8 charClass = fields[0].GetUInt8();
// use charClass
}However I think this is a bit unnecessary. You already have access to the player object that has the race and class info.
Simply use player->getClass()

[CODE]#include “ScriptMgr.h”
#include “Player.h”
#include “Chat.h”

class Player_BoA : public PlayerScript
{

public:
Player_BoA() : PlayerScript(“Player_BoA”) { }

void OnLogin(Player* player, bool firstLogin) override
{
    if (!firstLogin) // Run script only on first login
        return;

    uint32 shoulders = 0, chest = 0, ring = 0, trinkett = 0, weapon = 0;

    ring = 50255;
    switch (player->getClass())
    {
    case CLASS_WARRIOR:
        shoulders = 42949;
        chest = 48685;
        trinkett = 42991;
        weapon = 42945;
        break;
    case CLASS_PALADIN:
        shoulders = 42949;
        chest = 48685;
        trinkett = 42991;
        weapon = 42945;
        break;
    case CLASS_HUNTER:
        break;
    case CLASS_ROGUE:
        break;
    case CLASS_PRIEST:
        break;
    case CLASS_DEATH_KNIGHT:
        shoulders = 42949;
        chest = 48685;
        trinkett = 42991;
        weapon = 42945;
        break;
    case CLASS_SHAMAN:
        break;
    case CLASS_MAGE:
        break;
    case CLASS_WARLOCK:
        break;
    case CLASS_DRUID:
        break;
    default:
        return;
    }
    player->AddItem(shoulders, 1);
    player->AddItem(trinkett, 2);
    player->AddItem(ring, 1);
    player->AddItem(chest, 1);
    player->AddItem(weapon, 1);
}

};

void AddSC_Player_BoA()
{
new Player_BoA();
}
[/CODE]

Thanks Rochet! That’s a whole lot simpler than running a query and I would think it would be a lot better on the server load!