FlacoBey

Untitled

Dec 24th, 2018
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.84 KB | None | 0 0
  1. #pragma semicolon 1
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5. #include <sdkhooks>
  6.  
  7. #define MAX_FRAMECHECK 10
  8.  
  9. bool bPistol[MAXPLAYERS+1] = {true, ...};
  10. bool bPistolFix[MAXPLAYERS+1] = {true, ...};
  11.  
  12. public void OnPluginStart()
  13. {
  14.     HookEvent("player_use", Event_Ammo_Pickup);
  15. }
  16.  
  17. public void OnClientPostAdminCheck(int client)
  18. {
  19.     if (IsFakeClient(client)) return;
  20.  
  21.     bPistol[client] = true;
  22.     bPistolFix[client] = true;
  23.  
  24.     SDKHook(client, SDKHook_WeaponEquip, Hook_WeaponEquip);
  25. }
  26.  
  27. public Action Hook_WeaponEquip(int client, int weapon)
  28. {
  29.     if (!IsSurvivor(client) || !bPistolFix[client])
  30.         return;
  31.  
  32.     bPistolFix[client] = false;
  33. }
  34.  
  35. /*[----->|BOT PISTOL AMMO|<-----]*/
  36. public void OnGameFrame()
  37. {
  38.     int iFrameskip = 0;
  39.     iFrameskip = (iFrameskip + 1) % MAX_FRAMECHECK;
  40.     if(iFrameskip != 0 || !IsServerProcessing())
  41.         return;
  42.  
  43.     for (int client = 1; client <= MaxClients; client++)
  44.     {
  45.         if (!IsSurvivor(client) || !IsPlayerAlive(client) || !IsFakeClient(client))
  46.             continue;
  47.        
  48.        
  49.         int Weapon = GetPlayerWeaponSlot(client, 1);
  50.         if (Weapon == -1) continue;
  51.  
  52.         char sWeapon[32];
  53.         GetEntityClassname(Weapon, sWeapon, sizeof(sWeapon));
  54.  
  55.         int AmmoType = GetEntProp(Weapon, Prop_Data, "m_iPrimaryAmmoType");    
  56.         int Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
  57.        
  58.         if (StrEqual(sWeapon, "weapon_pistol"))
  59.         {
  60.             if (AmmoType == -1) continue;
  61.            
  62.             if (Ammo == 0)
  63.                 SetEntProp(client, Prop_Send, "m_iAmmo", 60, _, AmmoType);
  64.         }
  65.         if (StrEqual(sWeapon, "weapon_pistol", false) && GetEntProp(Weapon, Prop_Send, "m_hasDualWeapons"))
  66.         {
  67.             if (AmmoType == -1) continue;
  68.            
  69.             if (Ammo == 0)
  70.             {
  71.                 SetEntProp(client, Prop_Send, "m_iAmmo", 120, _, AmmoType);
  72.             }
  73.         }
  74.         if  (StrEqual(sWeapon, "weapon_pistol_magnum", false))
  75.         {
  76.             SetEntProp(client, Prop_Send, "m_iAmmo", 40, _, AmmoType);
  77.         }
  78.     }
  79. }
  80.  
  81. public Action Event_Ammo_Pickup(Event event, const char[] name, bool dontBroadcast)
  82. {
  83.     int client = GetClientOfUserId(event.GetInt("userid"));
  84.     if (!IsSurvivor(client) || !IsPlayerAlive(client)) return;
  85.  
  86.     int AmmoPile = event.GetInt("targetid");
  87.     if (!IsValidEntity(AmmoPile)) return;
  88.  
  89.     char sWeapon[32];
  90.     GetEntityClassname(AmmoPile, sWeapon, sizeof(sWeapon));
  91.  
  92.     if (!StrEqual(sWeapon, "weapon_ammo_spawn", false))
  93.         return;
  94.  
  95.     int Weapon = GetPlayerWeaponSlot(client, 1);
  96.     if (Weapon == -1) return;
  97.  
  98.     GetEntityClassname(Weapon, sWeapon, sizeof(sWeapon));
  99.  
  100.     if (!(StrEqual(sWeapon, "weapon_pistol", false) || StrEqual(sWeapon, "weapon_pistol_magnum", false)))
  101.         return;
  102.  
  103.     float cPos[3];
  104.     GetEntPropVector(client, Prop_Data, "m_vecAbsOrigin", cPos);
  105.  
  106.     float aPos[3];
  107.     GetEntPropVector(AmmoPile, Prop_Data, "m_vecAbsOrigin", aPos);
  108.  
  109.     if (GetVectorDistance(cPos, aPos) <= 100)
  110.     {
  111.         bPistol[client] = true; //FIXES WEAPON EMPTY MESSAGE IN AMMO LOCK TIMER
  112.  
  113.         int AmmoType = GetEntProp(Weapon, Prop_Data, "m_iPrimaryAmmoType");
  114.         if (AmmoType == -1) return;
  115.        
  116.         int Clip = GetEntProp(Weapon, Prop_Send, "m_iClip1");
  117.  
  118.         if (StrEqual(sWeapon, "weapon_pistol", false) && GetEntProp(Weapon, Prop_Send, "m_hasDualWeapons"))
  119.         {
  120.             SetEntProp(Weapon, Prop_Send, "m_iClip1", Clip);
  121.             SetEntProp(client, Prop_Send, "m_iAmmo", 30, _, AmmoType);
  122.         }
  123.         else if (StrEqual(sWeapon, "weapon_pistol", false))
  124.         {
  125.  
  126.             SetEntProp(Weapon, Prop_Send, "m_iClip1", Clip);
  127.             SetEntProp(client, Prop_Send, "m_iAmmo", 15, _, AmmoType);
  128.         }
  129.  
  130.         if (StrEqual(sWeapon, "weapon_pistol_magnum", false))
  131.         {
  132.             SetEntProp(Weapon, Prop_Send, "m_iClip1", Clip);
  133.             SetEntProp(client, Prop_Send, "m_iAmmo", 16, _, AmmoType);
  134.         }
  135.     }
  136. }
  137.  
  138. stock bool IsValidAdmin(int client)
  139. {
  140.     if (GetUserFlagBits(client) & ADMFLAG_ROOT) return true;
  141.     return false;
  142. }
  143.  
  144. stock bool IsValidClient(int client)
  145. {
  146.     if (client > 0 && client <= MaxClients && IsClientInGame(client)) return true;
  147.     return false;
  148. }
  149.  
  150. stock bool IsSpectator(int client)
  151. {
  152.     if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 1) return true;
  153.     return false;
  154. }
  155.  
  156. stock bool IsSurvivor(int client)
  157. {
  158.     if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 2) return true;
  159.     return false;
  160. }
  161.  
  162. stock bool IsInfected(int client)
  163. {
  164.     if (client > 0 && client <= MaxClients && IsClientInGame(client) && GetClientTeam(client) == 3) return true;
  165.     return false;
  166. }
Advertisement
Add Comment
Please, Sign In to add comment