Diff
checker
Testo
Testo
Immagini
Documenti
Excel
Cartelle
Legal
Enterprise
Applicazione per desktop
Prezzi
Accedi
Scarica Diffchecker Desktop
Confronta il testo
Trova la differenza tra due file di testo
Strumenti
Cronologia
Visualizzazione
Layout
Diviso
Unificato
Editor live
Nascondi spazi bianchi
Comprimi invariate
Senza a capo
Livello di dettaglio
Intelligente
Sintassi
Nessuno
Modifica aspetto
Elaborazione
Ignora
Trasforma testo
Vai alla prima modifica
Modifica input
Diffchecker Desktop
Il modo più sicuro per usare Diffchecker. Ottieni l'app Diffchecker Desktop: i tuoi diff non lasciano mai il tuo computer!
Ottieni Desktop
Untitled diff
Creato
11 anni fa
Il diff non scade mai
Eliminare
Esporta
Condividere
Spiegare
550 rimozioni
Linee
Totale
Rimosso
Caratteri
Totale
Rimosso
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
575 linee
Copia tutti
159 aggiunte
Linee
Totale
Aggiunto
Caratteri
Totale
Aggiunto
Per continuare a utilizzare questa funzione, aggiorna a
Diff
checker
Pro
Visualizza prezzi
187 linee
Copia tutti
#include <sourcemod>
#include <sourcemod>
#include <sdktools>
#include <sdktools>
Copia
Copiato
Copia
Copiato
#include <sdkhooks>
Copia
Copiato
Copia
Copiato
#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
Copia
Copiato
Copia
Copiato
//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
Copia
Copiato
Copia
Copiato
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"
}
}
Copia
Copiato
Copia
Copiato
public
OnPluginStart()
public
OnMapStart()
{
{
precacheModels();
//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)
}
}
Copia
Copiato
Copia
Copiato
PrecacheWeaponModels()
public OnClientPostAdminCheck(client) {
{
SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage);
//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")
}
}
Copia
Copiato
Copia
Copiato
public Action:
InitHiddenWeaponsDelay(Handle:timer, any:client)
public Action:
eventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) {
{
if (isMapAllowed()) {
//Spawn and delete the hidden weapons,
CreateTimer(1.0, roundStartDelay, TIMER_FLAG_NO_MAPCHANGE);
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.")
}
}
Copia
Copiato
Copia
Copiato
public ConVarChange_Enabled(Handle:convar, const String:oldValue[], const String:newValue[])
{
if ((StringToInt(oldValue) == 1) && (StringToInt(newValue) == 0)) RestoreWeaponSpawns()
if ((StringToInt(oldValue) == 0) && (StringToInt(newValue) == 1)) CreateTimer(0.1, RoundStartDelay)
}
}
Copia
Copiato
Copia
Copiato
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)
{
if (GetConVarInt(h_Enabled) == 0) return
//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)
}
}
Copia
Copiato
Copia
Copiato
public Action:
R
oundStartDelay(Handle:timer)
public Action:
r
oundStartDelay(Handle:timer)
{
{
precacheModels();
//Look up the map and type of game we're running.
proccessReplace();
GetConVarString(FindConVar("mp_gamemode"), GameMode, sizeof(GameMode))
if (StrEqual(GameMode, "survival")) return
if (StrEqual(GameMode, "scavenge"))
{
if (g_bScavengeHalftime == true) g_bScavengeHalftime = false
else GetWeaponSpawns()
SetWeaponSpawns()
return
}
if (StrEqual(GameMode, "versus"))
{
if (g_bNewMap == true)
{
GetWeaponSpawns()
g_bNewMap = false
}
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()
}
}
Copia
Copiato
Copia
Copiato
public Action:Event_ScavengeRoundHalftime(Handle:event, const String:name[], bool:dontBroadcast)
stock proccessReplace() {
{
new spawnedAwp, spawnedScout;
g_bScavengeHalftime = true
for (new i = GetMaxClients(); i < GetMaxEntities(); i++) {
if (IsValidEdict(i) && IsValidEntity(i)) {
new String:classname[STRING_SIZE];
GetEdictClassname(i, classname, sizeof(classname));
new weaponSpawnId;
if (StrEqual(classname, "weapon_spawn")) {
weaponSpawnId = GetEntProp(i, Prop_Send, "m_weaponID");
}
}
/*
if (StrEqual(classname, "weapon_sniper_military") || StrEqual(classname, "weapon_sniper_military_spawn") || weaponSpawnId == WEAPONID_MILITARY) {
//Spawn bats at the survivors' position.
if (spawnedAwp < AWP_LIMIT && isRandomAllowing(50)) {
public Action:SpawnBatsDelay(Handle:timer)
new weapon = replace(i, "weapon_sniper_awp");
{
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4);
for (new i = 1; i <= MaxClients; i++)
spawnedAwp++;
{
if ((IsClientInGame(i)) && (GetClientTeam(i)==2))
{
new Float:Origin[3]
new index = CreateEntityByName("weapon_melee")
GetClientAbsOrigin(i, Origin)
TeleportEntity(index, Origin, NULL_VECTOR, NULL_VECTOR)
DispatchKeyValue(index, "melee_script_name", "baseball_bat")
DispatchSpawn(index)
}
}
}
}
}
*/
else if (StrEqual(classname, "weapon_hunting_rifle") || StrEqual(classname, "weapon_hunting_rifle_spawn") || weaponSpawnId == WEAPONID_HUNTING) {
public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast)
if (spawnedScout < SCOUT_LIMIT && isRandomAllowing(50)) {
{
new weapon = replace(i, "weapon_sniper_scout");
new target = GetClientOfUserId(GetEventInt(event, "userid"))
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4);
if (target == 0) return
spawnedScout++;
//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)
}
}
}
}
else if (StrEqual(classname, "weapon_rifle_desert")) {
GetWeaponSpawns()
new weapon = replace(i, "weapon_rifle_sg552");
{
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 360, 4);
//Search for dynamic weapon spawns,
decl String:EdictClassName[32]
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++
}
}
Copia
Copiato
Copia
Copiato
else if (StrEqual(classname, "weapon_rifle_desert_spawn") || weaponSpawnId == WEAPONID_DESERT) {
replace(i, "weapon_rifle_sg552", FLAG_WEAPON_SPAWN);
Copia
Copiato
Copia
Copiato
}
}
Copia
Copiato
Copia
Copiato
else if (StrEqual(classname, "weapon_smg")) {
new weapon = replace(i, "weapon_smg_mp5");
if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 650, 4);
Copia
Copiato
Copia
Copiato
}
}
//If dynamic spawns were found, and we're not running scavenge, modify the stored spawns like this:
else if (StrEqual(classname, "weapon_smg_spawn") || weaponSpawnId == WEAPONID_SMG) {
if (count != 0 && !StrEqual(GameMode, "scavenge"))
replace(i, "weapon_smg_mp5", FLAG_WEAPON_SPAWN);
{
for (new i = 0; i < sizeof(WeaponSpawn_ID); i++)
{
if (WeaponSpawn_ID[i] == -1) break
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;
}
}
}
}
}
}
Copia
Copiato
Copia
Copiato
//Otherwise, search for static spawns,
else
{
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++
Copia
Copiato
Copia
Copiato
}
}
Copia
Copiato
Copia
Copiato
stock replace(oldWeapon, const String:newWeaponName[], bool:isSpawn = false) {
new Float:origin[3], Float:angles[3];
GetEntPropVector(oldWeapon, Prop_Send, "m_vecOrigin", origin);
GetEntPropVector(oldWeapon, Prop_Send, "m_angRotation", angles);
RemoveEdict(oldWeapon);
new newItemEntity;
if (isSpawn) {
newItemEntity = CreateEntityByName("weapon_spawn");
if (StrEqual(newWeaponName, "weapon_rifle_sg552")) {
SetEntityModel(newItemEntity, "models/w_models/weapons/w_rifle_sg552.mdl");
SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SG552);
} else if (StrEqual(newWeaponName, "weapon_smg_mp5")) {
if (IsModelPrecached("models/w_models/weapons/w_smg_mp5.mdl")) {
SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_mp5.mdl");
SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_MP5);
} else {
SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_uzi.mdl");
SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SMG);
}
}
Copia
Copiato
Copia
Copiato
} else {
return 0;
}
}
Copia
Copiato
Copia
Copiato
//and modify them like this:
} else {
for (new i = 0; i < sizeof(WeaponSpawn_ID); i++)
newItemEntity = CreateEntityByName(newWeaponName);
{
if (WeaponSpawn_ID[i] == -1) break
WeaponSpawn_IDMod[i] = WeaponSpawn_ID[i]
switch(WeaponSpawn_ID[i])
{
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;
if (IsValidEdict(newItemEntity)) {
//Since the hunting rifle is a T1 weapon in L4D2, we'll upgrade it to a T2 sniper rifle for L4D1 maps.
TeleportEntity(newItemEntity, origin, angles, NULL_VECTOR);
case HUNTING_RIFLE:
if (isSpawn) DispatchKeyValue(newItemEntity, "count", "4");
if (GetConVarInt(h_AWPEnabled) == 1)
DispatchSpawn(newItemEntity);
{
switch(GetRandomInt(1, 2))
{
case 2: WeaponSpawn_IDMod[i] = SNIPER_MILITARY;
case 1: WeaponSpawn_IDMod[i] = SNIPER_AWP;
}
}
Copia
Copiato
Copia
Copiato
return newItemEntity;
Copia
Copiato
Copia
Copiato
}
}
else WeaponSpawn_IDMod[i] = SNIPER_MILITARY;
case RIFLE:
public OnEntityCreated(entity, const String:classname[]) {
if (GetConVarInt(h_SG552Enabled) == 1)
if (StrEqual(classname, "infected") || StrEqual(classname, "witch")) {
{
SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage);
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
{
public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) {
switch(GetRandomInt(1, 3) == 1)
if (inflictor && attacker && victim && IsValidEdict(victim) && IsValidEdict(inflictor)) {
{
if (IsClientInGame(victim) && GetClientTeam(victim) == 2) {
case 2: WeaponSpawn_IDMod[i] = RIFLE_AK47;
return Plugin_Continue;
case 1: WeaponSpawn_IDMod[i] = RIFLE_DESERT;
}
}
}
case AUTOSHOTGUN: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SHOTGUN_SPAS;
new String:classname[STRING_SIZE];
case PUMPSHOTGUN: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = SHOTGUN_CHROME;
new weapon = GetEntPropEnt(attacker, Prop_Data, "m_hActiveWeapon");
case SMG:
GetEdictClassname(weapon, classname, sizeof(classname));
if (GetConVarInt(h_MP5Enabled) == 1)
{
if (StrEqual(classname, "weapon_sniper_awp")) {
switch(GetRandomInt(1, 3))
damage = 600.0;
{
return Plugin_Changed;
case 2: WeaponSpawn_IDMod[i] = SMG_SILENCED;
case 1: WeaponSpawn_IDMod[i] = SMG_MP5;
}
}
Copia
Copiato
Copia
Copiato
if (StrEqual(classname, "weapon_sniper_scout")) {
damage = 350.0;
return Plugin_Changed;
Copia
Copiato
Copia
Copiato
}
}
else
if (
GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i]
=
SMG_SILENCED
;
if (
StrEqual(classname, "weapon_rifle_sg552")) {
case PISTOL: if (GetRandomInt(1, 2) == 1) WeaponSpawn_IDMod[i] = PISTOL_MAGNUM
;
damage
=
50.0
;
return Plugin_Changed
;
}
}
Copia
Copiato
Copia
Copiato
if (StrEqual(classname, "weapon_smg_mp5")) {
damage = 25.0;
return Plugin_Changed;
}
}
}
}
Copia
Copiato
Copia
Copiato
return Plugin_Continue;
}
}
Copia
Copiato
Copia
Copiato
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
}
}
}
}
}
}
}
Copia
Copiato
Copia
Copiato
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
_rif
le.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)
}
}
}
}
Copia
Copiato
Copia
Copiato
stock lateLoadSDKHook() {
for (new i = 1; i <= MaxClients; i++) {
if (IsClientInGame(i)) {
SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage);
}
}
}
}
}
}
Copia
Copiato
Copia
Copiato
ReplaceWeaponSpawn(target, source)
{
new Float:Origin[3]
Origin[0] = WeaponSpawn_X[source]
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)
}
Diff salvati
Testo originale
Apri file
#include <sourcemod> #include <sdktools> #define PLUGIN_VERSION "0.8.1" #define PISTOL 1 #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. new Handle:h_Enabled new Handle:h_AWPEnabled new Handle:h_MP5Enabled new Handle:h_ScoutEnabled new Handle:h_SG552Enabled new Handle:h_ScoutBoost new Handle:h_AWPBoost //new Handle:h_BatterUp //Used to store weapon spawns. 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 = { name = "[L4D2] Weapon Unlock", 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() { //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) { //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[]) { if ((StringToInt(oldValue) == 1) && (StringToInt(newValue) == 0)) RestoreWeaponSpawns() if ((StringToInt(oldValue) == 0) && (StringToInt(newValue) == 1)) CreateTimer(0.1, RoundStartDelay) } public OnMapStart() { g_bNewMap = true g_bScavengeHalftime = false for (new i = 0; i < sizeof(WeaponSpawn_ID); i++) WeaponSpawn_ID[i] = -1 } public Action:Event_RoundStart(Handle:event, const String:name[], bool:dontBroadcast) { if (GetConVarInt(h_Enabled) == 0) return //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) { //Look up the map and type of game we're running. GetConVarString(FindConVar("mp_gamemode"), GameMode, sizeof(GameMode)) if (StrEqual(GameMode, "survival")) return if (StrEqual(GameMode, "scavenge")) { if (g_bScavengeHalftime == true) g_bScavengeHalftime = false else GetWeaponSpawns() SetWeaponSpawns() return } if (StrEqual(GameMode, "versus")) { if (g_bNewMap == true) { GetWeaponSpawns() g_bNewMap = false } 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) { g_bScavengeHalftime = true } /* //Spawn bats at the survivors' position. public Action:SpawnBatsDelay(Handle:timer) { for (new i = 1; i <= MaxClients; i++) { if ((IsClientInGame(i)) && (GetClientTeam(i)==2)) { new Float:Origin[3] new index = CreateEntityByName("weapon_melee") GetClientAbsOrigin(i, Origin) TeleportEntity(index, Origin, NULL_VECTOR, NULL_VECTOR) DispatchKeyValue(index, "melee_script_name", "baseball_bat") DispatchSpawn(index) } } } */ public Action:Event_PlayerHurt(Handle:event, const String:name[], bool:dontBroadcast) { new target = GetClientOfUserId(GetEventInt(event, "userid")) 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() { //Search for dynamic weapon spawns, decl String:EdictClassName[32] 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++ } } } //If dynamic spawns were found, and we're not running scavenge, modify the stored spawns like this: if (count != 0 && !StrEqual(GameMode, "scavenge")) { for (new i = 0; i < sizeof(WeaponSpawn_ID); i++) { if (WeaponSpawn_ID[i] == -1) break 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; } } } //Otherwise, search for static spawns, else { 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: for (new i = 0; i < sizeof(WeaponSpawn_ID); i++) { if (WeaponSpawn_ID[i] == -1) break WeaponSpawn_IDMod[i] = WeaponSpawn_ID[i] switch(WeaponSpawn_ID[i]) { 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; } } } } SetWeaponSpawns() { PrecacheWeaponModels() 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() { decl String:EdictClassName[32] for (new i = 0; i <= GetEntityCount(); i++) { if (IsValidEntity(i)) { GetEdictClassname(i, EdictClassName, sizeof(EdictClassName)) if (StrEqual(EdictClassName, "weapon_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_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) { new Float:Origin[3] Origin[0] = WeaponSpawn_X[source] 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) }
Testo modificato
Apri file
#include <sourcemod> #include <sdktools> #include <sdkhooks> #define STRING_SIZE 1024 #define FLAG_WEAPON_SPAWN true #define AWP_LIMIT 1 #define SCOUT_LIMIT 3 #define WEAPONID_MP5 33 #define WEAPONID_SG552 34 #define WEAPONID_AWP 35 #define WEAPONID_SCOUT 36 #define WEAPONID_SMG 2 #define WEAPONID_HUNTING 6 #define WEAPONID_DESERT 9 #define WEAPONID_MILITARY 10 public OnPluginStart() { HookEvent("round_start", eventRoundStart); lateLoadSDKHook(); } public OnMapStart() { precacheModels(); } public OnClientPostAdminCheck(client) { SDKHook(client, SDKHook_OnTakeDamage, OnTakeDamage); } public Action:eventRoundStart(Handle:event, const String:name[], bool:dontBroadcast) { if (isMapAllowed()) { CreateTimer(1.0, roundStartDelay, TIMER_FLAG_NO_MAPCHANGE); } } stock isMapAllowed() { new String:currentMap[STRING_SIZE]; GetCurrentMap(currentMap, sizeof(currentMap)); 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)) { return false; } return true; } public Action:roundStartDelay(Handle:timer) { precacheModels(); proccessReplace(); } stock proccessReplace() { new spawnedAwp, spawnedScout; for (new i = GetMaxClients(); i < GetMaxEntities(); i++) { if (IsValidEdict(i) && IsValidEntity(i)) { new String:classname[STRING_SIZE]; GetEdictClassname(i, classname, sizeof(classname)); new weaponSpawnId; if (StrEqual(classname, "weapon_spawn")) { weaponSpawnId = GetEntProp(i, Prop_Send, "m_weaponID"); } if (StrEqual(classname, "weapon_sniper_military") || StrEqual(classname, "weapon_sniper_military_spawn") || weaponSpawnId == WEAPONID_MILITARY) { if (spawnedAwp < AWP_LIMIT && isRandomAllowing(50)) { new weapon = replace(i, "weapon_sniper_awp"); if (weapon > 0) SetEntProp(weapon, Prop_Send, "m_iExtraPrimaryAmmo", 180, 4); spawnedAwp++; } } 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); } } } } stock replace(oldWeapon, const String:newWeaponName[], bool:isSpawn = false) { new Float:origin[3], Float:angles[3]; GetEntPropVector(oldWeapon, Prop_Send, "m_vecOrigin", origin); GetEntPropVector(oldWeapon, Prop_Send, "m_angRotation", angles); RemoveEdict(oldWeapon); new newItemEntity; if (isSpawn) { newItemEntity = CreateEntityByName("weapon_spawn"); if (StrEqual(newWeaponName, "weapon_rifle_sg552")) { SetEntityModel(newItemEntity, "models/w_models/weapons/w_rifle_sg552.mdl"); SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SG552); } else if (StrEqual(newWeaponName, "weapon_smg_mp5")) { if (IsModelPrecached("models/w_models/weapons/w_smg_mp5.mdl")) { SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_mp5.mdl"); SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_MP5); } else { SetEntityModel(newItemEntity, "models/w_models/weapons/w_smg_uzi.mdl"); SetEntProp(newItemEntity, Prop_Send, "m_weaponID", WEAPONID_SMG); } } 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 OnEntityCreated(entity, const String:classname[]) { if (StrEqual(classname, "infected") || StrEqual(classname, "witch")) { SDKHook(entity, SDKHook_OnTakeDamage, OnTakeDamage); } } public Action:OnTakeDamage(victim, &attacker, &inflictor, &Float:damage, &damagetype) { if (inflictor && attacker && victim && IsValidEdict(victim) && IsValidEdict(inflictor)) { if (IsClientInGame(victim) && GetClientTeam(victim) == 2) { return Plugin_Continue; } new String:classname[STRING_SIZE]; new weapon = GetEntPropEnt(attacker, Prop_Data, "m_hActiveWeapon"); GetEdictClassname(weapon, classname, sizeof(classname)); if (StrEqual(classname, "weapon_sniper_awp")) { damage = 600.0; return Plugin_Changed; } if (StrEqual(classname, "weapon_sniper_scout")) { damage = 350.0; return Plugin_Changed; } if (StrEqual(classname, "weapon_rifle_sg552")) { damage = 50.0; return Plugin_Changed; } if (StrEqual(classname, "weapon_smg_mp5")) { damage = 25.0; return Plugin_Changed; } } return Plugin_Continue; } stock isRandomAllowing(chance) { if (GetRandomInt(1, 100) <= chance) return true; return false; } stock precacheModels() { PrecacheModel("models/w_models/weapons/w_smg_mp5.mdl"); PrecacheModel("models/w_models/weapons/w_rifle_sg552.mdl"); PrecacheModel("models/w_models/weapons/w_sniper_awp.mdl"); PrecacheModel("models/w_models/weapons/w_sniper_scout.mdl"); PrecacheModel("models/v_models/v_rif_sg552.mdl"); PrecacheModel("models/v_models/v_smg_mp5.mdl"); PrecacheModel("models/v_models/v_snip_awp.mdl"); PrecacheModel("models/v_models/v_snip_scout.mdl"); } stock lateLoadSDKHook() { for (new i = 1; i <= MaxClients; i++) { if (IsClientInGame(i)) { SDKHook(i, SDKHook_OnTakeDamage, OnTakeDamage); } } }
Trovare la differenza