Help - Sql Teleporter menu

Shout-Out

User Tag List

Results 1 to 3 of 3
  1. #1
    rampage's Avatar Member
    Reputation
    5
    Join Date
    Sep 2007
    Posts
    21
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help - Sql Teleporter

    Need Help with updating SQL Teleporter to Hearthstone Latest Revs. Im Getting Errors While Compiling.
    Hope Someone Can Help.


    Code For Teleporter

    #include "StdAfx.h"
    #include "Setup.h"
    #include <iostream>
    #include <vector>
    using namespace std;
    #ifdef WIN32
    #pragma warning(disable:4305) // warning C4305: 'argument' : truncation from 'double' to 'float'
    #endif
    #define MAX_ENTRIES 80
    class SCRIPT_DECL Warper : public GossipScript
    {
    public:
    void GossipHello(ObjectPointer Ob, PlayerPointer Plr, bool AutoSend);
    void GossipSelectOption(ObjectPointer Ob, PlayerPointer Plr, uint32 Id, uint32 IntId, const char * Code);
    void GossipEnd(ObjectPointer Ob, PlayerPointer Plr);
    private:
    void GetTeleportEntries(uint32 creature,uint32 parent,std::vector<ct_entry> &entries);
    void GetTeleportEntry(uint32 creature,uint32 id, ct_entry &entry);
    bool CanDisplay(ct_entry entry, PlayerPointer Plr);
    bool ProcessEntryData(uint32 creature,QueryResult * res,ct_entry &entry);
    bool IsValid(QueryResult * res);
    };
    void Warper::GossipHello(ObjectPointer Ob, PlayerPointer Plr, bool AutoSend)
    {
    Creature * pCreature = (Ob->GetTypeId()==TYPEID_UNIT)?((Creature*)Ob):NULL;
    if(pCreature==NULL)
    return;
    GossipMenu *Menu;
    objmgr.CreateGossipMenuForPlayer(&Menu, Ob->GetGUID(), 1, Plr);
    std::vector<ct_entry> entries;
    GetTeleportEntries(pCreature->GetEntry(),0,entries);
    for(std::vector<ct_entry>::iterator itEntry = entries.begin(); itEntry != entries.end(); itEntry++)
    {
    ct_entry entry = *(itEntry);
    if (CanDisplay(entry,Plr))
    Menu->AddItem(entry.icon,entry.gossip,entry.menuid);

    }
    if(AutoSend)
    Menu->SendTo(Plr);
    }
    void Warper::GossipSelectOption(ObjectPointer Ob, PlayerPointer Plr, uint32 Id, uint32 IntId, const char * Code)
    {
    Creature * pCreature = (Ob->GetTypeId()==TYPEID_UNIT)?((Creature*)Ob):NULL;
    if(pCreature==NULL)
    return;
    if (IntId == 9999)
    {
    GossipHello(Ob,Plr,true);
    return;
    }
    ct_entry entry;
    GetTeleportEntry(pCreature->GetEntry(),IntId,entry);
    if (entry.hasChildren)
    {
    GossipMenu * Menu;
    objmgr.CreateGossipMenuForPlayer(&Menu, Ob->GetGUID(), 1, Plr);
    std::vector<ct_entry> entries;
    GetTeleportEntries(pCreature->GetEntry(),IntId,entries);
    std::vector<ct_entry>::iterator itEntry;
    for(itEntry = entries.begin(); itEntry != entries.end(); itEntry++)
    {
    ct_entry entry = *(itEntry);
    if (CanDisplay(entry,Plr))
    Menu->AddItem(entry.icon,entry.gossip,entry.menuid);
    }
    if (IntId > 0)
    Menu->AddItem(0, "[Back]", 9999);
    entries.clear();
    Menu->SendTo(Plr);
    }
    else
    {
    Plr->EventTeleport(entry.map,entry.position_x,entry.position_y,entry.position_z);
    }
    }
    void Warper::GossipEnd(ObjectPointer Ob, PlayerPointer Plr)
    {
    GossipScript::GossipEnd(Ob, Plr);
    }
    void Warper::GetTeleportEntries(uint32 creature, uint32 parent,std::vector<ct_entry> &entries)
    {
    QueryResult * res;
    res = WorldDatabase.Query("SELECT * FROM `custom_teleporter` WHERE creature='%u' AND parent='%u' LIMIT %u",creature,parent,MAX_ENTRIES);
    if(res)
    {
    do
    {
    ct_entry entry;
    if(ProcessEntryData(creature,res,entry)) entries.push_back(entry);
    } while(res->NextRow());
    }
    delete res;

    }
    void Warper::GetTeleportEntry(uint32 creature, uint32 id, ct_entry &entry)
    {
    QueryResult * res;
    res = WorldDatabase.Query("SELECT * FROM `custom_teleporter` WHERE creature='%u' AND menuid='%u'",creature,id);
    ProcessEntryData(creature,res,entry);
    delete res;
    }
    bool Warper::CanDisplay(ct_entry, Plr)
    {
    if ((entry.team != -1) && (entry.team != Plr->GetTeam())) return false;
    if ((entry.minlevel > 0) && (Plr->getLevel() < entry.minlevel)) return false;
    if ((entry.maxlevel > 0) && (Plr->getLevel() > entry.maxlevel)) return false;
    return true;
    }
    bool Warper::ProcessEntryData(uint32 creature, QueryResult * res,ct_entry & entry)
    {
    if(res)
    {
    QueryResult * res2;
    bool hasChildren = false;
    res2 = WorldDatabase.Query("SELECT menuid FROM `custom_teleporter` WHERE creature='%u' AND parent='%u'", creature,res->Fetch()[2].GetUInt32());
    if (res2)
    {
    hasChildren = true;
    }
    else
    {
    if (!IsValid(res))
    {
    // If it doesn't have children, it must have valid coordinates
    Log.Color(TRED);
    printf("[Teleporter] Invalid menu entry (creature='%u',menuid='%u')",creature,res->Fetch()[2].GetUInt32());
    Log.Color(TNORMAL);
    Log.Line();
    return false;
    }
    }
    entry.creature = res->Fetch()[0].GetUInt32();
    entry.parent = res->Fetch()[1].GetUInt32();
    entry.menuid = res->Fetch()[2].GetUInt32();
    entry.icon = res->Fetch()[3].GetUInt32();
    entry.gossip = res->Fetch()[4].GetString();
    entry.map = res->Fetch()[5].GetUInt32();
    entry.position_x = res->Fetch()[6].GetFloat();
    entry.position_y = res->Fetch()[7].GetFloat();
    entry.position_z = res->Fetch()[8].GetFloat();
    entry.minlevel = res->Fetch()[9].GetUInt32();
    entry.maxlevel = res->Fetch()[10].GetUInt32();
    entry.team = res->Fetch()[11].GetInt32();
    entry.hasChildren = hasChildren;

    delete res2;
    return true;
    }
    }
    bool Warper::IsValid(QueryResult * res)
    {
    return ((res->Fetch()[5].GetString() != 0) &&
    (res->Fetch()[6].GetString() != 0) &&
    (res->Fetch()[7].GetString() != 0) &&
    (res->Fetch()[8].GetString() != 0)
    );
    }
    void SetupWarper(ScriptMgr * mgr)
    {
    GossipScript * gs = (GossipScript*) new Warper();
    QueryResult * res = WorldDatabase.Query("SELECT DISTINCT(`creature`) FROM `custom_teleporter`");
    if(res)
    {
    do
    {
    mgr->register_gossip_script(res->Fetch()[0].GetUInt32(), gs);
    } while(res->NextRow());
    }
    delete res;
    }




    Errors While Compiling


    Error 1 error C2440: 'type cast' : cannot convert from 'ObjectPointer' to 'Creature *' d:\SVN\EMU\ASPIRE\branches\Hearthstone\src\scripts\src\CustomTeleporter\Custom_T eleporters.cpp 31 CustomTeleporter
    Error 2 error C2440: 'type cast' : cannot convert from 'ObjectPointer' to 'Creature *' d:\SVN\EMU\ASPIRE\branches\Hearthstone\src\scripts\src\CustomTeleporter\Custom_T eleporters.cpp 56 CustomTeleporter
    Error 3 error C2061: syntax error : identifier 'Plr' d:\SVN\EMU\ASPIRE\branches\Hearthstone\src\scripts\src\CustomTeleporter\Custom_T eleporters.cpp 126 CustomTeleporter
    Error 4 error C2511: 'bool Warper::CanDisplay(ct_entry)' : overloaded member function not found in 'Warper' d:\SVN\EMU\ASPIRE\branches\Hearthstone\src\scripts\src\CustomTeleporter\Custom_T eleporters.cpp 127 CustomTeleporter




    Hope Someone out there can Help

    Help - Sql Teleporter
  2. #2
    waymirec's Avatar Member
    Reputation
    49
    Join Date
    Jan 2008
    Posts
    155
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    wow. people are still using that code?

  3. #3
    latruwski's Avatar Banned
    Reputation
    647
    Join Date
    Dec 2006
    Posts
    2,456
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    post between code tags pls...

    first 2 errors say that you cant convert an object of Class "ObjectPointer" to an object of the Class "Creature"
    So somewhere in your code you are messing those 2 up...(confusing the 2 classes)
    3th error is a Syntax error... i am sure you know what that means...
    My guess: you are using "Plr" where it is not type-casted
    last error is saying "bool Warper::CanDisplay(ct_entry)" is overloaded...probably you ust too much paramaters in it? (dont know)

    But meh... it has been so long for me...
    I'll be back into core developing/scripting soon... after my exams (next week)

Similar Threads

  1. SQL Teleporter
    By Bapes in forum World of Warcraft Emulator Servers
    Replies: 22
    Last Post: 06-01-2008, 12:02 PM
  2. [help] Sql
    By mager1794 in forum World of Warcraft Emulator Servers
    Replies: 2
    Last Post: 05-20-2008, 08:17 PM
  3. [Help]SQL Errorr
    By Neth'zul in forum World of Warcraft Emulator Servers
    Replies: 4
    Last Post: 05-20-2008, 05:54 PM
  4. *HELP* Sql Error +rep
    By thegame240 in forum World of Warcraft Emulator Servers
    Replies: 3
    Last Post: 05-07-2008, 03:39 PM
  5. [Help] SQL Trouble with my backup
    By marcicompita in forum World of Warcraft Emulator Servers
    Replies: 6
    Last Post: 03-04-2008, 12:37 PM
All times are GMT -5. The time now is 04:17 AM. Powered by vBulletin® Version 4.2.3
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Google Authenticator verification provided by Two-Factor Authentication (Free) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search