Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- public OnPluginStart()
- {
- HookEvent("item_pickup", Event_ItemPickup, EventHookMode_Pre)
- }
- public Action:Event_ItemPickup(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"))
- if (!client || !IsClientInGame(client)) return Plugin_Continue;
- decl String:ent_name[128]
- GetEventString(event, "item", ent_name, sizeof(ent_name))
- new targetgun = GetPlayerWeaponSlot(client, 0)
- new iPrimType2 = GetEntProp(targetgun, Prop_Send, "m_iPrimaryAmmoType");
- if (IsValidEdict(targetgun))
- {
- GetEdictClassname(targetgun, ent_name, sizeof(ent_name)); //get the entities name
- if (StrEqual(ent_name, "weapon_ammo_spawn", false))
- {
- new weaponIndex = GetPlayerWeaponSlot(client, 0);
- if(weaponIndex == -1)
- return Plugin_Continue;
- new String:classname[64];
- GetEdictClassname(weaponIndex, classname, sizeof(classname));
- if(StrEqual(classname, "weapon_rifle_m60"))
- {
- SetEntProp(weaponIndex, Prop_Send, "m_iClip1", 150);
- }
- else if(StrEqual(classname, "weapon_grenade_launcher"))
- {
- new iClip1 = GetEntProp(weaponIndex, Prop_Send, "m_iClip1");
- new iPrimType = GetEntProp(weaponIndex, Prop_Send, "m_iPrimaryAmmoType");
- if (iClip1 > 0)
- {
- SetEntProp(client, Prop_Send, "m_iAmmo", 7, _, iPrimType);
- }
- else if (iClip1 == 0)
- {
- SetEntProp(client, Prop_Send, "m_iAmmo", 8, _, iPrimType);
- }
- }
- }
- else if (StrEqual(ent_name, "weapon_rifle_m60", false))
- {
- SetEntProp(targetgun, Prop_Send, "m_iClip1", 150);
- }
- else if (StrEqual(ent_name, "weapon_grenade_launcher", false))
- {
- SetEntProp(targetgun, Prop_Send, "m_iClip1", 7, _, iPrimType2);
- }
- }
- return Plugin_Continue;
- }
- //Done!
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement