Untitled diff

Created Diff never expires
537 removals
575 lines
149 additions
187 lines
#include <sourcemod>
#include <sourcemod>
#include <sdktools>
#include <sdktools>
#include <sdkhooks>


#define PLUGIN_VERSION "0.8.1"
#define STRING_SIZE 1024
#define PISTOL 1
#define FLAG_WEAPON_SPAWN true
#define SMG 2
#define PUMPSHOTGUN 3
#define AUTOSHOTGUN 4
#define RIFLE 5
#define HUNTING_RIFLE 6
#define SMG_SILENCED 7
#define SHOTGUN_CHROME 8
#define RIFLE_DESERT 9
#define SNIPER_MILITARY 10
#define SHOTGUN_SPAS 11
#define MOLOTOV 13
#define PIPE_BOMB 14
#define VOMITJAR 25
#define RIFLE_AK47 26
#define PISTOL_MAGNUM 32
#define SMG_MP5 33
#define RIFLE_SG552 34
#define SNIPER_AWP 35
#define SNIPER_SCOUT 36


//Cvar handles.
#define AWP_LIMIT 1
new Handle:h_Enabled
#define SCOUT_LIMIT 3
new Handle:h_AWPEnabled
#define WEAPONID_MP5 33
new Handle:h_MP5Enabled
#define WEAPONID_SG552 34
new Handle:h_ScoutEnabled
#define WEAPONID_AWP 35
new Handle:h_SG552Enabled
#define WEAPONID_SCOUT 36
new Handle:h_ScoutBoost
#define WEAPONID_SMG 2
new Handle:h_AWPBoost
#define WEAPONID_HUNTING 6
//new Handle:h_BatterUp
#define WEAPONID_DESERT 9
//Used to store weapon spawns.
#define WEAPONID_MILITARY 10
new WeaponSpawn_ID[64]
new WeaponSpawn_IDMod[64]
new Float:WeaponSpawn_X[64]
new Float:WeaponSpawn_Y[64]
new Float:WeaponSpawn_Z[64]
new String:Map[64]
new String:GameMode[16]
//Used to keep spawns the same for both teams on competitive modes.
new bool:g_bNewMap
new bool:g_bScavengeHalftime


public Plugin:myinfo =
public OnPluginStart() {
{
HookEvent("round_start", eventRoundStart);
name = "[L4D2] Weapon Unlock",
lateLoadSDKHook();
author = "Crimson_Fox",
description = "Unlocks the hidden CSS weapons.",
version = PLUGIN_VERSION,
url = "http://forums.alliedmods.net/showthread.php?p=1041458"
}

public OnPluginStart()
{
//Look up what game we're running,
decl String:game[16]
GetGameFolderName(game, sizeof(game))
//and don't load if it's not L4D2.
if (!StrEqual(game, "left4dead2", false)) SetFailState("Plugin supports Left 4 Dead 2 only.")
//Set up cvars and event hooks.
CreateConVar("l4d2_WeaponUnlock", PLUGIN_VERSION, "Weapon Unlock version.", FCVAR_PLUGIN|FCVAR_SPONLY|FCVAR_REPLICATED|FCVAR_NOTIFY|FCVAR_DONTRECORD)
h_Enabled = CreateConVar("l4d2_wu_enable", "1", "Is Weapon Unlock plug-in enabled?", FCVAR_PLUGIN|FCVAR_DONTRECORD)
h_AWPEnabled = CreateConVar("l4d2_wu_awp", "1", "Enable AWP sniper rifle?", FCVAR_PLUGIN)
h_MP5Enabled = CreateConVar("l4d2_wu_mp5", "1", "Enable MP5 submachine gun?", FCVAR_PLUGIN)
h_ScoutEnabled = CreateConVar("l4d2_wu_scout", "1", "Enable Scout sniper rifle?", FCVAR_PLUGIN)
h_SG552Enabled = CreateConVar("l4d2_wu_sg552", "1", "Enable SG552 assault rifle?", FCVAR_PLUGIN)
h_AWPBoost = CreateConVar("l4d2_wu_awpboost", "135", "Amount of damage added to AWP sniper rifle.", FCVAR_PLUGIN)
h_ScoutBoost = CreateConVar("l4d2_wu_scoutboost", "110", "Amount of damage added to scout sniper rifle.", FCVAR_PLUGIN)
// h_BatterUp = CreateConVar("l4d2_wu_bat", "0", "Spawn baseball bats for survivors?", FCVAR_PLUGIN)
AutoExecConfig(true, "l4d2_WeaponUnlock")
HookEvent("round_start", Event_RoundStart)
HookEvent("scavenge_round_halftime", Event_ScavengeRoundHalftime)
HookEvent("player_hurt", Event_PlayerHurt)
HookConVarChange(h_Enabled, ConVarChange_Enabled)
//Precache hidden weapon models and initialize them after one second.
PrecacheWeaponModels()
CreateTimer(1.0, InitHiddenWeaponsDelay)
}
}


PrecacheWeaponModels()
public OnMapStart() {
{
precacheModels();
//Precache weapon models if they're not loaded.
if (!IsModelPrecached("models/w_models/weapons/w_rifle_sg552.mdl")) PrecacheModel("models/w_models/weapons/w_rifle_sg552.mdl")
if (!IsModelPrecached("models/w_models/weapons/w_smg_mp5.mdl")) PrecacheModel("models/w_models/weapons/w_smg_mp5.mdl")
if (!IsModelPrecached("models/w_models/weapons/w_sniper_awp.mdl")) PrecacheModel("models/w_models/weapons/w_sniper_awp.mdl")
if (!IsModelPrecached("models/w_models/weapons/w_sniper_scout.mdl")) PrecacheModel("models/w_models/weapons/w_sniper_scout.mdl")
if (!IsModelPrecached("models/w_models/weapons/w_eq_bile_flask.mld")) PrecacheModel("models/w_models/weapons/w_eq_bile_flask.mld")
if (!IsModelPrecached("models/v_models/v_rif_sg552.mdl")) PrecacheModel("models/v_models/v_rif_sg552.mdl")
if (!IsModelPrecached("models/v_models/v_smg_mp5.mdl")) PrecacheModel("models/v_models/v_smg_mp5.mdl")
if (!IsModelPrecached("models/v_models/v_snip_awp.mdl")) PrecacheModel("models/v_models/v_snip_awp.mdl")
if (!IsModelPrecached("models/v_models/v_snip_scout.mdl")) PrecacheModel("models/v_models/v_snip_scout.mdl")
}
}


public Action:InitHiddenWeaponsDelay(Handle:timer, any:client)
public OnClientPostAdminCheck(client) {
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
//Spawn and delete the hidden weapons,
new index = CreateEntityByName("weapon_rifle_sg552")
DispatchSpawn(index)
RemoveEdict(index)
index = CreateEntityByName("weapon_smg_mp5")
DispatchSpawn(index)
RemoveEdict(index)
index = CreateEntityByName("weapon_sniper_awp")
DispatchSpawn(index)
RemoveEdict(index)
index = CreateEntityByName("weapon_sniper_scout")
DispatchSpawn(index)
RemoveEdict(index)
GetCurrentMap(Map, sizeof(Map))
ForceChangeLevel(Map, "Hidden weapon initialization.")
}
}


public ConVarChange_Enabled(Handle:convar, const String:oldValue[], const String:newValue[])
public Action:eventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) {
{
if (isMapAllowed()) {
if ((StringToInt(oldValue) == 1) && (StringToInt(newValue) == 0)) RestoreWeaponSpawns()
CreateTimer(1.0, roundStartDelay, TIMER_FLAG_NO_MAPCHANGE);
if ((StringToInt(oldValue) == 0) && (StringToInt(newValue) == 1)) CreateTimer(0.1, RoundStartDelay)
}
}
}


public OnMapStart()
stock isMapAllowed() {
{
new String:currentMap[STRING_SIZE];
g_bNewMap = true
GetCurrentMap(currentMap, sizeof(currentMap));
g_bScavengeHalftime = false
if (StrEqual(currentMap, "c4m1_milltown_a", false) || StrEqual(currentMap, "c4m2_sugarmill_a", false) || StrEqual(currentMap, "c4m3_sugarmill_b", false) || StrEqual(currentMap, "c4m4_milltown_b", false)) {
for (new i = 0; i < sizeof(WeaponSpawn_ID); i++) WeaponSpawn_ID[i] = -1
return false;
}
return true;
}
}


public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast)
public Action:roundStartDelay(Handle:timer) {
{
precacheModels();
if (GetConVarInt(h_Enabled) == 0) return
proccessReplace();
//Spawn baseball bats if the option is enabled.
// if (GetConVarInt(h_BatterUp) != 0) CreateTimer(15.0, SpawnBatsDelay)
//Need a delay here to let OnMapStart() run.
CreateTimer(1.0, RoundStartDelay)
}
}


public Action:RoundStartDelay(Handle:timer)
stock proccessReplace() {
{
new spawnedAwp, spawnedScout;
//Look up the map and type of game we're running.
for (new i = GetMaxClients(); i < GetMaxEntities(); i++) {
GetConVarString(FindConVar("mp_gamemode"), GameMode, sizeof(GameMode))
if (IsValidEdict(i) && IsValidEntity(i)) {
if (StrEqual(GameMode, "survival")) return
new String:classname[STRING_SIZE];
if (StrEqual(GameMode, "scavenge"))
GetEdictClassname(i, classname, sizeof(classname));
{
if (g_bScavengeHalftime == true) g_bScavengeHalftime = false
new weaponSpawnId;
else GetWeaponSpawns()
if (StrEqual(classname, "weapon_spawn")) {
SetWeaponSpawns()
weaponSpawnId = GetEntProp(i, Prop_Send, "m_weaponID");
return
}
}
if (StrEqual(GameMode, "versus"))
if (StrEqual(classname, "weapon_sniper_military") || StrEqual(classname, "weapon_sniper_military_spawn") || weaponSpawnId == WEAPONID_MILITARY) {
{
if (spawnedAwp < AWP_LIMIT && isRandomAllowing(50)) {
if (g_bNewMap == true)
new weapon = replace(i, "weapon_sniper_awp");
{
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4);
GetWeaponSpawns()
spawnedAwp++;
g_bNewMap = false
}
}
else if (StrEqual(classname, "weapon_hunting_rifle") || StrEqual(classname, "weapon_hunting_rifle_spawn") || weaponSpawnId == WEAPONID_HUNTING) {
if (spawnedScout < SCOUT_LIMIT && isRandomAllowing(50)) {
new weapon = replace(i, "weapon_sniper_scout");
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4);
spawnedScout++;
}
}
else if (StrEqual(classname, "weapon_rifle_desert")) {
new weapon = replace(i, "weapon_rifle_sg552");
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 360, 4);
}
else if (StrEqual(classname, "weapon_rifle_desert_spawn") || weaponSpawnId == WEAPONID_DESERT) {
replace(i, "weapon_rifle_sg552", FLAG_WEAPON_SPAWN);
}
else if (StrEqual(classname, "weapon_smg")) {
new weapon = replace(i, "weapon_smg_mp5");
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 650, 4);
}
else if (StrEqual(classname, "weapon_smg_spawn") || weaponSpawnId == WEAPONID_SMG) {
replace(i, "weapon_smg_mp5", FLAG_WEAPON_SPAWN);
}
}
}
SetWeaponSpawns()
return
}
}
GetCurrentMap(Map, sizeof(Map))
//If we're in a coop mode and running c4m1-4, don't modify spawns as it causes crashes on transitions.
if (
(StrEqual(GameMode, "coop") ||
StrEqual(GameMode, "realism")) &&
(StrEqual(Map, "c4m1_milltown_a") ||
StrEqual(Map, "c4m2_sugarmill_a") ||
StrEqual(Map, "c4m3_sugarmill_b") ||
StrEqual(Map, "c4m4_milltown_b")))
return
GetWeaponSpawns()
SetWeaponSpawns()
}
}


public Action:Event_ScavengeRoundHalftime(Handle:event, const String:name[], bool:dontBroadcast)
stock replace(oldWeapon, const String:newWeaponName[], bool:isSpawn = false) {
{
new Float:origin[3], Float:angles[3];
g_bScavengeHalftime = true
GetEntPropVector(oldWeapon, Prop_Send, "m_vecOrigin", origin);
}
GetEntPropVector(oldWeapon, Prop_Send, "m_angRotation", angles);

RemoveEdict(oldWeapon);
/*
new newItemEntity;
//Spawn bats at the survivors' position.
if (isSpawn) {
public Action:SpawnBatsDelay(Handle:timer)
newItemEntity = CreateEntityByName("weapon_spawn");
{
if (StrEqual(newWeaponName, "weapon_rifle_sg552")) {
for (new i = 1; i <= MaxClients; i++)
SetEntityModel(newItemEntity, "models/w_models/weapons/w_rifle_sg552.mdl");
{
SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SG552);
if ((IsClientInGame(i)) && (GetClientTeam(i)==2))
} else if (StrEqual(newWeaponName, "weapon_smg_mp5")) {
{
if (IsModelPrecached("models/w_models/weapons/w_smg_mp5.mdl")) {
new Float:Origin[3]
SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_mp5.mdl");
new index = CreateEntityByName("weapon_melee")
SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_MP5);
GetClientAbsOrigin(i, Origin)
} else {
TeleportEntity(index, Origin, NULL_VECTOR, NULL_VECTOR)
SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_uzi.mdl");
DispatchKeyValue(index, "melee_script_name", "baseball_bat")
SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SMG);
DispatchSpawn(index)
}
} else {
return 0;
}
}
} else {
newItemEntity = CreateEntityByName(newWeaponName);
}
}
if (IsValidEdict(newItemEntity)) {
TeleportEntity(newItemEntity, origin, angles, NULL_VECTOR);
if (isSpawn) DispatchKeyValue(newItemEntity, "count", "4");
DispatchSpawn(newItemEntity);
}
return newItemEntity;
}
}
*/

public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
public OnEntityCreated(entity, const String:classname[]) {
{
if (StrEqual(classname, "infected") || StrEqual(classname, "witch")) {
new target = GetClientOfUserId(GetEventInt(event, "userid"))
SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
if (target == 0) return
//If the player that was hurt was not infected, go back.
if (GetClientTeam(target) != 3) return
decl String:weapon[16]
GetEventString(event, "weapon", weapon, sizeof(weapon))
if (StrEqual(weapon, "sniper_awp"))
{
new health = GetClientHealth(target)
new damage = GetConVarInt(h_AWPBoost)
if (health-damage < 0) SetEntityHealth(target, 0)
else SetEntityHealth(target, health-damage)
}
if (StrEqual(weapon, "sniper_scout"))
{
new health = GetClientHealth(target)
new damage = GetConVarInt(h_ScoutBoost)
if (health-damage < 0) SetEntityHealth(target, 0)
else SetEntityHealth(target, health-damage)
}
}
}
}


GetWeaponSpawns()
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) {
{
if (inflictor && attacker && victim && IsValidEdict(victim) && IsValidEdict(inflictor)) {
//Search for dynamic weapon spawns,
if (IsClientInGame(victim) && GetClientTeam(victim) == 2) {
decl String:EdictClassName[32]
return Plugin_Continue;
new count = 0
for (new i = 0; i <= GetEntityCount(); i++)
{
if (IsValidEntity(i))
{
GetEdictClassname(i, EdictClassName, sizeof(EdictClassName))
if (StrEqual(EdictClassName, "weapon_spawn"))
{
//and record their position.
new Float:Location[3]
GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location)
WeaponSpawn_ID[count] = GetEntProp(i, Prop_Send, "m_weaponID")
WeaponSpawn_X[count] = Location[0]
WeaponSpawn_Y[count] = Location[1]
WeaponSpawn_Z[count] = Location[2]
count++
}
}
}
}
new String:classname[STRING_SIZE];
//If dynamic spawns were found, and we're not running scavenge, modify the stored spawns like this:
new weapon = GetEntPropEnt(attacker, Prop_Data, "m_hActiveWeapon");
if (count != 0 && !StrEqual(GameMode, "scavenge"))
GetEdictClassname(weapon, classname, sizeof(classname));
{
for (new i = 0; i < sizeof(WeaponSpawn_ID); i++)
if (StrEqual(classname, "weapon_sniper_awp")) {
{
damage = 600.0;
if (WeaponSpawn_ID[i] == -1) break
return Plugin_Changed;
WeaponSpawn_IDMod[i] = WeaponSpawn_ID[i]
switch(WeaponSpawn_ID[i])
{
case RIFLE_AK47: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552;
case SNIPER_MILITARY: if ((GetConVarInt(h_AWPEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_AWP;
case RIFLE_DESERT: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552;
case SMG_SILENCED: if ((GetConVarInt(h_MP5Enabled) == 1) && (GetRandomInt(1, 3) == 1)) WeaponSpawn_IDMod[i] = SMG_MP5;
case HUNTING_RIFLE: if ((GetConVarInt(h_ScoutEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_SCOUT;
case RIFLE: if ((GetConVarInt(h_SG552Enabled) == 1) && (GetRandomInt(1, 4) == 1)) WeaponSpawn_IDMod[i] = RIFLE_SG552;
case SMG: if ((GetConVarInt(h_MP5Enabled) == 1) && (GetRandomInt(1, 3) == 1)) WeaponSpawn_IDMod[i] = SMG_MP5;
}
}
}
}
if (StrEqual(classname, "weapon_sniper_scout")) {
//Otherwise, search for static spawns,
damage = 350.0;
else
return Plugin_Changed;
{
for (new i = 0; i <= GetEntityCount(); i++)
{
if (IsValidEntity(i))
{
GetEdictClassname(i, EdictClassName, sizeof(EdictClassName))
if (
StrEqual(EdictClassName, "weapon_autoshotgun_spawn") ||
StrEqual(EdictClassName, "weapon_hunting_rifle_spawn") ||
StrEqual(EdictClassName, "weapon_molotov_spawn") ||
StrEqual(EdictClassName, "weapon_pipe_bomb_spawn") ||
StrEqual(EdictClassName, "weapon_pistol_magnum_spawn") ||
StrEqual(EdictClassName, "weapon_pistol_spawn") ||
StrEqual(EdictClassName, "weapon_pumpshotgun_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_ak47_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_desert_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_spawn") ||
StrEqual(EdictClassName, "weapon_shotgun_chrome_spawn") ||
StrEqual(EdictClassName, "weapon_shotgun_spas_spawn") ||
StrEqual(EdictClassName, "weapon_smg_spawn") ||
StrEqual(EdictClassName, "weapon_smg_silenced_spawn") ||
StrEqual(EdictClassName, "weapon_sniper_military_spawn") ||
StrEqual(EdictClassName, "weapon_vomitjar_spawn"))
{
//record their position,
new Float:Location[3]
GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location)
WeaponSpawn_ID[count] = GetEntProp(i, Prop_Send, "m_weaponID")
WeaponSpawn_X[count] = Location[0]
WeaponSpawn_Y[count] = Location[1]
WeaponSpawn_Z[count] = Location[2]
count++
}
}
}
}
//and modify them like this:
if (StrEqual(classname, "weapon_rifle_sg552")) {
for (new i = 0; i < sizeof(WeaponSpawn_ID); i++)
damage = 50.0;
{
return Plugin_Changed;
if (WeaponSpawn_ID[i] == -1) break
}
WeaponSpawn_IDMod[i] = WeaponSpawn_ID[i]
if (StrEqual(classname, "weapon_smg_mp5")) {
switch(WeaponSpawn_ID[i])
damage = 25.0;
{
return Plugin_Changed;
case PISTOL_MAGNUM: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PISTOL;
case RIFLE_AK47:
if (GetConVarInt(h_SG552Enabled) == 1)
{
switch(GetRandomInt(1, 4))
{
case 3: WeaponSpawn_IDMod[i] = RIFLE;
case 2: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552;
}
}
else
{
switch(GetRandomInt(1, 3) == 1)
{
case 2: WeaponSpawn_IDMod[i] = RIFLE;
case 1: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
}
}
case VOMITJAR:
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = PIPE_BOMB;
case 1: WeaponSpawn_IDMod[i] = MOLOTOV;
}
case PIPE_BOMB:
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = MOLOTOV;
case 1: WeaponSpawn_IDMod[i] = VOMITJAR;
}
case MOLOTOV:
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = VOMITJAR;
case 1: WeaponSpawn_IDMod[i] = PIPE_BOMB;
}
case SHOTGUN_SPAS: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = AUTOSHOTGUN;
case SNIPER_MILITARY: if ((GetConVarInt(h_AWPEnabled) == 1) && (GetRandomInt(1, 2) == 1)) WeaponSpawn_IDMod[i] = SNIPER_AWP;
case RIFLE_DESERT:
if (GetConVarInt(h_SG552Enabled) == 1)
{
switch(GetRandomInt(1, 4))
{
case 3: WeaponSpawn_IDMod[i] = RIFLE;
case 2: WeaponSpawn_IDMod[i] = RIFLE_AK47;
case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552;
}
}
else
{
switch(GetRandomInt(1, 3) == 1)
{
case 2: WeaponSpawn_IDMod[i] = RIFLE;
case 1: WeaponSpawn_IDMod[i] = RIFLE_AK47;
}
}
case SHOTGUN_CHROME: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PUMPSHOTGUN;
case SMG_SILENCED:
if (GetConVarInt(h_MP5Enabled) == 1)
{
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = SMG;
case 1: WeaponSpawn_IDMod[i] = SMG_MP5;
}
}
else if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SMG;
//Since the hunting rifle is a T1 weapon in L4D2, we'll upgrade it to a T2 sniper rifle for L4D1 maps.
case HUNTING_RIFLE:
if (GetConVarInt(h_AWPEnabled) == 1)
{
switch(GetRandomInt(1, 2))
{
case 2: WeaponSpawn_IDMod[i] = SNIPER_MILITARY;
case 1: WeaponSpawn_IDMod[i] = SNIPER_AWP;
}
}
else WeaponSpawn_IDMod[i] = SNIPER_MILITARY;
case RIFLE:
if (GetConVarInt(h_SG552Enabled) == 1)
{
switch(GetRandomInt(1, 4))
{
case 3: WeaponSpawn_IDMod[i] = RIFLE_AK47;
case 2: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
case 1: WeaponSpawn_IDMod[i] = RIFLE_SG552;
}
}
else
{
switch(GetRandomInt(1, 3) == 1)
{
case 2: WeaponSpawn_IDMod[i] = RIFLE_AK47;
case 1: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
}
}
case AUTOSHOTGUN: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SHOTGUN_SPAS;
case PUMPSHOTGUN: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SHOTGUN_CHROME;
case SMG:
if (GetConVarInt(h_MP5Enabled) == 1)
{
switch(GetRandomInt(1, 3))
{
case 2: WeaponSpawn_IDMod[i] = SMG_SILENCED;
case 1: WeaponSpawn_IDMod[i] = SMG_MP5;
}
}
else if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SMG_SILENCED;
case PISTOL: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PISTOL_MAGNUM;
}
}
}
}
}
return Plugin_Continue;
}
}


SetWeaponSpawns()
stock isRandomAllowing(chance) {
{
if (GetRandomInt(1, 100) <= chance) return true;
PrecacheWeaponModels()
return false;
decl String:EdictClassName[32]
for (new i = 0; i <= GetEntityCount(); i++)
{
if (IsValidEntity(i))
{
GetEdictClassname(i, EdictClassName, sizeof(EdictClassName))
if (
StrEqual(EdictClassName, "weapon_spawn") ||
StrEqual(EdictClassName, "weapon_autoshotgun_spawn") ||
StrEqual(EdictClassName, "weapon_hunting_rifle_spawn") ||
StrEqual(EdictClassName, "weapon_molotov_spawn") ||
StrEqual(EdictClassName, "weapon_pipe_bomb_spawn") ||
StrEqual(EdictClassName, "weapon_pistol_magnum_spawn") ||
StrEqual(EdictClassName, "weapon_pistol_spawn") ||
StrEqual(EdictClassName, "weapon_pumpshotgun_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_ak47_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_desert_spawn") ||
StrEqual(EdictClassName, "weapon_rifle_spawn") ||
StrEqual(EdictClassName, "weapon_shotgun_chrome_spawn") ||
StrEqual(EdictClassName, "weapon_shotgun_spas_spawn") ||
StrEqual(EdictClassName, "weapon_smg_spawn") ||
StrEqual(EdictClassName, "weapon_smg_silenced_spawn") ||
StrEqual(EdictClassName, "weapon_sniper_military_spawn") ||
StrEqual(EdictClassName, "weapon_vomitjar_spawn"))
{
new Float:Location[3]
GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location)
new weaponID = GetEntProp(i, Prop_Send, "m_weaponID")
for (new x = 0; x < sizeof(WeaponSpawn_IDMod); x++)
{
if (WeaponSpawn_ID[x] == -1) break
if (
((FloatAbs(WeaponSpawn_X[x] - Location[0]) < 2) &&
(FloatAbs(WeaponSpawn_Y[x] - Location[1]) < 2) &&
(FloatAbs(WeaponSpawn_Z[x] - Location[2]) < 2)) &&
(weaponID != WeaponSpawn_IDMod[x]))
{
ReplaceWeaponSpawn(i, x)
break
}
}
}
}
}
}
}


RestoreWeaponSpawns()
stock precacheModels() {
{
PrecacheModel("models/w_models/weapons/w_smg_mp5.mdl");
decl String:EdictClassName[32]
PrecacheModel("models/w_models/weapons/w_rifle_sg552.mdl");
for (new i = 0; i <= GetEntityCount(); i++)
PrecacheModel("models/w_models/weapons/w_sniper_awp.mdl");
{
PrecacheModel("models/w_models/weapons/w_sniper_scout.mdl");
if (IsValidEntity(i))
PrecacheModel("models/v_models/v_rif_sg552.mdl");
{
PrecacheModel("models/v_models/v_smg_mp5.mdl");
GetEdictClassname(i, EdictClassName, sizeof(EdictClassName))
PrecacheModel("models/v_models/v_snip_awp.mdl");
if (StrEqual(EdictClassName, "weapon_spawn"))
PrecacheModel("models/v_models/v_snip_scout.mdl");
{
new Float:Location[3]
GetEntPropVector(i, Prop_Send, "m_vecOrigin", Location)
new weaponID = GetEntProp(i, Prop_Send, "m_weaponID")
for (new x = 0; x < sizeof(WeaponSpawn_ID); x++)
{
if (WeaponSpawn_ID[x] == -1) break
if (
((FloatAbs(WeaponSpawn_X[x] - Location[0]) < 2) &&
(FloatAbs(WeaponSpawn_Y[x] - Location[1]) < 2) &&
(FloatAbs(WeaponSpawn_Z[x] - Location[2]) < 2)) &&
(weaponID != WeaponSpawn_ID[x]))
{
new Float:Angles[3]
GetEntPropVector(i, Prop_Send, "m_angRotation", Angles)
RemoveEdict(i)
new index = CreateEntityByName("weapon_spawn")
switch(WeaponSpawn_ID[x])
{
case PISTOL_MAGNUM: SetEntityModel(index, "models/w_models/weapons/w_desert_eagle.mdl");
case RIFLE_AK47: SetEntityModel(index, "models/w_models/weapons/w_rifle_ak47.mdl");
case VOMITJAR: SetEntityModel(index, "models/w_models/weapons/w_eq_bile_flask.mld");
case PIPE_BOMB: SetEntityModel(index, "models/w_models/weapons/w_eq_pipebomb.mdl");
case MOLOTOV: SetEntityModel(index, "models/w_models/weapons/w_eq_molotov.mdl");
case SHOTGUN_SPAS: SetEntityModel(index, "models/w_models/weapons/w_shotgun_spas.mdl");
case SNIPER_MILITARY: SetEntityModel(index, "models/w_models/weapons/w_sniper_military.mdl");
case RIFLE_DESERT: SetEntityModel(index, "models/w_models/weapons/w_desert_rifle.mdl");
case SHOTGUN_CHROME: SetEntityModel(index, "models/w_models/weapons/w_pumpshotgun_a.mdl");
case SMG_SILENCED: SetEntityModel(index, "models/w_models/weapons/w_smg_a.mdl");
case HUNTING_RIFLE: SetEntityModel(index, "models/w_models/weapons/w_sniper_mini14.mdl");
case RIFLE: SetEntityModel(index, "models/w_models/weapons/w_rifle_m16a2.mdl");
case AUTOSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_autoshot_m4super.mdl");
case PUMPSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_shotgun.mdl");
case SMG: SetEntityModel(index, "models/w_models/weapons/w_smg_uzi.mdl");
case PISTOL: SetEntityModel(index, "models/w_models/weapons/w_pistol_a.mdl");
}
SetEntProp(index, Prop_Send, "m_weaponID", WeaponSpawn_ID[x])
TeleportEntity(index, Location, Angles, NULL_VECTOR)
if (
WeaponSpawn_ID[x] == VOMITJAR ||
WeaponSpawn_ID[x] == PIPE_BOMB ||
WeaponSpawn_ID[x] == MOLOTOV)
DispatchKeyValue(index, "count", "1")
else DispatchKeyValue(index, "count", "4")
DispatchSpawn(index)
}
}
}
}
}
}
}


ReplaceWeaponSpawn(target, source)
stock lateLoadSDKHook() {
{
for (new i = 1; i <= MaxClients; i++) {
new Float:Origin[3]
if (IsClientInGame(i)) {
Origin[0] = WeaponSpawn_X[source]
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
Origin[1] = WeaponSpawn_Y[source]
}
Origin[2] = WeaponSpawn_Z[source]
new Float:Angles[3]
GetEntPropVector(target, Prop_Send, "m_angRotation", Angles)
RemoveEdict(target)
new index = CreateEntityByName("weapon_spawn")
switch(WeaponSpawn_IDMod[source])
{
case SNIPER_SCOUT: SetEntityModel(index, "models/w_models/weapons/w_sniper_scout.mdl");
case SNIPER_AWP: SetEntityModel(index, "models/w_models/weapons/w_sniper_awp.mdl");
case RIFLE_SG552: SetEntityModel(index, "models/w_models/weapons/w_rifle_sg552.mdl");
case SMG_MP5: SetEntityModel(index, "models/w_models/weapons/w_smg_mp5.mdl");
case PISTOL_MAGNUM: SetEntityModel(index, "models/w_models/weapons/w_desert_eagle.mdl");
case RIFLE_AK47: SetEntityModel(index, "models/w_models/weapons/w_rifle_ak47.mdl");
case VOMITJAR: SetEntityModel(index, "models/w_models/weapons/w_eq_bile_flask.mld");
case PIPE_BOMB: SetEntityModel(index, "models/w_models/weapons/w_eq_pipebomb.mdl");
case MOLOTOV: SetEntityModel(index, "models/w_models/weapons/w_eq_molotov.mdl");
case SHOTGUN_SPAS: SetEntityModel(index, "models/w_models/weapons/w_shotgun_spas.mdl");
case SNIPER_MILITARY: SetEntityModel(index, "models/w_models/weapons/w_sniper_military.mdl");
case RIFLE_DESERT: SetEntityModel(index, "models/w_models/weapons/w_desert_rifle.mdl");
case SHOTGUN_CHROME: SetEntityModel(index, "models/w_models/weapons/w_pumpshotgun_a.mdl");
case SMG_SILENCED: SetEntityModel(index, "models/w_models/weapons/w_smg_a.mdl");
case HUNTING_RIFLE: SetEntityModel(index, "models/w_models/weapons/w_sniper_mini14.mdl");
case RIFLE: SetEntityModel(index, "models/w_models/weapons/w_rifle_m16a2.mdl");
case AUTOSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_autoshot_m4super.mdl");
case PUMPSHOTGUN: SetEntityModel(index, "models/w_models/weapons/w_shotgun.mdl");
case SMG: SetEntityModel(index, "models/w_models/weapons/w_smg_uzi.mdl");
case PISTOL: SetEntityModel(index, "models/w_models/weapons/w_pistol_a.mdl");
}
}
SetEntProp(index, Prop_Send, "m_weaponID", WeaponSpawn_IDMod[source])
TeleportEntity(index, Origin, Angles, NULL_VECTOR)
if (
WeaponSpawn_IDMod[source] == VOMITJAR ||
WeaponSpawn_IDMod[source] == PIPE_BOMB ||
WeaponSpawn_IDMod[source] == MOLOTOV)
DispatchKeyValue(index, "count", "1")
else DispatchKeyValue(index, "count", "4")
DispatchSpawn(index)
}
}