ArcEmu: "cannot Access Protected Member Declared In Class" - ArcEmu

Jump to content

Toggle shoutbox Lastest Announcements

dfighter  : (07 December 2014 - 12:06 PM) Arcemu is in hibernation mode, please read http://arcemu.org/fo...showtopic=26903
dfighter  : (01 January 2013 - 05:56 PM) Arcemu wishes you all a happy new year!
Hasbro  : (12 September 2012 - 10:01 AM) Please excuse our outage from the web! Our web host had a major malfunction!
dfighter  : (01 September 2012 - 04:05 PM) Since the spam bots just don't want to stop, I've enabled admin verification when registering.
dfighter  : (23 January 2012 - 09:56 PM) Please note that from now on you will need to confirm your email on the wiki in order to edit it!
Hasbro  : (31 December 2011 - 12:50 PM) Happy New Years all!
Navid  : (26 December 2011 - 04:09 AM) Merry Christmas !!!!!! Happy holidays all :)
WAmadeus  : (24 December 2011 - 03:54 PM) Merry Christmas to all!
dfighter  : (24 December 2011 - 11:05 AM) The Arcemu team wishes y'all a Merry Christmukkah!
Hasbro  : (05 October 2011 - 12:53 PM) Looking for web designers for upcoming web related project. If you're interested in designing user interfaces contact me
dfighter  : (02 September 2011 - 03:47 PM) So who here wants vehicles in Arcemu? :P http://arcemu.org/fo...showtopic=25440
Hasbro  : (14 August 2011 - 03:25 PM) Join us on irc, grab an irc client and connect to irc.freenode.net join channel #arcemu /server irc.freenode.net:6667 /join #arcemu
jackpoz  : (03 August 2011 - 05:33 AM) to all Lua Engine (old one) users: please check http://arcemu.org/fo...showtopic=25274
Hasbro  : (20 May 2011 - 05:27 PM) Looking for people experienced with CMake configuration and setup! Contact me asap
Hasbro  : (15 May 2011 - 05:03 PM) ArcEmu is recruiting C++ programmers, contact Hasbro if interested.
paroxysm  : (03 May 2011 - 06:26 PM) Updated luabridge gossip example to describe the whole gossip creation process rather than just how to create menu. Gossip tutorial
paroxysm  : (23 April 2011 - 11:35 AM) Lua writers can refer to the Luabridge Tutorials section in the Wiki to learn how to write gossip code correctly.
Hasbro  : (20 April 2011 - 05:22 PM) Thank you for your continuous contribution of bug reports, we are working on them.
Hasbro  : (17 April 2011 - 03:20 AM) Please consider donating to support our bills. Donations can be sent using PayPal to donations@arcemu.org - Thank you for your support.
paroxysm  : (10 April 2011 - 12:43 AM) Refer to the Luabridge Tutorials section in the Wiki to learn the new syntax of luabridge.
Resize Shouts Area

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

"cannot Access Protected Member Declared In Class" Help Please.

#1 User is offline   Sykez 

  • Member
  • Pip
  • Group: Members
  • Posts: 12
  • Joined: 03-December 09

Posted 12 March 2011 - 12:53 PM

Im trying to make a gossip Npc that does commands for players, but I come across this error.

"cannot access protected member declared in class"

Heres my script.

#include "Setup.h"



#ifdef WIN32
#pragma warning(disable: 4305)
#endif

ChatHandler *command;
char args[20];
WorldSession *m_session;
Creature *_npc;
class GossipNPC : public GossipScript
{
public:
	void GossipHello(Object* pObject, Player* Plr, bool AutoSend);
	void GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * EnteredCode);
	void GossipEnd(Object* pObject, Player* Plr);
};

void GossipNPC::GossipHello(Object* pObject, Player* Plr, bool AutoSend)
{
	Creature* pCreature = (pObject->IsCreature())?(TO_CREATURE(pObject)):NULL;
	if(pCreature==NULL)
		return;

	GossipMenu *menu;
	objmgr.CreateGossipMenuForPlayer(&menu, pObject->GetGUID(), 1, Plr);
	menu->AddItem(1, "Port me to the Mall.", 0);
	menu->AddItem(1, "[Player Commands]", 1);
	menu->AddItem(1, "I don't need any help.", 56);
	if (AutoSend)
	{
		menu->SendTo(Plr);
	}
}

void GossipNPC::GossipSelectOption(Object* pObject, Player* Plr, uint32 Id, uint32 IntId, const char * EnteredCode)
{
	Creature* pCreature = (pObject->IsCreature())?(TO_CREATURE(pObject)):NULL;
	if(pCreature==NULL)
		return;

	GossipMenu *menu;
	switch(IntId)
	{
	case 0:
		Plr->SafeTeleport(1, Plr->GetInstanceID(), -10705.700195, 2534.929932, 4.032576, 1.827630);
		break;

	case  1:
		menu->AddItem(1, "[Appear]", 3);
		menu->AddItem(1, "[Summon]", 4);
		menu->AddItem(1, "[Revive]", 5);
		menu->AddItem(1, "[Revive Player]", 6);
		menu->AddItem(1, "[DeMorph]", 7);
		menu->AddItem(1, "[Mount]", 8);
		menu->AddItem(1, "[GPS]", 9);
		menu->AddItem(1, "[WorldPort]", 10);
		menu->AddItem(1, "[Modify]", 11);
		menu->AddItem(1, "[GM]", 12);
		menu->AddItem(1, "[Cheat]", 13);
		menu->AddItem(1, "[Recall]", 14);
		menu->AddItem(1, "[Server]", 15);
		menu->AddItem(1, "[AddItem]", 16);
		menu->AddItem(1, "[Learn Skill]", 17);
		menu->AddItem(1, "[Learn Spell]", 18);
		menu->AddItem(1, "[Phase]", 19);
		menu->AddItem(1, "[Set Title]", 20);
		menu->AddItem(1, "[Repair Items]", 21);
		menu->AddItem(1, "[Rename]", 22);
		menu->AddItem(1, "[AddItemSet]", 23);
		menu->AddItem(1, "[Increase Weapon Skill]", 24);
		menu->AddItem(1, "[Advance Skill]", 25);
		menu->AddItem(1, "[Remove Skill]", 26);
		menu->AddItem(1, "[Remove Item]", 27);
		menu->AddItem(1, "[Npc]", 28);

	case 3:
		command->HandleAppearCommand(args, m_session), true;
	case 56:
		Plr->Gossip_Complete();
		_npc->Delete();
		break;
	};

	if (Plr->Gossip_Complete(), true)
	{
		_npc->GetEntry();
		_npc->Delete();
	}

}

void GossipNPC::GossipEnd(Object* pObject, Player* Plr)
{
	GossipScript::GossipEnd(pObject, Plr);
}
void SetupGossipNPC(ScriptMgr *mgr)
{
	GossipScript *gs = (GossipScript*) new GossipNPC();
	mgr->register_gossip_script(99900, gs);
}


I even changed the commands declared in the ChatHandler class from protected to public and I still get the error. Please Help ArcEmu!!!
0

#2 User is offline   jackpoz 

  • ArcEmu Lemon Priest
  • PipPipPipPipPipPipPipPip
  • Group: Developers
  • Posts: 2,153
  • Joined: 19-June 08
  • Gender:Male
  • Location:Italy
  • Server OS:Windows

Posted 12 March 2011 - 02:34 PM

View PostSykez, on 12 March 2011 - 12:53 PM, said:

#pragma warning(disable: 4305) 


why are you hiding warnings under the carpet instead of properly fixing them?

View PostSykez, on 12 March 2011 - 12:53 PM, said:

ChatHandler *command; 
char args[20]; 
WorldSession *m_session; 
Creature *_npc; 


why are these variables declared as global? they are not even inizialized

View PostSykez, on 12 March 2011 - 12:53 PM, said:

GossipScript *gs = (GossipScript*) new GossipNPC();


why are you casting the pointer of an instance of a class derived from GossipScript to GossipScript* ?

if you were to define your C++ knowledge, which option would you choose ?
- very bad
- bad
- I know the basics
- I'm better than you
(imho accessing your C++ knowledge will throw a unhandled NULL dereference exception :))
Posted Image We develop dreams. Your dreams ;)
Posted ImagePosted Image
1

#3 User is offline   Sykez 

  • Member
  • Pip
  • Group: Members
  • Posts: 12
  • Joined: 03-December 09

Posted 14 March 2011 - 08:03 PM

There's a logical way to pointing out errors, I'm still learning thank you, but thanks for pointing them out now I know whats needed. I would suggest you visit some peer mediation classes though.
0

#4 User is offline   kjanko 

  • Enthusiast
  • PipPipPip
  • Group: Members
  • Posts: 171
  • Joined: 10-August 09
  • Gender:Male

Posted 15 March 2011 - 01:58 PM

http://www.javacoffe...aq/faq0002.html
Posted Image
0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users