Advertisement
FlacoBey

Untitled

Jun 14th, 2019
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.05 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6. #include sdkhooks
  7.  
  8. Handle Blood;
  9. float vPos[MAXPLAYERS+1][3];
  10.  
  11. public void OnPluginStart()
  12. {
  13.     Handle hGameConf = LoadGameConfigFile("ChooseVictim");
  14.     if( hGameConf == null )
  15.         SetFailState("Couldn't find the offsets and signatures file. Please, check that it is installed correctly.");
  16.     StartPrepSDKCall(SDKCall_Static);
  17.     if( PrepSDKCall_SetFromConf(hGameConf, SDKConf_Signature, "Blood") == false )
  18.         SetFailState("Could not load the \"CPipeBombProjectile_Create\" gamedata signature.");
  19.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  20.     PrepSDKCall_AddParameter(SDKType_Vector, SDKPass_ByRef);
  21.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Pointer);
  22.     PrepSDKCall_AddParameter(SDKType_PlainOldData, SDKPass_Pointer);
  23.     Blood = EndPrepSDKCall();
  24.    
  25.     HookEvent("bullet_impact", EventImpact);
  26. }
  27.  
  28. public Action EventImpact(Handle event, const char[] name, bool dontBroadcast)
  29. {
  30.     int userid = GetClientOfUserId(GetEventInt(event, "userid"));
  31.    
  32.     if(bIsSurivor(userid))
  33.     {
  34.         vPos[userid][0] = GetEventFloat(event, "x");
  35.         vPos[userid][1] = GetEventFloat(event, "y");
  36.         vPos[userid][2] = GetEventFloat(event, "z");
  37.     }
  38. }
  39.  
  40. public void OnClientConnected(int client)
  41. {
  42.     SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
  43. }
  44.  
  45. public Action OnTakeDamage(int victim, int &attacker, int &inflictor, float &damage, int &damagetype)  
  46. {
  47.     if(bIsSurivor(victim))
  48.     {
  49.         float vStart[3];
  50.         for(int i = 1; i < GetRandomInt(1, 5); i++)
  51.         {
  52.             vStart[0] = vPos[attacker][0] + GetRandomInt(-5, 5);
  53.             vStart[1] = vPos[attacker][1] + GetRandomInt(-5, 5);
  54.             vStart[2] = vPos[attacker][2] + GetRandomInt(-5, 5);
  55.             SDKCall(Blood, vStart, vStart, 40, 40);
  56.         }
  57.     }
  58. }
  59.  
  60. public bool bIsSurivor(int client)
  61. {
  62.     if (client <= 0)
  63.         return false;
  64.        
  65.     if (client > MaxClients)
  66.         return false;
  67.        
  68.     if (!IsClientInGame(client))
  69.         return false;
  70.        
  71.     if (!IsPlayerAlive(client))
  72.         return false;
  73.        
  74.     if (GetClientTeam(client) != 2)
  75.         return false;
  76.  
  77.     return true;
  78. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement