FlacoBey

Untitled

May 20th, 2019
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 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. }
  23.  
  24. public void OnEntityCreated(int entity, const char[] classname)
  25. {
  26.     if (StrEqual(classname, "tank_rock", false))
  27.         RequestFrame(OnTankRockNextFrame, EntIndexToEntRef(entity));
  28. }
  29.  
  30. void OnTankRockNextFrame(int iEntRef)
  31. {
  32.    
  33.     if (!IsValidEntRef(iEntRef))
  34.         return;
  35.    
  36.     int entity = EntRefToEntIndex(iEntRef);
  37.    
  38.     int client = GetEntPropEnt(entity, Prop_Send, "m_hOwnerEntity");
  39.    
  40.     if (!IsValidClient(client))
  41.         return;
  42.    
  43.     if (!IsPlayerAlive(client))
  44.         return;
  45.  
  46.     if (GetClientTeam(client) != TEAM_INFECTED)
  47.         return;
  48.  
  49.     if (IsPlayerGhost(client))
  50.         return;
  51.  
  52.  
  53.     switch (GetRandomInt(1, 5))
  54.     {
  55.         case 1: SetEntityModel(entity, MODEL_CONCRETE_CHUNK);
  56.         case 2: SetEntityModel(entity, MODEL_TREE_TRUNK);
  57.         case 3: SetEntityModel(entity, MODEL_ROCK);
  58.         case 4: SetEntityModel(entity, MODEL_LOCK);
  59.         case 5: SetEntityModel(entity, MODEL_DPAW);
  60.     }
  61. }
  62.  
  63.  
  64. bool IsValidClient(int client)
  65. {
  66.     return (1 <= client <= MaxClients && IsClientInGame(client));
  67. }
  68.  
  69. bool IsPlayerGhost(int client)
  70. {
  71.     return GetEntProp(client, Prop_Send, "m_isGhost", 1) == 1;
  72. }
  73.  
  74. bool IsValidEntRef(int iEntRef)
  75. {
  76.     return iEntRef != 0 && EntRefToEntIndex(iEntRef) != INVALID_ENT_REFERENCE;
  77. }
Advertisement
Add Comment
Please, Sign In to add comment