Advertisement
FlacoBey

Untitled

Jun 17th, 2019
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.82 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include sdktools
  5. #include sdkhooks
  6.  
  7. #define MAX_LIST 18
  8.  
  9. float Health[2048+1];
  10.  
  11. static const char gWeapons[MAX_LIST][] =
  12. {
  13.     "weapon_autoshotgun",
  14.     "weapon_hunting_rifle",
  15.     "weapon_pistol",
  16.     "weapon_pistol_magnum",
  17.     "weapon_pumpshotgun",
  18.     "weapon_rifle",
  19.     "weapon_rifle_ak47",
  20.     "weapon_rifle_desert",
  21.     "weapon_rifle_m60",
  22.     "weapon_rifle_sg552",
  23.     "weapon_shotgun_chrome",
  24.     "weapon_shotgun_spas",
  25.     "weapon_smg",
  26.     "weapon_smg_mp5",
  27.     "weapon_smg_silenced",
  28.     "weapon_sniper_awp",
  29.     "weapon_sniper_military",
  30.     "weapon_sniper_scout"
  31. };
  32.  
  33. static const float gDistance[MAX_LIST] =
  34. {
  35.     1650.0,
  36.     660.0,
  37.     880.0,
  38.     1980.0,
  39.     1650.0,
  40.     1100.0,
  41.     1100.0,
  42.     1100.0,
  43.     1320.0,
  44.     1100.0,
  45.     1540.0,
  46.     1540.0,
  47.     880.0,
  48.     880.0,
  49.     880.0,
  50.     1870.0,
  51.     1320.0,
  52.     1320.0
  53. };
  54.  
  55. public void OnPluginStart()
  56. {
  57.     HookEvent("round_start", EventFire, EventHookMode_PostNoCopy);
  58. }
  59.  
  60. public Action EventFire(Handle event, const char[] name, bool dontbroadcast)
  61. {
  62.     int entity = -1;
  63.     while((entity = FindEntityByClassname(entity, "prop_door_rotating_checkpoint")) != INVALID_ENT_REFERENCE)
  64.     {
  65.         SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
  66.         Health[entity] = 50000.0;
  67.     }
  68. }
  69.  
  70. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)
  71. {
  72.     if(bIsSurvivor(attacker) && IsValidEntity(victim))
  73.     {
  74.         char m_flModelName[128];
  75.         int weapon = GetEntPropEnt(attacker, Prop_Send, "m_hActiveWeapon");
  76.         if(IsValidEntity(weapon))
  77.         {
  78.             char weaponname[36];
  79.             GetEntityClassname(weapon, weaponname, sizeof(weaponname));
  80.             for( int i = 0; i < MAX_LIST; i++ )
  81.             {
  82.                 if(strcmp(weaponname, gWeapons[i]) == 0)
  83.                 {
  84.                     PrintToChatAll("Damage = %.2f", gDistance[i]);
  85.                     PrintToChatAll("Health = %.2f", Health[victim]);
  86.                     if((Health[victim] - gDistance[i]) > 0)
  87.                     {
  88.                         Health[victim] -= gDistance[i];
  89.                     }
  90.                     else
  91.                     {
  92.                         Health[victim] = 0.0;
  93.                         float vPos[3], vAng[3];
  94.                         GetEntPropVector(victim, Prop_Send, "m_vecOrigin", vPos);
  95.                         GetEntPropVector(victim, Prop_Send, "m_angRotation", vAng);
  96.                         GetEntPropString(victim, Prop_Data, "m_ModelName", m_flModelName, sizeof(m_flModelName));
  97.                        
  98.                         int physics = CreateEntityByName("prop_physics");
  99.                         SetEntityModel(physics, m_flModelName);
  100.                         DispatchSpawn(physics);
  101.                         TeleportEntity(physics, vPos, vAng, NULL_VECTOR);
  102.                         SetEntityMoveType(physics, MOVETYPE_VPHYSICS);
  103.                         AcceptEntityInput(victim, "kill");
  104.                        
  105.                     }
  106.                 }
  107.             }
  108.         }
  109.     }
  110. }
  111.  
  112. stock bool bIsSurvivor(int client)
  113. {
  114.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement