Advertisement
Guest User

Untitled

a guest
Nov 12th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.34 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. ConVar szybkosc_odepchniecia;
  5. ConVar sila_odepchniecia;
  6. ConVar odlegosc_do_odepchniecia;
  7. ConVar cooldown;
  8.  
  9. int iCooldown[MAXPLAYERS+1];
  10.  
  11. public Plugin myinfo =
  12. {
  13. name = "Odpychanie na E",
  14. author = "SUPER TIMOR",
  15. description = "Plugin na odpychanie graczy",
  16. version = "1.0",
  17. url = "http://goBoosting.pl"
  18. };
  19.  
  20. public void OnPluginStart()
  21. {
  22. HookEvent("player_spawn", OdrodzenieGracza);
  23. szybkosc_odepchniecia = CreateConVar("szybkosc_odepchniecia", "25.0", "Szybkosc lotu odepchnietego");
  24. sila_odepchniecia = CreateConVar("sila_odepchniecia", "8.0", "Sila odepchniecia");
  25. odlegosc_do_odepchniecia = CreateConVar("odlegosc_do_odepchniecia", "70.0", "Ogległość, w której muszą się znajdować gracze by się odepchnąć");
  26. cooldown = CreateConVar("odepchniecie_cooldown", "5", "Ile sekund między odepchnięciami?");
  27. AutoExecConfig(true, "", "sourcemod");
  28. }
  29.  
  30. public Action OnPlayerRunCmd(int client, int& buttons, int& impulse, float vel[3], float angles[3], int& weapons)
  31. {
  32. if(!IsValidClient(client) || !IsPlayerAlive(client))
  33. return Plugin_Continue;
  34.  
  35. if(buttons & IN_USE)
  36. {
  37. if(iCooldown[client] >= GetTime())
  38. return Plugin_Continue;
  39.  
  40. int target = GetClientAimTarget(client);
  41.  
  42. if(!IsValidClient(target) || !IsPlayerAlive(target))
  43. return Plugin_Continue;
  44.  
  45. float clientPos[3], targetPos[3], pushVel[3];
  46. GetClientAbsOrigin(client, clientPos);
  47. GetClientAbsOrigin(target, targetPos);
  48. float distance = GetVectorDistance(targetPos, clientPos);
  49. distance = (distance > 0.0) ? distance : 1.0;
  50. if(distance > odlegosc_do_odepchniecia.FloatValue)
  51. return Plugin_Continue;
  52.  
  53. SubtractVectors(clientPos, targetPos, pushVel);
  54.  
  55. pushVel[0] = -pushVel[0];
  56. pushVel[1] = -pushVel[1];
  57. pushVel[2] = szybkosc_odepchniecia.FloatValue;
  58. ScaleVector(pushVel, sila_odepchniecia.FloatValue);
  59. TeleportEntity(target, NULL_VECTOR, NULL_VECTOR, pushVel);
  60. iCooldown[client] = GetTime() + cooldown.IntValue;
  61. }
  62.  
  63. return Plugin_Continue;
  64. }
  65. public Action OdrodzenieGracza(Event event, char[] name, bool dontBroadcast)
  66. {
  67. int client = GetClientOfUserId(GetEventInt(event, "userid"));
  68. iCooldown[client] = 0;
  69. }
  70. public bool IsValidClient(int client)
  71. {
  72. if(client >= 1 && client <= MaxClients && IsClientInGame(client))
  73. return true;
  74.  
  75. return false;
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement