Thank you.
However, it doesn't helped. Any idea why?
PHP Code:
#pragma semicolon 1
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
public void OnPluginStart()
{
RegAdminCmd("sm_b", CmdB, ADMFLAG_ROOT, "");
}
public Action CmdB(int client, int args)
{
PrintToChat(client, "is inside? %b", IsInSafeRoom(client));
return Plugin_Handled;
}
public void OnMapStart()
{
ExpandSaferoom();
}
void ExpandSaferoom()
{
int chl;
chl = FindEntityByClassname(-1, "info_changelevel");
if (chl == -1)
{
chl = FindEntityByClassname(-1, "trigger_changelevel");
if (chl == -1)
return;
}
float min[3], max[3];
GetEntPropVector(chl, Prop_Send, "m_vecMins", min);
GetEntPropVector(chl, Prop_Send, "m_vecMaxs", max);
// zone expanding by Y-axis
max[0] += 200.0;
max[1] += 200.0;
max[2] += 200.0;
min[0] -= 100.0;
min[1] -= 100.0;
min[2] -= 100.0;
SetEntPropVector(chl, Prop_Send, "m_vecMins", min);
SetEntPropVector(chl, Prop_Send, "m_vecMaxs", max);
ChangeEdictState(chl, 0);
}
bool IsInSafeRoom(int client)
{
float pos[3], min[3], max[3], me[3];
int chl;
chl = FindEntityByClassname(-1, "info_changelevel");
if (chl == -1)
{
chl = FindEntityByClassname(-1, "trigger_changelevel");
if (chl == -1)
return false;
}
GetEntPropVector(chl, Prop_Send, "m_vecOrigin", pos);
GetEntPropVector(chl, Prop_Send, "m_vecMins", min);
GetEntPropVector(chl, Prop_Send, "m_vecMaxs", max);
AddVectors(min, pos, min);
AddVectors(max, pos, max);
GetEntPropVector(client, Prop_Send, "m_vecOrigin", me);
PrintToChat(client, "me: %f %f %f", me[0], me[1], me[2]);
PrintToChat(client, "zone min: %f %f %f", min[0], min[1], min[2]);
PrintToChat(client, "zone max: %f %f %f", max[0], max[1], max[2]);
//TeleportEntity(client, min, NULL_VECTOR, NULL_VECTOR);
return IsDotInside(me, min, max);
}
bool IsDotInside(float dot[3], float min[3], float max[3])
{
if( min[0] < dot[0] < max[0] &&
min[1] < dot[1] < max[1] &&
min[2] < dot[2] < max[2]) {
return true;
}
return false;
}
Quote:
> on the toilet:
me: -2432.692138 2.869050 178.092575
zone min: -2745.000000 -137.000000 163.000000
zone max: -2399.000000 173.000000 401.000000
is inside? 1
|
Quote:
> on the floor:
me: -2436.478759 2.897515 160.031250
zone min: -2745.000000 -137.000000 163.000000
zone max: -2399.000000 173.000000 401.000000
is inside? 0
|
Yes, these numbers looks very strange, e.g.:
"on the floor" y-axis player coord = 160, and this value is out of the "min" zone range, however trigger is correctly react on it.
And vice versa, "on the toilet" all coords looks like inside the zone, but map end trigger is not react.
And yes, I checked math calculation by teleporting players to that pos. They looks correct.
And, IsInSafeRoom() function show correct data for ALL other maps.
It's only "l4d_smalltown03_ranchhouse" map show such strange result on Y-axis.
I very like idea to expand zone to allow people finish round by standing on such places.
Hope, we can find solution.
Appreciate for help.
P.S. One walkaround to manually force end round, but it is too large hack, IMHO.