Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #define PLUGIN_VERSION "1.5.3"
- #define L4D2_WEPUPGFLAG_LASER (1 << 2)
- public Plugin:myinfo =
- {
- name = "[L4D2] Random Ammunition",
- author = "NoBody",
- description = "Periodically changes the amount of ammo contained in picked up guns",
- version = PLUGIN_VERSION,
- url = ""
- };
- new Handle:smgammo = INVALID_HANDLE;
- new Handle:shotammo = INVALID_HANDLE;
- new Handle:rifleammo = INVALID_HANDLE;
- new Handle:huntingrifleammo = INVALID_HANDLE;
- new Handle:autoshotammo = INVALID_HANDLE;
- new Handle:glammo = INVALID_HANDLE;
- new Handle:m60ammo = INVALID_HANDLE;
- new Handle:sniperammo = INVALID_HANDLE;
- new Handle:pumpshotammo_min = INVALID_HANDLE
- new Handle:chromeshotammo_min = INVALID_HANDLE
- new Handle:autoshotammo_min = INVALID_HANDLE
- new Handle:shotspasammo_min = INVALID_HANDLE
- new Handle:smgammo_min = INVALID_HANDLE
- new Handle:smg5ammo_min = INVALID_HANDLE
- new Handle:smgsammo_min = INVALID_HANDLE
- new Handle:m16ammo_min = INVALID_HANDLE
- new Handle:sg552ammo_min = INVALID_HANDLE
- new Handle:desertammo_min = INVALID_HANDLE
- new Handle:ak47ammo_min = INVALID_HANDLE
- new Handle:huntingrifleammo_min = INVALID_HANDLE
- new Handle:militaryammo_min = INVALID_HANDLE
- new Handle:scoutammo_min = INVALID_HANDLE
- new Handle:glammo_min = INVALID_HANDLE
- new Handle:m60ammo_min = INVALID_HANDLE
- new Handle:awpammo_min = INVALID_HANDLE
- new Handle:pumpshotammo_max = INVALID_HANDLE
- new Handle:chromeshotammo_max = INVALID_HANDLE
- new Handle:autoshotammo_max = INVALID_HANDLE
- new Handle:shotspasammo_max = INVALID_HANDLE
- new Handle:smgammo_max = INVALID_HANDLE
- new Handle:smg5ammo_max = INVALID_HANDLE
- new Handle:smgsammo_max = INVALID_HANDLE
- new Handle:m16ammo_max = INVALID_HANDLE
- new Handle:sg552ammo_max = INVALID_HANDLE
- new Handle:desertammo_max = INVALID_HANDLE
- new Handle:ak47ammo_max = INVALID_HANDLE
- new Handle:huntingrifleammo_max = INVALID_HANDLE
- new Handle:militaryammo_max = INVALID_HANDLE
- new Handle:scoutammo_max = INVALID_HANDLE
- new Handle:awpammo_max = INVALID_HANDLE
- new Handle:glammo_max = INVALID_HANDLE
- new Handle:glamount_max = INVALID_HANDLE
- new Handle:m60ammo_max = INVALID_HANDLE
- new Handle:m60amount_max = INVALID_HANDLE
- new Handle:l4d2_LaserEnabled = INVALID_HANDLE;
- new Handle:l4d2_M16laser_chance = INVALID_HANDLE;
- new Handle:l4d2_AK47laser_chance = INVALID_HANDLE;
- new Handle:l4d2_DesertRiflelaser_chance = INVALID_HANDLE;
- new Handle:l4d2_SG552laser_chance = INVALID_HANDLE;
- new Handle:l4d2_HuntingRiflelaser_chance = INVALID_HANDLE;
- new Handle:l4d2_Militarylaser_chance = INVALID_HANDLE;
- new Handle:l4d2_SMGlaser_chance = INVALID_HANDLE;
- new Handle:l4d2_SMG5laser_chance = INVALID_HANDLE;
- new Handle:l4d2_SMGSlaser_chance = INVALID_HANDLE;
- //new slot;
- //Create the timer that decides how often to change the gun cvars, edit the number to change the interval, it is 90 at the moment
- public OnPluginStart()
- {
- decl String:game_name[64]
- GetGameFolderName(game_name, sizeof(game_name))
- if (!StrEqual(game_name, "left4dead2", false))
- SetFailState("Plugin supports Left 4 Dead 2 only.")
- HookEvent("player_use", Event_PlayerUse, EventHookMode_Pre);
- HookEvent("item_pickup", Event_ItemPickup, EventHookMode_Pre)
- HookEvent("weapon_drop", Event_WeaponDrop, EventHookMode_Pre);
- HookEvent("round_start", Event_RoundStart, EventHookMode_PostNoCopy);
- HookEvent("round_end", Event_RoundEnd, EventHookMode_Pre);
- CreateConVar("l4d_varyingammo_version", PLUGIN_VERSION, "L4D2 Varying Ammo Version", FCVAR_NONE)
- huntingrifleammo = FindConVar("ammo_huntingrifle_max")
- rifleammo = FindConVar("ammo_assaultrifle_max")
- autoshotammo = FindConVar("ammo_autoshotgun_max")
- shotammo = FindConVar("ammo_shotgun_max")
- smgammo = FindConVar("ammo_smg_max")
- m60ammo = FindConVar("ammo_m60_max")
- glammo = FindConVar("ammo_grenadelauncher_max")
- sniperammo = FindConVar("ammo_sniperrifle_max")
- huntingrifleammo_min = CreateConVar("l4d_huntingrifle_ammo_min", "45", "Min Hunting Rifle ammo variation", FCVAR_NOTIFY)
- m16ammo_min = CreateConVar("l4d_rifleammo_min", "150", "Min M16 ammo variation", FCVAR_NOTIFY)
- sg552ammo_min = CreateConVar("l4d_sg552_ammo_min", "150", "Min SG552 ammo variation", FCVAR_NOTIFY)
- desertammo_min = CreateConVar("l4d_desert_ammo_min", "150", "Min Desert Rifle ammo variation", FCVAR_NOTIFY)
- ak47ammo_min = CreateConVar("l4d_ak47_ammo_min", "150", "Min Ak-47 ammo variation", FCVAR_NOTIFY)
- pumpshotammo_min = CreateConVar("l4d_pumpshotgun_ammo_min", "25", "Min Shotgun Pump ammo variation", FCVAR_NOTIFY)
- chromeshotammo_min = CreateConVar("l4d_chromeshotgun_ammo_min", "25", "Min Shotgun Chrome ammo variation", FCVAR_NOTIFY)
- autoshotammo_min = CreateConVar("l4d_autoshot_ammo_min", "25", "Min AutoShotgun ammo variation", FCVAR_NOTIFY)
- shotspasammo_min = CreateConVar("l4d_shotspas_ammo_min", "25", "Min Shotgun Spas ammo variation", FCVAR_NOTIFY)
- smgammo_min = CreateConVar("l4d_smg_ammo_min", "250", "Min Smg ammo variation", FCVAR_NOTIFY)
- smg5ammo_min = CreateConVar("l4d_smg5_ammo_min", "250", "Min Smg MP5 ammo variation", FCVAR_NOTIFY)
- smgsammo_min = CreateConVar("l4d_smgs_ammo_min", "250", "Min Smg Silenced ammo variation", FCVAR_NOTIFY)
- militaryammo_min = CreateConVar("l4d_military_ammo_min", "25", "Min Sniper Military ammo variation", FCVAR_NOTIFY)
- scoutammo_min = CreateConVar("l4d_scout_ammo_min", "15", "Min Sniper Scout ammo variation", FCVAR_NOTIFY)
- awpammo_min = CreateConVar("l4d_awp_ammo_min", "20", "Min Sniper Awp ammo variation", FCVAR_NOTIFY)
- glammo_min = CreateConVar("l4d_glammo_min", "1", "Min Grenade Launcher ammo variation", FCVAR_NOTIFY)
- m60ammo_min = CreateConVar("l4d_m60ammo_min", "50", "Min M60 ammo variation", FCVAR_NOTIFY)
- // max ammo (created own convar to avoid conflicts)
- huntingrifleammo_max = CreateConVar("l4d_huntingrifleammo_max", "135", "Max Hunting Rifle ammo variation", FCVAR_NOTIFY)
- m16ammo_max = CreateConVar("l4d_rifle_ammo_max", "450", "Max M16 ammo variation", FCVAR_NOTIFY)
- sg552ammo_max = CreateConVar("l4d_sg552_ammo_max", "450", "Max SG552 ammo variation", FCVAR_NOTIFY)
- desertammo_max = CreateConVar("l4d_desert_ammo_max", "450", "Max Desert Rifle ammo variation", FCVAR_NOTIFY)
- ak47ammo_max = CreateConVar("l4d_ak47_ammo_max", "450", "Max Ak-47 ammo variation", FCVAR_NOTIFY)
- pumpshotammo_max = CreateConVar("l4d_pumpshotgun_ammo_max", "75", "Max Shotgun Pump ammo variation", FCVAR_NOTIFY)
- chromeshotammo_max = CreateConVar("l4d_chromeshotgun_ammo_max", "75", "Max Shotgun Chrome ammo variation", FCVAR_NOTIFY)
- autoshotammo_max = CreateConVar("l4d_autoshot_ammo_max", "120", "Max AutoShotgun ammo variation", FCVAR_NOTIFY)
- shotspasammo_max = CreateConVar("l4d_shotspas_ammo_max", "120", "Max Shotgun Spas ammo variation", FCVAR_NOTIFY)
- smgammo_max = CreateConVar("l4d_smg_ammo_max", "700", "Max Smg ammo variation", FCVAR_NOTIFY)
- smg5ammo_max = CreateConVar("l4d_smg5_ammo_max", "700", "Max Smg MP5 ammo variation", FCVAR_NOTIFY)
- smgsammo_max = CreateConVar("l4d_smgs_ammo_max", "700", "Max Smg Silenced ammo variation", FCVAR_NOTIFY)
- militaryammo_max = CreateConVar("l4d_military_ammo_max", "180", "Max Sniper Military ammo variation", FCVAR_NOTIFY)
- scoutammo_max = CreateConVar("l4d_scout_ammo_max", "100", "Max Sniper Scout ammo variation", FCVAR_NOTIFY)
- awpammo_max = CreateConVar("l4d_awp_ammo_max", "100", "Max Sniper Awp ammo variation", FCVAR_NOTIFY)
- glammo_max = CreateConVar("l4d_glammo_max", "12", "Max Grenade Launcher ammo variation", FCVAR_NOTIFY)
- glamount_max = CreateConVar("l4d_gl_amount_max", "18", "Maximum Grenade Launcher amount of amunition to picked up", FCVAR_NOTIFY)
- m60ammo_max = CreateConVar("l4d_m60ammo_max", "500", "Max M60 ammo variation", FCVAR_NOTIFY)
- m60amount_max = CreateConVar("l4d_m60_amount_max", "500", "Maximum M60 amount of amunition to picked up", FCVAR_NOTIFY)
- l4d2_LaserEnabled = CreateConVar("l4d2_laser_enabled", "1", "Enables - Disables the Heashot Cash plugin", FCVAR_NONE);
- l4d2_M16laser_chance = CreateConVar("l4d2_m16_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- l4d2_AK47laser_chance = CreateConVar("l4d2_ak47_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- l4d2_DesertRiflelaser_chance = CreateConVar("l4d2_desert_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- l4d2_SG552laser_chance = CreateConVar("l4d2_sg552_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- l4d2_HuntingRiflelaser_chance = CreateConVar("l4d2_hunting_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- l4d2_Militarylaser_chance = CreateConVar("l4d2_military_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- l4d2_SMGlaser_chance = CreateConVar("l4d2_SMG_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- l4d2_SMG5laser_chance = CreateConVar("l4d2_SMG5_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- l4d2_SMGSlaser_chance = CreateConVar("l4d2_SMGS_laser_chance", "5.0", "normal chance [0.0, 100.0]", FCVAR_NONE);
- AutoExecConfig(true, "l4d2_varyingammo", "sourcemod")
- }
- public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
- {
- CreateTimer(4.0, GunTimer, TIMER_REPEAT, TIMER_FLAG_NO_MAPCHANGE);
- CreateTimer(5.0, TimerPluginOn, TIMER_FLAG_NO_MAPCHANGE);
- }
- public Action:Event_RoundEnd(Handle:event, const String:name[], bool:dontBroadcast)
- {
- SetConVarInt(FindConVar("l4d2_laser_enabled"), 0);
- }
- public Action:TimerPluginOn(Handle:timer)
- {
- SetConVarInt(FindConVar("l4d2_laser_enabled"), 1);
- }
- public Action:GunTimer(Handle:timer)
- {
- static NumPrinted = 0
- if (NumPrinted++ <= 2)
- {
- new m60 = GetRandomInt(GetConVarInt(m60ammo_min), GetConVarInt(m60ammo_max))
- new m79 = GetRandomInt(GetConVarInt(glammo_min), GetConVarInt(glammo_max))
- new m16 = GetRandomInt(GetConVarInt(m16ammo_min), GetConVarInt(m16ammo_max))
- new ak47 = GetRandomInt(GetConVarInt(ak47ammo_min), GetConVarInt(ak47ammo_max))
- new desert = GetRandomInt(GetConVarInt(desertammo_min), GetConVarInt(desertammo_max))
- new sg552 = GetRandomInt(GetConVarInt(sg552ammo_min), GetConVarInt(sg552ammo_max))
- new huntingRifle = GetRandomInt(GetConVarInt(huntingrifleammo_min), GetConVarInt(huntingrifleammo_max))
- new sniperScout = GetRandomInt(GetConVarInt(scoutammo_min), GetConVarInt(scoutammo_max))
- new sniperMilitary = GetRandomInt(GetConVarInt(militaryammo_min), GetConVarInt(militaryammo_max))
- new sniperAwp = GetRandomInt(GetConVarInt(awpammo_min), GetConVarInt(awpammo_max))
- new autoshotgun = GetRandomInt(GetConVarInt(autoshotammo_min), GetConVarInt(autoshotammo_max))
- new pumpShotgun = GetRandomInt(GetConVarInt(pumpshotammo_min), GetConVarInt(pumpshotammo_max))
- new shotgunChrome = GetRandomInt(GetConVarInt(chromeshotammo_min), GetConVarInt(chromeshotammo_max))
- new shotgunSpas = GetRandomInt(GetConVarInt(shotspasammo_min), GetConVarInt(shotspasammo_max))
- new smg = GetRandomInt(GetConVarInt(smgammo_min), GetConVarInt(smgammo_max))
- new smg5 = GetRandomInt(GetConVarInt(smg5ammo_min), GetConVarInt(smg5ammo_max))
- new smgs = GetRandomInt(GetConVarInt(smgsammo_min), GetConVarInt(smgsammo_max))
- SetConVarInt(huntingrifleammo, m60)
- SetConVarInt(glammo, m79)
- SetConVarInt(rifleammo, m16)
- SetConVarInt(rifleammo, ak47)
- SetConVarInt(rifleammo, desert)
- SetConVarInt(rifleammo, sg552)
- SetConVarInt(m60ammo, huntingRifle)
- SetConVarInt(sniperammo, sniperScout)
- SetConVarInt(sniperammo, sniperMilitary)
- SetConVarInt(m60ammo, sniperAwp)
- SetConVarInt(autoshotammo, autoshotgun)
- SetConVarInt(shotammo, pumpShotgun)
- SetConVarInt(shotammo, shotgunChrome)
- SetConVarInt(autoshotammo, shotgunSpas)
- SetConVarInt(smgammo, smg)
- SetConVarInt(smgammo, smg5)
- SetConVarInt(smgammo, smgs)
- NumPrinted = 0
- }
- return Plugin_Continue
- }
- public Action:Event_WeaponDrop(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- if (client == 0 || !IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != 2) return;
- if (GetPlayerWeaponSlot(client, slot) > 0)
- {
- new String:weapon[32];
- new ammo;
- new clip;
- new upgrade;
- new upammo;
- new ammoOffset = FindSendPropInfo("CTerrorPlayer", "m_iAmmo");
- GetEdictClassname(GetPlayerWeaponSlot(client, slot), weapon, 32);
- if (slot == 0)
- {
- clip = GetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_iClip1");
- upgrade = GetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_upgradeBitVec");
- upammo = GetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_nUpgradedPrimaryAmmoLoaded");
- if (StrEqual(weapon, "weapon_rifle") || StrEqual(weapon, "weapon_rifle_sg552") || StrEqual(weapon, "weapon_rifle_desert") || StrEqual(weapon, "weapon_rifle_ak47"))
- {
- ammo = GetEntData(client, ammoOffset+(12));
- SetEntData(client, ammoOffset+(12), 0);
- }
- else if (StrEqual(weapon, "weapon_smg") || StrEqual(weapon, "weapon_smg_silenced") || StrEqual(weapon, "weapon_smg_mp5"))
- {
- ammo = GetEntData(client, ammoOffset+(20));
- SetEntData(client, ammoOffset+(20), 0);
- }
- else if (StrEqual(weapon, "weapon_pumpshotgun") || StrEqual(weapon, "weapon_shotgun_chrome"))
- {
- ammo = GetEntData(client, ammoOffset+(28));
- SetEntData(client, ammoOffset+(28), 0);
- }
- else if (StrEqual(weapon, "weapon_autoshotgun") || StrEqual(weapon, "weapon_shotgun_spas"))
- {
- ammo = GetEntData(client, ammoOffset+(32));
- SetEntData(client, ammoOffset+(32), 0);
- }
- else if (StrEqual(weapon, "weapon_hunting_rifle"))
- {
- ammo = GetEntData(client, ammoOffset+(36));
- SetEntData(client, ammoOffset+(36), 0);
- }
- else if (StrEqual(weapon, "weapon_sniper_scout") || StrEqual(weapon, "weapon_sniper_military") || StrEqual(weapon, "weapon_sniper_awp"))
- {
- ammo = GetEntData(client, ammoOffset+(40));
- SetEntData(client, ammoOffset+(40), 0);
- }
- else if (StrEqual(weapon, "weapon_grenade_launcher"))
- {
- ammo = GetEntData(client, ammoOffset+(68));
- SetEntData(client, ammoOffset+(68), 0);
- }
- }
- new index = CreateEntityByName(weapon);
- new Float:origin[3];
- GetEntPropVector(client, Prop_Send, "m_vecOrigin", origin);
- origin[2]+=20;
- TeleportEntity(index, origin, NULL_VECTOR, NULL_VECTOR);
- DispatchSpawn(index);
- ActivateEntity(index);
- RemovePlayerItem(client, GetPlayerWeaponSlot(client, slot));
- if (slot == 0)
- {
- SetEntProp(index, Prop_Send, "m_iExtraPrimaryAmmo", ammo);
- SetEntProp(index, Prop_Send, "m_iClip1", clip);
- SetEntProp(index, Prop_Send, "m_upgradeBitVec", upgrade);
- SetEntProp(index, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", upammo);
- }
- }
- }
- public Event_PlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new playerClient = GetClientOfUserId(GetEventInt(event, "userid"));
- new entityId = GetEventInt(event, "targetid");
- decl String:ent_name[64];
- if (IsValidEdict(entityId))
- {
- GetEdictClassname(entityId, ent_name, sizeof(ent_name)); //get the entities name
- if (StrEqual(ent_name, "weapon_ammo_spawn", false))
- {
- new weaponIndex = GetPlayerWeaponSlot(playerClient, 0);
- if(weaponIndex == -1)
- return;
- new String:classname[64];
- GetEdictClassname(weaponIndex, classname, sizeof(classname));
- if(StrEqual(classname, "weapon_rifle"))
- {
- int m16 = 120;
- SetConVarInt(rifleammo, m16)
- }
- else if(StrEqual(classname, "weapon_rifle_sg552"))
- {
- int sg552 = 120;
- SetConVarInt(rifleammo, sg552)
- }
- else if(StrEqual(classname, "weapon_rifle_ak47"))
- {
- int ak47 = 120;
- SetConVarInt(rifleammo, ak47)
- }
- else if(StrEqual(classname, "weapon_rifle_desert"))
- {
- int desert = 120;
- SetConVarInt(rifleammo, desert)
- }
- else if(StrEqual(classname, "weapon_smg"))
- {
- int smg = 250;
- SetConVarInt(smgammo, smg)
- }
- else if(StrEqual(classname, "weapon_smg_mp5"))
- {
- int smg5 = 250;
- SetConVarInt(smgammo, smg5)
- }
- else if(StrEqual(classname, "weapon_smg_silenced"))
- {
- int smgs = 250;
- SetConVarInt(smgammo, smgs)
- }
- else if(StrEqual(classname, "weapon_pumpshotgun"))
- {
- int pumpShotgun = 32;
- SetConVarInt(shotammo, pumpShotgun)
- }
- else if(StrEqual(classname, "weapon_shotgun_chrome"))
- {
- int shotgunChrome = 32;
- SetConVarInt(shotammo, shotgunChrome)
- }
- else if(StrEqual(classname, "weapon_autoshotgun"))
- {
- int autoshotgun = 32;
- SetConVarInt(autoshotammo, autoshotgun)
- }
- else if(StrEqual(classname, "weapon_shotgun_spas"))
- {
- int shotgunSpas = 32;
- SetConVarInt(autoshotammo, shotgunSpas)
- }
- else if(StrEqual(classname, "weapon_sniper_military"))
- {
- new sniperMilitary = 60;
- SetConVarInt(sniperammo, sniperMilitary)
- }
- else if(StrEqual(classname, "weapon_sniper_awp"))
- {
- int sniperAwp = 30;
- SetConVarInt(m60ammo, sniperAwp)
- }
- else if(StrEqual(classname, "weapon_sniper_scout"))
- {
- int sniperScout = 60;
- SetConVarInt(sniperammo, sniperScout)
- }
- else if(StrEqual(classname, "weapon_hunting_rifle"))
- {
- int huntingRifle = 30;
- SetConVarInt(m60ammo, huntingRifle)
- }
- else if(StrEqual(classname, "weapon_rifle_m60"))
- {
- int iClip1 = GetEntProp(weaponIndex, Prop_Send, "m_iClip1");
- int iPrimType = GetEntProp(weaponIndex, Prop_Send, "m_iPrimaryAmmoType");
- SetEntProp(playerClient, Prop_Send, "m_iAmmo", (GetConVarInt(m60amount_max)-iClip1), _, iPrimType);
- }
- else if(StrEqual(classname, "weapon_grenade_launcher"))
- {
- int iClip1 = GetEntProp(weaponIndex, Prop_Send, "m_iClip1");
- int iPrimType = GetEntProp(weaponIndex, Prop_Send, "m_iPrimaryAmmoType");
- SetEntProp(playerClient, Prop_Send, "m_iAmmo", (GetConVarInt(glamount_max)-iClip1), _, iPrimType);
- }
- }
- }
- //CreateTimer(30.0, GunTimer, TIMER_FLAG_NO_MAPCHANGE);
- }
- public Action:Event_ItemPickup(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(!GetConVarInt(l4d2_LaserEnabled)) return Plugin_Continue;
- new client = GetClientOfUserId(GetEventInt(event, "userid"))
- if (!client || !IsClientInGame(client)) return Plugin_Continue;
- decl String:weaponname[128]
- GetEventString(event, "item", weaponname, sizeof(weaponname))
- new targetgun = GetPlayerWeaponSlot(client, 0)
- if (IsValidEdict(targetgun))
- {
- if (StrEqual(weaponname, "rifle_m60", false))
- {
- new ammmo = GetRandomInt(0, 150);
- new M60 = GetRandomInt(GetConVarInt(m60ammo_min), GetConVarInt(m60ammo_max))
- SetConVarInt(huntingrifleammo, M60)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- }
- else if (StrEqual(weaponname, "grenade_launcher", false))
- {
- new GrenadeLauncher = GetRandomInt(GetConVarInt(glammo_min), GetConVarInt(glammo_max))
- SetConVarInt(glammo, GrenadeLauncher)
- }
- else if (StrEqual(weaponname, "rifle", false))
- {
- new ammmo = GetRandomInt(0, 50);
- new M16 = GetRandomInt(GetConVarInt(m16ammo_min), GetConVarInt(m16ammo_max))
- SetConVarInt(rifleammo, M16)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_M16laser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- else if (StrEqual(weaponname, "rifle_ak47", false))
- {
- new ammmo = GetRandomInt(0, 40);
- new Ak47 = GetRandomInt(GetConVarInt(ak47ammo_min), GetConVarInt(ak47ammo_max))
- SetConVarInt(rifleammo, Ak47)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_AK47laser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- else if (StrEqual(weaponname, "rifle_desert", false))
- {
- new ammmo = GetRandomInt(0, 60);
- new Desert = GetRandomInt(GetConVarInt(desertammo_min), GetConVarInt(desertammo_max))
- SetConVarInt(rifleammo, Desert)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_DesertRiflelaser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- else if (StrEqual(weaponname, "rifle_sg552", false))
- {
- new ammmo = GetRandomInt(0, 50);
- new Sg552 = GetRandomInt(GetConVarInt(sg552ammo_min), GetConVarInt(sg552ammo_max))
- SetConVarInt(rifleammo, Sg552)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_SG552laser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- else if (StrEqual(weaponname, "hunting_rifle", false))
- {
- new ammmo = GetRandomInt(0, 5);
- new Huntingrifle = GetRandomInt(GetConVarInt(huntingrifleammo_min), GetConVarInt(huntingrifleammo_max))
- SetConVarInt(m60ammo, Huntingrifle)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_HuntingRiflelaser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- else if (StrEqual(weaponname, "sniper_scout", false))
- {
- new ammmo = GetRandomInt(0, 10);
- new SniperScout = GetRandomInt(GetConVarInt(scoutammo_min), GetConVarInt(scoutammo_max))
- SetConVarInt(sniperammo, SniperScout)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- }
- else if(StrEqual(weaponname, "sniper_military", false))
- {
- new ammmo = GetRandomInt(0, 20);
- new SniperMilitary = GetRandomInt(GetConVarInt(militaryammo_min), GetConVarInt(militaryammo_max))
- SetConVarInt(sniperammo, SniperMilitary)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_Militarylaser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- else if (StrEqual(weaponname, "sniper_awp", false))
- {
- new ammmo = GetRandomInt(0, 5);
- new SniperAwp = GetRandomInt(GetConVarInt(awpammo_min), GetConVarInt(awpammo_max))
- SetConVarInt(m60ammo, SniperAwp)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- }
- else if (StrEqual(weaponname, "autoshotgun", false))
- {
- new ammmo = GetRandomInt(0, 6);
- new AutoShot = GetRandomInt(GetConVarInt(autoshotammo_min), GetConVarInt(autoshotammo_max))
- SetConVarInt(autoshotammo, AutoShot)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- }
- else if (StrEqual(weaponname, "pumpshotgun", false))
- {
- new ammmo = GetRandomInt(0, 6);
- new PumpShotgun = GetRandomInt(GetConVarInt(pumpshotammo_min), GetConVarInt(pumpshotammo_max))
- SetConVarInt(shotammo, PumpShotgun)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- }
- else if (StrEqual(weaponname, "shotgun_chrome", false))
- {
- new ammmo = GetRandomInt(0, 8);
- new ChromeShotgun = GetRandomInt(GetConVarInt(chromeshotammo_min), GetConVarInt(chromeshotammo_max))
- SetConVarInt(shotammo, ChromeShotgun)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- }
- else if (StrEqual(weaponname, "shotgun_spas", false))
- {
- new ammmo = GetRandomInt(0, 8);
- new ShotSpas = GetRandomInt(GetConVarInt(shotspasammo_min), GetConVarInt(shotspasammo_max))
- SetConVarInt(autoshotammo, ShotSpas)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- }
- else if(StrEqual(weaponname, "smg", false))
- {
- new ammmo = GetRandomInt(0, 50);
- new Smg = GetRandomInt(GetConVarInt(smgammo_min), GetConVarInt(smgammo_max))
- SetConVarInt(smgammo, Smg)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_SMGlaser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- else if (StrEqual(weaponname, "smg_mp5", false))
- {
- new ammmo = GetRandomInt(0, 50);
- new Smg5 = GetRandomInt(GetConVarInt(smg5ammo_min), GetConVarInt(smg5ammo_max))
- SetConVarInt(smgammo, Smg5)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_SMG5laser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- else if (StrEqual(weaponname, "smg_silenced", false))
- {
- new ammmo = GetRandomInt(0, 50);
- new SmgS = GetRandomInt(GetConVarInt(smgsammo_min), GetConVarInt(smgsammo_max))
- SetConVarInt(smgammo, SmgS)
- SetEntProp(targetgun, Prop_Send, "m_iClip1", ammmo, 1)
- new Handle:chance=l4d2_SMGSlaser_chance;
- if(GetRandomFloat(0.0,100.0)<GetConVarFloat(chance))
- {
- GiveClientLaser(client);
- }
- }
- }
- new pistol = GetPlayerWeaponSlot(client, 1)
- if (IsValidEdict(pistol))
- {
- if (StrEqual(weaponname, "pistol", false))
- {
- new ammmo = GetRandomInt(0, 15);
- SetEntProp(pistol, Prop_Send, "m_iClip1", ammmo, 1)
- }
- else if (StrEqual(weaponname, "pistol_magnum", false))
- {
- new ammmo = GetRandomInt(0, 8);
- SetEntProp(pistol, Prop_Send, "m_iClip1", ammmo, 1)
- }
- }
- return Plugin_Continue;
- }
- stock GiveClientLaser(any:client)
- {
- new priWeapon = GetPlayerWeaponSlot(client, 0);
- if (priWeapon <= 0 || !IsValidEntity(priWeapon)) return;
- new upgrades = L4D2_GetWeaponUpgrades(priWeapon);
- if (upgrades & L4D2_WEPUPGFLAG_LASER) return;
- L4D2_SetWeaponUpgrades(priWeapon, upgrades | L4D2_WEPUPGFLAG_LASER);
- }
- stock L4D2_GetWeaponUpgrades(weapon)
- {
- return GetEntProp(weapon, Prop_Send, "m_upgradeBitVec");
- }
- stock L4D2_SetWeaponUpgrades(weapon, upgrades)
- {
- SetEntProp(weapon, Prop_Send, "m_upgradeBitVec", upgrades);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement