Having a little trouble setting security level to a player and making it save/stick.
What I have is an NPC that will apply security level to a player once they have the appropriate VIP tokens. It works and sets the players access level but only for the time being, upon logout it is not saved. I know it works temporarily because of .account and .chat working and showing the correct levels.
Any help is appreciated!
What I have is an NPC that will apply security level to a player once they have the appropriate VIP tokens. It works and sets the players access level but only for the time being, upon logout it is not saved. I know it works temporarily because of .account and .chat working and showing the correct levels.
Code:
class vip_activator : public CreatureScript
{
public:
vip_activator() : CreatureScript("vip_activator") { }
bool OnGossipHello(Player* player, Creature* creature)
{
player->ADD_GOSSIP_ITEM(6, "Activate VIP Rank 1", GOSSIP_SENDER_MAIN, 0);
player->ADD_GOSSIP_ITEM(6, "Activate VIP Rank 2", GOSSIP_SENDER_MAIN, 1);
player->ADD_GOSSIP_ITEM(6, "Activate VIP Rank 3", GOSSIP_SENDER_MAIN, 2);
player->ADD_GOSSIP_ITEM(6, "Activate VIP Rank 4", GOSSIP_SENDER_MAIN, 3);
player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID());
return true;
}
bool OnGossipSelect(Player *player, Creature *creature, uint32 sender, uint32 uiAction)
{
if (sender == GOSSIP_SENDER_MAIN)
{
player->PlayerTalkClass->ClearMenus();
switch (uiAction)
{
case 0:
if (player->HasItemCount(60000, 1, false))
{
player->CLOSE_GOSSIP_MENU();
player->DestroyItemCount(60000, 1, true, false);
player->GetSession()->SetSecurity(SEC_VIP1);
player->SaveToDB();
creature->Whisper("Rank 1 VIP has been applied to your account, please restart your WoW.", LANG_UNIVERSAL, player);
}
else
{
player->CLOSE_GOSSIP_MENU();
creature->Whisper("You do not have the Rank 1 VIP Token.", LANG_UNIVERSAL, player);
return false;
}
break;
case 1:
if (player->HasItemCount(60001, 1, false))
{
player->CLOSE_GOSSIP_MENU();
player->DestroyItemCount(60001, 1, true, false);
player->GetSession()->SetSecurity(SEC_VIP2);
player->SaveToDB();
creature->Whisper("Rank 2 VIP has been applied to your account, please restart your WoW.", LANG_UNIVERSAL, player);
}
else
{
player->CLOSE_GOSSIP_MENU();
creature->Whisper("You do not have the Rank 2 VIP Token.", LANG_UNIVERSAL, player);
return false;
}
break;
case 2:
if (player->HasItemCount(60002, 1, false))
{
player->CLOSE_GOSSIP_MENU();
player->DestroyItemCount(60002, 1, true, false);
player->GetSession()->SetSecurity(SEC_VIP3);
player->SaveToDB();
creature->Whisper("Rank 3 VIP has been applied to your account, please restart your WoW.", LANG_UNIVERSAL, player);
}
else
{
player->CLOSE_GOSSIP_MENU();
creature->Whisper("You do not have the Rank 3 VIP Token.", LANG_UNIVERSAL, player);
return false;
}
break;
case 3:
if (player->HasItemCount(60003, 1, false))
{
player->CLOSE_GOSSIP_MENU();
player->DestroyItemCount(60003, 1, true, false);
player->GetSession()->SetSecurity(SEC_VIP4);
player->SaveToDB();
creature->Whisper("Rank 4 VIP has been applied to your account, please restart your WoW.", LANG_UNIVERSAL, player);
}
else
{
player->CLOSE_GOSSIP_MENU();
creature->Whisper("You do not have the Rank 4 VIP Token.", LANG_UNIVERSAL, player);
return false;
}
break;
}
}
return true;
}
};
void AddSC_vip_activator()
{
new vip_activator();
}
Any help is appreciated!