/* AMX Mod X - Script
*
* Admin Spectator ESP v1.5
* Copyright (C) 2006 by KoST
*
* This plugin along with its compiled version can de downloaded here:
* http://forums.alliedmods.net/showthread.php?t=23691
*
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
* or download here: http://www.gnu.org/licenses/gpl.txt
*
* In addition, as a special exception, the author gives permission to
* link the code of this program with the Half-Life Game Engine ("HL
* Engine") and Modified Game Libraries ("MODs") developed by Valve,
* L.L.C ("Valve"). You must obey the GNU General Public License in all
* respects for all of the code used other than the HL Engine and MODs
* from Valve. If you modify this file, you may extend this exception
* to your version of the file, but you are not obligated to do so. If
* you do not wish to do so, delete this exception statement from your
* version.
*/
//----------------------------------------------------------------------------------------------------------------------------
#include <amxmodx>
#include <fakemeta>
#define VERSION "1.5"
#define OFFSET_TEAM 114
// Feel free to change this flag.
#define ASESP_LEVEL_RCON ADMIN_KICK
enum
{
ESP_ON = 0,
ESP_LINE,
ESP_BOX,
ESP_NAME,
ESP_HEALTH_ARMOR,
ESP_WEAPON,
ESP_CLIP_AMMO,
ESP_DISTANCE,
ESP_TEAM_MATES,
ESP_AIM_VEC
};
new bool: bAdminOptions[ 33 ][ 10 ];
new bool: bAdmin[ 33 ], bool: bFirstPerson[ 33 ],
bool: bDucking[ 33 ], bool: bIsInMenu[ 33 ];
new g_pCvarESPEnabled, g_pCvarESPTimer,
g_pCvarESPAllowAll, g_pCvarESPDisableDefaultKeys;
new iTeamColors[ 4 ][ 3 ] =
{
{ 0, 0, 0 },
{ 150, 0, 0 },
{ 0, 0, 150 },
{ 0, 150 ,0 }
};
new iEspColors[ 5 ][ 3 ] =
{
{ 0, 255, 0 },
{ 100, 60, 60 },
{ 60, 60, 100 },
{ 255, 0, 255 },
{ 128, 128, 128 }
};
new iLaser;
new g_iDamageDoneTo[ 33 ], g_iViewTarget[ 33 ],
g_iSpectator[ 33 ];
new g_iMsgSayText;
new g_iMaxPlayers;
new iWeapons[ 30 ][ 10 ] =
{
"None", "P228", "Scout", "HE", "XM1014", "C4",
"MAC-10", "AUG", "Smoke", "Elite", "Fiveseven",
"UMP45", "SIG550", "Galil", "Famas", "USP", "Glock",
"AWP", "MP5", "M249", "M3", "M4A1", "TMP", "G3SG1",
"Flash", "Deagle", "SG552", "AK47", "Knife", "P90"
};
public plugin_init( )
{
register_plugin( "Admin Spectator ESP", VERSION, "KoST" );
server_print( "^n^tAdmin Spectator ESP v%s, Copyright (C) 2006 by KoST^n", VERSION );
register_clcmd( "esp_menu", "ESP_Menu", ASESP_LEVEL_RCON, "ESP menu mutatasa" )
register_clcmd( "say /esp_menu", "ESP_Menu", ASESP_LEVEL_RCON, "ESP menu mutatasa" )
register_clcmd( "esp_toggle", "ESP_Toggle", ASESP_LEVEL_RCON, "ESP KI/BE kapcsolasa" )
register_clcmd( "say /esp_toggle", "ESP_Toggle", ASESP_LEVEL_RCON, "ESP KI/BE kapcsolasa" )
register_clcmd( "esp_settings", "ESP_Settings", ASESP_LEVEL_RCON, " ESP Beallitasok" )
g_pCvarESPEnabled = register_cvar( "esp_enabled", "1" )
g_pCvarESPTimer = register_cvar( "esp_timer", "0.3" )
g_pCvarESPAllowAll = register_cvar( "esp_allow_all", "0" )
g_pCvarESPDisableDefaultKeys = register_cvar( "esp_disable_default_keys", "0" )
new g_pCvar = register_cvar( "esp_version", VERSION, FCVAR_SERVER | FCVAR_UNLOGGED | FCVAR_SPONLY )
set_pcvar_string( g_pCvar, VERSION )
register_forward( FM_PlayerPreThink, "Fw_PlayerPreThink" )
register_event( "StatusValue", "SpecTarget", "bd", "1=2" )
register_event( "SpecHealth2", "SpecTarget", "bd" )
register_event( "TextMsg", "SpecMode", "b", "2&#Spec_Mode" )
register_event( "Damage", "Damage", "b", "2!0", "3=0", "4!0" )
register_event( "ResetHUD", "ResetHUD", "be")
new iKeys = MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9
register_menucmd( register_menuid( "Admin Specator ESP" ), iKeys, "AdminSpectatorESP_Menu" )
g_iMsgSayText = get_user_msgid( "SayText" );
g_iMaxPlayers = get_maxplayers( )
// Start esp_timer for the first time.
set_task( 1.0, "ESP_Timer" )
}
public plugin_precache( )
iLaser = precache_model( "sprites/laserbeam.spr" );
public client_putinserver( id )
{
bFirstPerson[ id ] = false
if( ( get_user_flags( id ) & ASESP_LEVEL_RCON ) || get_pcvar_num( g_pCvarESPAllowAll ) == 1 )
{
bAdmin[ id ] = true
AdminOptions( id )
}
else
bAdmin[id]=false
}
AdminOptions( id )
{
for( new i = 0; i < 10; i++ )
bAdminOptions[ id ][ i ] = true
bAdminOptions[ id ][ ESP_TEAM_MATES ] = false
LoadData( id )
}
public ESP_Menu( id )
{
if( bAdmin[ id ] && get_pcvar_num( g_pCvarESPEnabled ) == 1 )
ShowESP_Menu( id )
}
ShowESP_Menu( id )
{
bIsInMenu[ id ] = true
new iOnOff[ 2 ][ ] =
{
{ "\rKI\w" },
{ "\yBE\w" }
};
new iText[ 2 ][ ] =
{
{ "(Hasznald az előre-hátramenet gombokat a KI/BE kapcsoláshoz)" },
{ "(Használd az esp_toggle parancsot, a kapcsoláshoz)" }
};
new iTextIndex = get_pcvar_num( g_pCvarESPDisableDefaultKeys )
if( iTextIndex!= 1 )
iTextIndex = 0
new iMenu[ 301 ];
new iKeys = MENU_KEY_0 | MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_5 | MENU_KEY_6 | MENU_KEY_7 | MENU_KEY_8 | MENU_KEY_9
formatex( iMenu, charsmax( iMenu ), "Admin Spectator ESP^n %s %s^n^n1. Vonal %s^n2. ESP Box %s^n3. Név %s^n4. Élet/Pajzs %s^n5. Fegyver %s^n6. Golyó/Tár %s^n7. Távolság %s^n8. Csapattársak mutatása %s^n9. Célzás figyelés %s^n^n0. Kilépés",
iOnOff[ bAdminOptions[ id ][ ESP_ON ] ], iText[ iTextIndex ], iOnOff[ bAdminOptions[ id ][ ESP_LINE ] ], iOnOff[ bAdminOptions[ id ][ ESP_BOX]], iOnOff[ bAdminOptions[ id ][ ESP_NAME ] ],
iOnOff[ bAdminOptions[ id ][ ESP_HEALTH_ARMOR ] ], iOnOff[ bAdminOptions[ id ][ ESP_WEAPON ] ], iOnOff[ bAdminOptions[ id ][ ESP_CLIP_AMMO ] ], iOnOff[ bAdminOptions[ id ][ ESP_DISTANCE ] ],
iOnOff[ bAdminOptions[ id ][ ESP_TEAM_MATES ] ], iOnOff[ bAdminOptions[ id ][ ESP_AIM_VEC ] ] )
show_menu( id, iKeys, iMenu )
return PLUGIN_HANDLED;
}
public ESP_Toggle( id )
{
if( bAdmin[ id ] && get_pcvar_num( g_pCvarESPEnabled ) == 1 )
ESP_Status( id, !bAdminOptions[ id ][ 0 ] )
}
ESP_Status( id, bool: bOn )
{
if( bOn )
{
bAdminOptions[ id ][ 0 ] = true
if( !bIsInMenu[ id ] )
ChatColor( id, "!g[Admin Spec ESP v%s] !yBEKAPCSOLVA", VERSION )
if( bIsInMenu[ id ] )
ShowESP_Menu( id )
}
else
{
bAdminOptions[ id ][ 0 ] = false
if( !bIsInMenu[ id ] )
ChatColor( id, "!g[Admin Spec ESP v%s] !yKIKAPCSOLVA", VERSION )
if( bIsInMenu[ id ] )
ShowESP_Menu( id )
}
}
public ESP_Settings( id )
{
if( bAdmin[ id ] )
{
new iOut[ 11 ];
read_argv( 1, iOut, charsmax( iOut ) )
new iLen = strlen( iOut )
for( new i = 0; i < iLen; i++ )
{
if( iOut[ i ] == '1' )
bAdminOptions[ id ][ i ] = true
else
bAdminOptions[ id ][ i ] = false
}
}
}
public Fw_PlayerPreThink( id )
{
if( !is_user_connected( id ) )
return FMRES_IGNORED;
static iButton;
iButton = pev( id, pev_button )
if( iButton == 0 )
return FMRES_IGNORED;
static iOldButton;
iOldButton = pev( id, pev_oldbuttons )
if( iButton & IN_DUCK )
bDucking[ id ] = true
else
bDucking[ id ] = false
if( ( get_pcvar_num( g_pCvarESPEnabled ) ==1 ) && ( get_pcvar_num( g_pCvarESPDisableDefaultKeys )!= 1 ) )
{
if( bAdmin[ id ] )
{
if( bFirstPerson[ id ] && !is_user_alive( id ) )
{
if( ( iButton & IN_RELOAD ) && !( iOldButton & IN_RELOAD ) )
ShowESP_Menu( id )
if( ( iButton & IN_FORWARD ) && !( iOldButton & IN_FORWARD ) && !bAdminOptions[ id ][ 0 ] )
ESP_Status( id, true )
if( ( iButton & IN_BACK ) && !( iOldButton & IN_BACK ) && bAdminOptions[ id ][ 0 ] )
ESP_Status( id, false )
}
}
}
return FMRES_HANDLED;
}
public SpecTarget( id )
{
if( id > 0 )
{
new iTarget = read_data( 2 )
if( iTarget!= 0 )
g_iSpectator[ id ] = iTarget
}
return PLUGIN_CONTINUE;
}
public SpecMode( id )
{
new iSpecMode[ 12 ];
read_data( 2, iSpecMode, charsmax( iSpecMode ) );
if( equal( iSpecMode, "#Spec_Mode4" ) )
bFirstPerson[ id ] = true
else
bFirstPerson[ id ] = false
return PLUGIN_CONTINUE;
}
public Damage( id )
{
if( id > 0 )
{
new iAttacker = get_user_attacker( id )
if( iAttacker > 0 && iAttacker <= g_iMaxPlayers )
{
if( g_iViewTarget[ iAttacker ] == id )
g_iDamageDoneTo[ iAttacker ] = id
}
}
return PLUGIN_CONTINUE;
}
public ResetHUD( id )
g_iSpectator[ id ] = 0
public AdminSpectatorESP_Menu( id, iKey )
{
if( iKey == 9 )
{
bIsInMenu[ id ] = false
return PLUGIN_HANDLED;
}
if( bAdminOptions[ id ][ iKey + 1 ] )
bAdminOptions[ id ][ iKey + 1 ] = false
else
bAdminOptions[ id ][ iKey + 1 ] = true
ShowESP_Menu( id )
return PLUGIN_HANDLED;
}
SaveData( id )
{
if( bAdmin[ id ] )
{
new uAuthId[ 35 ];
get_user_authid( id, uAuthId, charsmax( uAuthId ) );
new iTmp[ 11 ];
for( new s = 0; s < 10; s++ )
{
if( bAdminOptions[ id ][ s ] )
iTmp[ s ] = '1';
else
iTmp[ s ] = '0';
}
iTmp[ 10 ] = 0
// server_print( "STEAM-ID: %s OPTIONS: %s", uAuthId, iTmp );
new iKey[ 41 ];
formatex( iKey, charsmax( iKey ), "ESP_%s", uAuthId )
set_vaultdata( iKey, iTmp )
}
}
LoadData( id )
{
if( bAdmin[ id ] )
{
new iData[ 11 ], uAuthId[ 35 ];
get_user_authid( id, uAuthId, charsmax( uAuthId ) );
new iKey[ 41 ];
formatex( iKey, charsmax( iKey ), "ESP_%s", uAuthId )
get_vaultdata( iKey, iData, charsmax( iData ) )
if( strlen( iData ) > 0 )
{
for( new s = 0; s < 10; s++ )
{
if( iData[ s ] == '1' )
bAdminOptions[ id ][ s ] = true
else
bAdminOptions[ id ][ s ] = false
}
}
}
}
public DrawAimVector( i, s, iLen )
{
new iTmp[ 3 ];
get_user_origin( s, iTmp, 1 )
new Float: fVec[ 3 ];
new Float: fEndPoint[ 3 ];
IVecFVec( iTmp, fVec )
fVec[ 2 ]-= 6.0
velocity_by_aim( s, iLen, fEndPoint )
AddVec( fEndPoint, fVec )
Make_TE_BEAMPOINTS( i, 4, fVec, fEndPoint, 10, 255 )
return PLUGIN_CONTINUE;
}
public ESP_Timer( )
{
if( get_pcvar_num( g_pCvarESPEnabled )!= 1 )
{
set_task( 1.0, "ESP_Timer" ) // Check for reactivation in 1 sec intervals.
return PLUGIN_CONTINUE;
}
static iSpectatorId, Float: fMyOrigin[ 3 ], iMyTeam, Float: fSmallestAngle, iSmallestId, Float: fX_Pos, Float: fY_Pos, Float: fDist, iTargetTeam, Float: fTargetOrigin[ 3 ], Float: fDistance, iWidth,
Float: fMiddle[ 3 ], Float: fHitPoint[ 3 ], Float: fDistanceToHitPoint, Float: fScaledBoneLen, Float: fScaledBoneWidth, Float: fBone_Start[ 3 ], Float: fBone_End[ 3 ], Float: fOffSet_Vector[ 3 ],
Float: fEyeLevel[ 3 ], Float: fDistanceTargetHitPoint, iActualBright, iColor, Float: fRet[ 2 ], Float: fX_Angle, iName[ 37 ], iHealthAndArmor[ 25 ], iClipAndAmmo[ 22 ], iWeaponId, iWeaponName[21];
for( new i = 1; i <= g_iMaxPlayers; i++ )
{
if( bAdminOptions[ i ][ ESP_ON ] && bFirstPerson[ i ] && is_user_connected( i ) && bAdmin[ i ] && ( !is_user_alive( i ) ) && ( g_iSpectator[ i ] > 0 ) && is_user_alive( g_iSpectator[ i ] ) )
{
iSpectatorId = g_iSpectator[ i ];
pev( i, pev_origin, fMyOrigin ) // Get origin of spectating admin.
// Get team of spectated.
iMyTeam = get_pdata_int( iSpectatorId, OFFSET_TEAM )
iSmallestId = 0;
fSmallestAngle = 180.0;
// X,Y of hudmessage.
fX_Pos = 2.0
fY_Pos = 2.0
for( new s = 1; s <= g_iMaxPlayers; s++ )
{
if( is_user_alive( s ) )
{
iTargetTeam = get_pdata_int( s, OFFSET_TEAM )
if( !( iTargetTeam == 3 ) )
{
if( iSpectatorId!= s )
{
if( ( ( iMyTeam != iTargetTeam && ( iTargetTeam == 1 || iTargetTeam == 2 ) ) || bAdminOptions[ i ][ ESP_TEAM_MATES ] ) )
{
// Get origin of target.
pev( s, pev_origin, fTargetOrigin )
// Get distance from me to target.
fDistance = vector_distance( fMyOrigin, fTargetOrigin )
if( bAdminOptions[ i ][ ESP_LINE ] )
{
if( fDistance < 2040.0 )
iWidth = ( 255 - floatround( fDistance / 8.0 ) ) / 3
else
iWidth = 1
Make_TE_BEAMENTPOINT( i, fTargetOrigin, iWidth, iTargetTeam )
}
// Get vector from me to target.
SubVec( fTargetOrigin, fMyOrigin, fMiddle )
// Trace from me to target, getting hitpoint.
engfunc( EngFunc_TraceLine, fMyOrigin, fTargetOrigin, 1, -1, 0 )
get_tr2( 0, TR_vecEndPos, fHitPoint )
// Get distance from me to hitpoint (nearest wall).
fDistanceToHitPoint = vector_distance( fMyOrigin, fHitPoint )
// Scale.
if( bDucking[ iSpectatorId ] )
fScaledBoneLen = fDistanceToHitPoint / fDistance * ( 50.0 - 18.0 )
else
fScaledBoneLen = fDistanceToHitPoint / fDistance * 50.0
fScaledBoneLen = fDistanceToHitPoint / fDistance * 50.0
fScaledBoneWidth = fDistanceToHitPoint / fDistance * 150.0
// Get the point 10.0 units away from wall.
Normalize( fMiddle, fOffSet_Vector, fDistanceToHitPoint - 10.0 ) // Offset from wall.
// Set to eye level.
CopyVec( fMyOrigin, fEyeLevel )
if( bDucking[ iSpectatorId ] )
fEyeLevel[ 2 ]+= 12.3
else
fEyeLevel[ 2 ]+= 17.5
AddVec( fOffSet_Vector, fEyeLevel )
// Start and end of green box.
CopyVec( fOffSet_Vector, fBone_Start )
CopyVec( fOffSet_Vector, fBone_End )
fBone_End[ 2 ]-= fScaledBoneLen
fDistanceTargetHitPoint = fDistance - fDistanceToHitPoint;
iActualBright = 255;
if( bAdminOptions[ i ][ ESP_BOX ] )
{
if( fDistanceTargetHitPoint < 2040.0 )
iActualBright = ( 255 - floatround( fDistanceTargetHitPoint / 12.0 ) )
else
iActualBright = 85
if( fDistanceToHitPoint!= fDistance )
iColor = 0
else
iColor = iTargetTeam
if( g_iDamageDoneTo[ iSpectatorId ] == s )
{
iColor = 3
g_iDamageDoneTo[ iSpectatorId ] = 0
}
Make_TE_BEAMPOINTS( i, iColor, fBone_Start, fBone_End, floatround( fScaledBoneWidth ), iActualBright )
}
if( bAdminOptions[ i ][ ESP_AIM_VEC ] || bAdminOptions[ i ][ ESP_NAME ] || bAdminOptions[ i ][ ESP_HEALTH_ARMOR ] || bAdminOptions[ i ][ ESP_WEAPON ] || bAdminOptions[ i ][ ESP_CLIP_AMMO ] || bAdminOptions[ i ][ ESP_DISTANCE ] )
{
fX_Angle = GetScreenPos( iSpectatorId, fMiddle, fRet )
// Find target with the smallest distance to crosshair (on x-axis).
if( fSmallestAngle > floatabs( fX_Angle ) )
{
if( floatabs( fX_Angle )!= 0.0 )
{
fSmallestAngle = floatabs( fX_Angle )
g_iViewTarget[ iSpectatorId ] = s
iSmallestId = s // Store nearest target id.
fX_Pos = fRet[ 0 ] // And x, y coordinates of hudmessage.
fY_Pos = fRet[ 1 ]
fDist = fDistance
}
}
}
}
}
}
}
}
if( !is_user_alive( iSmallestId ) )
{
iSmallestId = 0
fX_Pos =-1.0
}
if( iSmallestId > 0 && bAdminOptions[ i ][ ESP_AIM_VEC ] )
DrawAimVector( i, iSmallestId, 2000 )
if( fX_Pos > 0.0 && fX_Pos <= 1.0 && fY_Pos > 0.0 && fY_Pos <= 1.0 )
{
set_hudmessage( 255, 255, 0, floatabs( fX_Pos ), floatabs( fY_Pos ), 0, 0.0, get_pcvar_float( g_pCvarESPTimer ), 0.0, 0.0, -1 )
iName[ 0 ] = '^0'
if( bAdminOptions[ i ][ ESP_NAME ] )
{
new uName[ 33 ];
get_user_name( iSmallestId, uName, charsmax( uName ) )
formatex( iName, charsmax( iName ), "[%s]^n", uName )
}
iHealthAndArmor[ 0 ] = '^0'
if( bAdminOptions[ i ][ ESP_HEALTH_ARMOR ] )
{
new iHP = get_user_health( iSmallestId )
new iArmor = get_user_armor( iSmallestId )
formatex( iHealthAndArmor, charsmax( iHealthAndArmor ), "Élet: %d Pajzs: %d^n", iHP, iArmor )
}
iWeaponName[ 0 ] = '^0'
if( bAdminOptions[ i ][ ESP_WEAPON ] )
{
if( ( iWeaponId - 1 ) < 0 || ( iWeaponId - 1 ) > 29 )
iWeaponId = 1
formatex( iWeaponName, charsmax( iWeaponName ), "Fegyver: %s^n", iWeapons[ iWeaponId - 1 ] )
}
iClipAndAmmo[ 0 ] = '^0'
if( bAdminOptions[ i ][ ESP_CLIP_AMMO ] )
{
new iClip, iAmmo;
iWeaponId = get_user_weapon( iSmallestId, iClip, iAmmo )
formatex( iClipAndAmmo, charsmax( iClipAndAmmo ), "Golyó: %d Tár: %d^n", iClip, iAmmo )
}
new iStrDist[ 19 ];
if( bAdminOptions[ i ][ ESP_DISTANCE ] )
formatex( iStrDist, charsmax( iStrDist ), "Távolság: %d^n", floatround( fDist ) )
show_hudmessage( i, "%s%s%s%s%s", iName, iHealthAndArmor, iWeaponName, iClipAndAmmo, iStrDist)
}
}
}
set_task( get_pcvar_float( g_pCvarESPTimer ), "ESP_Timer" ) // Keep it going.
return PLUGIN_CONTINUE;
}
Float: GetScreenPos( id, Float: fMeToTarget[ 3 ], Float: fRet[ 2 ] )
{
new Float: fAim1[ 3 ];
velocity_by_aim( id, 1, fAim1 ) // Get aim vector.
new Float: fAim2[ 3 ];
CopyVec( fAim1, fAim2 ) // Make backup copy of fAim1.
fAim1[ 2 ] = 0.0 // Project aim vector vertically to x,y plane.
new Float: fTarget[ 3 ];
CopyVec( fMeToTarget, fTarget )
fTarget[ 2 ] = 0.0 // Project target vector vertically to x,y plane.
// Both fAim1 and fTarget are in the x,y plane, so angle can be calculated.
new Float: fX_Angle;
new Float: fX_Pos = GetScreenPos_X( fTarget, fAim1, fX_Angle ) // Get the x coordinate of hudmessage..
new Float: fY_Pos = GetScreenPos_Y( fMeToTarget, fAim2 ) // Get the y coordinate of hudmessage..
fRet[ 0 ]= fX_Pos
fRet[ 1 ]= fY_Pos
return fX_Angle;
}
Float: GetScreenPos_X( Float: fTarget[ 3 ], Float: fAim[ 3 ], &Float: fX_Angle )
{
new Float: fX_Angle1 = floatacos( VectorProduct( fAim, fTarget ) / ( GetVecLen ( fAim ) * GetVecLen( fTarget ) ), 1 ) // Get angle between vectors.
new Float: fX_Pos;
if( ScalarTripleProduct( fAim, fTarget ) < 0.0 )
fX_Angle1*=-1
if( fX_Angle1>=-45.0 && fX_Angle1<= 45.0 )
{
fX_Pos = 1.0 - ( floattan( fX_Angle1, degrees ) + 1.0 ) / 2.0
fX_Angle = fX_Angle1
return fX_Pos;
}
fX_Angle = 0.0
return -2.0
}
Float: GetScreenPos_Y( Float: fTarget[ 3 ], Float: fAim[ 3 ] )
{
new Float: fTarget1[ 3 ]
// Rotate vector about z-axis directly over the direction vector (to get height angle);
RotateVectorZ( fTarget, fAim, fTarget1 )
// Get angle between aim vector and target vector.
new Float: fY_Angle = floatacos( VectorProduct( fAim, fTarget1 ) / ( GetVecLen( fAim ) * GetVecLen( fTarget1 ) ), 1 ) // Get angle between vectors.
new Float: fY_Pos;
new Float: fNormTarget[ 3 ], Float: fNormAim[ 3 ];
// Get normalized target and aim vectors.
Normalize( fTarget, fNormTarget, 1.0 )
Normalize( fAim, fNormAim, 1.0 )
// Since the 'angle between vectors' formula returns always positive values.
if( fNormTarget[ 2 ] < fNormAim[ 2 ] )
fY_Angle*=-1
if( fY_Angle>=-45.0 && fY_Angle<= 45.0 )
{
fY_Pos = 1.0 - ( floattan( fY_Angle, degrees ) + 1.0 ) / 2.0 // Calulate fY_Pos of hudmessage.
if( fY_Pos>= 0.0 && fY_Pos<= 1.0 )
return fY_Pos;
}
return -2.0
}
// Vector Operations ---------------------------------------------------------------------------------------------------------
Float: GetVecLen( Float: fVec[ 3 ] )
{
new Float: fVecNull[ 3 ] = { 0.0, 0.0, 0.0 }
new Float: fLen = vector_distance( fVec, fVecNull )
return fLen;
}
Float: ScalarTripleProduct( Float: fA[ 3 ], Float: fB[ 3 ] )
{
new Float: fUp[ 3 ] = { 0.0, 0.0, 1.0 }
new Float: fRet[ 3 ];
fRet[ 0 ] = fA[ 1 ] * fB[ 2 ] - fA[ 2 ] * fB[ 1 ]
fRet[ 1 ] = fA[ 2 ] * fB[ 0 ] - fA[ 0 ] * fB[ 2 ]
fRet[ 2 ] = fA[ 0 ] * fB[ 1 ] - fA[ 1 ] * fB[ 0 ]
return VectorProduct( fRet, fUp )
}
Normalize( Float: fVec[ 3 ], Float: fRet[ 3 ],Float: fMultiplier )
{
new Float: fLen = GetVecLen( fVec )
CopyVec( fVec, fRet )
fRet[ 0 ]/= fLen
fRet[ 1 ]/= fLen
fRet[ 2 ]/= fLen
fRet[ 0 ]*= fMultiplier
fRet[ 1 ]*= fMultiplier
fRet[ 2 ]*= fMultiplier
}
RotateVectorZ( Float: fVec[ 3 ], Float: fDirection[ 3 ], Float: fRet[ 3 ] )
{
// Rotates vector about z-axis.
new Float: fTmp[ 3 ];
CopyVec( fVec, fTmp )
fTmp[ 2 ] = 0.0
new Float: fDestLen = GetVecLen( fTmp )
CopyVec( fDirection, fTmp )
fTmp[ 2 ] = 0.0
new Float: fTmp2[ 3 ];
Normalize( fTmp, fTmp2, fDestLen )
fTmp2[ 2 ] = fVec[ 2 ]
CopyVec( fTmp2, fRet )
}
Float: VectorProduct( Float: fVec1[ 3 ], Float: fVec2[ 3 ] )
return fVec1[ 0 ] * fVec2[ 0 ] + fVec1[ 1 ] * fVec2[ 1 ] + fVec1[ 2 ] * fVec2[ 2 ]
CopyVec( Float: fVec[ 3 ], Float: fRet[ 3 ] )
{
fRet[ 0 ] = fVec[ 0 ]
fRet[ 1 ] = fVec[ 1 ]
fRet[ 2 ] = fVec[ 2 ]
}
SubVec( Float: fVec1[ 3 ], Float: fVec2[ 3 ], Float: fRet[ 3 ] )
{
fRet[ 0 ] = fVec1[ 0 ] - fVec2[ 0 ]
fRet[ 1 ] = fVec1[ 1 ] - fVec2[ 1 ]
fRet[ 2 ] = fVec1[ 2 ] - fVec2[ 2 ]
}
AddVec( Float: fVec1[ 3 ], Float: fVec2[ 3 ] )
{
fVec1[ 0 ]+= fVec2[ 0 ]
fVec1[ 1 ]+= fVec2[ 1 ]
fVec1[ 2 ]+= fVec2[ 2 ]
}
// Temporary Entities --------------------------------------------------------------------------------------------------------
// All messages are sent with MSG_ONE_UNRELIABLE flag to avoid overflow in case of very low esp_timer setting and much targets.
Make_TE_BEAMENTPOINT( id, Float: fTargetOrigin[ 3 ], iWidth, iTargetTeam )
{
message_begin( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, { 0, 0, 0 }, id )
write_byte( 1 )
write_short( id )
write_coord( floatround( fTargetOrigin[ 0 ] ) )
write_coord( floatround( fTargetOrigin[ 1 ] ) )
write_coord( floatround( fTargetOrigin[ 2 ] ) )
write_short( iLaser ) // Sprite index.
write_byte( 1 ) // Starting frame.
write_byte( 1 ) // Frame rate in 0.1's.
write_byte( floatround( get_pcvar_float( g_pCvarESPTimer ) *10 ) ) // Life in 0.1's.
write_byte( iWidth ) // Line width in 0.1's.
write_byte( 0 ) // Noise amplitude in 0.01's.
write_byte( iTeamColors[ iTargetTeam ][ 0 ] )
write_byte( iTeamColors[ iTargetTeam ][ 1 ] )
write_byte( iTeamColors[ iTargetTeam ][ 2 ] )
write_byte( 255 )
write_byte( 0 )// Scroll speed in 0.1's.
message_end( )
}
Make_TE_BEAMPOINTS( id, iColor, Float: fVec1[ 3 ], Float: fVec2[ 3 ], iWidth, iBrightness )
{
message_begin( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, { 0, 0, 0 }, id )
write_byte( 0 )
write_coord( floatround( fVec1[ 0 ] ) ) // Start position.
write_coord( floatround( fVec1[ 1 ] ) )
write_coord( floatround( fVec1[ 2 ] ) )
write_coord( floatround( fVec2[ 0 ] ) ) // End position.
write_coord( floatround( fVec2[ 1 ] ) )
write_coord( floatround( fVec2[ 2 ] ) )
write_short( iLaser ) // Sprite index.
write_byte( 3 ) // Starting frame.
write_byte( 0 ) // Frame rate in 0.1's.
write_byte( floatround( get_pcvar_float( g_pCvarESPTimer ) *10 ) ) // Life in 0.1's.
write_byte( iWidth ) // Line width in 0.1's.
write_byte( 0 ) // Noise amplitude in 0.01's.
write_byte( iEspColors[ iColor ][ 0 ] )
write_byte( iEspColors[ iColor ][ 1 ] )
write_byte( iEspColors[ iColor ][ 2 ] )
write_byte( iBrightness ) // Brightness.
write_byte( 0 ) // Scroll speed in 0.1's.
message_end( )
}
public client_disconnect( id )
{
SaveData( id )
bAdmin[ id ] = false
g_iSpectator[ id ] = 0
}
stock ChatColor( id, szInput[ ], any:... )
{
new iCount = 1, g_iPlayers[ 32 ];
static iMsgId[ 191 ];
vformat( iMsgId, 190, szInput, 3 );
replace_all( iMsgId, 190, "!y", "^1" ); // Default Color
replace_all( iMsgId, 190, "!g", "^4" ); // Green Color
replace_all( iMsgId, 190, "!team", "^3" ); // Team Color
if( id )
g_iPlayers[ 0 ] = id;
else
get_players( g_iPlayers, iCount, "ch" );
{
for( new i = 0; i < iCount; i++ )
{
if( is_user_connected( g_iPlayers[ i ] ) )
{
message_begin( MSG_ONE_UNRELIABLE, g_iMsgSayText, _, g_iPlayers[ i ] );
write_byte( g_iPlayers[ i ] );
write_string( iMsgId );
message_end( );
}
}
}
}