FlacoBey

Untitled

Jun 5th, 2019
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.16 KB | None | 0 0
  1. #include sdktools
  2. #include sdkhooks
  3.  
  4. #pragma newdecls required
  5. #pragma semicolon 1
  6.  
  7. public void OnEntityCreated(int entity, const char[] classname)
  8. {
  9.     if(IsValidEntity(entity))
  10.     {
  11.         SDKHook(entity, SDKHook_SpawnPost, SpawnPost);
  12.     }
  13. }
  14.  
  15. public void SpawnPost(int entity)
  16. {
  17.     if(IsValidEntity(entity))
  18.     {
  19.         RequestFrame(NextFrame, EntIndexToEntRef(entity));
  20.     }
  21. }
  22.  
  23. public void NextFrame(int entity)
  24. {
  25.     if(IsValidEntRef(entity))
  26.     {
  27.         entity = EntRefToEntIndex(entity);
  28.         if (IsValidEntity(entity))
  29.         {
  30.             char sClsName[32];
  31.             GetEntityClassname(entity, sClsName, sizeof(sClsName));
  32.             if(StrContains(sClsName, "spawn") > -1)
  33.             {
  34.                 if(StrContains(sClsName, "shotgun") > 1 || StrContains(sClsName, "rifle") > 1 || StrContains(sClsName, "sniper") || StrContains(sClsName, "smg") > 0)
  35.                 {
  36.                     DispatchKeyValue(entity, "count", "1");
  37.                 }
  38.             }
  39.         }
  40.     }
  41. }
  42.  
  43. bool IsValidEntRef(int iEnt)
  44. {
  45.     if( iEnt && EntRefToEntIndex(iEnt) != INVALID_ENT_REFERENCE )
  46.         return true;
  47.     return false;
  48. }
Advertisement
Add Comment
Please, Sign In to add comment