How do i restrict users to a specific set of zones or block them from entering other zones

Hi!

I'm working on my own server based on trinity core. I have an idea where all players are only allowed to visit and level in specific zones which unlock as they progress and I'm not sure how do implement this in the game.
I first had some ideas about placing invisible walls around the zones they are allowed to use and remove them when they unlock a new one but I have to clue how to place that amount of walls in a realistic manner. I'm currently thinking that players will travel between the zones via a npc, portal, teleporter etc if the zones aren't located right next to eachother.

Do you guys have any suggestions on how to solve this, I'm very new to wow servers but I have quite a bit of experience with programming and databases.

Thank you!

Easy. This was how retail did it, when customers did not order the latest expansion.

here is an example:

[FONT=‘Courier New’]if ((player->GetPositionX() >= x ) && (player->GetPositionY() >= y)){
//teleport the player
//send message to player - this is a restricted zone/area[/FONT]
[FONT=‘Courier New’]}[/FONT]

Hack way - add code in Player::Update that checks zone validity periodically and teleports back to last known “good” position (or fallback) if map is invalid.

PS: Note that this is a terribly inefficient idea.

PPS: Could also hook into, what’s the method…UpdateLiquid something or another, on player. That’s called whenever the player changes locality data (liquid state, area or zone id).

PPPS: Remember to check falling state for your last known good position, or you might end up repeatedly teleporting your player into a mid-jump or something, Portal style.

Thanks, I will look into this when I get home!

While I have you guys here, do you have any suggestions for how to learn more about how the code works, when what code is being executed etc. So far I've spent most of my time on debug mode in visual studio and stepping through events like looting etc. 

Thanks a bunch for the help!

That’s a pretty solid way to do it. That, and experience. Lots of it.

(PS: And get on IRC so you can ask questions.)

I think there is also a PlayerScript hook onArea/ZoneEnter enter which could be used to create a non hacky solution.

If you can’t teleport inside the script you could attach an asynchronous timed event player->m_Events to the player.

Naios is correct. Use a timed event. Or if you’re lazy, just create a new member variable for the Player object. When OnZoneEnter is triggered, check if the zone is valid. If so, update the player’s member as the last known “good” coordinates. If not, teleport the player to the last known “good” coordinates by referencing the one in the Player object, simple.

I would love a laymen’s explanation of this. I am trying to create a similar function, but I do not have experience with Coding for trinity, and this is not very helpful without that knowledge. Has anyone figured out a good way to write this?