Hello
I have a problem when compiling a WarpNPC with C++. The compiler says something about a wrong syntax or something when using break; and case. It also has some other problems. Here is my compilers output:
I know its alot of errors but they're all the same. Here is my Warper.cpp (I'm compiling it in the GossipScripts folder):Code:1>------ Rebuild All started: Project: GossipScripts, Configuration: Release Win32 ------ 1>Deleting intermediate and output files for project 'GossipScripts', configuration 'Release|Win32' 1>Compiling... 1>Warper.cpp 1>..srcGossipScriptsWarper.cpp(42) : error C2059: syntax error : 'switch' 1>..srcGossipScriptsWarper.cpp(43) : error C2143: syntax error : missing ';' before '{' 1>..srcGossipScriptsWarper.cpp(43) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(48) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(49) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(58) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(61) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(62) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(71) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(74) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(75) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(82) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(84) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(85) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(90) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(92) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(93) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(98) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(100) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(101) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(104) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(106) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(107) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(110) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(112) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(113) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(116) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(118) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(119) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(122) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(124) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(125) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(128) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(130) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(131) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(134) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(136) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(137) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(140) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(142) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(143) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(146) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(148) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(149) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(152) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(154) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(155) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(160) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(162) : error C2059: syntax error : 'case' 1>..srcGossipScriptsWarper.cpp(163) : error C2447: '{' : missing function header (old-style formal list?) 1>..srcGossipScriptsWarper.cpp(172) : error C2059: syntax error : 'break' 1>..srcGossipScriptsWarper.cpp(183) : error C2143: syntax error : missing ';' before '}' 1>GuardGossip.cpp 1>Gossip_Innkeepers.cpp 1>Gossip_Battlemaster.cpp 1>Setup.cpp 1>Build log was saved at "file://c:UsersBennerDesktopAscentSourcesrcscriptsprojects2008_int_release_gossipscriptsBuildLog.htm" 1>GossipScripts - 52 error(s), 0 warning(s) ========== Rebuild All: 0 succeeded, 1 failed, 0 skipped ==========
Code:#include "StdAfx.h" #include "Setup.h" #ifdef WIN32 #pragma warning(disable:4305) #endif class SCRIPT_DECL GlobalNPC : public GossipScript { public: void GossipHello(Object * pObject, Player* Plr, bool AutoSend); void GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code); void GossipEnd(Object * pObject, Player* Plr); void Destroy() { delete this; } }; void GlobalNPC::GossipHello(Object * pObject, Player* Plr, bool AutoSend) { GossipMenu *Menu; objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); if(Plr->getRace()== 10||Plr->getRace()== 2||Plr->getRace()== 6||Plr->getRace()== 8||Plr->getRace()== 5) {Menu->AddItem(0, "[Horde Cities]", 1);}else{Menu->AddItem(0, "[Alliance Cities]", 2);} Menu->AddItem(0, "[Cross Faction Cities]", 3); Menu->AddItem(5, "Shopping Mall", 4); Menu->AddItem(5, "Concert", 5); if(AutoSend) Menu->SendTo(Plr); } void GlobalNPC::GossipSelectOption(Object * pObject, Player* Plr, uint32 Id, uint32 IntId, const char * Code) { Creature * pCreature = (pObject->GetTypeId()==TYPEID_UNIT)?((Creature*)pObject):NULL; if(pCreature==NULL) return; } GossipMenu * Menu; switch(IntId) { case 0: //Nothing GossipHello(pObject, Plr, true); break; } case 1: //Horde Cities { objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); Menu->AddItem(5, "Orgrimmar", 6); Menu->AddItem(5, "Thunder Bluff", 7); Menu->AddItem(5, "Undercity", 8); Menu->AddItem(5, "Silvermoon City", 9); Menu->AddItem(5, "[Back]", 99); Menu->SendTo(Plr); } break; case 2: //Ally Cities { objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); Menu->AddItem(5, "Ironforge", 10); Menu->AddItem(5, "Stormwind City", 11); Menu->AddItem(5, "Darnassus", 12); Menu->AddItem(5, "The Exodar", 13); Menu->AddItem(5, "[Back]", 99); Menu->SendTo(Plr); } break; case 3: //Crossed Cities { objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); Menu->AddItem(5, "Shattrath City", 14); Menu->AddItem(5, "Sharalith City", 15); Menu->AddItem(5, "[Back]", 99); Menu->SendTo(Plr); } break; case 4: //Shopping Mall { objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); Menu->AddItem(5, "Shopping Mall is currently unavailable", 99); Menu->SendTo(Plr); } break; case 5: //Concert { objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); Menu->AddItem(5, "Concert is currently unavailable", 99); Menu->SendTo(Plr); } break; case 6: //Orgrimmar { Plr->EventTeleport(1, 1502.71, -4415.42, 22.5512); } break; case 7: //Thunder Bluff { Plr->EventTeleport(1, -1285.42, 176.523, 130.994); } break; case 8: //Undercity { Plr->EventTeleport(0, 1831.26, 238.53, 61.52); } break; case 9: //Silvermoon { Plr->EventTeleport(530, 9414.18, -7278.97, 15.2031); } break; case 10: //Ironforge { Plr->EventTeleport(0, -4981.25, -881.542, 502.66); } break; case 11: //Stormwind { Plr->EventTeleport(0, -8913.23, 554.633, 94.7944); } break; case 12: //Darnassus { Plr->EventTeleport(1, 8795.8, 969.427, 31.1955); } break; case 13: //Exodar { Plr->EventTeleport(530, -4014.08, -11895.8, -0.99324); } break; case 14: //Shattrath { Plr->EventTeleport(530, -1722.58, 5382.7, 2.47504); } break; case 15: //Sharalith { objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); Menu->AddItem(5, "Sharalith is under Development", 99); Menu->SendTo(Plr); } break; case 99: //Back { objmgr.CreateGossipMenuForPlayer(&Menu, pObject->GetGUID(), 1, Plr); if(Plr->getRace()== 10||Plr->getRace()== 2||Plr->getRace()== 6||Plr->getRace()== 8||Plr->getRace()== 5) {Menu->AddItem(0, "[Horde Cities]", 1);}else{Menu->AddItem(0, "[Alliance Cities]", 2);} Menu->AddItem(0, "[Cross Faction Cities]", 3); Menu->AddItem(5, "Shopping Mall", 4); Menu->AddItem(5, "Concert", 5); Menu->SendTo(Plr); } break; void GlobalNPC::GossipEnd(Object * pObject, Player* Plr) { GossipScript::GossipEnd(pObject, Plr); } void SetupGlobalNPC(ScriptMgr * mgr) { GossipScript * gs = (GossipScript*) new GlobalNPC(); mgr->register_gossip_script(100000, gs) }