[Help] Vote Vendor script from Mangos to Trinity

Hello people,

I had this script working on mangos, it checks for reward_points on auth.account table and gave the player the item he choose according to the amount of points he has, if the transaction is done it save a log on realmd.vote_redemptions table.

Could someone help me to switch this to work on Trinity too? I would appreciate a lot.


#include "precompiled.h"


#include "../../../../shared/Config/Config.h"

#include "../../Config.h"

#include "../../../../game/Language.h"

#include "../../../../shared/Database/DatabaseMysql.h"

extern DatabaseMysql SD2Database;  


void GiveItem(uint32 uiItemId, uint32 uiCount, uint32 uiCost, uint32 uiPoints, Creature* pCreature, Player* pPlayer)

{     

    if (Item* pItem = pPlayer->StoreNewItemInInventorySlot(uiItemId, uiCount))

    {

        pPlayer->SendNewItem(pItem, 1, true, false);


        std::ostringstream ss;

        ss << "Has usado " << uiCost<< " puntos, ahora te quedan " << uiPoints - uiCost << " puntos.";

        pCreature->MonsterWhisper(ss.str().c_str(), pPlayer);

        SD2Database.PExecute("UPDATE realmd.account SET reward_points = reward_points - '%u' WHERE id = '%u'", uiCost, pPlayer->GetSession()->GetAccountId());

        pPlayer->SaveInventoryAndGoldToDB();

		SD2Database.PExecute("INSERT INTO realmd.vote_redemptions (acct, char_GUID, reward, cost) VALUES ('%u','%u','%u','%u')", pPlayer->GetSession()->GetAccountId(), pPlayer, uiItemId, uiCost);

        return;

    }


    pCreature->MonsterWhisper("No pudo ser entregado el item!", pPlayer);

}


bool GossipHello_vote_vendor(Player *player, Creature *_Creature)

{

    //Arbitrary icon IDs have been replaced with defined names

    //consider doing this for the rest

    //see: enum GossipOptionIcon (src/game/GossipDef.h ln. 54)

	player->PlayerTalkClass->ClearMenus(); 

    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE,        "Armas y Ropa"    , GOSSIP_SENDER_MAIN, 5000);

    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI,          "Monturas"        , GOSSIP_SENDER_MAIN, 6000);

    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI,          "Mascotas"        , GOSSIP_SENDER_MAIN, 4000);

    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TABARD,        "Tabardos"        , GOSSIP_SENDER_MAIN, 7000);

    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR,        "Bolsas"          , GOSSIP_SENDER_MAIN, 8000);

    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG,     "Tokens"          , GOSSIP_SENDER_MAIN, 9000);


//    if(player->getLevel() < 80)

//    {

//        player->ADD_GOSSIP_ITEM( 5, "1 Level up - 20 Vote Points", GOSSIP_SENDER_MAIN, 3000);

//    }


    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Cuantos puntos tengo?", GOSSIP_SENDER_MAIN, 1000);

    player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

    return true;

}


void SendDefaultMenu_vote_vendor(Player *player, Creature *_Creature, uint32 action)

{

    // More efficient to check this before doing database stuff

    // Disable npc if in combat

    if(player->isInCombat())

    {

        player->CLOSE_GOSSIP_MENU();

        _Creature->MonsterWhisper("Estas en combate!", player);

        return;

    }


    QueryResult *result;

    result = SD2Database.PQuery("SELECT reward_points FROM realmd.account WHERE id = '%u'", player->GetSession()->GetAccountId());

    Field *Fields = result->Fetch();

    uint32 points = Fields[0].GetUInt32();//retrieves points from db


    switch(action)

    {

        case 1000: //Print how many vote points player has. 

            if(result)

            {

                if( points == 0) // If the player doesn't have any vote points

                    _Creature->MonsterWhisper("No tienes puntos de votacion!", player);

                else // Unsigned, so must be greater than 0!

                {

                    player->PlayerTalkClass->ClearMenus();

                    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, "Deseo adquirir mis premios."                    , GOSSIP_SENDER_MAIN, 9999);

                    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                    , GOSSIP_SENDER_MAIN, 9999);

                    player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

                    std::ostringstream ss;

                    ss << "Tienes " << points << " puntos disponibles.";

                    player->GetSession()->SendAreaTriggerMessage(ss.str().c_str());

                    _Creature->MonsterWhisper(ss.str().c_str(), player);

                    return;

                }

            }

            else //Just in case something went wrong with the first query

                _Creature->MonsterWhisper("Error: Problema con la base de datos, contacta a un administrador e informale del problema.", player);

            break;

        case 5000: //Armas

            player->PlayerTalkClass->ClearMenus();

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Sharpened Scarlet Kris - 30 Puntos"           , GOSSIP_SENDER_MAIN, 5001);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Battleworn Thrash Blade - 30 Puntos"          , GOSSIP_SENDER_MAIN, 5002);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Venerable Mass of McGowan - 30 Puntos"        , GOSSIP_SENDER_MAIN, 5003);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Grand Staff of Jordan - 30 Puntos"            , GOSSIP_SENDER_MAIN, 5004);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Reforged Truesilver Champion - 30 Puntos"     , GOSSIP_SENDER_MAIN, 5005);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Charmed Ancient Bone Bow - 30 Puntos"         , GOSSIP_SENDER_MAIN, 5006);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Discerning Eye of the Beast - 30 Puntos"      , GOSSIP_SENDER_MAIN, 5007);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_BATTLE, "Swift Hand of Justice - 30 Puntos"            , GOSSIP_SENDER_MAIN, 5008);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                                  , GOSSIP_SENDER_MAIN, 9999);

            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

            return;

        case 5001: //Sharpened Scarlet Kris - 30 Puntos

            if(points >= 30)

                GiveItem(44091, 1, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 5002: //Battleworn Thrash Blade - 30 Puntos

            if(points >= 30)

                GiveItem(44096, 1, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 5003: //Venerable Mass of McGowan - 30 Puntos

            if(points >= 30)

                GiveItem(48716, 1, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 5004: //Grand Staff of Jordan - 30 Puntos

            if(points >= 30)

                GiveItem(44095, 1, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 5005: //Reforged Truesilver Champion - 30 Puntos

            if(points >= 30)

                GiveItem(44092, 1, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 5006: //Charmed Ancient Bone Bow - 30 Puntos

            if(points >= 30)

                GiveItem(42946, 1, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 5007: //Discerning Eye of the Beast - 30 Puntos

            if(points >= 30)

                GiveItem(42992, 1, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 5008: //Swift Hand of Justice - 30 Puntos

            if(points >= 30)

                GiveItem(42991, 1, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6000: //Mounts Menu

            player->PlayerTalkClass->ClearMenus();

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Riding Turtle - 120 Puntos"               , GOSSIP_SENDER_MAIN, 6001);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Sea Turtle - 120 Puntos"                  , GOSSIP_SENDER_MAIN, 6002);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Swift Spectral Tiger - 150 Puntos"        , GOSSIP_SENDER_MAIN, 6003);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Reins of the Violet Proto - 200 Puntos"   , GOSSIP_SENDER_MAIN, 6004);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Mimiron's Head - 200 Puntos"              , GOSSIP_SENDER_MAIN, 6005);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "X-53 Touring Rocket - 200 Puntos"         , GOSSIP_SENDER_MAIN, 6006);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Big Blizzard Bear - 200 Puntos"           , GOSSIP_SENDER_MAIN, 6007);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "[Siguiente]"                              , GOSSIP_SENDER_MAIN, 6010);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                            , GOSSIP_SENDER_MAIN, 9999);

            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

            return;

        case 6010: //Mounts Menu

            player->PlayerTalkClass->ClearMenus();

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Swift Nether Drake - 200 Puntos"                  , GOSSIP_SENDER_MAIN, 6011);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Merciless Nether Drake - 200 Puntos"              , GOSSIP_SENDER_MAIN, 6012);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Vengeful Nether Drake - 200 Puntos"               , GOSSIP_SENDER_MAIN, 6013);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Brutal Nether Drake - 200 Puntos"                 , GOSSIP_SENDER_MAIN, 6014);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Deadly Gladiator's Frost Wyrm - 200 Puntos"       , GOSSIP_SENDER_MAIN, 6015);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Furious Gladiator's Frost Wyrm - 200 Puntos"      , GOSSIP_SENDER_MAIN, 6016);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TAXI, "Relentless Gladiator's Frost Wyrm - 200 Puntos"   , GOSSIP_SENDER_MAIN, 6017);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                                    , GOSSIP_SENDER_MAIN, 9999);

            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

            return;

        case 6001: //Riding Turtle - 120 Vote Points

            if(points >= 120)

                GiveItem(23720, 1, 120, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6002: //Sea Turtle - 120 Puntos

            if(points >= 120)

                GiveItem(46109, 1, 120, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6003: //Swift Spectral Tiger - 150 Vote Points

            if(points >= 150)

                GiveItem(49284, 1, 150, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6004: //Reins of the Violet Proto-Drake - 200 Vote Points

            if(points >= 200)

                GiveItem(44177, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6005: //Mimiron's Head - 200 Puntos

            if(points >= 200)

                GiveItem(45693, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6006: //X-53 Touring Rocket - 200 Puntos

            if(points >= 200)

                GiveItem(54860, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6007: //Big Blizzard Bear - 200 Puntos

            if(points >= 200)

                GiveItem(43599, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6011: //Swift Nether Drake - 200 Vote Points

            if(points >= 200)

                GiveItem(30609, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6012: //Merciless Nether Drake - 200 Puntos

            if(points >= 200)

                GiveItem(34092, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6013: //Vengeful Nether Drake - 200 Puntos

            if(points >= 200)

                GiveItem(37676, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6014: //Brutal Nether Drake - 200 Puntos

            if(points >= 200)

                GiveItem(43516, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6015: //Deadly Gladiator's Frost Wyrm - 200 Puntos

            if(points >= 200)

                GiveItem(46708, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6016: //Furious Gladiator's Frost Wyrm - 200 Puntos

            if(points >= 200)

                GiveItem(46171, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 6017: //Relentless Gladiator's Frost Wyrm - 200 Puntos

            if(points >= 200)

                GiveItem(47840, 1, 200, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4000: //Mascotas 1

            player->PlayerTalkClass->ClearMenus();

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Unhatched Mr. Chilly - 100 Puntos"       , GOSSIP_SENDER_MAIN, 4001);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Dragon Kite - 100 Puntos"                , GOSSIP_SENDER_MAIN, 4002);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Curious Wolvar Pup - 100 Puntos"         , GOSSIP_SENDER_MAIN, 4003);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Curious Oracle Hatchling - 100 Puntos"   , GOSSIP_SENDER_MAIN, 4004);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Diablo Stone - 100 Puntos"               , GOSSIP_SENDER_MAIN, 4005);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Panda Collar - 100 Puntos"               , GOSSIP_SENDER_MAIN, 4006);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Zergling Leash - 100 Puntos"             , GOSSIP_SENDER_MAIN, 4007);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "[Siguiente]"                            , GOSSIP_SENDER_MAIN, 4010);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                          , GOSSIP_SENDER_MAIN, 9999);

            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

			return;

        case 4010: //Mascotas 2

            player->PlayerTalkClass->ClearMenus();

//		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Truesilver Shafted Arrow - 100 Puntos"       , GOSSIP_SENDER_MAIN, 4011);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Elekk Training Collar - 100 Puntos"          , GOSSIP_SENDER_MAIN, 4012);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Perky Pug - 100 Puntos"                      , GOSSIP_SENDER_MAIN, 4013);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Netherwhelp's Collar - 100 Puntos"           , GOSSIP_SENDER_MAIN, 4014);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Murkimus' Little Spear - 100 Puntos"         , GOSSIP_SENDER_MAIN, 4015);

//		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Tyrael's Hilt"                               , GOSSIP_SENDER_MAIN, 4016);

		    player->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Magical Crawdad Box - 100 Puntos"            , GOSSIP_SENDER_MAIN, 4017);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                              , GOSSIP_SENDER_MAIN, 9999);

            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

			return;

        case 4001: //Unhatched Mr. Chilly

            if(points >= 100)

                GiveItem(41133, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4002: //Dragon Kite

            if(points >= 100)

                GiveItem(34493, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4003: //Curious Wolvar Pup

            if(points >= 100)

                GiveItem(46544, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4004: //Curious Oracle Hatchling

            if(points >= 100)

                GiveItem(46545, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4005: //Diablo Stone

            if(points >= 100)

                GiveItem(13584, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4006: //Panda Collar

            if(points >= 100)

                GiveItem(13583, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4007: //Zergling Leash

            if(points >= 100)

                GiveItem(13582, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4011: //Truesilver Shafted Arrow

            if(points >= 100)

                GiveItem(22235, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4012: //Elekk Training Collar

            if(points >= 100)

                GiveItem(32622, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4013: //Perky Pug

            if(points >= 100)

                GiveItem(49912, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4014: //Netherwhelp's Collar

            if(points >= 100)

                GiveItem(25535, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4015: //Murkimus' Little Spear

            if(points >= 100)

                GiveItem(45180, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4016: //Tyrael's Hilt

            if(points >= 100)

                GiveItem(39656, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 4017: //Magical Crawdad Box

            if(points >= 100)

                GiveItem(27445, 1, 100, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 7000: //Tabards Menu

            player->PlayerTalkClass->ClearMenus();

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TABARD, "Special Melee Guild Tabard - 130 Puntos"          , GOSSIP_SENDER_MAIN, 7001);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TABARD, "Special Caster Guild Tabard - 130 Puntos"         , GOSSIP_SENDER_MAIN, 7002);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TABARD, "Tabard of Mele - 180 Puntos"        , GOSSIP_SENDER_MAIN, 7003);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TABARD, "Tabard of Caster - 180 Puntos"    , GOSSIP_SENDER_MAIN, 7004);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TABARD, "Tabard of the Killer Chicken - 20 Puntos"         , GOSSIP_SENDER_MAIN, 7005);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                                      , GOSSIP_SENDER_MAIN, 9999);

            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

            return;

        case 7001: //Special Melee Guild Tabard - 130 Puntos

            if(points >= 130)

                GiveItem(100020, 1, 130, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 7002: //Special Caster Guild Tabard - 130 Puntos

            if(points >= 130)

                GiveItem(100021, 1, 130, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 7003: //Tabard of Mele - 180 Puntos

            if(points >= 180)

                GiveItem(82100, 1, 180, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 7004: //Tabard of SexyGirl: Caster - 180 Puntos

            if(points >= 180)

                GiveItem(82101, 1, 180, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 7005: //Tabard of the Killer Chicken - 20 Puntos

            if(points >= 20)

                GiveItem(88820, 1, 20, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;    

        case 8000: //Bags Menu

            player->PlayerTalkClass->ClearMenus();

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Pouch - 50 Puntos"              , GOSSIP_SENDER_MAIN, 8001);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Bag - 70 Puntos"              , GOSSIP_SENDER_MAIN, 8002);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Sack of True - 90 Puntos"        , GOSSIP_SENDER_MAIN, 8003);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_VENDOR, "Sack of Elite - 120  Puntos"     , GOSSIP_SENDER_MAIN, 8004);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                                  , GOSSIP_SENDER_MAIN, 9999);

            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

            return;

        case 8001: //Pouch - 50 Puntos

            if(points >= 50)

                GiveItem(88821, 1, 50, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 8002: //Bag - 70 Puntos

            if(points >= 70)

                GiveItem(88822, 1, 70, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 8003: //Sack - 90 Puntos

            if(points >= 90)

                GiveItem(88823, 1, 90, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 8004: //Sack - 120  Puntos

            if(points >= 120)

                GiveItem(88824, 1, 120, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 9000: //Currency Menu

            player->PlayerTalkClass->ClearMenus();

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "1,000 Gold - 10 Vote Points"               , GOSSIP_SENDER_MAIN, 9001);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "2,500 Gold - 20 Vote Points"               , GOSSIP_SENDER_MAIN, 9002);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "20 Emblems of Heroism - 30 Vote Points"    , GOSSIP_SENDER_MAIN, 9003);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "20 Emblems of Valor - 30 Vote Points"      , GOSSIP_SENDER_MAIN, 9004);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "20 Emblems of Conquest - 30 Vote Points"   , GOSSIP_SENDER_MAIN, 9005);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "20 Emblems of Triumph - 30 Vote Points"    , GOSSIP_SENDER_MAIN, 9006);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_MONEY_BAG, "20 Emblems of Frost - 30 Vote Points"      , GOSSIP_SENDER_MAIN, 9007);

            player->ADD_GOSSIP_ITEM(GOSSIP_ICON_INTERACT_1, "[Atras]"                                  , GOSSIP_SENDER_MAIN, 9999);

            player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE,_Creature->GetGUID());

            return;

        case 9001: //1000 Gold - 10 Vote Points

            if(points >= 10)

            {

                SD2Database.PExecute("UPDATE realmd.account SET reward_points = reward_points - 10 WHERE id = '%u'", player->GetSession()->GetAccountId());

                player->ModifyMoney(10000000);

                std::ostringstream ss;

                ss << "Has usado 10 puntos en 1.000 de oro y ahora te quedan " << points - 10 << " puntos.";

                _Creature->MonsterWhisper(ss.str().c_str(), player);

                player->SaveGoldToDB();

            }

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 9002: //2500 Gold - 20 Vote Points

            if(points >= 20)

            {

                SD2Database.PExecute("UPDATE realmd.account SET reward_points = reward_points - 20 WHERE id = '%u'", player->GetSession()->GetAccountId());

                player->ModifyMoney(25000000);

                std::ostringstream ss;

                ss << "Has usado 20 puntos en 2.500 de oro y ahora te quedan " << points - 20 << " puntos.";

                _Creature->MonsterWhisper(ss.str().c_str(), player);

                player->SaveGoldToDB();

            }

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 9003: //20 Emblems of Heroism - 30 Vote Points

            if(points >= 30)

                GiveItem(40752, 20, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

		case 9004: //20 Emblems of Valor - 30 Vote Points

            if(points >= 30)

                GiveItem(40753, 20, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

		case 9005: //20 Emblems of Conquest - 30 Vote Points

            if(points >= 30)

                GiveItem(45624, 20, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

		case 9006: //20 Emblems of Triumph - 30 Vote Points

            if(points >= 30)

                GiveItem(47241, 20, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

		case 9007: //20 Emblems of Frost - 30 Vote Points

            if(points >= 30)

                GiveItem(49426, 20, 30, points, _Creature, player);

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 9500: //1 Level up - 40 Vote Coins

            if(points >= 40)

            {

                points-=40;

                SD2Database.PExecute("UPDATE realmd.account SET reward_points = reward_points - 40 WHERE id = '%u'", player->GetSession()->GetAccountId());

                player->GiveLevel(player->getLevel() + 1);

                _Creature->MonsterWhisper("You received 1 level up", player);

            }

            else

                _Creature->MonsterWhisper("No tienes suficientes puntos para adquirir este premio!", player);

            break;

        case 9999://if (IntId == 9999)

            GossipHello_vote_vendor(player,_Creature);

            return;

    } //End switch


    player->CLOSE_GOSSIP_MENU();

} //End function


bool GossipSelect_vote_vendor(Player *player, Creature *_Creature, uint32 sender, uint32 action)

{

    if (sender == GOSSIP_SENDER_MAIN) // Redundant

        SendDefaultMenu_vote_vendor( player, _Creature, action );

    return true;

}


void AddSC_vote_vendor()

{

    Script *newscript;


    newscript = new Script;

    newscript->Name = "vote_vendor";

    newscript->pGossipHello = &GossipHello_vote_vendor;

    newscript->pGossipSelect = &GossipSelect_vote_vendor;

    newscript->RegisterSelf();

}

sorry nobody here is going to help with that script. tc does not condone voting enabled scripts.

Well don’t see it as a “vote script”, see it as a reward exchange system you use when you help the server /emoticons/default_smile.png

Anyway, I hope to find someone that could help me with this, if that person would like to contact me with a PM please feel free to do it and we can get into something.

learn c++ its not that hard when you look into it actualy. but takes time /emoticons/default_wink.png

A better solution to create a lookup table, put the item ID and how many points needed into that table and then use a query instead of having massive if and case statements… but I don’t know whether the list to user can be generated dynamically…

And btw, however you might want to phrase it, it’s still essentially a money making exercise…

Tip: Check the TeleNPC2 script, it is almost same as gossip, im maybe gonna make one rewarder script when i got more time, but dont have time atm /emoticons/default_sad.png

Would take some time converting this one. Will get back to you if I have time to convert it.

I would appreciate it kjanko, thanks a lot =)

Kjanko, if ya get it working and non-crashy please share on forums /emoticons/default_biggrin.png

ya ya

Here you go: Wrote in 45 min or something (not that hard if you know how to use database xD)


#include "ScriptPCH.h"

#include <cstring>

#include "CharacterDatabaseCleaner.h"

#include "DatabaseEnv.h"

#include "ObjectMgr.h"



class voterewarder : public CreatureScript

{

    public:


        voterewarder()

            : CreatureScript("voterewarder")

        {

        }


        void RewardItem(Player* pPlayer, Creature* pCreature, int item , int count, int cost)

        {

            QueryResult result;

            result = CharacterDatabase.PQuery("SELECT votepoints FROM auth.account WHERE id = '%u'", pPlayer->GetSession()->GetAccountId());

            char str[200];

            if (!result) // check

            {

                sprintf(str,"I'm Broken! Contact a gamemaster!");

                pPlayer->PlayerTalkClass->ClearMenus();

                OnGossipHello(pPlayer, pCreature);

                pCreature->MonsterSay(str, LANG_UNIVERSAL, pPlayer->GetGUID());

                return;

            }

            Field *fields = result->Fetch();

            uint32 points = fields[0].GetUInt32();


            if (item == 0)

            {

                sprintf(str,"You got %u voting points!", points);

                pPlayer->MonsterWhisper(str,pPlayer->GetGUID(),true);

            }

            else

            {

                if (points < cost)

                {

                     sprintf(str,"You don't have enough points for this item!!");

                     pPlayer->MonsterWhisper(str,pPlayer->GetGUID(),true);

                }

                else

                {

                    if (pPlayer->AddItem(item, count))

                    {

                        CharacterDatabase.PQuery("Update auth.account Set votepoints = votepoints - '%u' WHERE id = '%u'", cost, pPlayer->GetSession()->GetAccountId());

                        sprintf(str,"Your points are taken and your item is given!!!");

                        pPlayer->MonsterWhisper(str,pPlayer->GetGUID(),true);

                    }

                    else

                    {

                        sprintf(str,"Item can't be given(your bag is full or you already got the item!)!");

                        pPlayer->MonsterWhisper(str,pPlayer->GetGUID(),true);

                    }


                }

            }

            pPlayer->PlayerTalkClass->ClearMenus();

            OnGossipHello(pPlayer, pCreature);

        }


        bool OnGossipHello(Player* pPlayer, Creature* pCreature)

        {

            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Homuch voting points do i have?", GOSSIP_SENDER_MAIN, 1000);

            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Weapons", GOSSIP_SENDER_MAIN, 2000);

            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Rings/Trinkets", GOSSIP_SENDER_MAIN, 3000);

            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Vote Token - Cost 5 VP", GOSSIP_SENDER_MAIN, 4000);

            pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_CHAT, "Other Stuff", GOSSIP_SENDER_MAIN, 5000);



            pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());


            return true;

        }


        bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 /*uiSender*/, uint32 uiAction)

        {

            pPlayer->PlayerTalkClass->ClearMenus();


            switch (uiAction)

            {

            case 1000:

                RewardItem(pPlayer, pCreature, 0, 0, 0);

                break;

            case 2000:

                pPlayer->PlayerTalkClass->ClearMenus();

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Havoc's Call, Blade of Lordaeron Kings - 70 VP", GOSSIP_SENDER_MAIN, 2001);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Mithrios, Bronzebeard's Legacy - 100 VP", GOSSIP_SENDER_MAIN, 2002);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Shadowmourne - 120 VP", GOSSIP_SENDER_MAIN, 2003);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Archus, Greatstaff of Antonidas - 120 VP", GOSSIP_SENDER_MAIN, 2004);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Royal Scepter of Terenas II - 70 VP", GOSSIP_SENDER_MAIN, 2005);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Glorenzelg, High-Blade of the Silver Hand - 120 VP", GOSSIP_SENDER_MAIN, 2006);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Bloodsurge, Kel'Thuzad's Blade of Agony - 70 VP", GOSSIP_SENDER_MAIN, 2007);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Heaven's Fall, Kryss of a Thousand Lies - 70 VP", GOSSIP_SENDER_MAIN, 2008);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Oathbinder, Charge of the Ranger-General - 120 VP", GOSSIP_SENDER_MAIN, 2009);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Return", GOSSIP_SENDER_MAIN, 9999);

                pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());

                return true;

                break;

            case 2001:

                RewardItem(pPlayer, pCreature,50737,1,70); 

                break;

            case 2002:

                RewardItem(pPlayer, pCreature,50738,1,100);

                break;

            case 2003:

                RewardItem(pPlayer, pCreature,49623,1,120);

                break;

            case 2004:

                RewardItem(pPlayer, pCreature,50731,1,120);

                break;

            case 2005:

                RewardItem(pPlayer, pCreature,50734,1,70);

                break;

            case 2006:

                RewardItem(pPlayer, pCreature,50730,1,120);

                break;

            case 2007:

                RewardItem(pPlayer, pCreature,50732,1,70);

                break;

            case 2008:

                RewardItem(pPlayer, pCreature,50736,1,70);

                break;

            case 2009:

                RewardItem(pPlayer, pCreature,50735,1,120);

                break;

            case 3000:

                pPlayer->PlayerTalkClass->ClearMenus();                

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "[Deathbringers will](heroic) - 60 VP", GOSSIP_SENDER_MAIN, 3001);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Return", GOSSIP_SENDER_MAIN, 9999);

                pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());

                return true;

                break;

            case 3001:

                RewardItem(pPlayer, pCreature, 50363,1,60);

                break;

            case 4000:

                RewardItem(pPlayer,  pCreature, 37829, 1, 5);

                break;

            case 5000:

                pPlayer->PlayerTalkClass->ClearMenus();

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "[Murloc Costume] - 16 VP", GOSSIP_SENDER_MAIN, 5001);

                pPlayer->ADD_GOSSIP_ITEM(GOSSIP_ICON_DOT, "Return", GOSSIP_SENDER_MAIN, 9999);

                pPlayer->PlayerTalkClass->SendGossipMenu(907, pCreature->GetGUID());

                return true;

                break;

            case 5001:

                RewardItem(pPlayer, pCreature, 33079,1,16); 

                break;

            case 9999:

                pPlayer->PlayerTalkClass->ClearMenus();

                OnGossipHello(pPlayer, pCreature);

                break;

            }



            return true;

        }


};


void AddSC_voterewarder()

{

    new voterewarder();

}

lets get this trash off the trinity forums we are not a community that condones any type of rewards for voting, donating, or any other rewards type of script you guys can think of as harmless.

last year blizzard showed exactly what they’d do to people who profit off of blizzards name and property and it cost 88 million dollars.

you want to put trinity at risk of a DCMA cause you want to become more popular sorry i just don’t buy it.

Lol , trinity is learning project, and yes i learn some shit when i wrote it /emoticons/default_smile.png

Edit: Wowscape is nothing compared to private server linkin is forbidden now /emoticons/default_sad.png

I wonder if it is possible to give the gossip text some colors(smaller size??) /emoticons/default_smile.png? And seems GOSSIP_ICON dont work properly /emoticons/default_sad.png

Don’t you think, if that’s true, that it’s only a matter of time before Blizz goes after them? I mean, supposedly the reason they went after Scape was because they got too big & were making too much off donations.

Separately, I agree this thread should be deleted…it has no business being on TC’s forums.

Wowscape had around 16k players all the time, molten wow has the same duo the server limits + total 2k ppl in queue and since it is blizzlike ppl wont leave that fast and yes molten wow runnes trinity(with fixes ofcourse)

I created new npc for voterewarder , but how to add this script to that creature.

Thanks in advance.

DONT REMOVE THIS, THIS IS BRILLIANT!!! /emoticons/default_biggrin.png

@uroskmexyu go in the creature_template, search the entry of the npc which should have the script, and set the scriptname to the scriptname /emoticons/default_wink.png

you find a row scriptname at the end of the table /emoticons/default_smile.png

Thanks, so script name would be voterewarder right?