Advertisement
Qovii

grenade_trail cs 1.6

Feb 2nd, 2020
3,272
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.23 KB | None | 0 0
  1. /**
  2. *
  3. * Team Grenade Trail
  4. * by Numb
  5. *
  6. *
  7. * Description
  8. * This plugin adds a trail after the grenade. Each type of grenade has an unique
  9. * color what can be changed by cvar. Unlike other grenade trail plugins, this one
  10. * has two major differences. First is that trails are actually made out of arrows
  11. * what show direction in what grenade is moving (so now if you came out of corner
  12. * and see a trail - you can instantly tell where to expect grenade to be). Second
  13. * and most important one is that by default only team mates can see trails of your
  14. * thrown grenades (this gives you and your team mates advantage from misunderstandings
  15. * - no more guessing did any of those 10 noobs behind you thrown flashes or what;
  16. * but when it comes to enemy grenades - you still must spot the model of the grenade
  17. * to see and identify grenade type).
  18. *
  19. *
  20. * Requires:
  21. * CStrike
  22. * CSX
  23. *
  24. *
  25. * Cvars:
  26. *
  27. * + "amx_grentrail_status" - who can see the trail.
  28. * - "3" - everyone.
  29. * - "2" - team and everyone who's dead.
  30. * - "1" - only team. [default]
  31. * - "0" - plugin disabled.
  32. *
  33. * + "amx_grentrail_color_fb" - flashbang trail color [rrrgggbbb].
  34. * - "000255255" - red 0; 255 green; 255 blue [default].
  35. *
  36. * + "amx_grentrail_color_he" - explosive trail color [rrrgggbbb].
  37. * - "255063000" - red 255; 63 green; 0 blue [default].
  38. *
  39. * + "amx_grentrail_color_sg" - smokegren trail color [rrrgggbbb].
  40. * - "031255127" - red 31; 255 green; 127 blue [default].
  41. *
  42. * + "amx_grentrail_team_color" - extra trail line with owners team color.
  43. * - "1" - enabled.
  44. * - "0" - disabled. [default]
  45. *
  46. *
  47. * Additional info:
  48. * Tested in Counter-Strike 1.6 with amxmodx 1.8.2 (dev build hg21).
  49. *
  50. *
  51. * Credits:
  52. * Original idea came from AssKicR's ( http://forums.alliedmods.net/member.php?u=261 )
  53. * plugin ( http://forums.alliedmods.net/showthread.php?p=19096 ) what was published in
  54. * 2004/May/05. Method of showing trails taken from jim_yang's
  55. * ( http://forums.alliedmods.net/member.php?u=19661 ) plugin
  56. * ( http://forums.alliedmods.net/showthread.php?t=50171 ) what was published in 2007/Jan/21.
  57. *
  58. *
  59. * Change-Log:
  60. *
  61. * + 1.2
  62. * - Added: Support for team color trail (this is another smaller trail what has no effect on the main one).
  63. * - Changed: Improved plugin performance.
  64. * - Changed: Renamed "amx_grentrail_team" cvar to "amx_grentrail_status".
  65. * - Changed: Renamed "amx_grentrail_color_sm" cvar to "amx_grentrail_color_sg".
  66. *
  67. * + 1.1
  68. * - Fixed: An issue with team detection once player team was changed by some custom plugin.
  69. *
  70. * + 1.0
  71. * - First release.
  72. *
  73. *
  74. * Downloads:
  75. * Amx Mod X forums: http://forums.alliedmods.net/showthread.php?p=1443603#post1443603
  76. *
  77. **/
  78.  
  79. // ----------------------------------------- CONFIG START -----------------------------------------
  80.  
  81. // If you are having problems, that not everyone who should see the trail is seeing them, that can
  82. // be due to message type and ping. Using "MSG_ONE_UNRELIABLE" and "MSG_BROADCAST" is better for server
  83. // stability, however using "MSG_ONE" and "MSG_ALL" garanties that client will recieve the update.
  84. #define MSG_TYPE_ALONE MSG_ONE // default: (uncommented)
  85. //#define MSG_TYPE_ALONE MSG_ONE_UNRELIABLE // default: (commented)
  86. #define MSG_TYPE_ALL MSG_ALL // default: (uncommented)
  87. //#define MSG_TYPE_ALL MSG_BROADCAST // default: (commented)
  88.  
  89. // ------------------------------------------ CONFIG END ------------------------------------------
  90.  
  91.  
  92. #include <amxmodx>
  93. #include <cstrike>
  94. #include <csx>
  95.  
  96. #define PLUGIN_NAME "Team Grenade Trail"
  97. #define PLUGIN_VERSION "1.2"
  98. #define PLUGIN_AUTHOR "Numb"
  99.  
  100. #define SetPlayerBit(%1,%2) ( %1 |= ( 1 << ( %2 & 31 ) ) )
  101. #define ClearPlayerBit(%1,%2) ( %1 &= ~( 1 << ( %2 & 31 ) ) )
  102. #define CheckPlayerBit(%1,%2) ( %1 & ( 1 << ( %2 & 31 ) ) )
  103.  
  104. new g_iCvar_ColorFlash;
  105. new g_iCvar_ColorHe;
  106. new g_iCvar_ColorSmoke;
  107. new g_iCvar_TrailStatus;
  108. new g_iCvar_TeamColor;
  109.  
  110. new g_iSpriteLine;
  111. new g_iSpriteArrow;
  112.  
  113. new g_iConnectedUsers;
  114. new g_iDeadUsers;
  115. new g_iMaxPlayers;
  116.  
  117. public plugin_precache()
  118. {
  119. g_iSpriteArrow = precache_model("sprites/arrow1.spr");
  120. g_iSpriteLine = precache_model("sprites/smoke.spr");
  121. }
  122.  
  123. public plugin_init()
  124. {
  125. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  126.  
  127. g_iCvar_TrailStatus = register_cvar("amx_grentrail_status", "1");
  128.  
  129. g_iCvar_ColorFlash = register_cvar("amx_grentrail_color_fb", "000255255");
  130. g_iCvar_ColorHe = register_cvar("amx_grentrail_color_he", "255063000");
  131. g_iCvar_ColorSmoke = register_cvar("amx_grentrail_color_sg", "031255127");
  132.  
  133. g_iCvar_TeamColor = register_cvar("amx_grentrail_team_color", "0");
  134.  
  135. register_event("ResetHUD", "Event_ResetHUD", "be");
  136. register_event("Health", "Event_Health", "bd");
  137.  
  138. g_iMaxPlayers = clamp(get_maxplayers(), 1, 32);
  139. }
  140.  
  141. public client_connect(iPlrId)
  142. {
  143. ClearPlayerBit(g_iConnectedUsers, iPlrId);
  144. ClearPlayerBit(g_iDeadUsers, iPlrId);
  145. }
  146.  
  147. public client_putinserver(iPlrId)
  148. {
  149. if( !is_user_bot(iPlrId) )
  150. {
  151. SetPlayerBit(g_iConnectedUsers, iPlrId);
  152. if( is_user_alive(iPlrId) )
  153. ClearPlayerBit(g_iDeadUsers, iPlrId);
  154. else
  155. SetPlayerBit(g_iDeadUsers, iPlrId);
  156. }
  157. }
  158.  
  159. public client_disconnect(iPlrId)
  160. {
  161. ClearPlayerBit(g_iConnectedUsers, iPlrId);
  162. ClearPlayerBit(g_iDeadUsers, iPlrId);
  163. }
  164.  
  165. public Event_ResetHUD(iPlrId)
  166. {
  167. if( CheckPlayerBit(g_iConnectedUsers, iPlrId) )
  168. {
  169. if( is_user_alive(iPlrId) )
  170. ClearPlayerBit(g_iDeadUsers, iPlrId);
  171. else
  172. SetPlayerBit(g_iDeadUsers, iPlrId);
  173. }
  174. }
  175.  
  176. public Event_Health(iPlrId)
  177. {
  178. if( CheckPlayerBit(g_iConnectedUsers, iPlrId) )
  179. {
  180. if( is_user_alive(iPlrId) )
  181. ClearPlayerBit(g_iDeadUsers, iPlrId);
  182. else
  183. SetPlayerBit(g_iDeadUsers, iPlrId);
  184. }
  185. }
  186.  
  187. public plugin_unpause()
  188. {
  189. g_iConnectedUsers = 0;
  190. g_iDeadUsers = 0;
  191.  
  192. for( new iPlrId=1; iPlrId<=g_iMaxPlayers; iPlrId++ )
  193. {
  194. if( is_user_connected(iPlrId) )
  195. {
  196. if( !is_user_bot(iPlrId) )
  197. {
  198. SetPlayerBit(g_iConnectedUsers, iPlrId);
  199. if( !is_user_alive(iPlrId) )
  200. SetPlayerBit(g_iDeadUsers, iPlrId);
  201. }
  202. }
  203. }
  204. }
  205.  
  206. public grenade_throw(iPlrId, iGrenId, iWeaponType)
  207. {
  208. new iTemp;
  209. switch( iWeaponType )
  210. {
  211. case CSW_FLASHBANG: iTemp = get_pcvar_num(g_iCvar_ColorFlash);
  212. case CSW_HEGRENADE: iTemp = get_pcvar_num(g_iCvar_ColorHe);
  213. case CSW_SMOKEGRENADE: iTemp = get_pcvar_num(g_iCvar_ColorSmoke);
  214. default: return;
  215. }
  216.  
  217. new iRed = iTemp/1000000;
  218. iTemp %= 1000000;
  219. new iGreen = iTemp/1000;
  220. new iBlue = iTemp%1000;
  221.  
  222. iTemp = clamp(get_pcvar_num(g_iCvar_TeamColor), 0, 1);
  223.  
  224. switch( clamp(get_pcvar_num(g_iCvar_TrailStatus), 0, 3) )
  225. {
  226. case 1:
  227. {
  228. new CsTeams:iOwnerTeam = cs_get_user_team(iPlrId);
  229.  
  230. for( new iPlayer=1; iPlayer<=g_iMaxPlayers; iPlayer++ )
  231. {
  232. if( CheckPlayerBit(g_iConnectedUsers, iPlayer) )
  233. {
  234. if( cs_get_user_team(iPlayer)==iOwnerTeam )
  235. {
  236. message_begin(MSG_TYPE_ALONE, SVC_TEMPENTITY, _, iPlayer);
  237. write_byte(TE_BEAMFOLLOW);
  238. write_short(iGrenId);
  239. write_short(g_iSpriteArrow);
  240. write_byte(15);
  241. write_byte(7);
  242. write_byte(iRed);
  243. write_byte(iGreen);
  244. write_byte(iBlue);
  245. write_byte(191);
  246. message_end();
  247.  
  248. if( iTemp )
  249. {
  250. message_begin(MSG_TYPE_ALONE, SVC_TEMPENTITY, _, iPlayer);
  251. write_byte(TE_BEAMFOLLOW);
  252. write_short(iGrenId);
  253. write_short(g_iSpriteLine);
  254. write_byte(15);
  255. write_byte(1);
  256. switch( iOwnerTeam )
  257. {
  258. case CS_TEAM_T:
  259. {
  260. write_byte(255);
  261. write_byte(0);
  262. write_byte(0);
  263. }
  264. case CS_TEAM_CT:
  265. {
  266. write_byte(0);
  267. write_byte(0);
  268. write_byte(255);
  269. }
  270. default:
  271. {
  272. write_byte(127);
  273. write_byte(127);
  274. write_byte(127);
  275. }
  276. }
  277. write_byte(191);
  278. message_end();
  279. }
  280. }
  281. }
  282. }
  283. }
  284. case 2:
  285. {
  286. new CsTeams:iOwnerTeam = cs_get_user_team(iPlrId);
  287.  
  288. for( new iPlayer=1; iPlayer<=g_iMaxPlayers; iPlayer++ )
  289. {
  290. if( CheckPlayerBit(g_iConnectedUsers, iPlayer) )
  291. {
  292. if( CheckPlayerBit(g_iDeadUsers, iPlayer) || cs_get_user_team(iPlayer)==iOwnerTeam )
  293. {
  294. message_begin(MSG_TYPE_ALONE, SVC_TEMPENTITY, _, iPlayer);
  295. write_byte(TE_BEAMFOLLOW);
  296. write_short(iGrenId);
  297. write_short(g_iSpriteArrow);
  298. write_byte(15);
  299. write_byte(7);
  300. write_byte(iRed);
  301. write_byte(iGreen);
  302. write_byte(iBlue);
  303. write_byte(191);
  304. message_end();
  305.  
  306. if( iTemp )
  307. {
  308. message_begin(MSG_TYPE_ALONE, SVC_TEMPENTITY, _, iPlayer);
  309. write_byte(TE_BEAMFOLLOW);
  310. write_short(iGrenId);
  311. write_short(g_iSpriteLine);
  312. write_byte(15);
  313. write_byte(1);
  314. switch( iOwnerTeam )
  315. {
  316. case CS_TEAM_T:
  317. {
  318. write_byte(255);
  319. write_byte(0);
  320. write_byte(0);
  321. }
  322. case CS_TEAM_CT:
  323. {
  324. write_byte(0);
  325. write_byte(0);
  326. write_byte(255);
  327. }
  328. default:
  329. {
  330. write_byte(127);
  331. write_byte(127);
  332. write_byte(127);
  333. }
  334. }
  335. write_byte(191);
  336. message_end();
  337. }
  338. }
  339. }
  340. }
  341. }
  342. case 3:
  343. {
  344. message_begin(MSG_TYPE_ALL, SVC_TEMPENTITY);
  345. write_byte(TE_BEAMFOLLOW);
  346. write_short(iGrenId);
  347. write_short(g_iSpriteArrow);
  348. write_byte(15);
  349. write_byte(7);
  350. write_byte(iRed);
  351. write_byte(iGreen);
  352. write_byte(iBlue);
  353. write_byte(191);
  354. message_end();
  355.  
  356. if( iTemp )
  357. {
  358. message_begin(MSG_TYPE_ALL, SVC_TEMPENTITY);
  359. write_byte(TE_BEAMFOLLOW);
  360. write_short(iGrenId);
  361. write_short(g_iSpriteLine);
  362. write_byte(15);
  363. write_byte(1);
  364. switch( cs_get_user_team(iPlrId) )
  365. {
  366. case CS_TEAM_T:
  367. {
  368. write_byte(255);
  369. write_byte(0);
  370. write_byte(0);
  371. }
  372. case CS_TEAM_CT:
  373. {
  374. write_byte(0);
  375. write_byte(0);
  376. write_byte(255);
  377. }
  378. default:
  379. {
  380. write_byte(127);
  381. write_byte(127);
  382. write_byte(127);
  383. }
  384. }
  385. write_byte(191);
  386. message_end();
  387. }
  388. }
  389. }
  390. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement