• This is a read only backup of the old Emudevs forum. If you want to have anything removed, please message me on Discord: KittyKaev

C++ Learn Riding Spells - DKs not working?

Status
Not open for further replies.

Madness

Enthusiast
So I have a basic script that teaches characters riding spells OnLevelChanged at certain levels. It works great for all classes except for DKs? For some reason they're not hitting the switch. I've even tried adding a check like so, but it still doesn't work:

Code:
class Riding_Skills_OnLevel : public PlayerScript
{
public:
	Riding_Skills_OnLevel() : PlayerScript("Riding_Skills_OnLevel") { }

	void OnLevelChanged(Player* player, uint8 newLevel)
	{
		uint32 SpellID;
		switch (player->getLevel())
			{
			case 10: SpellID = 33388; break;
			case 40: SpellID = 33391; break;
			case 67: SpellID = 54197; break; // Cold Weather Flying
			case 70: SpellID = 34091; break;
		default: return;
		}
		player->LearnSpell(SpellID, true);

		if (player->getClass() == CLASS_DEATH_KNIGHT && player->getLevel() == 56)
		{
			player->LearnSpell(33388, true);
			player->LearnSpell(33391, true);
		}

	}
};

void AddSC_Riding_Skills_OnLevel()
{
	new Riding_Skills_OnLevel();
}
 
Last edited:

Tommy

Founder
You should probably consider the logic in the code below and remove it:

Code:
default: return;

The Death Knight code isn't being reached because of it most likely. One of your hook parameters is named wrong and can cause confusion (not saying it is affecting the script, just pointing it out):

Code:
uint8 newLevel

It is actually "oldLevel" because it gets the player's old level once they level up, not the new level.
 

Madness

Enthusiast
Thanks a lot mate, it was the return messing things up and I also changed the parameter to oldLevel. Makes much more sense!
 
Status
Not open for further replies.
Top