Advertisement
FlacoBey

Untitled

Jun 19th, 2019
127
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.48 KB | None | 0 0
  1. #pragma semicolon 1
  2. #pragma newdecls required
  3.  
  4. #include <sdktools>
  5. #include <sdkhooks>
  6.  
  7. #define MAX 8
  8.  
  9. char sMap[56];
  10. bool IsAllow[MAXPLAYERS+1];
  11.  
  12. static const char Inflicted[MAX][] =
  13. {  
  14.     "models/survivors/survivor_gambler.mdl",
  15.     "models/survivors/survivor_producer.mdl",
  16.     "models/survivors/survivor_coach.mdl",
  17.     "models/survivors/survivor_mechanic.mdl",
  18.     "models/survivors/survivor_namvet.mdl",
  19.     "models/survivors/survivor_teenangst.mdl",
  20.     "models/survivors/survivor_biker.mdl",
  21.     "models/survivors/survivor_manager.mdl"
  22. };
  23.  
  24. static const char gMaps[MAX - 2][] =
  25. {
  26.     "c7",
  27.     "c8",
  28.     "с9",
  29.     "c10",
  30.     "c11",
  31.     "c12"
  32. };
  33.  
  34. public void OnPluginStart()
  35. {
  36.     HookEvent("player_spawn", KnownM);
  37. }
  38.  
  39. public Action KnownM(Event event, const char[] name, bool dontbroadcast)
  40. {
  41.     int client = GetClientOfUserId(event.GetInt("userid"));
  42.     IsAllow[client] = false;
  43.     CreateTimer(5.0, vSetModel, client);
  44. }
  45.  
  46. public void OnMapStart()
  47. {
  48.     GetCurrentMap(sMap, sizeof(sMap));
  49.    
  50.     SetConVarInt(FindConVar("precache_all_survivors"), 1);
  51.     for( int i = 0; i < sizeof(Inflicted); i++ )
  52.     {
  53.         PrecacheModel(Inflicted[sizeof(i)][i], true);
  54.     }
  55. }
  56.  
  57. public void OnClientPutInServer(int client)
  58. {
  59.     IsAllow[client] = true;
  60. }
  61.  
  62. public Action vSetModel(Handle timer, int client)
  63. {
  64.     if(GetClientTeam(client) == 2 && !IsFakeClient(client))
  65.     {
  66.         bool IsDisAllow;
  67.         for( int i = 0; i < MAX - 2; i++ )
  68.         {
  69.             if(StrContains(sMap, gMaps[i]) > 1)
  70.             {
  71.                 int random = GetRandomInt(4, 7);
  72.                 SetEntProp(client, Prop_Send, "m_survivorCharacter", random);
  73.                 if(IsModelPrecached(Inflicted[random])) SetEntityModel(client, Inflicted[random]);
  74.                 else
  75.                 {
  76.                     PrintToServer("Opps! Something wrong...");
  77.                     PrecacheModel(Inflicted[random], true);
  78.                     SetEntityModel(client, Inflicted[random]);
  79.                     IsDisAllow = true;
  80.                 }
  81.                 break;
  82.             }
  83.         }
  84.         if(!IsDisAllow)
  85.         {
  86.             int random = GetRandomInt(0, 7);
  87.             SetEntProp(client, Prop_Send, "m_survivorCharacter", random);
  88.             if(IsModelPrecached(Inflicted[random])) SetEntityModel(client, Inflicted[random]);
  89.             else
  90.             {
  91.                 PrintToServer("Opps! Something wrong...");
  92.                 PrecacheModel(Inflicted[random], true);
  93.                 SetEntityModel(client, Inflicted[random]);
  94.             }
  95.         }
  96.     }
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement