Advertisement
FlacoBey

Untitled

May 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.11 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sourcemod>
  5. #include <sdktools>
  6.  
  7. #define TEAM_INFECTED                3
  8.  
  9. #define MODEL_CONCRETE_CHUNK         "models/props_debris/concrete_chunk01a.mdl"
  10. #define MODEL_TREE_TRUNK             "models/props_foliage/tree_trunk.mdl"
  11. #define MODEL_ROCK          "models/props_wasteland/rock_moss02.mdl"
  12. #define MODEL_LOCK "models/props_wasteland/rockcliff_cluster03a_river.mdl" //1
  13. #define MODEL_DPAW "models/props_foliage/cedar_medium01.mdl"//2
  14.  
  15. #define TYPE_CONCRETE_CHUNK          (1 << 0)
  16. #define TYPE_TREE_TRUNK              (1 << 1)
  17.  
  18. public void OnMapStart()
  19. {
  20.     PrecacheModel(MODEL_CONCRETE_CHUNK, true);
  21.     PrecacheModel(MODEL_TREE_TRUNK, true);
  22.     PrecacheModel(MODEL_ROCK, true);
  23.     PrecacheModel(MODEL_LOCK, true);
  24.     PrecacheModel(MODEL_DPAW, true);
  25. }
  26.  
  27. public void OnEntityCreated(int entity, const char[] classname)
  28. {
  29.     if (StrEqual(classname, "tank_rock", false))
  30.         RequestFrame(OnTankRockNextFrame, EntIndexToEntRef(entity));
  31. }
  32.  
  33. void OnTankRockNextFrame(int iEntRef)
  34. {
  35.    
  36.     if (!IsValidEntRef(iEntRef))
  37.         return;
  38.    
  39.     int entity = EntRefToEntIndex(iEntRef);
  40.    
  41.     int client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
  42.    
  43.     if (!IsValidClient(client))
  44.         return;
  45.    
  46.     if (!IsPlayerAlive(client))
  47.         return;
  48.  
  49.     if (GetClientTeam(client) != TEAM_INFECTED)
  50.         return;
  51.  
  52.     if (IsPlayerGhost(client))
  53.         return;
  54.  
  55.  
  56.     switch (GetRandomInt(1, 5))
  57.     {
  58.         case 1: SetEntityModel(entity, MODEL_CONCRETE_CHUNK);
  59.         case 2: SetEntityModel(entity, MODEL_TREE_TRUNK);
  60.         case 3: SetEntityModel(entity, MODEL_ROCK);
  61.         case 4: SetEntityModel(entity, MODEL_LOCK);
  62.         case 5: SetEntityModel(entity, MODEL_DPAW);
  63.     }
  64. }
  65.  
  66.  
  67. bool IsValidClient(int client)
  68. {
  69.     return (1 <= client <= MaxClients && IsClientInGame(client));
  70. }
  71.  
  72. bool IsPlayerGhost(int client)
  73. {
  74.     return GetEntProp(client, Prop_Send, "m_isGhost", 1) == 1;
  75. }
  76.  
  77. bool IsValidEntRef(int iEntRef)
  78. {
  79.     return iEntRef != 0 && EntRefToEntIndex(iEntRef) != INVALID_ENT_REFERENCE;
  80. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement