FlacoBey

Untitled

Jan 16th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.06 KB | None | 0 0
  1. #include sdktools
  2.  
  3. #define L4D2_WEPUPGFLAG_LASER (1 << 2)
  4.  
  5. static int bHasLaser[MAXPLAYERS+1] = 0;
  6.  
  7. public OnMapStart()
  8. {
  9. decl String:map[128];
  10. GetCurrentMap(map, 128);
  11. if (StrContains(map, "m1", false))
  12. {
  13. for(int i = 1; i <= MaxClients; ++i)
  14. {
  15. bHasLaser[i] = 0;
  16. }
  17. }
  18. }
  19.  
  20. public OnPluginStart()
  21. {
  22. HookEvent("player_death", PlayerLoseLaser);
  23. RegConsoleCmd("sm_l", CmdLaserToggle);
  24. }
  25.  
  26. public Action PlayerLoseLaser(Event event, const char[] name, bool dontBroadcast)
  27. {
  28. int death = GetClientOfUserId(event.GetInt("userid"));
  29. bHasLaser[death] = 0;
  30. }
  31.  
  32. public Action:CmdLaserToggle(client, args)
  33. {
  34. new priWeapon = GetPlayerWeaponSlot(client, 0);
  35. if (priWeapon <= 0 || !IsValidEntity(priWeapon))
  36. return;
  37.  
  38. new upgrades = L4D2_GetWeaponUpgrades(priWeapon);
  39. if (upgrades & L4D2_WEPUPGFLAG_LASER)
  40. {
  41. if (bHasLaser[client] == 0)
  42. {
  43. CheatCommand(client, "upgrade_remove", "LASER_SIGHT");
  44. bHasLaser[client]++;
  45. PrintHintText(client,"Лазер снят");
  46. }
  47. else
  48. {
  49. PrintHintText(client,"Зачем тебе ещё 1 лазер?");
  50. }
  51. }
  52. if (upgrades != L4D2_WEPUPGFLAG_LASER)
  53. {
  54. if (bHasLaser[client] == 1)
  55. {
  56. CheatCommand(client, "upgrade_add", "LASER_SIGHT");
  57. bHasLaser[client] = false;
  58. PrintHintText(client,"Лазер установлен");
  59. }
  60. }
  61. }
  62.  
  63. stock L4D2_GetWeaponUpgrades(weapon)
  64. {
  65. return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
  66. }
  67.  
  68. stock CheatCommand(client, const String:command[], const String:arguments[])
  69. {
  70. if (!client) return;
  71. new admindata = GetUserFlagBits(client);
  72. SetUserFlagBits(client, ADMFLAG_ROOT);
  73. new flags = GetCommandFlags(command);
  74. SetCommandFlags(command, flags & ~FCVAR_CHEAT);
  75. FakeClientCommand(client, "%s %s", command, arguments);
  76. SetCommandFlags(command, flags);
  77. SetUserFlagBits(client, admindata);
  78. }
Advertisement
Add Comment
Please, Sign In to add comment