I'm trying to add the CFG file to my plugin, but I'm dont successful. could you please help in this regard. my goal here is to try to prevent players from passing by adding barricades in sections without saferoom Gates.
PHP Code:
#pragma semicolon 1
#include <left4dhooks>
#pragma newdecls required
#include <sourcemod>
#include <sdktools>
#define PATCH "logs\\l4d2_wait_players.log"
#define PATCH "data/anti-rush_system-l4d2.cfg"
bool g_bFirstItemPickedUp;
bool g_bisAlreadyDone;
bool g_bisClean;
bool g_bLocked;
bool g_bIsClientLoading[MAXPLAYERS + 1];
bool g_bIsFirstAction[MAXPLAYERS + 1];
ConVar cvar_ClientTimeOut, cvar_Delay, cvar_LockHintText, cvar_LockRoundOne, cvar_LockRoundTwo;
float g_SpawnPos[3];
float g_pos[3];
int g_iClientTimeout[MAXPLAYERS + 1];
int g_iCooldown;
int g_iMap;
int g_iPlayerSpawn;
int g_iRoundStart;
char datafilepath[PLATFORM_MAX_PATH];
static char LOG[256];
static Handle g_IsWayUnlocked = null;
public Plugin myinfo =
{
name = "l4d2_wait_players",
author = "SupermenCJ,DarkWob",
description = "L4D2 wait loading players after map start",
version = "1.0",
url = "https://regionz.ml"
}
public void OnPluginStart()
{
BuildPath(Path_SM, LOG, sizeof(LOG), PATCH);
BuildPath(Path_SM, datafilepath, sizeof(datafilepath), "data/l4d2_wait_players.txt");
BuildPath(Path_SM, sDataFilePath, sizeof(sDataFilePath), "data/anti-rush_system-l4d2.cfg");
if (!FileExists(sDataFilePath))
{
SetFailState("[LOCK] Data File Not Found!");
}
cvar_ClientTimeOut = CreateConVar("l4d2_wait_timeout", "25", "How many seconds plugin will wait after a map starts before giving up on waiting for a client. (Default: 30)");
cvar_Delay = CreateConVar("l4d2_wait_delay", "40", "Delay to enable bots if no human does.");
cvar_LockHintText = CreateConVar("l4d2_wait_hinttext", "1", "Does the plugin print the countdown in center screen? (Default: 1)");
cvar_LockRoundOne = CreateConVar("l4d2_wait_roundone", "40", "How long the door is locked on round 1 - this round takes longer to load. (Default: 40)");
cvar_LockRoundTwo = CreateConVar("l4d2_wait_roundtwo", "30", "How long the door is locked on round two. (Default: 30)");
RegAdminCmd("sm_coord", CMD_Coord, ADMFLAG_ROOT, "Узнать координаты места");
RegAdminCmd("sm_coordsave", CMD_RecordCoord, ADMFLAG_ROOT, "Запись координат места для текущей карты");
RegAdminCmd("sm_savecoord", CMD_RecordCoord, ADMFLAG_ROOT, "Запись координат места для текущей карты");
HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
HookEvent("round_end", Event_RoundEnd, EventHookMode_PostNoCopy);
HookEvent("item_pickup", Event_ItemPickup);
HookEvent("player_left_checkpoint", Event_LeftSaferoom);
HookEvent("player_spawn", Event_PlayerSpawn, EventHookMode_PostNoCopy);
HookEvent("player_team", Event_JoinTeam);
g_IsWayUnlocked = CreateGlobalForward("Lock_CheckpointDoorStartOpened", ET_Ignore);
}
public void OnMapStart()
{
FindConVar("sb_stop").SetInt(0);
g_bisAlreadyDone = false;
g_bisClean = false;
g_bLocked = true;
g_iCooldown = cvar_LockRoundOne.IntValue;
g_iRoundStart = 0;
}
public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
{
if (buttons & IN_MOVELEFT || buttons & IN_BACK || buttons & IN_FORWARD || buttons & IN_MOVERIGHT || buttons & IN_USE)
{
if (GetClientTeam(client) != 2)
{
return Plugin_Continue;
}
if (IsFakeClient(client))
{
if (FindConVar("sb_stop").IntValue == 0 && !g_bisAlreadyDone)
{
FindConVar("sb_stop").SetInt(1);
CreateTimer(cvar_Delay.FloatValue, StartBotsDelay);
}
}
if (!IsFakeClient(client))
{
if (FindConVar("sb_stop").IntValue == 1 && !g_bisAlreadyDone)
{
g_bisAlreadyDone = true;
FindConVar("sb_stop").SetInt(0);
}
}
}
return Plugin_Continue;
}
public Action StartBotsDelay(Handle timer)
{
if (FindConVar("sb_stop").IntValue == 1 && !g_bisAlreadyDone)
{
g_bisAlreadyDone = true;
FindConVar("sb_stop").SetInt(0);
}
return Plugin_Stop;
}
public Action Event_ItemPickup(Event event, const char[] name, bool dontBroadcast)
{
if (!g_bFirstItemPickedUp)
{
g_bFirstItemPickedUp = true;
CreateTimer(0.2, PluginStartSequence01);
}
}
public Action PluginStartSequence01(Handle timer)
{
for (int i = 1; i <= MaxClients; i++)
{
g_bIsClientLoading[i] = true;
g_iClientTimeout[i] = 0;
}
CreateTimer(0.2, PluginStartSequence02);
}
public Action PluginStartSequence02(Handle timer)
{
CreateTimer(1.0, LoadingTimer, _, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
public Action LoadingTimer(Handle timer)
{
if (isFinishedLoading())
{
CreateTimer(1.0, timerLockSwitch,_, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
return Plugin_Stop;
}
return Plugin_Continue;
}
public Action timerLockSwitch(Handle timer, any client)
{
if(g_iCooldown > 0)
{
if (cvar_LockHintText.BoolValue)
PrintHintTextToAll("%i second(s) till the way unlock!", g_iCooldown);
if (g_iCooldown == 10)
PrintToChatAll("\x03[\x01\x04LOCK\x01\x03]\x01 \x04Way will unlocked in\x01 \x03%i\x01 \x04seconds!\x01", g_iCooldown);
}
else if (g_iCooldown == 0)
{
WayUnlocked();
PrintToChatAll("\x03[\x01\x04LOCK\x01\x03]\x01 \x04Way are unlocked!\x01");
if (cvar_LockHintText.BoolValue)
PrintHintTextToAll("WAY ARE UNLOCKED!");
}
else if (g_iCooldown < 0)
return Plugin_Stop;
g_iCooldown--;
return Plugin_Continue;
}
public Action Event_RoundStart(Event event, const char[] name, bool dontBroadcast)
{
FindConVar("sb_stop").SetInt(0);
g_bFirstItemPickedUp = false;
g_bisAlreadyDone = false;
g_bisClean = false;
g_bLocked = true;
if (g_iPlayerSpawn == 1 && g_iRoundStart == 0)
CreateTimer(g_iMap == 1 ? 5.0 : 1.0, tmrStart);
g_iRoundStart = 1;
}
public Action Event_RoundEnd(Event event, const char[] name, bool dontBroadcast)
{
g_bisClean = false;
g_bLocked = true;
ResetState();
}
public void OnClientConnected(int client)
{
g_bIsFirstAction[client] = true;
}
public void OnClientDisconnect(int client)
{
g_bIsClientLoading[client] = false;
g_iClientTimeout[client] = 0;
}
public Action Event_JoinTeam(Event event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(event.GetInt("userid"));
if (isClientValid(client))
{
g_bIsClientLoading[client] = false;
g_iClientTimeout[client] = 0;
}
}
bool isFinishedLoading()
{
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientConnected(i))
{
if (!IsClientInGame(i) && !IsFakeClient(i))
{
g_iClientTimeout[i]++;
if (g_bIsClientLoading[i])
{
if (g_iClientTimeout[i] == 1)
g_bIsClientLoading[i] = true;
}
if (g_iClientTimeout[i] == cvar_ClientTimeOut.IntValue)
g_bIsClientLoading[i] = false;
}
else
g_bIsClientLoading[i] = false;
}
else
g_bIsClientLoading[i] = false;
}
return !isAnyClientLoading();
}
bool isAnyClientLoading()
{
for (int i = 1; i <= MaxClients; i++)
{
if (g_bIsClientLoading[i])
return true;
}
return false;
}
bool isClientValid(int client)
{
if (client <= 0)
return false;
if (!IsClientConnected(client))
return false;
if (!IsClientInGame(client))
return false;
if (IsFakeClient(client))
return false;
return true;
}
public Action Event_PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
{
if (g_iPlayerSpawn == 0 && g_iRoundStart == 1)
CreateTimer(g_iMap == 1 ? 5.0 : 1.0, tmrStart);
g_iPlayerSpawn = 1;
}
void WayUnlocked()
{
if (!g_bisClean)
{
g_bisClean = true;
//ServerCommand("sm_cvar director_no_survivor_bots 0");
ServerCommand("sm_cvar sb_stop 0");
g_bLocked = false;
}
Call_StartForward(g_IsWayUnlocked);
Call_Finish();
}
public Action Event_LeftSaferoom(Event event, const char[] name, bool dontBroadcast)
{
if (!g_bLocked)
return Plugin_Continue;
int client = GetClientOfUserId(event.GetInt("userid"));
if (client && IsClientInGame(client) && g_bIsFirstAction[client])
{
g_bIsFirstAction[client] = false;
return Plugin_Continue;
}
if (client && IsClientInGame(client) && IsPlayerAlive(client) && GetClientTeam(client) == 2)
TeleportClientBack(client);
return Plugin_Continue;
}
public Action L4D_OnFirstSurvivorLeftSafeArea(int client)
{
if (g_bLocked)
return Plugin_Handled;
else
return Plugin_Continue;
}
void TeleportClientBack(int client)
{
char sMap[64];
float pos[3];
bool IsAllowed = true;
GetCurrentMap(sMap, sizeof(sMap));
if (StrEqual(sMap, "c1m1_hotel"))
{
pos[0] = 568.0; pos[1] = 5707.0; pos[2] = 2848.0;
}
else if (StrEqual(sMap, "c1m2_streets"))
{
pos[0] = 2371.7; pos[1] = 5164.9; pos[2] = 475.0;
}
else if (StrEqual(sMap, "c1m3_mall"))
{
pos[0] = 6747.3; pos[1] = -1440.7; pos[2] = 50.6;
}
else if (StrEqual(sMap, "c1m4_atrium"))
{
pos[0] = -2033.6; pos[1] = -4607.9; pos[2] = 559.0;
}
else if (StrEqual(sMap, "c2m1_highway"))
{
pos[0] = 10905.8; pos[1] = 7890.9; pos[2] = -527.0;
}
else if (StrEqual(sMap, "c2m2_fairgrounds"))
{
pos[0] = 1648.7; pos[1] = 2893.4; pos[2] = 33.2;
}
else if (StrEqual(sMap, "c2m3_coaster"))
{
pos[0] = 4450.6; pos[1] = 2056.4; pos[2] = -36.9;
}
else if (StrEqual(sMap, "c2m4_barns"))
{
pos[0] = 3185.0; pos[1] = 3717.1; pos[2] = -160.9;
}
else if (StrEqual(sMap, "c2m5_concert"))
{
pos[0] = -817.2; pos[1] = 2289.1; pos[2] = -229.0;
}
else if (StrEqual(sMap, "c3m1_plankcountry"))
{
pos[0] = -12543.2; pos[1] = 10475.3; pos[2] = 271.8;
}
else if (StrEqual(sMap, "c3m2_swamp"))
{
pos[0] = -8173.3; pos[1] = 7589.1; pos[2] = 39.0;
}
else if (StrEqual(sMap, "c3m3_shantytown"))
{
pos[0] = -5717.4; pos[1] = 2177.3; pos[2] = 165.1;
}
else if (StrEqual(sMap, "c3m4_plantation"))
{
pos[0] = -5074.4; pos[1] = -1685.5; pos[2] = -69.8;
}
else if (StrEqual(sMap, "c4m1_milltown_a"))
{
pos[0] = -6984.3; pos[1] = 7704.1; pos[2] = 131.2;
}
else if (StrEqual(sMap, "c4m2_sugarmill_a"))
{
pos[0] = 3663.1; pos[1] = -1697.4; pos[2] = 259.5;
}
else if (StrEqual(sMap, "c4m3_sugarmill_b"))
{
pos[0] = -1818.2; pos[1] = -13704.6; pos[2] = 158.8;
}
else if (StrEqual(sMap, "c4m4_milltown_b"))
{
pos[0] = 3884.5; pos[1] = -1586.0; pos[2] = 259.2;
}
else if (StrEqual(sMap, "c4m5_milltown_escape"))
{
pos[0] = -3048.1; pos[1] = 7823.6; pos[2] = 142.8;
}
else if (StrEqual(sMap, "c5m1_waterfront"))
{
pos[0] = 767.9; pos[1] = 674.1; pos[2] = -455.0;
}
else if (StrEqual(sMap, "c5m2_park"))
{
pos[0] = -4437.9; pos[1] = -1250.1; pos[2] = -322.1;
}
else if (StrEqual(sMap, "c5m3_cemetery"))
{
pos[0] = 6448.5; pos[1] = 8428.1; pos[2] = 27.0;
}
else if (StrEqual(sMap, "c5m4_quarter"))
{
pos[0] = -3046.3; pos[1] = 4881.7; pos[2] = 95.0;
}
else if (StrEqual(sMap, "c5m5_bridge"))
{
pos[0] = -12039.7; pos[1] = 5843.2; pos[2] = 155.0;
}
else if (StrEqual(sMap, "c6m1_riverbank"))
{
pos[0] = 928.0; pos[1] = 4278.0; pos[2] = 115.0;
}
else if (StrEqual(sMap, "c6m2_bedlam"))
{
pos[0] = 3156.7; pos[1] = -1235.4; pos[2] = -268.9;
}
else if (StrEqual(sMap, "c6m3_port"))
{
pos[0] = -2450.8; pos[1] = -523.2; pos[2] = -228.9;
}
else if (StrEqual(sMap, "c7m1_docks"))
{
pos[0] = 13830.0; pos[1] = 2894.8; pos[2] = 59.2;
}
else if (StrEqual(sMap, "c7m2_barge"))
{
pos[0] = 10788.4; pos[1] = 2479.7; pos[2] = 203.0;
}
else if (StrEqual(sMap, "c7m3_port"))
{
pos[0] = 1219.6; pos[1] = 3254.6; pos[2] = 195.0;
}
else if (StrEqual(sMap, "c8m1_apartment"))
{
pos[0] = 1766.9; pos[1] = 878.1; pos[2] = 459.0;
}
else if (StrEqual(sMap, "c8m2_subway"))
{
pos[0] = 2874.7; pos[1] = 3233.4; pos[2] = 43.0;
}
else if (StrEqual(sMap, "c8m3_sewers"))
{
pos[0] = 10849.5; pos[1] = 4755.3; pos[2] = 46.4;
}
else if (StrEqual(sMap, "c8m4_interior"))
{
pos[0] = 12357.0; pos[1] = 12260.3; pos[2] = 42.7;
}
else if (StrEqual(sMap, "c8m5_rooftop"))
{
pos[0] = 5579.6; pos[1] = 8348.0; pos[2] = 5563.0;
}
else if (StrEqual(sMap, "c9m1_alleys"))
{
pos[0] = -10015.6; pos[1] = -8564.0; pos[2] = 13.1;
}
else if (StrEqual(sMap, "c9m2_lots"))
{
pos[0] = 238.1; pos[1] = -1338.8; pos[2] = -148.9;
}
else if (StrEqual(sMap, "c10m1_caves"))
{
pos[0] = -11717.4; pos[1] = -14888.7; pos[2] = -198.5;
}
else if (StrEqual(sMap, "c10m2_drainage"))
{
pos[0] = -11135.1; pos[1] = -9126.9; pos[2] = -564.9;
}
else if (StrEqual(sMap, "c10m3_ranchhouse"))
{
pos[0] = -8308.3; pos[1] = -5547.5; pos[2] = 2.0;
}
else if (StrEqual(sMap, "c10m4_mainstreet"))
{
pos[0] = -3065.6; pos[1] = 135.5; pos[2] = 355.0;
}
else if (StrEqual(sMap, "c10m5_houseboat"))
{
pos[0] = 1963.1; pos[1] = 4729.9; pos[2] = -36.9;
}
else if (StrEqual(sMap, "c11m1_greenhouse"))
{
pos[0] = 6853.6; pos[1] = -681.1; pos[2] = 795.0;
}
else if (StrEqual(sMap, "c11m2_offices"))
{
pos[0] = 5123.5; pos[1] = 2613.8; pos[2] = 70.0;
}
else if (StrEqual(sMap, "c11m3_garage"))
{
pos[0] = -5373.3; pos[1] = -3080.7; pos[2] = 43.0;
}
else if (StrEqual(sMap, "c11m4_terminal"))
{
pos[0] = -370.8; pos[1] = 3580.5; pos[2] = 431.9;
}
else if (StrEqual(sMap, "c11m5_runway"))
{
pos[0] = -6714.3; pos[1] = 12058.9; pos[2] = 178.9;
}
else if (StrEqual(sMap, "c12m1_hilltop") || StrEqual(sMap, "C12m1_hilltop"))
{
pos[0] = -8043.8; pos[1] = -15147.0; pos[2] = 294.9;
}
else if (StrEqual(sMap, "c12m2_traintunnel") || StrEqual(sMap, "C12m2_traintunnel"))
{
pos[0] = -6649.4; pos[1] = -6801.1; pos[2] = 375.0;
}
else if (StrEqual(sMap, "c12m3_bridge") || StrEqual(sMap, "C12m3_bridge"))
{
pos[0] = -916.9; pos[1] = -10373.5; pos[2] = -38.1;
}
else if (StrEqual(sMap, "c12m4_barn") || StrEqual(sMap, "C12m4_barn"))
{
pos[0] = 7703.3; pos[1] = -11386.0; pos[2] = 466.8;
}
else if (StrEqual(sMap, "c12m5_cornfield") || StrEqual(sMap, "C12m5_cornfield"))
{
pos[0] = 10447.4; pos[1] = -391.5; pos[2] = -1.9;
}
else if (StrEqual(sMap, "c13m1_alpinecreek"))
{
pos[0] = -3048.7; pos[1] = -741.8; pos[2] = 101.8;
}
else if (StrEqual(sMap, "c13m2_southpinestream"))
{
pos[0] = 8778.0; pos[1] = 7157.1; pos[2] = 522.8;
}
else if (StrEqual(sMap, "c13m3_memorialbridge"))
{
pos[0] = -4420.4; pos[1] = -5145.5; pos[2] = 123.0;
}
else if (StrEqual(sMap, "c13m4_cutthroatcreek"))
{
pos[0] = -3396.6; pos[1] = -9301.5; pos[2] = 387.0;
}
else if (StrEqual(sMap, "l4d2_city17_01"))
{
pos[0] = 4000.7; pos[1] = -5344.0; pos[2] = -92.9;
}
else if (StrEqual(sMap, "l4d2_city17_02"))
{
pos[0] = 859.4; pos[1] = 2388.1; pos[2] = 79.0;
}
else if (StrEqual(sMap, "l4d2_city17_03"))
{
pos[0] = 4054.7; pos[1] = 802.5; pos[2] = 27.0;
}
else if (StrEqual(sMap, "l4d2_city17_04"))
{
pos[0] = -1755.2; pos[1] = 1942.3; pos[2] = -100.9;
}
else if (StrEqual(sMap, "l4d2_city17_05"))
{
pos[0] = 10122.1; pos[1] = 12351.0; pos[2] = -604.8;
}
else if (StrEqual(sMap, "srocchurch"))
{
pos[0] = 1139.018310; pos[1] = 1165.581909; pos[2] = 515.258483;
}
else if (StrEqual(sMap, "plaza_espana"))
{
pos[0] = -8265.963867; pos[1] = -9271.015625; pos[2] = 91.025924;
}
else if (StrEqual(sMap, "maria_cristina"))
{
pos[0] = -9940.217773; pos[1] = 6386.005859; pos[2] = -144.974075;
}
else if (StrEqual(sMap, "mnac"))
{
pos[0] = 9281.953125; pos[1] = 12409.876953; pos[2] = -4452.974121;
}
else if (StrEqual(sMap, "l4d2_stadium1_apartment"))
{
pos[0] = -218.690124; pos[1] = 1203.255737; pos[2] = 14.774141;
}
else if (StrEqual(sMap, "l4d2_stadium2_riverwalk"))
{
pos[0] = -1257.007568; pos[1] = 422.781219; pos[2] = -204.974075;
}
else if (StrEqual(sMap, "l4d2_vs_stadium2_riverwalk"))
{
pos[0] = -1257.007568; pos[1] = 422.781219; pos[2] = -204.974075;
}
else if (StrEqual(sMap, "l4d2_stadium3_city1"))
{
pos[0] = 1620.423583; pos[1] = 6824.679199; pos[2] = -397.864837;
}
else if (StrEqual(sMap, "l4d2_stadium4_city2"))
{
pos[0] = 624.662475; pos[1] = -558.739562; pos[2] = -535.213989;
}
else if (StrEqual(sMap, "l4d2_stadium5_stadium"))
{
pos[0] = 7627.667968; pos[1] = -5058.360839; pos[2] = 39.025917;
}
else
IsAllowed = false;
if (!IsAllowed)
{
KeyValues kv = new KeyValues("data");
kv.ImportFromFile(datafilepath);
if (kv.JumpToKey(sMap))
{
kv.GetVector("position", pos);
IsAllowed = true;
}
delete kv;
}
if (IsAllowed)
TeleportEntity(client, pos, NULL_VECTOR, NULL_VECTOR);
else
TeleportEntity(client, g_SpawnPos, NULL_VECTOR, NULL_VECTOR);
}
public Action CMD_RecordCoord(int client, int args)
{
if (!client)
return Plugin_Handled;
if (!SetTeleportEndPoint(client))
{
ReplyToCommand(client, "[VERSUS TOOL] Coordinate Error");
return Plugin_Handled;
}
char sMap[64];
GetCurrentMap(sMap, sizeof(sMap));
g_pos[2] -= 8.0;
KeyValues kv = new KeyValues("data");
kv.ImportFromFile(datafilepath);
kv.JumpToKey(sMap, true);
kv.SetVector("position", g_pos);
kv.Rewind();
kv.ExportToFile(datafilepath);
delete kv;
PrintToChat(client, "\x01Текущие координаты \x03pos[0] = %.1f pos[1] = %.1f pos[2] = %.1f\x01 были сохранены в KeyValues для карты \x05%s", g_pos[0], g_pos[1], g_pos[2], sMap);
return Plugin_Handled;
}
public Action tmrStart(Handle timer)
{
g_iMap = 0;
ResetState();
int client;
for (int i = 1; i <= MaxClients; i++)
{
if (IsClientInGame(i) && GetClientTeam(i) == 2 && IsPlayerAlive(i))
{
client = i;
break;
}
}
if (client)
{
GetClientAbsOrigin(client, g_SpawnPos);
g_SpawnPos[2] += 25.0;
}
}
public void OnMapEnd()
{
g_iMap = 1;
ResetState();
}
void ResetState()
{
g_iRoundStart = 0;
g_iPlayerSpawn = 0;
if (g_iRoundStart < 1)
g_iCooldown = cvar_LockRoundOne.IntValue;
else
g_iCooldown = cvar_LockRoundTwo.IntValue;
}
public Action CMD_Coord(int client, int args)
{
if (!client)
return Plugin_Handled;
if (!SetTeleportEndPoint(client))
{
ReplyToCommand(client, "[VERSUS TOOL] Coordinate Error");
return Plugin_Handled;
}
char sMap[64];
GetCurrentMap(sMap, sizeof(sMap));
g_pos[2] -= 8.0;
PrintToChat(client, "\x01else if (StrEqual(sMap, \"\x04%s\x01\")){\x03pos[0] = %.1f; pos[1] = %.1f; pos[2] = %.1f;\x01}", sMap, g_pos[0], g_pos[1], g_pos[2]);
LogToFile(LOG, "Карта %s | координаты pos[0] = %.1f pos[1] = %.1f pos[2] = %.1f", sMap, g_pos[0], g_pos[1], g_pos[2]);
return Plugin_Handled;
}
bool SetTeleportEndPoint(int client)
{
float vAngles[3];
float vOrigin[3];
float vBuffer[3];
float vStart[3];
float Distance;
GetClientEyePosition(client,vOrigin);
GetClientEyeAngles(client, vAngles);
Handle g_trace = TR_TraceRayFilterEx(vOrigin, vAngles, MASK_SHOT, RayType_Infinite, Player_TraceFilter);
if (TR_DidHit(g_trace))
{
TR_GetEndPosition(vStart, g_trace);
GetVectorDistance(vOrigin, vStart, false);
Distance = -35.0;
GetAngleVectors(vAngles, vBuffer, NULL_VECTOR, NULL_VECTOR);
g_pos[0] = vStart[0] + (vBuffer[0]*Distance);
g_pos[1] = vStart[1] + (vBuffer[1]*Distance);
g_pos[2] = vStart[2] + (vBuffer[2]*Distance);
}
else
{
g_trace.Close();
return false;
}
g_trace.Close();
return true;
}
public bool Player_TraceFilter(int entity, int contentsMask)
{
return entity > MaxClients || !entity;
}