Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.03 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6.  
  7. bool g_bHave[MAXPLAYERS + 1], g_bState[MAXPLAYERS + 1];
  8.  
  9. public void OnPluginStart()
  10. {
  11. RegConsoleCmd("sm_l", cLaser);
  12.  
  13. HookEvent("player_death", eDeath);
  14. HookEvent("round_start", eStart, EventHookMode_PostNoCopy);
  15. }
  16.  
  17. public void OnMapStart()
  18. {
  19. char szMap[56];
  20. GetCurrentMap(szMap, sizeof szMap);
  21.  
  22. if (StrContains(szMap, "m1") != -1)
  23. {
  24. for (int i = 1; i <= MaxClients; i++)
  25. {
  26. g_bHave[i] = false;
  27. g_bState[i] = false;
  28. }
  29. }
  30. }
  31.  
  32. public Action eStart(Event event, const char[] name, bool dontbroadcast)
  33. {
  34. for (int i = 1; i <= MaxClients; i++)
  35. if (g_bState[i])
  36. g_bHave[i] = true;
  37. }
  38.  
  39. public Action eDeath(Event event, const char[] name, bool dontbroadcast)
  40. {
  41. int client = GetClientOfUserId(event.GetInt("userid"));
  42.  
  43. if(g_bHave[client])
  44. g_bState[client] = true;
  45.  
  46. g_bHave[client] = false;
  47. }
  48.  
  49. public Action cLaser (int client, int args)
  50. {
  51. if (!client)
  52. return Plugin_Handled;
  53.  
  54. int iWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  55.  
  56. if (!IsValidEntity(iWeapon) || iWeapon != GetPlayerWeaponSlot(client, 0))
  57. return Plugin_Handled;
  58.  
  59. char szBuffer[36];
  60. GetEntityNetClass(iWeapon, szBuffer, sizeof szBuffer);
  61.  
  62. if (FindSendPropInfo(szBuffer, "m_upgradeBitVec") < 1)
  63. return Plugin_Handled;
  64.  
  65. if (GetEntProp(iWeapon, Prop_Send, "m_upgradeBitVec") == (1 << 2))
  66. {
  67. if (!g_bHave[client])
  68. {
  69. UpgradeSwitchBits(client, false);
  70. g_bHave[client] = true;
  71. }
  72. }
  73. else
  74. {
  75. if (g_bHave[client])
  76. {
  77. UpgradeSwitchBits(client, true);
  78. g_bHave[client] = false;
  79. }
  80. }
  81.  
  82. return Plugin_Handled;
  83. }
  84.  
  85. stock void UpgradeSwitchBits (int client, bool switchl)
  86. {
  87. char szBuffer[36];
  88. Format(szBuffer, sizeof szBuffer, "%s", switchl ? "upgrade_add" : "upgrade_remove");
  89.  
  90. int iFlags = GetCommandFlags(szBuffer);
  91. SetCommandFlags(szBuffer, iFlags & ~FCVAR_CHEAT);
  92. FakeClientCommand(client, "%s LASER_SIGHT", szBuffer);
  93. SetCommandFlags(szBuffer, iFlags);
  94. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement