View Full Version : [SOLVED] Help to mod a script

04-27-2015, 04:58 AM
Hello guys, I found a script here on old posts, and I want to know if someone can convert it to me, into [Lua], also I want to share some lua script that I have create, where's the current area for it?

#include "ScriptMgr.h"
#include "ObjectMgr.h"
#include "GossipDef.h"

class RacialSpellChanger : public CreatureScript
RacialSpellChanger() : CreatureScript("RacialSpellChanger") {}

void AddMenuItem(Player* player, uint8 icon, std::string text, uint32 sender, uint32 action)
player->PlayerTalkClass->GetGossipMenu().AddMenuItem(-1, icon, text, sender, action, "", 0, false);

bool OnGossipHello(Player* pPlayer, Creature* pCreature)
AddMenuItem(pPlayer, 0, "Get Human Racials", 0, 1);
AddMenuItem(pPlayer, 0, "Get Orc Racials", 0, 2);
AddMenuItem(pPlayer, 0, "Get Dwarf Racials", 0, 3);
AddMenuItem(pPlayer, 0, "Get Nightelf Racials", 0, 4);
AddMenuItem(pPlayer, 0, "Get Undead Racials", 0, 5);
AddMenuItem(pPlayer, 0, "Get Tauren Racials", 0, 6);
AddMenuItem(pPlayer, 0, "Get Gnome Racials", 0, 7);
AddMenuItem(pPlayer, 0, "Get Troll Racials", 0, 8);
AddMenuItem(pPlayer, 0, "Get Bloodelf Racials", 0, 10);
AddMenuItem(pPlayer, 0, "Get Dranaei Racials", 0, 11);

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

return true;

bool OnGossipSelect(Player* pPlayer, Creature* pCreature, uint32 sender, uint32 action)
for (ObjectMgr::RacialMap::const_iterator itr = sObjectMgr->GetRacialSpells().begin(); itr != sObjectMgr->GetRacialSpells().end(); ++itr)
if (itr->first != action)
pPlayer->removeSpell(itr->second, false, false);
pPlayer->learnSpell(itr->second, false);

return true;

04-27-2015, 04:42 PM
You can share LUA scripts here

04-27-2015, 08:42 PM
For you to make the conversion you would need a list of the race spells.
Lua doesnt have access to many functions and stores, so you need to either go around that or if you see that it would be widely useful, we might add it in.
For this script you cant access GetRacialSpells from lua.

By using http://eluna.emudevs.com/Global/RegisterCreatureGossipEvent.html
you can register a function to the gossip hello and select events.

In the function then just use http://eluna.emudevs.com/Player/GossipMenuAddItem.html and http://eluna.emudevs.com/Player/GossipSendMenu.html
as well as http://eluna.emudevs.com/Player/RemoveSpell.html and http://eluna.emudevs.com/Player/LearnSpell.html in similar fashion to your original script.