Guest User

First round

a guest
Jul 1st, 2016
101
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. #include <sdktools_gamerules>
  3. #include <sdktools_functions>
  4. #pragma newdecls required
  5.  
  6. public Plugin porno = {
  7.     name        = "First Round",
  8.     author      = "mukunda",
  9.     version     = "1.0.0",
  10. };
  11.  
  12. Handle rxg_mincash;
  13. int    c_mincash;
  14.  
  15. bool   g_first_round,
  16.     g_is_warmup;
  17.  
  18. public void OnPluginStart(){
  19.     HookEvent("player_spawn", OnPlayerSpawn);
  20.     HookEvent("round_start", OnRoundStart);
  21.    
  22.     rxg_mincash = CreateConVar("rxg_mincash", "3500", "Minimum amount of cash players start with (on non-pistol round)", FCVAR_PLUGIN);
  23.        
  24.     HookConVarChange(rxg_mincash, OnConVarChanged);
  25.    
  26.     c_mincash = GetConVarInt(rxg_mincash);
  27. }
  28.  
  29. public void OnConVarChanged(Handle cv, const char[] ov, const char[] nv){
  30.     c_mincash = GetConVarInt(rxg_mincash);
  31. }
  32.  
  33. public void OnRoundStart(Handle event, const char[] name, bool nb){
  34.  
  35.     bool warmup = !!GameRules_GetProp("m_bWarmupPeriod");
  36.     if (warmup){
  37.         g_is_warmup = true;
  38.         return;
  39.     }
  40.     g_is_warmup = false;
  41.    
  42.     int total_score = GetTeamScore(2) + GetTeamScore(3);
  43.     if (total_score == 0){
  44.         g_first_round = true;
  45.         return;
  46.     }
  47.    
  48.     if (GetConVarInt(FindConVar("mp_halftime")) == 1){
  49.         int maxrounds = GetConVarInt(FindConVar("mp_maxrounds"));
  50.         if (total_score == maxrounds / 2){
  51.             g_first_round = true;
  52.             return;
  53.         }
  54.     }
  55.     g_first_round = false;
  56. }
  57.  
  58. public Action PlayerSpawnDelay(Handle timer, int userid){
  59.     int client = GetClientOfUserId(userid);
  60.     if (client == 0) return;
  61.    
  62.     if (g_is_warmup){
  63.         SetEntProp(client, Prop_Send, "m_iAccount", 16000);
  64.         SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
  65.         SetEntProp(client, Prop_Send, "m_ArmorValue", 100);
  66.     }
  67.    
  68.     if (g_first_round){
  69.    
  70.         // delete defuser
  71.         SetEntProp(client, Prop_Send, "m_bHasDefuser", 0);
  72.        
  73.     } else {
  74.    
  75.         // give minimum cash
  76.         if (GetEntProp(client, Prop_Send, "m_iAccount") < c_mincash){
  77.             SetEntProp( client, Prop_Send, "m_iAccount", c_mincash );
  78.         }
  79.        
  80.         // give armor
  81.         SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
  82.         SetEntProp(client, Prop_Send, "m_ArmorValue", 100);
  83.        
  84.     }
  85. }
  86.  
  87. public void OnPlayerSpawn(Handle event, const char[] name, bool nb){
  88.     int userid = GetEventInt(event, "userid");
  89.    
  90.     CreateTimer(0.25, PlayerSpawnDelay, userid, TIMER_FLAG_NO_MAPCHANGE);
  91. }
Add Comment
Please, Sign In to add comment