Advertisement
Guest User

Untitled

a guest
Dec 12th, 2019
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 20.80 KB | None | 0 0
  1. ////////////////////////////////
  2. // Change this to your needs and recompile.
  3. // Added Cookie v.v
  4.  
  5. // Chat prefix:
  6. #define CHAT_PREFIX "{bluegrey}[TC]{default}"
  7.  
  8. // Trail opacity:
  9. #define TRAIL_OPACITY 128
  10.  
  11. ////////////////////////////////
  12.  
  13. #include <sourcemod>
  14. #include <sdktools>
  15. #include <multicolors>
  16. #include <clientprefs>
  17.  
  18. #pragma newdecls required
  19. #pragma semicolon 1
  20.  
  21. /* CVars */
  22.  
  23. ConVar gCV_PluginEnabled = null;
  24. ConVar gCV_AdminsOnly = null;
  25. ConVar gCV_BeamLife = null;
  26. ConVar gCV_BeamWidth = null;
  27.  
  28. /* Cached CVars */
  29.  
  30. bool gB_PluginEnabled = true;
  31. bool gB_AdminsOnly = true;
  32. float gF_BeamLife = 1.5;
  33. float gF_BeamWidth = 1.5;
  34.  
  35. /* Global variables */
  36.  
  37. int gI_BeamSprite;
  38. int gI_SelectedColor[MAXPLAYERS + 1];
  39.  
  40. int gI_CycleColor[MAXPLAYERS + 1][4];
  41. bool gB_RedToYellow[MAXPLAYERS + 1];
  42. bool gB_YellowToGreen[MAXPLAYERS + 1];
  43. bool gB_GreenToCyan[MAXPLAYERS + 1];
  44. bool gB_CyanToBlue[MAXPLAYERS + 1];
  45. bool gB_BlueToMagenta[MAXPLAYERS + 1];
  46. bool gB_MagentaToRed[MAXPLAYERS + 1];
  47.  
  48. bool gB_TouchingTrigger[MAXPLAYERS + 1];
  49. float gF_LastPosition[MAXPLAYERS + 1][3];
  50.  
  51.  
  52. /* Cookie */
  53.  
  54. Handle selection;
  55.  
  56. public Plugin myinfo =
  57. {
  58. name = "Trails Chroma",
  59. author = "Nickelony",
  60. description = "Adds colorful player trails with special effects.",
  61. version = "1.1",
  62. url = "http://steamcommunity.com/id/nickelony/"
  63. }
  64.  
  65. public void OnPluginStart()
  66. {
  67. HookEvent("player_spawn", PlayerSpawnEvent);
  68.  
  69. HookEntityOutput("trigger_teleport", "OnStartTouch", StartTouchTrigger);
  70. HookEntityOutput("trigger_teleport", "OnEndTouch", EndTouchTrigger);
  71.  
  72. RegConsoleCmd("sm_trail", Command_Trail, "Opens the 'Trail Color Selection' menu.");
  73. RegConsoleCmd("sm_trails", Command_Trail, "Opens the 'Trail Color Selection' menu.");
  74.  
  75. gCV_PluginEnabled = CreateConVar("sm_trails_enable", "1", "Enable or Disable all features of the plugin.", 0, true, 0.0, true, 1.0);
  76. gCV_AdminsOnly = CreateConVar("sm_trails_adminsonly", "1", "Enable trails for admins only.", 0, true, 0.0, true, 1.0);
  77. gCV_BeamLife = CreateConVar("sm_trails_life", "1.5", "Time duration of the trails.", FCVAR_NOTIFY, true, 0.0);
  78. gCV_BeamWidth = CreateConVar("sm_trails_width", "1.5", "Width of the trail beams.", FCVAR_NOTIFY, true, 0.0);
  79.  
  80. gCV_PluginEnabled.AddChangeHook(OnConVarChanged);
  81. gCV_AdminsOnly.AddChangeHook(OnConVarChanged);
  82. gCV_BeamLife.AddChangeHook(OnConVarChanged);
  83. gCV_BeamWidth.AddChangeHook(OnConVarChanged);
  84.  
  85. selection = RegClientCookie("trail_selection", "Trail selection", CookieAccess_Protected);
  86.  
  87. AutoExecConfig();
  88. }
  89.  
  90. public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
  91. {
  92. gB_PluginEnabled = gCV_PluginEnabled.BoolValue;
  93. gB_AdminsOnly = gCV_AdminsOnly.BoolValue;
  94. gF_BeamLife = gCV_BeamLife.FloatValue;
  95. gF_BeamWidth = gCV_BeamWidth.FloatValue;
  96. }
  97.  
  98. public void OnMapStart()
  99. {
  100. if(!gB_PluginEnabled)
  101. {
  102. return;
  103. }
  104.  
  105. HookEntityOutput("trigger_teleport", "OnStartTouch", StartTouchTrigger);
  106. HookEntityOutput("trigger_teleport", "OnEndTouch", EndTouchTrigger);
  107.  
  108. gI_BeamSprite = PrecacheModel("materials/trails/beam_01.vmt", true);
  109.  
  110. AddFileToDownloadsTable("materials/trails/beam_01.vmt");
  111. AddFileToDownloadsTable("materials/trails/beam_01.vtf");
  112. }
  113.  
  114. public void PlayerSpawnEvent(Event event, const char[] name, bool dontBroadcast)
  115. {
  116. if(!gB_PluginEnabled)
  117. {
  118. return;
  119. }
  120.  
  121. int client = GetClientOfUserId(event.GetInt("userid"));
  122. gB_TouchingTrigger[client] = false;
  123. }
  124.  
  125. public void OnClientCookiesCached(int client)
  126. {
  127. char trailCookie[32];
  128.  
  129. GetClientCookie(client, selection, trailCookie, sizeof(trailCookie));
  130. gI_SelectedColor[client] = StringToInt(trailCookie);
  131.  
  132. }
  133.  
  134.  
  135. public Action Command_Trail(int client, int args)
  136. {
  137. if(!gB_PluginEnabled || IsFakeClient(client))
  138. {
  139. return Plugin_Handled;
  140. }
  141.  
  142. if(!IsPlayerAlive(client))
  143. {
  144. CPrintToChat(client, "%s You must be alive to choose a trail!", CHAT_PREFIX);
  145. return Plugin_Handled;
  146. }
  147.  
  148. if(gB_AdminsOnly && !CheckCommandAccess(client, "sm_trails_override", ADMFLAG_RESERVATION))
  149. {
  150. CPrintToChat(client, "%s Only admins may use this command.", CHAT_PREFIX);
  151. return Plugin_Handled;
  152. }
  153.  
  154. Menu menu = new Menu(Menu_Handler);
  155. menu.SetTitle("Choose Trail Color:");
  156.  
  157. menu.AddItem("0", "NONE", (gI_SelectedColor[client] == 0)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  158. menu.AddItem("1", "Red", (gI_SelectedColor[client] == 1)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  159. menu.AddItem("2", "Orange", (gI_SelectedColor[client] == 2)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  160. menu.AddItem("3", "Yellow", (gI_SelectedColor[client] == 3)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  161. menu.AddItem("4", "Lime", (gI_SelectedColor[client] == 4)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  162. menu.AddItem("5", "Green", (gI_SelectedColor[client] == 5)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  163. menu.AddItem("6", "Emerald", (gI_SelectedColor[client] == 6)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  164. menu.AddItem("7", "Cyan", (gI_SelectedColor[client] == 7)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  165. menu.AddItem("8", "Light Blue", (gI_SelectedColor[client] == 8)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  166. menu.AddItem("9", "Blue", (gI_SelectedColor[client] == 9)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  167. menu.AddItem("10", "Purple", (gI_SelectedColor[client] == 10)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  168. menu.AddItem("11", "Magenta", (gI_SelectedColor[client] == 11)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  169. menu.AddItem("12", "Pink", (gI_SelectedColor[client] == 12)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  170. menu.AddItem("13", "White", (gI_SelectedColor[client] == 13)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  171.  
  172. menu.AddItem("x", "", ITEMDRAW_SPACER);
  173. menu.AddItem("14", "Velocity", (gI_SelectedColor[client] == 14)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  174. menu.AddItem("15", "Spectrum", (gI_SelectedColor[client] == 15)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  175. menu.AddItem("16", "Wave", (gI_SelectedColor[client] == 16)? ITEMDRAW_DISABLED:ITEMDRAW_DEFAULT);
  176.  
  177. menu.ExitButton = true;
  178. menu.Display(client, 20);
  179.  
  180. return Plugin_Handled;
  181. }
  182.  
  183. public int Menu_Handler(Menu menu, MenuAction action, int param1, int param2)
  184. {
  185. if(action == MenuAction_Select)
  186. {
  187. char[] info = new char[16];
  188. menu.GetItem(param2, info, 16);
  189.  
  190. MenuSelection(param1, info);
  191. SetClientCookie(param1, selection, info);
  192. }
  193.  
  194. else if(action == MenuAction_End)
  195. {
  196. delete menu;
  197. }
  198.  
  199. return 0;
  200. }
  201.  
  202. void MenuSelection(int client, char[] info)
  203. {
  204. int choice;
  205. char[] color = new char[32];
  206.  
  207. if(StrEqual(info, "1"))
  208. {
  209. choice = 1;
  210. FormatEx(color, 32, "{darkred}RED{default}");
  211. PrintTrailMessage(client, choice, color);
  212. gI_SelectedColor[client] = choice;
  213. }
  214.  
  215. else if(StrEqual(info, "2"))
  216. {
  217. choice = 2;
  218. FormatEx(color, 32, "{orange}ORANGE{default}");
  219. PrintTrailMessage(client, choice, color);
  220. gI_SelectedColor[client] = choice;
  221. }
  222.  
  223. else if(StrEqual(info, "3"))
  224. {
  225. choice = 3;
  226. FormatEx(color, 32, "{yellow}YELLOW{default}");
  227. PrintTrailMessage(client, choice, color);
  228. gI_SelectedColor[client] = choice;
  229. }
  230.  
  231. else if(StrEqual(info, "4"))
  232. {
  233. choice = 4;
  234. FormatEx(color, 32, "{lime}LIME{default}");
  235. PrintTrailMessage(client, choice, color);
  236. gI_SelectedColor[client] = choice;
  237. }
  238.  
  239. else if(StrEqual(info, "5"))
  240. {
  241. choice = 5;
  242. FormatEx(color, 32, "{green}GREEN{default}");
  243. PrintTrailMessage(client, choice, color);
  244. gI_SelectedColor[client] = choice;
  245. }
  246.  
  247. else if(StrEqual(info, "6"))
  248. {
  249. choice = 6;
  250. FormatEx(color, 32, "{olive}EMERALD{default}");
  251. PrintTrailMessage(client, choice, color);
  252. gI_SelectedColor[client] = choice;
  253. }
  254.  
  255. else if(StrEqual(info, "7"))
  256. {
  257. choice = 7;
  258. FormatEx(color, 32, "{blue}CYAN{default}");
  259. PrintTrailMessage(client, choice, color);
  260. gI_SelectedColor[client] = choice;
  261. }
  262.  
  263. else if(StrEqual(info, "8"))
  264. {
  265. choice = 8;
  266. FormatEx(color, 32, "{lightblue}LIGHT BLUE{default}");
  267. PrintTrailMessage(client, choice, color);
  268. gI_SelectedColor[client] = choice;
  269. }
  270.  
  271. else if(StrEqual(info, "9"))
  272. {
  273. choice = 9;
  274. FormatEx(color, 32, "{darkblue}BLUE{default}");
  275. PrintTrailMessage(client, choice, color);
  276. gI_SelectedColor[client] = choice;
  277. }
  278.  
  279. else if(StrEqual(info, "10"))
  280. {
  281. choice = 10;
  282. FormatEx(color, 32, "{purple}PURPLE{default}");
  283. PrintTrailMessage(client, choice, color);
  284. gI_SelectedColor[client] = choice;
  285. }
  286.  
  287. else if(StrEqual(info, "11"))
  288. {
  289. choice = 11;
  290. FormatEx(color, 32, "{orchid}MAGENTA{default}");
  291. PrintTrailMessage(client, choice, color);
  292. gI_SelectedColor[client] = choice;
  293. }
  294.  
  295. else if(StrEqual(info, "12"))
  296. {
  297. choice = 12;
  298. FormatEx(color, 32, "{lightred}PINK{default}");
  299. PrintTrailMessage(client, choice, color);
  300. gI_SelectedColor[client] = choice;
  301. }
  302.  
  303. else if(StrEqual(info, "13"))
  304. {
  305. choice = 13;
  306. FormatEx(color, 32, "{grey2}WHITE{default}");
  307. PrintTrailMessage(client, choice, color);
  308. gI_SelectedColor[client] = choice;
  309. }
  310.  
  311. else if(StrEqual(info, "14"))
  312. {
  313. choice = 14;
  314. FormatEx(color, 32, "{darkred}Velocity {green}Trail");
  315. PrintSpecialMessage(client, choice, color);
  316. gI_SelectedColor[client] = choice;
  317. }
  318.  
  319. else if(StrEqual(info, "15"))
  320. {
  321. choice = 15;
  322. FormatEx(color, 32, "{darkred}Spectrum {green}Cycle");
  323. PrintSpecialMessage(client, choice, color);
  324.  
  325. gB_RedToYellow[client] = true;
  326. gI_SelectedColor[client] = choice;
  327. }
  328.  
  329. else if(StrEqual(info, "16"))
  330. {
  331. choice = 16;
  332. FormatEx(color, 32, "{darkred}Wave {green}Trail");
  333. PrintSpecialMessage(client, choice, color);
  334.  
  335. gB_RedToYellow[client] = true;
  336. gI_SelectedColor[client] = choice;
  337. }
  338.  
  339. else
  340. {
  341. if(gI_SelectedColor[client] != 0)
  342. {
  343. CPrintToChat(client, "%s Your trail is now {darkred}DISABLED{default}.", CHAT_PREFIX);
  344. }
  345.  
  346. gI_SelectedColor[client] = 0;
  347. }
  348. }
  349.  
  350. void PrintTrailMessage(int client, int choice, char[] color)
  351. {
  352. if(gI_SelectedColor[client] == 0)
  353. {
  354. CPrintToChat(client, "%s Your trail is now {green}ENABLED{default}.", CHAT_PREFIX);
  355. CPrintToChat(client, "{default}Your beam color is %s.", color);
  356. }
  357.  
  358. if(gI_SelectedColor[client] != 0 && gI_SelectedColor[client] != choice)
  359. {
  360. CPrintToChat(client, "%s Your trail color is now %s.", CHAT_PREFIX, color);
  361. }
  362. }
  363.  
  364. void PrintSpecialMessage(int client, int choice, char[] color)
  365. {
  366. if(gI_SelectedColor[client] == 0)
  367. {
  368. CPrintToChat(client, "%s Your trail is now {green}ENABLED{default}.", CHAT_PREFIX);
  369. CPrintToChat(client, "%s {darkblue}ENABLED{default}.", color);
  370. }
  371.  
  372. if(gI_SelectedColor[client] != 0 && gI_SelectedColor[client] != choice)
  373. {
  374. CPrintToChat(client, "%s %s {darkblue}ENABLED{default}.", CHAT_PREFIX, color);
  375. }
  376. }
  377.  
  378. public Action OnPlayerRunCmd(int client)
  379. {
  380. float origin[3];
  381. GetClientAbsOrigin(client, origin);
  382.  
  383. CreatePlayerTrail(client, origin);
  384. gF_LastPosition[client] = origin;
  385. }
  386.  
  387. void CreatePlayerTrail(int client, float origin[3])
  388. {
  389. if(!gB_PluginEnabled || !IsPlayerAlive(client) || gB_TouchingTrigger[client])
  390. {
  391. return;
  392. }
  393.  
  394. if(gB_AdminsOnly && !CheckCommandAccess(client, "sm_trails_override", ADMFLAG_RESERVATION))
  395. {
  396. return;
  397. }
  398.  
  399. float pos1[3];
  400. pos1[0] = origin[0];
  401. pos1[1] = origin[1];
  402. pos1[2] = origin[2] + 5.0;
  403.  
  404. float pos2[3];
  405. pos2[0] = gF_LastPosition[client][0];
  406. pos2[1] = gF_LastPosition[client][1];
  407. pos2[2] = gF_LastPosition[client][2] + 5.0;
  408.  
  409. int rgba[4];
  410. rgba[3] = TRAIL_OPACITY;
  411.  
  412. int stepsize;
  413.  
  414. switch(gI_SelectedColor[client])
  415. {
  416. case 1: // Red trail
  417. {
  418. rgba[0] = 255; rgba[1] = 0; rgba[2] = 0;
  419. }
  420.  
  421. case 2: // Orange trail
  422. {
  423. rgba[0] = 255; rgba[1] = 128; rgba[2] = 0;
  424. }
  425.  
  426. case 3: // Yellow trail
  427. {
  428. rgba[0] = 255; rgba[1] = 255; rgba[2] = 0;
  429. }
  430.  
  431. case 4: // Lime trail
  432. {
  433. rgba[0] = 128; rgba[1] = 255; rgba[2] = 0;
  434. }
  435.  
  436. case 5: // Green trail
  437. {
  438. rgba[0] = 0; rgba[1] = 255; rgba[2] = 0;
  439. }
  440.  
  441. case 6: // Emerald trail
  442. {
  443. rgba[0] = 0; rgba[1] = 255; rgba[2] = 128;
  444. }
  445.  
  446. case 7: // Cyan trail
  447. {
  448. rgba[0] = 0; rgba[1] = 255; rgba[2] = 255;
  449. }
  450.  
  451. case 8: // Light blue trail
  452. {
  453. rgba[0] = 0; rgba[1] = 128; rgba[2] = 255;
  454. }
  455.  
  456. case 9: // Blue trail
  457. {
  458. rgba[0] = 0; rgba[1] = 0; rgba[2] = 255;
  459. }
  460.  
  461. case 10: // Purple trail
  462. {
  463. rgba[0] = 128; rgba[1] = 0; rgba[2] = 255;
  464. }
  465.  
  466. case 11: // Magenta trail
  467. {
  468. rgba[0] = 255; rgba[1] = 0; rgba[2] = 255;
  469. }
  470.  
  471. case 12: // Pink trail
  472. {
  473. rgba[0] = 255; rgba[1] = 64; rgba[2] = 128;
  474. }
  475.  
  476. case 13: // White trail
  477. {
  478. rgba[0] = 255; rgba[1] = 255; rgba[2] = 255;
  479. }
  480.  
  481. case 14: // Velocity trail
  482. {
  483. float fAbsVelocity[3];
  484. GetEntPropVector(client, Prop_Data, "m_vecAbsVelocity", fAbsVelocity);
  485. float fCurrentSpeed = SquareRoot(Pow(fAbsVelocity[0], 2.0) + Pow(fAbsVelocity[1], 2.0));
  486.  
  487. DrawVelocityTrail(client, fCurrentSpeed);
  488.  
  489. rgba[0] = gI_CycleColor[client][0]; rgba[1] = gI_CycleColor[client][1]; rgba[2] = gI_CycleColor[client][2];
  490. }
  491.  
  492. case 15: // Spectrum trail
  493. {
  494. stepsize = 1;
  495. DrawSpectrumTrail(client, stepsize);
  496.  
  497. rgba[0] = gI_CycleColor[client][0]; rgba[1] = gI_CycleColor[client][1]; rgba[2] = gI_CycleColor[client][2];
  498. }
  499.  
  500. case 16: // Wave trail
  501. {
  502. stepsize = 15;
  503. DrawSpectrumTrail(client, stepsize);
  504.  
  505. rgba[0] = gI_CycleColor[client][0]; rgba[1] = gI_CycleColor[client][1]; rgba[2] = gI_CycleColor[client][2];
  506. }
  507.  
  508. default: // None
  509. {
  510. return;
  511. }
  512. }
  513.  
  514. TE_SetupBeamPoints(pos1, pos2, gI_BeamSprite, 0, 0, 0, gF_BeamLife, gF_BeamWidth, gF_BeamWidth, 10, 0.0, rgba, 0);
  515. TE_SendToAll(0.0);
  516. }
  517.  
  518. void DrawSpectrumTrail(int client, int stepsize)
  519. {
  520. if(gB_RedToYellow[client])
  521. {
  522. gB_MagentaToRed[client] = false;
  523. gI_CycleColor[client][0] = 255; gI_CycleColor[client][1] += stepsize; gI_CycleColor[client][2] = 0;
  524.  
  525. if(gI_CycleColor[client][0] >= 255 && gI_CycleColor[client][1] >= 255 && gI_CycleColor[client][2] <= 0)
  526. gB_YellowToGreen[client] = true;
  527. }
  528.  
  529. if(gB_YellowToGreen[client])
  530. {
  531. gB_RedToYellow[client] = false;
  532. gI_CycleColor[client][0] -= stepsize; gI_CycleColor[client][1] = 255; gI_CycleColor[client][2] = 0;
  533.  
  534. if(gI_CycleColor[client][0] <= 0 && gI_CycleColor[client][1] >= 255 && gI_CycleColor[client][2] <= 0)
  535. gB_GreenToCyan[client] = true;
  536. }
  537.  
  538. if(gB_GreenToCyan[client])
  539. {
  540. gB_YellowToGreen[client] = false;
  541. gI_CycleColor[client][0] = 0; gI_CycleColor[client][1] = 255; gI_CycleColor[client][2] += stepsize;
  542.  
  543. if(gI_CycleColor[client][0] <= 0 && gI_CycleColor[client][1] >= 255 && gI_CycleColor[client][2] >= 255)
  544. gB_CyanToBlue[client] = true;
  545. }
  546.  
  547. if(gB_CyanToBlue[client])
  548. {
  549. gB_GreenToCyan[client] = false;
  550. gI_CycleColor[client][0] = 0; gI_CycleColor[client][1] -= stepsize; gI_CycleColor[client][2] = 255;
  551.  
  552. if(gI_CycleColor[client][0] <= 0 && gI_CycleColor[client][1] <= 0 && gI_CycleColor[client][2] >= 255)
  553. gB_BlueToMagenta[client] = true;
  554. }
  555.  
  556. if(gB_BlueToMagenta[client])
  557. {
  558. gB_CyanToBlue[client] = false;
  559. gI_CycleColor[client][0] += stepsize; gI_CycleColor[client][1] = 0; gI_CycleColor[client][2] = 255;
  560.  
  561. if(gI_CycleColor[client][0] >= 255 && gI_CycleColor[client][1] <= 0 && gI_CycleColor[client][2] >= 255)
  562. gB_MagentaToRed[client] = true;
  563. }
  564.  
  565. if(gB_MagentaToRed[client])
  566. {
  567. gB_BlueToMagenta[client] = false;
  568.  
  569. gI_CycleColor[client][0] = 255; gI_CycleColor[client][1] = 0; gI_CycleColor[client][2] -= stepsize;
  570.  
  571. if(gI_CycleColor[client][0] >= 255 && gI_CycleColor[client][1] <= 0 && gI_CycleColor[client][2] <= 0)
  572. gB_RedToYellow[client] = true;
  573. }
  574. }
  575.  
  576. void DrawVelocityTrail(int client, float fCurrentSpeed)
  577. {
  578. int stepsize;
  579.  
  580. if(fCurrentSpeed <= 255.0)
  581. {
  582. gI_CycleColor[client][0] = 0; gI_CycleColor[client][1] = 0; gI_CycleColor[client][2] = 255;
  583. }
  584.  
  585. else if(fCurrentSpeed > 255.0 && fCurrentSpeed <= 510.0)
  586. {
  587. stepsize = RoundToFloor(fCurrentSpeed) - 255;
  588. gI_CycleColor[client][0] = 0; gI_CycleColor[client][1] = stepsize; gI_CycleColor[client][2] = 255;
  589. }
  590.  
  591. else if(fCurrentSpeed > 510.0 && fCurrentSpeed <= 765.0)
  592. {
  593. stepsize = RoundToFloor(-fCurrentSpeed) + 510;
  594. gI_CycleColor[client][0] = 0; gI_CycleColor[client][1] = 255; gI_CycleColor[client][2] = stepsize;
  595. }
  596.  
  597. else if(fCurrentSpeed > 765.0 && fCurrentSpeed <= 1020.0)
  598. {
  599. stepsize = RoundToFloor(fCurrentSpeed) - 765;
  600. gI_CycleColor[client][0] = stepsize; gI_CycleColor[client][1] = 255; gI_CycleColor[client][2] = 0;
  601. }
  602.  
  603. else if(fCurrentSpeed > 1020.0 && fCurrentSpeed <= 1275.0)
  604. {
  605. stepsize = RoundToFloor(-fCurrentSpeed) + 1020;
  606. gI_CycleColor[client][0] = 255; gI_CycleColor[client][1] = stepsize; gI_CycleColor[client][2] = 0;
  607. }
  608.  
  609. else if(fCurrentSpeed > 1275.0 && fCurrentSpeed <= 1530.0)
  610. {
  611. stepsize = RoundToFloor(fCurrentSpeed) - 1275;
  612. gI_CycleColor[client][0] = 255; gI_CycleColor[client][1] = 0; gI_CycleColor[client][2] = stepsize;
  613. }
  614.  
  615. else if(fCurrentSpeed > 1530.0 && fCurrentSpeed <= 1660.0)
  616. {
  617. stepsize = RoundToFloor(-fCurrentSpeed) + 1530;
  618. gI_CycleColor[client][0] = stepsize; gI_CycleColor[client][1] = 0; gI_CycleColor[client][2] = 255;
  619. }
  620.  
  621. else
  622. {
  623. gI_CycleColor[client][0] = 125; gI_CycleColor[client][1] = 0; gI_CycleColor[client][2] = 255;
  624. }
  625. }
  626.  
  627. /* Don't draw the trail after touching trigger_teleport */
  628.  
  629. public int StartTouchTrigger(const char[] output, int entity, int client, float delay)
  630. {
  631. if(client < 1 || client > MaxClients)
  632. {
  633. return;
  634. }
  635.  
  636. if(!IsClientInGame(client) || !IsPlayerAlive(client))
  637. {
  638. return;
  639. }
  640.  
  641. gB_TouchingTrigger[client] = true;
  642. }
  643.  
  644. public int EndTouchTrigger(const char[] output, int entity, int client, float delay)
  645. {
  646. if(client < 1 || client > MaxClients)
  647. {
  648. return;
  649. }
  650.  
  651. if(!IsClientInGame(client) || !IsPlayerAlive(client))
  652. {
  653. return;
  654. }
  655.  
  656. CreateTimer(0.1, BlockOffTrigger, client, TIMER_FLAG_NO_MAPCHANGE);
  657. }
  658.  
  659. public Action BlockOffTrigger(Handle timer, any client)
  660. {
  661. gB_TouchingTrigger[client] = false;
  662. return Plugin_Stop;
  663. }
  664. ____ is offline
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement