Advertisement
Guest User

Untitled

a guest
Jan 20th, 2020
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.28 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <cstrike>
  3. #include <sdktools>
  4.  
  5. #pragma semicolon 1
  6. #pragma newdecls required
  7.  
  8. int offsetFlash;
  9. int offsetHealth;
  10. int g_fLastButtons[MAXPLAYERS+1], g_fLastFlags[MAXPLAYERS+1], g_iJumps[MAXPLAYERS+1];
  11.  
  12. public void OnPluginStart()
  13. {
  14.     HookEvent("player_spawn", PlayerSpawn);
  15.     HookEvent("player_death", PlayerDeath);
  16. }
  17.  
  18. public void OnMapStart()
  19. {
  20.    
  21.     int entindex;
  22.  
  23.     entindex = CreateEntityByName("weapon_flashbang");
  24.     DispatchSpawn(entindex);
  25.     offsetFlash = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
  26.     AcceptEntityInput(entindex, "Kill");
  27.  
  28.     entindex = CreateEntityByName("weapon_healthshot");
  29.     DispatchSpawn(entindex);
  30.     offsetHealth = GetEntProp(entindex, Prop_Send, "m_iPrimaryAmmoType");
  31.     AcceptEntityInput(entindex, "Kill");
  32.  
  33. }
  34.  
  35. public Action PlayerSpawn(Event event, const char[] name, bool dontBroadcast)
  36. {
  37.     int client = GetClientOfUserId(GetEventInt(event, "userid"));
  38.     if(IsValidPlayer(client) && IsPlayerVIP(client))
  39.     {
  40.         if(IsPlayerAlive(client))
  41.         {
  42.             CreateTimer(0.1, GiveEquipment, GetEventInt(event, "userid"), TIMER_FLAG_NO_MAPCHANGE);
  43.         }
  44.     }
  45. }
  46. public Action GiveEquipment(Handle timer, any userid) {
  47.     int client = GetClientOfUserId(userid);
  48.    
  49.     if(!IsPlayerAlive(client) || !IsValidPlayer(client)) return;
  50.    
  51.     if(GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 0 && GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 15)
  52.     {  
  53.         SetEntProp(client, Prop_Send, "m_ArmorValue", 100);
  54.         SetEntProp(client, Prop_Send, "m_bHasHelmet", 1);
  55.         SetEntityHealth(client, GetEntProp(client, Prop_Send, "m_iHealth") + 5);
  56.        
  57.         if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetFlash) < 1)
  58.             GivePlayerItem(client, "weapon_flashbang");
  59.         if(GetEntProp(client, Prop_Send, "m_iAmmo", _, offsetHealth) < 1)
  60.             GivePlayerItem(client, "weapon_healthshot");
  61.         if(GetClientTeam(client) == CS_TEAM_CT)
  62.         if(GetClientTeam(client) == CS_TEAM_CT)
  63.             if (GetEntProp(client, Prop_Send, "m_bHasDefuser") == 0)
  64.                 GivePlayerItem(client, "item_defuser");
  65.     }
  66. }
  67. public Action PlayerDeath(Handle event, const char[] name, bool dontBroadcast) {
  68.     if(GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 0 && GetTeamScore(CS_TEAM_CT) + GetTeamScore(CS_TEAM_T) != 15)
  69.     {
  70.         int attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  71.         if(!IsValidPlayer(attacker) || !IsPlayerVIP(attacker)) return;
  72.         int health = GetClientHealth(attacker);
  73.         SetEntityHealth(attacker, health+1);
  74.         //int money = GetEntProp(attacker, Prop_Send, "m_iAccount");
  75.         //SetEntProp(attacker, Prop_Send, "m_iAccount", money+100);
  76.         bool headshot = GetEventBool(event, "headshot", false);
  77.             if(headshot)
  78.             {
  79.                 health = GetClientHealth(attacker);
  80.                 SetEntityHealth(attacker, health+2);
  81.                 //money = GetEntProp(attacker, Prop_Send, "m_iAccount");
  82.                 //SetEntProp(attacker, Prop_Send, "m_iAccount", money+100);
  83.             }
  84.         if(GetClientHealth(attacker) > 105)
  85.         SetEntityHealth(attacker, 105);
  86.     }
  87. }
  88.  
  89. public Action OnPlayerRunCmd(int client, int &buttons, int &impulse, float vel[3], float angles[3], int &weapon)
  90. {
  91.     if (IsValidPlayer(client) && IsPlayerVIP(client))
  92.     {
  93.         int fCurFlags = GetEntityFlags(client);
  94.         int fCurButtons = GetClientButtons(client);
  95.                    
  96.         if (g_fLastFlags[client] & FL_ONGROUND)
  97.         {      
  98.             if (!(fCurFlags & FL_ONGROUND) &&!(g_fLastButtons[client] & IN_JUMP) && fCurButtons & IN_JUMP)
  99.             {
  100.                 g_iJumps[client]++;        
  101.             }
  102.         }
  103.         else if (fCurFlags & FL_ONGROUND)
  104.         {
  105.             g_iJumps[client] = 0;                      
  106.         }
  107.         else if (!(g_fLastButtons[client] & IN_JUMP) && fCurButtons & IN_JUMP)
  108.         {
  109.             if ( 1 <= g_iJumps[client] < 2)
  110.             {                      
  111.                 g_iJumps[client]++;                                        
  112.                 float vVel[3];
  113.                 GetEntPropVector(client, Prop_Data, "m_vecVelocity", vVel);
  114.                                
  115.                 vVel[2] = 250.0;
  116.                 TeleportEntity(client, NULL_VECTOR, NULL_VECTOR, vVel);
  117.             }                          
  118.         }
  119.         g_fLastFlags[client] = fCurFlags;              
  120.         g_fLastButtons[client] = fCurButtons;
  121.     }
  122. }
  123.  
  124. stock bool IsValidPlayer(int client)
  125. {
  126.     if(client >= 1 && client <= MaxClients && IsClientInGame(client) && IsClientConnected(client) && !IsFakeClient(client) && !IsClientReplay(client) && !IsClientSourceTV(client))
  127.         return true;
  128.     return false;
  129. }
  130.  
  131. stock bool IsPlayerVIP(int client)
  132. {
  133.     if(GetUserFlagBits(client) & ADMFLAG_CUSTOM1)
  134.         return true;
  135.     return false;
  136. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement