Advertisement
FlacoBey

Untitled

Feb 15th, 2019
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.17 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. public OnPluginStart()
  5. {
  6.     HookEvent("item_pickup", Event_ItemPickup, EventHookMode_Pre)
  7. }
  8.  
  9. public Action:Event_ItemPickup(Handle:event, const String:name[], bool:dontBroadcast)
  10. {
  11.    
  12.     new client = GetClientOfUserId(GetEventInt(event, "userid"))
  13.    
  14.     if (!client || !IsClientInGame(client)) return Plugin_Continue;
  15.     decl String:ent_name[128]
  16.     GetEventString(event, "item", ent_name, sizeof(ent_name))
  17.    
  18.     new targetgun = GetPlayerWeaponSlot(client, 0)
  19.     new iPrimType2 = GetEntProp(targetgun, Prop_Send, "m_iPrimaryAmmoType");
  20.     if (IsValidEdict(targetgun))
  21.     {
  22.         GetEdictClassname(targetgun, ent_name, sizeof(ent_name)); //get the entities name
  23.        
  24.         if (StrEqual(ent_name, "weapon_ammo_spawn", false))
  25.         {
  26.             new weaponIndex = GetPlayerWeaponSlot(client, 0);
  27.            
  28.             if(weaponIndex == -1)
  29.             return Plugin_Continue;
  30.            
  31.             new String:classname[64];
  32.            
  33.             GetEdictClassname(weaponIndex, classname, sizeof(classname));
  34.            
  35.             if(StrEqual(classname, "weapon_rifle_m60"))
  36.             {
  37.                 SetEntProp(weaponIndex, Prop_Send, "m_iClip1", 150);
  38.             }
  39.             else if(StrEqual(classname, "weapon_grenade_launcher"))
  40.             {
  41.                 new iClip1 = GetEntProp(weaponIndex, Prop_Send, "m_iClip1");
  42.                 new iPrimType = GetEntProp(weaponIndex, Prop_Send, "m_iPrimaryAmmoType");
  43.                 if (iClip1 > 0)
  44.                 {
  45.                     SetEntProp(client, Prop_Send, "m_iAmmo", 7, _, iPrimType);
  46.                 }
  47.                 else if (iClip1 == 0)
  48.                 {
  49.                     SetEntProp(client, Prop_Send, "m_iAmmo", 8, _, iPrimType);
  50.                 }
  51.             }
  52.         }
  53.         else if (StrEqual(ent_name, "weapon_rifle_m60", false))
  54.         {
  55.             SetEntProp(targetgun, Prop_Send, "m_iClip1", 150);
  56.         }
  57.         else if (StrEqual(ent_name, "weapon_grenade_launcher", false))
  58.         {
  59.             SetEntProp(targetgun, Prop_Send, "m_iClip1", 7, _, iPrimType2);
  60.         }
  61.     }
  62.     return Plugin_Continue;
  63. }
  64.  
  65. //Done!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement