HLMOD.HU Forrás Megtekintés - www.hlmod.hu
  1. /* AMX Mod X - Script
  2. *
  3. * Admin Spectator ESP v1.5
  4. * Copyright (C) 2006 by KoST
  5. *
  6. * This plugin along with its compiled version can de downloaded here:
  7. * http://forums.alliedmods.net/showthread.php?t=23691
  8. *
  9. *
  10. * This program is free software; you can redistribute it and/or
  11. * modify it under the terms of the GNU General Public License
  12. * as published by the Free Software Foundation; either version 2
  13. * of the License, or (at your option) any later version.
  14. *
  15. * This program is distributed in the hope that it will be useful,
  16. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  17. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  18. * GNU General Public License for more details.
  19. *
  20. * You should have received a copy of the GNU General Public License
  21. * along with this program; if not, write to the Free Software
  22. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  23. * or download here: http://www.gnu.org/licenses/gpl.txt
  24. *
  25. * In addition, as a special exception, the author gives permission to
  26. * link the code of this program with the Half-Life Game Engine ("HL
  27. * Engine") and Modified Game Libraries ("MODs") developed by Valve,
  28. * L.L.C ("Valve"). You must obey the GNU General Public License in all
  29. * respects for all of the code used other than the HL Engine and MODs
  30. * from Valve. If you modify this file, you may extend this exception
  31. * to your version of the file, but you are not obligated to do so. If
  32. * you do not wish to do so, delete this exception statement from your
  33. * version.
  34. */
  35. //----------------------------------------------------------------------------------------------------------------------------
  36.  
  37. #include <amxmodx>
  38. #include <fakemeta>
  39.  
  40. #define VERSION "1.5"
  41.  
  42. #define OFFSET_TEAM 114
  43.  
  44. // Feel free to change this flag.
  45. #define ASESP_LEVEL_RCON ADMIN_KICK
  46.  
  47. enum
  48. {
  49. ESP_ON = 0,
  50. ESP_LINE,
  51. ESP_BOX,
  52. ESP_NAME,
  53. ESP_HEALTH_ARMOR,
  54. ESP_WEAPON,
  55. ESP_CLIP_AMMO,
  56. ESP_DISTANCE,
  57. ESP_TEAM_MATES,
  58. ESP_AIM_VEC
  59. };
  60.  
  61. new bool: bAdminOptions[ 33 ][ 10 ];
  62.  
  63. new bool: bAdmin[ 33 ], bool: bFirstPerson[ 33 ],
  64. bool: bDucking[ 33 ], bool: bIsInMenu[ 33 ];
  65.  
  66. new g_pCvarESPEnabled, g_pCvarESPTimer,
  67. g_pCvarESPAllowAll, g_pCvarESPDisableDefaultKeys;
  68.  
  69. new iTeamColors[ 4 ][ 3 ] =
  70. {
  71. { 0, 0, 0 },
  72. { 150, 0, 0 },
  73. { 0, 0, 150 },
  74. { 0, 150 ,0 }
  75. };
  76.  
  77. new iEspColors[ 5 ][ 3 ] =
  78. {
  79. { 0, 255, 0 },
  80. { 100, 60, 60 },
  81. { 60, 60, 100 },
  82. { 255, 0, 255 },
  83. { 128, 128, 128 }
  84. };
  85.  
  86. new iLaser;
  87.  
  88. new g_iDamageDoneTo[ 33 ], g_iViewTarget[ 33 ],
  89. g_iSpectator[ 33 ];
  90.  
  91. new g_iMsgSayText;
  92.  
  93. new g_iMaxPlayers;
  94.  
  95. new iWeapons[ 30 ][ 10 ] =
  96. {
  97. "None", "P228", "Scout", "HE", "XM1014", "C4",
  98. "MAC-10", "AUG", "Smoke", "Elite", "Fiveseven",
  99. "UMP45", "SIG550", "Galil", "Famas", "USP", "Glock",
  100. "AWP", "MP5", "M249", "M3", "M4A1", "TMP", "G3SG1",
  101. "Flash", "Deagle", "SG552", "AK47", "Knife", "P90"
  102. };
  103.  
  104. public plugin_init( )
  105. {
  106. register_plugin( "Admin Spectator ESP", VERSION, "KoST" );
  107. server_print( "^n^tAdmin Spectator ESP v%s, Copyright (C) 2006 by KoST^n", VERSION );
  108.  
  109. register_clcmd( "esp_menu", "ESP_Menu", ASESP_LEVEL_RCON, "ESP menu mutatasa" )
  110. register_clcmd( "say /esp_menu", "ESP_Menu", ASESP_LEVEL_RCON, "ESP menu mutatasa" )
  111.  
  112. register_clcmd( "esp_toggle", "ESP_Toggle", ASESP_LEVEL_RCON, "ESP KI/BE kapcsolasa" )
  113. register_clcmd( "say /esp_toggle", "ESP_Toggle", ASESP_LEVEL_RCON, "ESP KI/BE kapcsolasa" )
  114.  
  115. register_clcmd( "esp_settings", "ESP_Settings", ASESP_LEVEL_RCON, " ESP Beallitasok" )
  116.  
  117. g_pCvarESPEnabled = register_cvar( "esp_enabled", "1" )
  118. g_pCvarESPTimer = register_cvar( "esp_timer", "0.3" )
  119. g_pCvarESPAllowAll = register_cvar( "esp_allow_all", "0" )
  120. g_pCvarESPDisableDefaultKeys = register_cvar( "esp_disable_default_keys", "0" )
  121.  
  122. new g_pCvar = register_cvar( "esp_version", VERSION, FCVAR_SERVER | FCVAR_UNLOGGED | FCVAR_SPONLY )
  123. set_pcvar_string( g_pCvar, VERSION )
  124.  
  125. register_forward( FM_PlayerPreThink, "Fw_PlayerPreThink" )
  126.  
  127. register_event( "StatusValue", "SpecTarget", "bd", "1=2" )
  128. register_event( "SpecHealth2", "SpecTarget", "bd" )
  129. register_event( "TextMsg", "SpecMode", "b", "2&#Spec_Mode" )
  130. register_event( "Damage", "Damage", "b", "2!0", "3=0", "4!0" )
  131. register_event( "ResetHUD", "ResetHUD", "be")
  132.  
  133. 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
  134. register_menucmd( register_menuid( "Admin Specator ESP" ), iKeys, "AdminSpectatorESP_Menu" )
  135.  
  136. g_iMsgSayText = get_user_msgid( "SayText" );
  137.  
  138. g_iMaxPlayers = get_maxplayers( )
  139.  
  140. // Start esp_timer for the first time.
  141. set_task( 1.0, "ESP_Timer" )
  142. }
  143.  
  144. public plugin_precache( )
  145. iLaser = precache_model( "sprites/laserbeam.spr" );
  146.  
  147. public client_putinserver( id )
  148. {
  149. bFirstPerson[ id ] = false
  150.  
  151. if( ( get_user_flags( id ) & ASESP_LEVEL_RCON ) || get_pcvar_num( g_pCvarESPAllowAll ) == 1 )
  152. {
  153. bAdmin[ id ] = true
  154. AdminOptions( id )
  155. }
  156. else
  157. bAdmin[id]=false
  158. }
  159.  
  160. AdminOptions( id )
  161. {
  162. for( new i = 0; i < 10; i++ )
  163. bAdminOptions[ id ][ i ] = true
  164.  
  165. bAdminOptions[ id ][ ESP_TEAM_MATES ] = false
  166. LoadData( id )
  167. }
  168.  
  169. public ESP_Menu( id )
  170. {
  171. if( bAdmin[ id ] && get_pcvar_num( g_pCvarESPEnabled ) == 1 )
  172. ShowESP_Menu( id )
  173. }
  174.  
  175. ShowESP_Menu( id )
  176. {
  177. bIsInMenu[ id ] = true
  178.  
  179. new iOnOff[ 2 ][ ] =
  180. {
  181. { "\rKI\w" },
  182. { "\yBE\w" }
  183. };
  184.  
  185. new iText[ 2 ][ ] =
  186. {
  187. { "(Hasznald az előre-hátramenet gombokat a KI/BE kapcsoláshoz)" },
  188. { "(Használd az esp_toggle parancsot, a kapcsoláshoz)" }
  189. };
  190.  
  191. new iTextIndex = get_pcvar_num( g_pCvarESPDisableDefaultKeys )
  192. if( iTextIndex!= 1 )
  193. iTextIndex = 0
  194.  
  195. new iMenu[ 301 ];
  196. 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
  197.  
  198. 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",
  199. iOnOff[ bAdminOptions[ id ][ ESP_ON ] ], iText[ iTextIndex ], iOnOff[ bAdminOptions[ id ][ ESP_LINE ] ], iOnOff[ bAdminOptions[ id ][ ESP_BOX]], iOnOff[ bAdminOptions[ id ][ ESP_NAME ] ],
  200. iOnOff[ bAdminOptions[ id ][ ESP_HEALTH_ARMOR ] ], iOnOff[ bAdminOptions[ id ][ ESP_WEAPON ] ], iOnOff[ bAdminOptions[ id ][ ESP_CLIP_AMMO ] ], iOnOff[ bAdminOptions[ id ][ ESP_DISTANCE ] ],
  201. iOnOff[ bAdminOptions[ id ][ ESP_TEAM_MATES ] ], iOnOff[ bAdminOptions[ id ][ ESP_AIM_VEC ] ] )
  202.  
  203. show_menu( id, iKeys, iMenu )
  204.  
  205. return PLUGIN_HANDLED;
  206. }
  207.  
  208. public ESP_Toggle( id )
  209. {
  210. if( bAdmin[ id ] && get_pcvar_num( g_pCvarESPEnabled ) == 1 )
  211. ESP_Status( id, !bAdminOptions[ id ][ 0 ] )
  212. }
  213.  
  214. ESP_Status( id, bool: bOn )
  215. {
  216. if( bOn )
  217. {
  218. bAdminOptions[ id ][ 0 ] = true
  219. if( !bIsInMenu[ id ] )
  220. ChatColor( id, "!g[Admin Spec ESP v%s] !yBEKAPCSOLVA", VERSION )
  221.  
  222. if( bIsInMenu[ id ] )
  223. ShowESP_Menu( id )
  224. }
  225. else
  226. {
  227. bAdminOptions[ id ][ 0 ] = false
  228. if( !bIsInMenu[ id ] )
  229. ChatColor( id, "!g[Admin Spec ESP v%s] !yKIKAPCSOLVA", VERSION )
  230.  
  231. if( bIsInMenu[ id ] )
  232. ShowESP_Menu( id )
  233. }
  234. }
  235.  
  236. public ESP_Settings( id )
  237. {
  238. if( bAdmin[ id ] )
  239. {
  240. new iOut[ 11 ];
  241. read_argv( 1, iOut, charsmax( iOut ) )
  242.  
  243. new iLen = strlen( iOut )
  244. for( new i = 0; i < iLen; i++ )
  245. {
  246. if( iOut[ i ] == '1' )
  247. bAdminOptions[ id ][ i ] = true
  248. else
  249. bAdminOptions[ id ][ i ] = false
  250. }
  251. }
  252. }
  253.  
  254. public Fw_PlayerPreThink( id )
  255. {
  256. if( !is_user_connected( id ) )
  257. return FMRES_IGNORED;
  258.  
  259. static iButton;
  260. iButton = pev( id, pev_button )
  261. if( iButton == 0 )
  262. return FMRES_IGNORED;
  263.  
  264. static iOldButton;
  265. iOldButton = pev( id, pev_oldbuttons )
  266.  
  267. if( iButton & IN_DUCK )
  268. bDucking[ id ] = true
  269. else
  270. bDucking[ id ] = false
  271.  
  272. if( ( get_pcvar_num( g_pCvarESPEnabled ) ==1 ) && ( get_pcvar_num( g_pCvarESPDisableDefaultKeys )!= 1 ) )
  273. {
  274. if( bAdmin[ id ] )
  275. {
  276. if( bFirstPerson[ id ] && !is_user_alive( id ) )
  277. {
  278. if( ( iButton & IN_RELOAD ) && !( iOldButton & IN_RELOAD ) )
  279. ShowESP_Menu( id )
  280.  
  281. if( ( iButton & IN_FORWARD ) && !( iOldButton & IN_FORWARD ) && !bAdminOptions[ id ][ 0 ] )
  282. ESP_Status( id, true )
  283.  
  284. if( ( iButton & IN_BACK ) && !( iOldButton & IN_BACK ) && bAdminOptions[ id ][ 0 ] )
  285. ESP_Status( id, false )
  286. }
  287. }
  288. }
  289. return FMRES_HANDLED;
  290. }
  291.  
  292. public SpecTarget( id )
  293. {
  294. if( id > 0 )
  295. {
  296. new iTarget = read_data( 2 )
  297. if( iTarget!= 0 )
  298. g_iSpectator[ id ] = iTarget
  299. }
  300. return PLUGIN_CONTINUE;
  301. }
  302.  
  303. public SpecMode( id )
  304. {
  305. new iSpecMode[ 12 ];
  306. read_data( 2, iSpecMode, charsmax( iSpecMode ) );
  307.  
  308. if( equal( iSpecMode, "#Spec_Mode4" ) )
  309. bFirstPerson[ id ] = true
  310. else
  311. bFirstPerson[ id ] = false
  312.  
  313. return PLUGIN_CONTINUE;
  314. }
  315.  
  316. public Damage( id )
  317. {
  318. if( id > 0 )
  319. {
  320. new iAttacker = get_user_attacker( id )
  321. if( iAttacker > 0 && iAttacker <= g_iMaxPlayers )
  322. {
  323. if( g_iViewTarget[ iAttacker ] == id )
  324. g_iDamageDoneTo[ iAttacker ] = id
  325. }
  326. }
  327. return PLUGIN_CONTINUE;
  328. }
  329.  
  330. public ResetHUD( id )
  331. g_iSpectator[ id ] = 0
  332.  
  333. public AdminSpectatorESP_Menu( id, iKey )
  334. {
  335. if( iKey == 9 )
  336. {
  337. bIsInMenu[ id ] = false
  338. return PLUGIN_HANDLED;
  339. }
  340. if( bAdminOptions[ id ][ iKey + 1 ] )
  341. bAdminOptions[ id ][ iKey + 1 ] = false
  342. else
  343. bAdminOptions[ id ][ iKey + 1 ] = true
  344.  
  345. ShowESP_Menu( id )
  346. return PLUGIN_HANDLED;
  347. }
  348.  
  349. SaveData( id )
  350. {
  351. if( bAdmin[ id ] )
  352. {
  353. new uAuthId[ 35 ];
  354. get_user_authid( id, uAuthId, charsmax( uAuthId ) );
  355.  
  356. new iTmp[ 11 ];
  357. for( new s = 0; s < 10; s++ )
  358. {
  359. if( bAdminOptions[ id ][ s ] )
  360. iTmp[ s ] = '1';
  361. else
  362. iTmp[ s ] = '0';
  363. }
  364. iTmp[ 10 ] = 0
  365.  
  366. // server_print( "STEAM-ID: %s OPTIONS: %s", uAuthId, iTmp );
  367. new iKey[ 41 ];
  368. formatex( iKey, charsmax( iKey ), "ESP_%s", uAuthId )
  369.  
  370. set_vaultdata( iKey, iTmp )
  371. }
  372. }
  373.  
  374. LoadData( id )
  375. {
  376. if( bAdmin[ id ] )
  377. {
  378. new iData[ 11 ], uAuthId[ 35 ];
  379. get_user_authid( id, uAuthId, charsmax( uAuthId ) );
  380.  
  381. new iKey[ 41 ];
  382. formatex( iKey, charsmax( iKey ), "ESP_%s", uAuthId )
  383.  
  384. get_vaultdata( iKey, iData, charsmax( iData ) )
  385.  
  386. if( strlen( iData ) > 0 )
  387. {
  388. for( new s = 0; s < 10; s++ )
  389. {
  390. if( iData[ s ] == '1' )
  391. bAdminOptions[ id ][ s ] = true
  392. else
  393. bAdminOptions[ id ][ s ] = false
  394. }
  395. }
  396. }
  397.  
  398. }
  399.  
  400. public DrawAimVector( i, s, iLen )
  401. {
  402. new iTmp[ 3 ];
  403. get_user_origin( s, iTmp, 1 )
  404.  
  405. new Float: fVec[ 3 ];
  406. new Float: fEndPoint[ 3 ];
  407.  
  408. IVecFVec( iTmp, fVec )
  409. fVec[ 2 ]-= 6.0
  410.  
  411. velocity_by_aim( s, iLen, fEndPoint )
  412. AddVec( fEndPoint, fVec )
  413. Make_TE_BEAMPOINTS( i, 4, fVec, fEndPoint, 10, 255 )
  414. return PLUGIN_CONTINUE;
  415. }
  416.  
  417. public ESP_Timer( )
  418. {
  419. if( get_pcvar_num( g_pCvarESPEnabled )!= 1 )
  420. {
  421. set_task( 1.0, "ESP_Timer" ) // Check for reactivation in 1 sec intervals.
  422. return PLUGIN_CONTINUE;
  423. }
  424.  
  425. static iSpectatorId, Float: fMyOrigin[ 3 ], iMyTeam, Float: fSmallestAngle, iSmallestId, Float: fX_Pos, Float: fY_Pos, Float: fDist, iTargetTeam, Float: fTargetOrigin[ 3 ], Float: fDistance, iWidth,
  426. Float: fMiddle[ 3 ], Float: fHitPoint[ 3 ], Float: fDistanceToHitPoint, Float: fScaledBoneLen, Float: fScaledBoneWidth, Float: fBone_Start[ 3 ], Float: fBone_End[ 3 ], Float: fOffSet_Vector[ 3 ],
  427. Float: fEyeLevel[ 3 ], Float: fDistanceTargetHitPoint, iActualBright, iColor, Float: fRet[ 2 ], Float: fX_Angle, iName[ 37 ], iHealthAndArmor[ 25 ], iClipAndAmmo[ 22 ], iWeaponId, iWeaponName[21];
  428.  
  429.  
  430. for( new i = 1; i <= g_iMaxPlayers; i++ )
  431. {
  432. 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 ] ) )
  433. {
  434. iSpectatorId = g_iSpectator[ i ];
  435. pev( i, pev_origin, fMyOrigin ) // Get origin of spectating admin.
  436.  
  437. // Get team of spectated.
  438. iMyTeam = get_pdata_int( iSpectatorId, OFFSET_TEAM )
  439.  
  440. iSmallestId = 0;
  441. fSmallestAngle = 180.0;
  442.  
  443. // X,Y of hudmessage.
  444. fX_Pos = 2.0
  445. fY_Pos = 2.0
  446.  
  447. for( new s = 1; s <= g_iMaxPlayers; s++ )
  448. {
  449. if( is_user_alive( s ) )
  450. {
  451. iTargetTeam = get_pdata_int( s, OFFSET_TEAM )
  452. if( !( iTargetTeam == 3 ) )
  453. {
  454. if( iSpectatorId!= s )
  455. {
  456. if( ( ( iMyTeam != iTargetTeam && ( iTargetTeam == 1 || iTargetTeam == 2 ) ) || bAdminOptions[ i ][ ESP_TEAM_MATES ] ) )
  457. {
  458. // Get origin of target.
  459. pev( s, pev_origin, fTargetOrigin )
  460.  
  461. // Get distance from me to target.
  462. fDistance = vector_distance( fMyOrigin, fTargetOrigin )
  463.  
  464. if( bAdminOptions[ i ][ ESP_LINE ] )
  465. {
  466. if( fDistance < 2040.0 )
  467. iWidth = ( 255 - floatround( fDistance / 8.0 ) ) / 3
  468. else
  469. iWidth = 1
  470.  
  471. Make_TE_BEAMENTPOINT( i, fTargetOrigin, iWidth, iTargetTeam )
  472. }
  473.  
  474. // Get vector from me to target.
  475. SubVec( fTargetOrigin, fMyOrigin, fMiddle )
  476.  
  477. // Trace from me to target, getting hitpoint.
  478. engfunc( EngFunc_TraceLine, fMyOrigin, fTargetOrigin, 1, -1, 0 )
  479. get_tr2( 0, TR_vecEndPos, fHitPoint )
  480.  
  481. // Get distance from me to hitpoint (nearest wall).
  482. fDistanceToHitPoint = vector_distance( fMyOrigin, fHitPoint )
  483.  
  484. // Scale.
  485. if( bDucking[ iSpectatorId ] )
  486. fScaledBoneLen = fDistanceToHitPoint / fDistance * ( 50.0 - 18.0 )
  487. else
  488. fScaledBoneLen = fDistanceToHitPoint / fDistance * 50.0
  489.  
  490. fScaledBoneLen = fDistanceToHitPoint / fDistance * 50.0
  491. fScaledBoneWidth = fDistanceToHitPoint / fDistance * 150.0
  492.  
  493. // Get the point 10.0 units away from wall.
  494. Normalize( fMiddle, fOffSet_Vector, fDistanceToHitPoint - 10.0 ) // Offset from wall.
  495.  
  496. // Set to eye level.
  497. CopyVec( fMyOrigin, fEyeLevel )
  498.  
  499. if( bDucking[ iSpectatorId ] )
  500. fEyeLevel[ 2 ]+= 12.3
  501. else
  502. fEyeLevel[ 2 ]+= 17.5
  503.  
  504. AddVec( fOffSet_Vector, fEyeLevel )
  505.  
  506. // Start and end of green box.
  507. CopyVec( fOffSet_Vector, fBone_Start )
  508. CopyVec( fOffSet_Vector, fBone_End )
  509. fBone_End[ 2 ]-= fScaledBoneLen
  510.  
  511. fDistanceTargetHitPoint = fDistance - fDistanceToHitPoint;
  512.  
  513. iActualBright = 255;
  514.  
  515. if( bAdminOptions[ i ][ ESP_BOX ] )
  516. {
  517. if( fDistanceTargetHitPoint < 2040.0 )
  518. iActualBright = ( 255 - floatround( fDistanceTargetHitPoint / 12.0 ) )
  519. else
  520. iActualBright = 85
  521.  
  522. if( fDistanceToHitPoint!= fDistance )
  523. iColor = 0
  524. else
  525. iColor = iTargetTeam
  526.  
  527. if( g_iDamageDoneTo[ iSpectatorId ] == s )
  528. {
  529. iColor = 3
  530. g_iDamageDoneTo[ iSpectatorId ] = 0
  531. }
  532. Make_TE_BEAMPOINTS( i, iColor, fBone_Start, fBone_End, floatround( fScaledBoneWidth ), iActualBright )
  533. }
  534.  
  535. 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 ] )
  536. {
  537. fX_Angle = GetScreenPos( iSpectatorId, fMiddle, fRet )
  538.  
  539. // Find target with the smallest distance to crosshair (on x-axis).
  540. if( fSmallestAngle > floatabs( fX_Angle ) )
  541. {
  542. if( floatabs( fX_Angle )!= 0.0 )
  543. {
  544. fSmallestAngle = floatabs( fX_Angle )
  545. g_iViewTarget[ iSpectatorId ] = s
  546. iSmallestId = s // Store nearest target id.
  547. fX_Pos = fRet[ 0 ] // And x, y coordinates of hudmessage.
  548. fY_Pos = fRet[ 1 ]
  549. fDist = fDistance
  550. }
  551. }
  552. }
  553. }
  554. }
  555. }
  556. }
  557. }
  558. if( !is_user_alive( iSmallestId ) )
  559. {
  560. iSmallestId = 0
  561. fX_Pos =-1.0
  562. }
  563. if( iSmallestId > 0 && bAdminOptions[ i ][ ESP_AIM_VEC ] )
  564. DrawAimVector( i, iSmallestId, 2000 )
  565.  
  566. if( fX_Pos > 0.0 && fX_Pos <= 1.0 && fY_Pos > 0.0 && fY_Pos <= 1.0 )
  567. {
  568. set_hudmessage( 255, 255, 0, floatabs( fX_Pos ), floatabs( fY_Pos ), 0, 0.0, get_pcvar_float( g_pCvarESPTimer ), 0.0, 0.0, -1 )
  569.  
  570. iName[ 0 ] = '^0'
  571. if( bAdminOptions[ i ][ ESP_NAME ] )
  572. {
  573. new uName[ 33 ];
  574. get_user_name( iSmallestId, uName, charsmax( uName ) )
  575. formatex( iName, charsmax( iName ), "[%s]^n", uName )
  576. }
  577.  
  578. iHealthAndArmor[ 0 ] = '^0'
  579. if( bAdminOptions[ i ][ ESP_HEALTH_ARMOR ] )
  580. {
  581. new iHP = get_user_health( iSmallestId )
  582. new iArmor = get_user_armor( iSmallestId )
  583. formatex( iHealthAndArmor, charsmax( iHealthAndArmor ), "Élet: %d Pajzs: %d^n", iHP, iArmor )
  584. }
  585.  
  586. iWeaponName[ 0 ] = '^0'
  587. if( bAdminOptions[ i ][ ESP_WEAPON ] )
  588. {
  589. if( ( iWeaponId - 1 ) < 0 || ( iWeaponId - 1 ) > 29 )
  590. iWeaponId = 1
  591.  
  592. formatex( iWeaponName, charsmax( iWeaponName ), "Fegyver: %s^n", iWeapons[ iWeaponId - 1 ] )
  593. }
  594.  
  595. iClipAndAmmo[ 0 ] = '^0'
  596. if( bAdminOptions[ i ][ ESP_CLIP_AMMO ] )
  597. {
  598. new iClip, iAmmo;
  599. iWeaponId = get_user_weapon( iSmallestId, iClip, iAmmo )
  600. formatex( iClipAndAmmo, charsmax( iClipAndAmmo ), "Golyó: %d Tár: %d^n", iClip, iAmmo )
  601. }
  602.  
  603. new iStrDist[ 19 ];
  604. if( bAdminOptions[ i ][ ESP_DISTANCE ] )
  605. formatex( iStrDist, charsmax( iStrDist ), "Távolság: %d^n", floatround( fDist ) )
  606.  
  607. show_hudmessage( i, "%s%s%s%s%s", iName, iHealthAndArmor, iWeaponName, iClipAndAmmo, iStrDist)
  608. }
  609. }
  610. }
  611. set_task( get_pcvar_float( g_pCvarESPTimer ), "ESP_Timer" ) // Keep it going.
  612. return PLUGIN_CONTINUE;
  613. }
  614.  
  615. Float: GetScreenPos( id, Float: fMeToTarget[ 3 ], Float: fRet[ 2 ] )
  616. {
  617. new Float: fAim1[ 3 ];
  618. velocity_by_aim( id, 1, fAim1 ) // Get aim vector.
  619.  
  620. new Float: fAim2[ 3 ];
  621. CopyVec( fAim1, fAim2 ) // Make backup copy of fAim1.
  622. fAim1[ 2 ] = 0.0 // Project aim vector vertically to x,y plane.
  623.  
  624. new Float: fTarget[ 3 ];
  625. CopyVec( fMeToTarget, fTarget )
  626. fTarget[ 2 ] = 0.0 // Project target vector vertically to x,y plane.
  627.  
  628. // Both fAim1 and fTarget are in the x,y plane, so angle can be calculated.
  629. new Float: fX_Angle;
  630. new Float: fX_Pos = GetScreenPos_X( fTarget, fAim1, fX_Angle ) // Get the x coordinate of hudmessage..
  631. new Float: fY_Pos = GetScreenPos_Y( fMeToTarget, fAim2 ) // Get the y coordinate of hudmessage..
  632. fRet[ 0 ]= fX_Pos
  633. fRet[ 1 ]= fY_Pos
  634. return fX_Angle;
  635. }
  636.  
  637. Float: GetScreenPos_X( Float: fTarget[ 3 ], Float: fAim[ 3 ], &Float: fX_Angle )
  638. {
  639. new Float: fX_Angle1 = floatacos( VectorProduct( fAim, fTarget ) / ( GetVecLen ( fAim ) * GetVecLen( fTarget ) ), 1 ) // Get angle between vectors.
  640.  
  641. new Float: fX_Pos;
  642. if( ScalarTripleProduct( fAim, fTarget ) < 0.0 )
  643. fX_Angle1*=-1
  644.  
  645. if( fX_Angle1>=-45.0 && fX_Angle1<= 45.0 )
  646. {
  647. fX_Pos = 1.0 - ( floattan( fX_Angle1, degrees ) + 1.0 ) / 2.0
  648. fX_Angle = fX_Angle1
  649. return fX_Pos;
  650. }
  651. fX_Angle = 0.0
  652. return -2.0
  653. }
  654.  
  655. Float: GetScreenPos_Y( Float: fTarget[ 3 ], Float: fAim[ 3 ] )
  656. {
  657. new Float: fTarget1[ 3 ]
  658.  
  659. // Rotate vector about z-axis directly over the direction vector (to get height angle);
  660. RotateVectorZ( fTarget, fAim, fTarget1 )
  661.  
  662. // Get angle between aim vector and target vector.
  663. new Float: fY_Angle = floatacos( VectorProduct( fAim, fTarget1 ) / ( GetVecLen( fAim ) * GetVecLen( fTarget1 ) ), 1 ) // Get angle between vectors.
  664.  
  665. new Float: fY_Pos;
  666. new Float: fNormTarget[ 3 ], Float: fNormAim[ 3 ];
  667.  
  668. // Get normalized target and aim vectors.
  669. Normalize( fTarget, fNormTarget, 1.0 )
  670. Normalize( fAim, fNormAim, 1.0 )
  671.  
  672. // Since the 'angle between vectors' formula returns always positive values.
  673. if( fNormTarget[ 2 ] < fNormAim[ 2 ] )
  674. fY_Angle*=-1
  675.  
  676. if( fY_Angle>=-45.0 && fY_Angle<= 45.0 )
  677. {
  678. fY_Pos = 1.0 - ( floattan( fY_Angle, degrees ) + 1.0 ) / 2.0 // Calulate fY_Pos of hudmessage.
  679. if( fY_Pos>= 0.0 && fY_Pos<= 1.0 )
  680. return fY_Pos;
  681. }
  682. return -2.0
  683. }
  684.  
  685. // Vector Operations ---------------------------------------------------------------------------------------------------------
  686.  
  687. Float: GetVecLen( Float: fVec[ 3 ] )
  688. {
  689. new Float: fVecNull[ 3 ] = { 0.0, 0.0, 0.0 }
  690. new Float: fLen = vector_distance( fVec, fVecNull )
  691. return fLen;
  692. }
  693.  
  694. Float: ScalarTripleProduct( Float: fA[ 3 ], Float: fB[ 3 ] )
  695. {
  696. new Float: fUp[ 3 ] = { 0.0, 0.0, 1.0 }
  697.  
  698. new Float: fRet[ 3 ];
  699. fRet[ 0 ] = fA[ 1 ] * fB[ 2 ] - fA[ 2 ] * fB[ 1 ]
  700. fRet[ 1 ] = fA[ 2 ] * fB[ 0 ] - fA[ 0 ] * fB[ 2 ]
  701. fRet[ 2 ] = fA[ 0 ] * fB[ 1 ] - fA[ 1 ] * fB[ 0 ]
  702. return VectorProduct( fRet, fUp )
  703. }
  704.  
  705. Normalize( Float: fVec[ 3 ], Float: fRet[ 3 ],Float: fMultiplier )
  706. {
  707. new Float: fLen = GetVecLen( fVec )
  708. CopyVec( fVec, fRet )
  709. fRet[ 0 ]/= fLen
  710. fRet[ 1 ]/= fLen
  711. fRet[ 2 ]/= fLen
  712. fRet[ 0 ]*= fMultiplier
  713. fRet[ 1 ]*= fMultiplier
  714. fRet[ 2 ]*= fMultiplier
  715. }
  716.  
  717. RotateVectorZ( Float: fVec[ 3 ], Float: fDirection[ 3 ], Float: fRet[ 3 ] )
  718. {
  719. // Rotates vector about z-axis.
  720. new Float: fTmp[ 3 ];
  721. CopyVec( fVec, fTmp )
  722. fTmp[ 2 ] = 0.0
  723.  
  724. new Float: fDestLen = GetVecLen( fTmp )
  725. CopyVec( fDirection, fTmp )
  726. fTmp[ 2 ] = 0.0
  727.  
  728. new Float: fTmp2[ 3 ];
  729. Normalize( fTmp, fTmp2, fDestLen )
  730. fTmp2[ 2 ] = fVec[ 2 ]
  731. CopyVec( fTmp2, fRet )
  732. }
  733.  
  734. Float: VectorProduct( Float: fVec1[ 3 ], Float: fVec2[ 3 ] )
  735. return fVec1[ 0 ] * fVec2[ 0 ] + fVec1[ 1 ] * fVec2[ 1 ] + fVec1[ 2 ] * fVec2[ 2 ]
  736.  
  737. CopyVec( Float: fVec[ 3 ], Float: fRet[ 3 ] )
  738. {
  739. fRet[ 0 ] = fVec[ 0 ]
  740. fRet[ 1 ] = fVec[ 1 ]
  741. fRet[ 2 ] = fVec[ 2 ]
  742. }
  743.  
  744. SubVec( Float: fVec1[ 3 ], Float: fVec2[ 3 ], Float: fRet[ 3 ] )
  745. {
  746. fRet[ 0 ] = fVec1[ 0 ] - fVec2[ 0 ]
  747. fRet[ 1 ] = fVec1[ 1 ] - fVec2[ 1 ]
  748. fRet[ 2 ] = fVec1[ 2 ] - fVec2[ 2 ]
  749. }
  750.  
  751. AddVec( Float: fVec1[ 3 ], Float: fVec2[ 3 ] )
  752. {
  753. fVec1[ 0 ]+= fVec2[ 0 ]
  754. fVec1[ 1 ]+= fVec2[ 1 ]
  755. fVec1[ 2 ]+= fVec2[ 2 ]
  756. }
  757.  
  758. // Temporary Entities --------------------------------------------------------------------------------------------------------
  759. // All messages are sent with MSG_ONE_UNRELIABLE flag to avoid overflow in case of very low esp_timer setting and much targets.
  760.  
  761. Make_TE_BEAMENTPOINT( id, Float: fTargetOrigin[ 3 ], iWidth, iTargetTeam )
  762. {
  763. message_begin( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, { 0, 0, 0 }, id )
  764. write_byte( 1 )
  765. write_short( id )
  766. write_coord( floatround( fTargetOrigin[ 0 ] ) )
  767. write_coord( floatround( fTargetOrigin[ 1 ] ) )
  768. write_coord( floatround( fTargetOrigin[ 2 ] ) )
  769. write_short( iLaser ) // Sprite index.
  770. write_byte( 1 ) // Starting frame.
  771. write_byte( 1 ) // Frame rate in 0.1's.
  772. write_byte( floatround( get_pcvar_float( g_pCvarESPTimer ) *10 ) ) // Life in 0.1's.
  773. write_byte( iWidth ) // Line width in 0.1's.
  774. write_byte( 0 ) // Noise amplitude in 0.01's.
  775. write_byte( iTeamColors[ iTargetTeam ][ 0 ] )
  776. write_byte( iTeamColors[ iTargetTeam ][ 1 ] )
  777. write_byte( iTeamColors[ iTargetTeam ][ 2 ] )
  778. write_byte( 255 )
  779. write_byte( 0 )// Scroll speed in 0.1's.
  780. message_end( )
  781. }
  782.  
  783. Make_TE_BEAMPOINTS( id, iColor, Float: fVec1[ 3 ], Float: fVec2[ 3 ], iWidth, iBrightness )
  784. {
  785. message_begin( MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, { 0, 0, 0 }, id )
  786. write_byte( 0 )
  787. write_coord( floatround( fVec1[ 0 ] ) ) // Start position.
  788. write_coord( floatround( fVec1[ 1 ] ) )
  789. write_coord( floatround( fVec1[ 2 ] ) )
  790. write_coord( floatround( fVec2[ 0 ] ) ) // End position.
  791. write_coord( floatround( fVec2[ 1 ] ) )
  792. write_coord( floatround( fVec2[ 2 ] ) )
  793. write_short( iLaser ) // Sprite index.
  794. write_byte( 3 ) // Starting frame.
  795. write_byte( 0 ) // Frame rate in 0.1's.
  796. write_byte( floatround( get_pcvar_float( g_pCvarESPTimer ) *10 ) ) // Life in 0.1's.
  797. write_byte( iWidth ) // Line width in 0.1's.
  798. write_byte( 0 ) // Noise amplitude in 0.01's.
  799. write_byte( iEspColors[ iColor ][ 0 ] )
  800. write_byte( iEspColors[ iColor ][ 1 ] )
  801. write_byte( iEspColors[ iColor ][ 2 ] )
  802. write_byte( iBrightness ) // Brightness.
  803. write_byte( 0 ) // Scroll speed in 0.1's.
  804. message_end( )
  805. }
  806.  
  807. public client_disconnect( id )
  808. {
  809. SaveData( id )
  810.  
  811. bAdmin[ id ] = false
  812. g_iSpectator[ id ] = 0
  813. }
  814.  
  815. stock ChatColor( id, szInput[ ], any:... )
  816. {
  817. new iCount = 1, g_iPlayers[ 32 ];
  818. static iMsgId[ 191 ];
  819. vformat( iMsgId, 190, szInput, 3 );
  820.  
  821. replace_all( iMsgId, 190, "!y", "^1" ); // Default Color
  822. replace_all( iMsgId, 190, "!g", "^4" ); // Green Color
  823. replace_all( iMsgId, 190, "!team", "^3" ); // Team Color
  824.  
  825. if( id )
  826. g_iPlayers[ 0 ] = id;
  827. else
  828. get_players( g_iPlayers, iCount, "ch" );
  829. {
  830. for( new i = 0; i < iCount; i++ )
  831. {
  832. if( is_user_connected( g_iPlayers[ i ] ) )
  833. {
  834. message_begin( MSG_ONE_UNRELIABLE, g_iMsgSayText, _, g_iPlayers[ i ] );
  835. write_byte( g_iPlayers[ i ] );
  836. write_string( iMsgId );
  837. message_end( );
  838. }
  839. }
  840. }
  841. }
  842.