Advertisement
FlacoBey

Untitled

May 21st, 2019
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.11 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. ConVar dark, iKills;
  5.  
  6. new bool:IsKilled[2048+1] = false;
  7. int ref[2048+1];
  8. int iKill[MAXPLAYERS+1];
  9.  
  10. public OnPluginStart()
  11. {
  12.     dark = CreateConVar("melee_chance", "25", "Chance", FCVAR_NONE);
  13.     iKills = CreateConVar("melee_kills", "50", "Number of kills to trigger the chance.", FCVAR_NONE);
  14.    
  15.     HookEvent("infected_death", InKill);
  16.     HookEvent("infected_hurt", Mind, EventHookMode_Pre);
  17.     HookEvent("player_death", InDeath);
  18. }
  19.  
  20. public OnClientPutInServer(client)
  21. {
  22.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  23. }
  24.  
  25. public OnClientDisconnect(client)
  26. {
  27.     SDKUnhook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  28. }
  29.  
  30. public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype)  
  31. {
  32.     if (IsValidInfected(victim))
  33.     {
  34.         if(bIsSurvivor(attacker) && !IsFakeClient(attacker))
  35.         {
  36.             int iCurrentWeapon = GetEntPropEnt(attacker, Prop_Send, "m_hActiveWeapon");
  37.             new NotWeapon = EntRefToEntIndex(ref[iCurrentWeapon])
  38.             if(IsKilled[NotWeapon])
  39.             {
  40.                 damage = 0.0;
  41.                 return Plugin_Changed;
  42.             }
  43.         }
  44.     }
  45.     return Plugin_Continue;
  46. }
  47.  
  48. public Action InKill(Event event, const char[] name, bool dontBroadcast)
  49. {
  50.     //int XD = GetClientOfUserId(event.GetInt("infected_id"));
  51.     int client = GetClientOfUserId(event.GetInt("attacker"));
  52.    
  53.     if(bIsSurvivor(client) && !IsFakeClient(client))
  54.     {
  55.        
  56.         new vSlot = GetPlayerWeaponSlot(client, 1);
  57.         int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  58.         char sWeaponEx[32]
  59.         GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof(sWeaponEx))
  60.        
  61.         if(iCurrentWeapon == vSlot)
  62.         {
  63.             if(StrEqual(sWeaponEx, "weapon_melee"))
  64.             {
  65.                 if(!IsKilled[iCurrentWeapon])
  66.                 {
  67.                     if(iKill[client] >= GetConVarInt(iKills))
  68.                     {
  69.                         if(GetRandomInt(0, 100) < GetConVarInt(dark))
  70.                         {
  71.                             IsKilled[iCurrentWeapon] = true;
  72.                             ref[iCurrentWeapon] = EntIndexToEntRef(iCurrentWeapon)
  73.                             PrintToChat(client, "Ваша рукпоашка откинулась.")
  74.                         }
  75.                         iKill[client] = 0;
  76.                     }
  77.                     iKill[client]++
  78.                 }
  79.             }
  80.         }
  81.     }
  82. }
  83.  
  84. public Action Mind(Handle:event, const String:name[], bool:dontBroadcast)
  85. {
  86.     new client = GetClientOfUserId(GetEventInt(event, "attacker"));
  87.     new Idiot = GetEventInt(event, "entityid");
  88.     if(bIsSurvivor(client) && !IsFakeClient(client))
  89.     {
  90.         int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  91.         new NotWeapon = EntRefToEntIndex(ref[iCurrentWeapon])
  92.         if(IsKilled[NotWeapon])
  93.         {
  94.             new Hada = GetEventInt(event,"amount");
  95.             new blood = GetEntProp(Idiot, Prop_Data, "m_iHealth");
  96.             new twillight = Hada + blood;
  97.             SetEntProp(Idiot, Prop_Data, "m_iHealth", twillight++);
  98.             SetEventInt(event, "amount", 0);
  99.         }
  100.     }
  101. }
  102.  
  103. public Action InDeath(Event event, const char[] name, bool dontBroadcast)
  104. {
  105.     int client = GetClientOfUserId(event.GetInt("attacker"));
  106.    
  107.     if(bIsSurvivor(client) && !IsFakeClient(client))
  108.     {
  109.        
  110.         new vSlot = GetPlayerWeaponSlot(client, 1);
  111.         int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  112.         char sWeaponEx[32]
  113.         GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof(sWeaponEx))
  114.        
  115.         if(iCurrentWeapon == vSlot)
  116.         {
  117.             if(StrEqual(sWeaponEx, "weapon_melee"))
  118.             {
  119.                 if(!IsKilled[iCurrentWeapon])
  120.                 {
  121.                     if(iKill[client] >= GetConVarInt(iKills))
  122.                     {
  123.                         if(GetRandomInt(0, 100) < GetConVarInt(dark))
  124.                         {
  125.                             IsKilled[iCurrentWeapon] = true;
  126.                             ref[iCurrentWeapon] = EntIndexToEntRef(iCurrentWeapon)
  127.                             PrintToChat(client, "Ваша рукпоашка откинулась.")
  128.                         }
  129.                         iKill[client] = 0;
  130.                     }
  131.                     iKill[client]++
  132.                 }
  133.             }
  134.         }
  135.     }
  136. }
  137.  
  138. stock bool:IsValidInfected( client )
  139. {
  140.     if ( client < 1 || client > MaxClients ) return false;
  141.     if ( !IsClientConnected( client )) return false;
  142.     if ( !IsClientInGame( client )) return false;
  143.     if ( GetClientTeam( client ) != 3 ) return false;
  144.     return true;
  145. }
  146.  
  147. stock bool bIsSurvivor(int client)
  148. {
  149.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  150. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement