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

[SOLVED] Custom Restricted Flight Area (Again)

Status
Not open for further replies.

blackmetal

Exalted Member
After searching about no fly zone for specific zone, i found this http://emudevs.com/showthread.php/1931-HELP-Custom-Restricted-Flight-Area. And here the code from script i coppied

Code:
// Copy from Tommy - Emudevs - Thank you for create this script :)

class restricted_fly : public PlayerScript
{
public:
	restricted_fly() : PlayerScript("restricted_fly") { }

	void OnUpdateZone(Player* player, uint32 newZone, uint32 newArea)
	{
		if (newArea == 4197 || newArea == 200) // Change to your areaId
		{
			player->CastSpell(player, 58600); // Restricted Flight
			player->GetSession()->SendNotification("You aren't allowed to fly here!");
		}
	}

};

void AddSC_restricted_fly()
{
	new restricted_fly;
}

Problem is this spell 58600 does not effect much, it only stop player from flying, after that player can dismount and mount fly again. :sweaty: I dont know how to complete disable player fly in that zone :(
 

Tommy

Founder
You could use:

Code:
    void OnSpellCast(Player* player, Spell* spell, bool /*skipCheck*/)
    {
    }

check if it is a mount aura spell and if it is cancel the cast.
 

blackmetal

Exalted Member
What about disable ridding spell. I tried to disable those at Database, but player still can use mount and fly. :(
 

blackmetal

Exalted Member
Hmmm, after serveral day, it still hard to make a zone can not fly ( get in zone,get dismount, in zone, can not flying ). I was tried so much way to do this... Event tried change flag in DBC, but nothing goes in good way
 

Tommy

Founder
The amount of time you spent on random things you could've taken my advice, gathered up the code above and looked through the source for a code solution & be done by now.

Since I got my up and running I was able to write something out in Visual Studio. NOTE: I'm using 3.3.5. You might have to convert if there's any 5.x.x errors. I'm also working blind here and you'll have to test this.

Code:
    void OnSpellCast(Player* player, Spell* spell, bool /*skipCheck*/)
    {
        uint32 zoneId = player->GetZoneId();
        if (zoneId == 1234)
        {
            SpellInfo const* info = spell->GetSpellInfo();
            if (!info)
                return;

            for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
            {
                if (info->Effects[i].ApplyAuraName == SPELL_AURA_FLY)
                {
                    spell->cancel();
                    player->GetSession()->SendNotification("You cannot mount here!");
                }
            }
        }
    }
 

blackmetal

Exalted Member
Nice to see website online again. Here is complete script that i know from here to make zone like wintergrasp can not use fly ;).

Code:
// Copy from Tommy - Emudevs - Thank you for create this script :)


class restricted_fly : public PlayerScript
{
public:
	restricted_fly() : PlayerScript("restricted_fly") { }

	void OnSpellCast(Player* player, Spell* spell, bool /*skipCheck*/)
	{
		uint32 zoneId = player->GetZoneId();
		if (zoneId == 4197)
		{
			SpellInfo const* info = spell->GetSpellInfo();
			if (!info)
				return;

			for (uint8 i = 0; i < MAX_SPELL_EFFECTS; ++i)
			{
				if (info->Effects[i].ApplyAuraName == SPELL_AURA_FLY || info->Effects[i].ApplyAuraName == SPELL_AURA_MOD_INCREASE_MOUNTED_FLIGHT_SPEED)
				{
					spell->cancel();
					player->GetSession()->SendNotification("You cannot mount here!");
				}
			}

		}
	}

	void OnUpdateZone(Player* player, uint32 newZone, uint32 newArea)
	{
		if (newArea == 4197) // Change to your areaId
		{
			player->CastSpell(player, 91604); // Restricted Flight
			player->GetSession()->SendNotification("You aren't allowed to fly here!");

		}

	}

};

void AddSC_restricted_fly()
{
	new restricted_fly;
}
 
Status
Not open for further replies.
Top