FlacoBey

Untitled

Mar 1st, 2019
134
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 3.36 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. new vClient[MAXPLAYERS+1];
  6.  
  7. public Action:OnPlayerRunCmd(client, &buttons, &impuls, Float:vel[3], Float:angles[3], &weapon)
  8. {
  9.     if(bIsSurvivor(client))
  10.     {
  11.         char sWeaponEx[32];
  12.         int iCurrentWeapon = GetEntPropEnt(client, Prop_Send, "m_hActiveWeapon");
  13.         if (IsValidEntity(iCurrentWeapon) && IsValidEdict(iCurrentWeapon))
  14.         {
  15.             GetEntityClassname(iCurrentWeapon, sWeaponEx, sizeof(sWeaponEx))
  16.             if(StrEqual(sWeaponEx, "weapon_melee"))
  17.             {
  18.                 if(impuls == 201)
  19.                 {
  20.                     SDKCallWeaponDrop(client, iCurrentWeapon);
  21.                     SDKHook(iCurrentWeapon, SDKHook_StartTouchPost, OnTouch)
  22.                     vClient[client] = client;
  23.                 }
  24.             }
  25.         }
  26.     }
  27. }
  28.  
  29. public OnTouch(int thing, int other)
  30. {
  31.     if(!IsValidClient(other))
  32.     {
  33.         SDKUnhook(thing, SDKHook_StartTouchPost, OnTouch)
  34.     }
  35.     else if(other != vClient[other])
  36.     {
  37.         ForceDamageEntity(thing, 250, other)
  38.     }
  39. }
  40.  
  41. stock void vSetVector(float target[3], float x, float y, float z)
  42. {
  43.     target[0] = x;
  44.     target[1] = y;
  45.     target[2] = z;
  46. }
  47.  
  48. stock bool:IsValidClient( client )
  49. {
  50.     if ( client < 1 || client > MaxClients ) return false;
  51.     if ( !IsClientConnected( client )) return false;
  52.     if ( !IsClientInGame( client )) return false;
  53.     if ( !IsPlayerAlive( client )) return false;
  54.     return true;
  55. }
  56.  
  57. stock ForceDamageEntity(causer, damage, victim)
  58. {
  59.     float victim_origin[3];
  60.     new String:rupture[32];
  61.     new String:damage_victim[32];
  62.     IntToString(damage, rupture, sizeof(rupture));
  63.     Format(damage_victim, sizeof(damage_victim), "hurtme%d", victim);
  64.     GetEntPropVector(victim, Prop_Send, "m_vecOrigin", victim_origin);
  65.     new entity = CreateEntityByName("point_hurt");
  66.     DispatchKeyValue(victim, "targetname", damage_victim);
  67.     DispatchKeyValue(entity, "DamageTarget", damage_victim);
  68.     DispatchKeyValue(entity, "Damage", rupture);
  69.     DispatchSpawn(entity);
  70.     TeleportEntity(entity, victim_origin, NULL_VECTOR, NULL_VECTOR);
  71.     AcceptEntityInput(entity, "Hurt", (causer > 0 && causer <= MaxClients) ? causer : -1);
  72.     DispatchKeyValue(entity, "classname", "point_hurt");
  73.     DispatchKeyValue(victim, "targetname", "null");
  74.     AcceptEntityInput(entity, "Kill");
  75. }
  76.  
  77. stock SDKCallWeaponDrop(client, weapon)
  78. {
  79.     decl Float:vecAngles[3], Float:vecTarget[3], Float:vecVelocity[3];
  80.     if (GetPlayerEye(client, vecTarget))
  81.     {
  82.         GetClientEyeAngles(client, vecAngles);
  83.         GetAngleVectors(vecAngles, vecVelocity, NULL_VECTOR, NULL_VECTOR)
  84.         vecVelocity[0] *= 475.0;
  85.         vecVelocity[1] *= 475.0;
  86.         vecVelocity[2] *= 475.0;
  87.  
  88.         SDKHooks_DropWeapon(client, weapon, NULL_VECTOR, NULL_VECTOR);
  89.        
  90.         TeleportEntity(weapon, NULL_VECTOR, NULL_VECTOR, vecVelocity)
  91.     }
  92. }
  93.  
  94. stock bool:GetPlayerEye(client, Float:vecTarget[3])
  95. {
  96.     decl Float:Origin[3], Float:Angles[3];
  97.     GetClientEyePosition(client, Origin);
  98.     GetClientEyeAngles(client, Angles);
  99.  
  100.     new Handle:trace = TR_TraceRayFilterEx(Origin, Angles, MASK_SHOT, RayType_Infinite, TraceEntityFilterPlayer);
  101.     if (TR_DidHit(trace))
  102.     {
  103.         TR_GetEndPosition(vecTarget, trace);
  104.         CloseHandle(trace);
  105.         return true;
  106.     }
  107.     CloseHandle(trace);
  108.     return false;
  109. }
  110.  
  111. public bool:TraceEntityFilterPlayer(entity, contentsMask)
  112. {
  113.     return entity > GetMaxClients() || !entity;
  114. }
  115.  
  116. stock bool bIsSurvivor(int client)
  117. {
  118.     return client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2 && !IsClientInKickQueue(client) && IsPlayerAlive(client);
  119. }
Advertisement
Add Comment
Please, Sign In to add comment