FlacoBey

Untitled

Jun 9th, 2019
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.06 KB | None | 0 0
  1. #include <sdktools>
  2. #include <sdkhooks>
  3.  
  4. #pragma newdecls required
  5. #pragma semicolon 1
  6.  
  7. #define iSound1 "player/charger/hit/charger_smash_02.wav"
  8.  
  9. public void OnMapStart()
  10. {
  11.     PrecacheParticle("boomer_explode");
  12.     PrecacheSound(iSound1);
  13. }
  14.  
  15. public void OnClientPutInServer(int client)
  16. {
  17.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  18. }
  19.  
  20. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)  
  21. {
  22.     if(bIsSurvivor(victim) && IsTank(attacker))
  23.     {
  24.         char classname[24];
  25.         GetEdictClassname(inflictor, classname, sizeof(classname));
  26.         if (strcmp(classname, "weapon_tank_claw") == 0)
  27.         {
  28.             CreateParticle(victim, "boomer_explode", false, 3.0);
  29.             ForcePlayerSuicide(victim);
  30.             EmitSoundToAll(iSound1, attacker, SNDCHAN_AUTO );
  31.         }
  32.     }
  33. }
  34.  
  35. bool IsTank(int client)
  36. {
  37.     if (client > 0 && client <= MaxClients && IsClientInGame(client))
  38.     {
  39.         char classname[32];
  40.         GetEntityNetClass(client, classname, 32);
  41.         if (StrEqual(classname, "Tank", false))
  42.         {
  43.             return true;
  44.         }
  45.     }
  46.     return false;
  47. }
  48.  
  49. public void PrecacheParticle(char[] particlename)
  50. {
  51.     int particle = CreateEntityByName("info_particle_system");
  52.     if (IsValidEntity(particle))
  53.     {
  54.         DispatchKeyValue(particle, "effect_name", particlename);
  55.         DispatchKeyValue(particle, "targetname", "particle");
  56.         DispatchSpawn(particle);
  57.         ActivateEntity(particle);
  58.         AcceptEntityInput(particle, "start", -1, -1, 0);
  59.         CreateTimer(0.1, DeleteParticles, particle, 2);
  60.     }
  61. }
  62.  
  63. public Action DeleteParticles(Handle timer, any particle)
  64. {
  65.     if (IsValidEntity(particle))
  66.     {
  67.         char classname[24];
  68.         GetEdictClassname(particle, classname, sizeof(classname));
  69.         if (StrEqual(classname, "info_particle_system"))
  70.         {
  71.             AcceptEntityInput(particle, "Kill");
  72.         }
  73.     }
  74. }
  75.  
  76. stock void CreateParticle(int client, char[] Particle_Name, bool Parent, float duration)
  77. {
  78.     float pos[3];
  79.     char sName[64], sTargetName[64];
  80.     int Particle = CreateEntityByName("info_particle_system");
  81.     GetClientAbsOrigin(client, pos);
  82.     TeleportEntity(Particle, pos, NULL_VECTOR, NULL_VECTOR);
  83.     DispatchKeyValue(Particle, "effect_name", Particle_Name);
  84.     if(Parent)
  85.     {
  86.         Format(sName, sizeof(sName), "%d", client+25);
  87.         DispatchKeyValue(client, "targetname", sName);
  88.         GetEntPropString(client, Prop_Data, "m_iName", sName, sizeof(sName));
  89.        
  90.         Format(sTargetName, sizeof(sTargetName), "%d", client+1000);
  91.         DispatchKeyValue(Particle, "targetname", sTargetName);
  92.         DispatchKeyValue(Particle, "parentname", sName);
  93.     }
  94.     DispatchSpawn(Particle);
  95.     DispatchSpawn(Particle);
  96.     if(Parent)
  97.     {
  98.         SetVariantString(sName);
  99.         AcceptEntityInput(Particle, "SetParent", Particle, Particle);
  100.     }
  101.     ActivateEntity(Particle);
  102.     AcceptEntityInput(Particle, "start");
  103.     CreateTimer(duration, timerStopAndRemoveParticle, Particle, TIMER_FLAG_NO_MAPCHANGE);
  104. }
  105.  
  106. public Action timerStopAndRemoveParticle(Handle timer, any entity)
  107. {
  108.     if(entity > 0 && IsValidEntity(entity) && IsValidEdict(entity))
  109.     {
  110.         AcceptEntityInput(entity, "Kill");
  111.     }
  112. }
  113.  
  114. stock bool bIsSurvivor(int client)
  115. {
  116.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  117. }
  118.  
  119. stock void ForceDamageEntity(int causer, int damage, int victim) // thanks to 达斯*维达
  120. {
  121.     float victim_origin[3];
  122.     char rupture[32];
  123.     char damage_victim[32];
  124.     IntToString(damage, rupture, sizeof(rupture));
  125.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  126.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  127.     int entity = CreateEntityByName("point_hurt");
  128.     DispatchKeyValue(victim, "targetname", damage_victim);
  129.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  130.     DispatchKeyValue(entity, "Damage", rupture);
  131.     DispatchSpawn(entity);
  132.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  133.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  134.     DispatchKeyValue(entity, "classname", "point_hurt");
  135.     DispatchKeyValue(victim, "targetname", "null");
  136.     AcceptEntityInput(entity, "Kill");
  137. }
Advertisement
Add Comment
Please, Sign In to add comment