Advertisement
agentagony124

Left 4 Dead 2 Useful Bots

Jul 15th, 2023
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.05 KB | Source Code | 0 0
  1. #define Damage 1.6
  2.  
  3. public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max)
  4. {
  5. EngineVersion test = GetEngineVersion();
  6. if (test != Engine_Left4Dead && test != Engine_Left4Dead2) {
  7. strcopy(error, err_max, "Plugin only supports Left 4 Dead 1 & 2.");
  8. return APLRes_SilentFailure;
  9. }
  10. return APLRes_Success;
  11. }
  12.  
  13. public OnPluginStart(){
  14.  
  15. HookEvent("player_hurt", PlayerHurt);
  16. HookEvent("infected_hurt", InfectedHurt);
  17.  
  18. }
  19.  
  20. public Action PlayerHurt(Event event, const char[] name, bool dontBroadcast)
  21. {
  22. int attackerId = event.GetInt("attacker");
  23. int attacker = GetClientOfUserId(attackerId);
  24. //char name[64];
  25. //GetClientName(attacker, name, sizeof(name));
  26. if(attacker > 0 && attacker <= MaxClients && IsClientConnected(attacker) && IsClientInGame(attacker) && GetClientTeam(attacker) == 2 && IsFakeClient(attacker))
  27. {
  28. int amount = event.GetInt("dmg_health");
  29. int UserId = event.GetInt("userid");
  30. int client = GetClientOfUserId(UserId);
  31. int cur_health = event.GetInt("health");
  32. int dmg_health = RoundToNearest(cur_health - amount*Damage);
  33. if(GetClientTeam(client) == 3)
  34. {
  35. SetEntProp(client, Prop_Data, "m_iHealth", dmg_health + amount);
  36. return Plugin_Handled;
  37. }
  38. }
  39. return Plugin_Continue;
  40. }
  41.  
  42. public Action InfectedHurt(Event event, const char[] name, bool dontBroadcast)
  43. {
  44. int attackerId = event.GetInt("attacker");
  45. int attacker = GetClientOfUserId(attackerId);
  46. //char name[64];
  47. //GetClientName(attacker, name, sizeof(name));
  48. if(attacker > 0 && attacker <= MaxClients && IsClientConnected(attacker) && IsClientInGame(attacker) && GetClientTeam(attacker) == 2 && IsFakeClient(attacker))
  49. {
  50. int amount = event.GetInt("amount");
  51. int client = event.GetInt("entityid");
  52. int cur_health = GetEntProp(client, Prop_Data, "m_iHealth");
  53. int dmg_health = RoundToNearest(cur_health - amount*Damage);
  54. if(cur_health > 0)
  55. {
  56. SetEntProp(client, Prop_Data, "m_iHealth", dmg_health);
  57. return Plugin_Handled;
  58. }
  59. }
  60. return Plugin_Continue;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement