At work so I can't test yet, but...
Have you implemented the menu items in this version?
Does this version allow you to specify the distance as well?
Edit: Yes it does, and it's 50 be default.
I'm also curious about how you're handling the 3D aspect.
Do you simply form a vertical cylinder of radius 50 around the point? If so, what if someone stood above/below the restricted point on another floor?
Does the radius refer to a sphere?
I bet you're just using a 2D circle, with maybe some tolerance in the Z-direction (essentially a very short cylinder).
The reason I ask is because I see potential issues when blocking spots on sloped terrain.
Edit: You're treating it as a sphere. This should cover sloped terrain easily, but may be a problem, say, under the ramp in NoMercy. (Someone on top of the ramp could get teleported if you set a single sphere large enough to cover the corner under the ramp.) This should be fine 99.9% of the time, and any adjustments could be made by changing the radius and adding multiple points as needed.
Maybe I'll whip something up tonight that uses a horizontal (x-y plane) radius and a vertical radius, and checks both vertical and horizontal distance, so you can have more control. This is a lot of work for very little benefit, so I'll play around with it last.
Radius is spelled "radious" in the code and printouts.
Here, if a player is moved, the minimum distance is still set based on their prior location.
Code:
// Checks all spots of the map
for (i=0;i<RestrictedSpots_Count; i++)
{
// calculates distance between the current position and the restricted spot ..
Dist = Distance(Coord[0], Coord[1], Coord[2], RestrictedSpots[i][0], RestrictedSpots[i][1], RestrictedSpots[i][2]);
// debug message
if (DEBUG_ENABLED == true) PrintToChat(client, "[RZ-debug] Distance to spot #%i = %f", i, Dist);
// If player is at least XX points close to that spot .... we move and warn him ...
if (Dist < RestrictedSpots[i][3])
{
// Get new location's coordinates (to where the player will be moved to if it's on the restricted spot)
NewCoord[0] = RestrictedSpots[i][4];
NewCoord[1] = RestrictedSpots[i][5];
NewCoord[2] = RestrictedSpots[i][6];
// Warn ...
PrintHintText(client, "\x01This zone is restricted. You have been moved by the server!");
// Move ...
TeleportEntity(client, NewCoord, NULL_VECTOR, NULL_VECTOR);
}
// If this distance is less than the current minimum .... we set it as minimum and then check if timer should be reset ...
if (Dist < MinimumDistance)
{
MinimumDistance = Dist;
}
}
I would recommend re-setting their distance (from the current spot) after teleporting them. Otherwise, you may be increasing the speed of the timer needlessly (after the offending player has been corrected). I've noticed it's usually once lamer who leads everyone else under a staircase, under a ramp, into a closet, into a vent, or up a loft.
Code:
// Checks all spots of the map
for (i=0;i<RestrictedSpots_Count; i++)
{
// calculates distance between the current position and the restricted spot ..
Dist = Distance(Coord[0], Coord[1], Coord[2], RestrictedSpots[i][0], RestrictedSpots[i][1], RestrictedSpots[i][2]);
// debug message
if (DEBUG_ENABLED == true) PrintToChat(client, "[RZ-debug] Distance to spot #%i = %f", i, Dist);
// If player is at least XX points close to that spot .... we move and warn him ...
if (Dist < RestrictedSpots[i][3])
{
// Get new location's coordinates (to where the player will be moved to if it's on the restricted spot)
NewCoord[0] = RestrictedSpots[i][4];
NewCoord[1] = RestrictedSpots[i][5];
NewCoord[2] = RestrictedSpots[i][6];
// Warn ...
PrintHintText(client, "\x01This zone is restricted. You have been moved by the server!");
// Move ...
TeleportEntity(client, NewCoord, NULL_VECTOR, NULL_VECTOR);
// Recalculate distance
Dist = Distance(NewCoord[0], NewCoord[1], NewCoord[2], RestrictedSpots[i][0], RestrictedSpots[i][1], RestrictedSpots[i][2]);
}
// If this distance is less than the current minimum .... we set it as minimum and then check if timer should be reset ...
if (Dist < MinimumDistance)
{
MinimumDistance = Dist;
}
}
Another issue I see is the following:
What if I set a RestrictedSpot with a MoveTo that was inside the Radius?
I haven't read through all of the code yet, so maybe you have taken this into account.
Edit: Nope, doesn't look like it.
I would recommend an initial loop on map load that loops through all restricted spots with all MoveTo coordinates. (You'll have to check each MoveTo with each spot!) You've got a lot of time initially now that you've implemented ChillyWI's idea, and survivors usually won't be camping out in restricted areas at the beginning. If a MoveTo is within a RestrcitedArea's Radius, there are three things you can do:
1 - Deactivate the Resitricted Spot with the bad MoveTo
2 - Deactivate the Resitricted Spot the bad MoveTo lands in
3 - Move the MoveTo location to somewhere else.
I believe number 3 would be best, with some sort of error printout.
Where would you move it to? That's another issue...
What about running a check when setting a restricted spot or moveto? This way you can tell the admin that the spot they've tried to set overlaps an existing moveto, or that the moveto they've tried to set lands in an existing restricted area. Obviously, problems could still arise by editing the file directly, and you would still need the initial check on map load. This would just provide immediate feedback to admins (as long as they're not editing the file manually).
You can get really crazy and try to handle cases where a survivor is teleported to an open spot, but is surrounded by restricted areas. (Way too complicated.)
Another method may be to teleport someone only once every X seconds. This would give them enough time to run out of the restricted area if they're teleported inside one (unless someone really messed up their areas and points...). It would still be frustrating to players though, to be bounced around trying to get out of some invisible prison, so warnings "You're in a restricted area! Move or you will be teleported!" would be helpful.
This is great as is (haven't tested it, but it all looks good from what I've read). I
really hate people exploiting closets and other areas, so I would love to help make this plugin more versatile (even if it makes it more complicated). I'll try to whip up some code tonight. I have no experience with sourcemod, but this is all easily readable, and all functions I would need to interact with the game are already there.