Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <sourcemod>
- #include <sdktools>
- #include <sdkhooks>
- #define TEAM_INFECTED 3
- #define ZC_BOOMER 2
- #define ZC_TANK 8
- new bool:CanPlayerDrop[MAXPLAYERS+1];
- new Handle:l4d_drop_probability_hunter;
- new Handle:l4d_drop_probability_boomer;
- new Handle:l4d_drop_probability_smoker;
- new Handle:l4d_drop_probability_jockey
- new Handle:l4d_drop_probability_charger;
- new Handle:l4d_drop_probability_tank
- new Handle:l4d_drop_probability_grab;
- new Handle:l4d_drop_probability_incap;
- new Handle:l4d_drop_enable= INVALID_HANDLE;
- //new Handle:h_ClientTimer[MAXPLAYERS+1] = INVALID_HANDLE;
- new bool:l4d2=false;
- new GameMode;
- new bool:IsConnected[MAXPLAYERS]
- new bool:IsReduce[MAXPLAYERS]
- new bool:IsWaterReduce[MAXPLAYERS]
- new bool:IsReduceBase[MAXPLAYERS]
- new bool:IsReduceWaterBase[MAXPLAYERS]
- #define IsClientValidConnected(%1) (1<=%1<=MaxClients && IsConnected[%1])
- #define IsClientValidAlive(%1) (1<=%1<=MaxClients && IsReduce[%1])
- #define IsValiddAliveAndInWater(%1) (1<=%1<=MaxClients && IsWaterReduce[%1])
- #define IsAlive(%1) (1<=%1<=MaxClients && IsReduceBase[%1])
- #define IsAliveAndInWater(%1) (1<=%1<=MaxClients && IsReduceWaterBase[%1])
- public Plugin:myinfo =
- {
- name = "L4D2 Realism Drop",
- author = "Pan Xiaohai & Frustian & kwski43 & NoBody",
- description = "<- Description ->",
- version = "1.1",
- url = "<- URL ->"
- }
- public OnPluginStart()
- {
- GameCheck();
- l4d_drop_enable = CreateConVar("l4d_drop_enable", "1", " 0:disable item drop, 1:eanble ", FCVAR_NONE);
- l4d_drop_probability_hunter = CreateConVar("l4d_drop_hunter", "30.0", "drop probability by hunter pounce", FCVAR_NONE);
- l4d_drop_probability_boomer = CreateConVar("l4d_drop_boomer", "10.0", "boomer explode", FCVAR_NONE);
- l4d_drop_probability_smoker = CreateConVar("l4d_drop_smoker", "30.0", "smoker drag", FCVAR_NONE);
- l4d_drop_probability_jockey = CreateConVar("l4d_drop_jockey", "30.0", "jockey ride", FCVAR_NONE);
- l4d_drop_probability_charger = CreateConVar("l4d_drop_charger", "30.0", "charger carray", FCVAR_NONE);
- l4d_drop_probability_tank = CreateConVar("l4d_drop_tank", "30.0", "tank punch", FCVAR_NONE);
- l4d_drop_probability_grab = CreateConVar("l4d_drop_ledge_grab", "30.0", "ledge grab", FCVAR_NONE);
- l4d_drop_probability_incap = CreateConVar("l4d_drop_incap", "20.0", "incapacitated", FCVAR_NONE);
- if(GameMode!=2)
- {
- if(l4d2)
- {
- HookEvent("jockey_ride", Event_JockeyRide, EventHookMode_Post);
- HookEvent("charger_carry_start", Event_CarrySstart, EventHookMode_Post);
- }
- HookEvent("tongue_grab", Event_TongueGrab, EventHookMode_Post);
- HookEvent("player_ledge_grab", Event_PlayerLedgeGrab, EventHookMode_Post);
- HookEvent("lunge_pounce", Event_LungePounce, EventHookMode_Post);
- HookEvent("player_now_it", PlayerDeath);
- HookEvent("player_incapacitated_start", Event_IncapacitatedStart, EventHookMode_Post);
- HookEvent("player_use", Event_PlayerUse);
- HookEvent("weapon_drop", Event_WeaponDrop);
- HookEvent("bot_player_replace", bot_player_replace);
- HookEvent("player_incapacitated", Event_PlayerIncap, EventHookMode_Post);
- //HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
- AutoExecConfig(true, "l4d12_drop");
- }
- }
- public OnClientPutInServer(client)
- {
- CanPlayerDrop[client] = true;
- IsConnected[client] = true;
- }
- public OnClientDisconnect(client)
- {
- IsReduce[client] = false
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- }
- public Action:OnPlayerRunCmd(client, &buttons, &impuls, Float:vel[3], Float:angles[3], &weapon)
- {
- if(CanPlayerDrop[client] == false && (buttons & IN_SPEED) && (buttons & IN_RELOAD))
- {
- return Plugin_Continue;
- }
- if(GetClientTeam(client) == 2 && !IsFakeClient(client) && IsPlayerAlive(client) && (buttons & IN_SPEED) && (buttons & IN_RELOAD))
- {
- CanPlayerDrop[client] = false;
- CreateTimer(0.5, ResetDelay, client);
- Command_Drop(client, 0)
- }
- if (!IsClientInGame(client) || GetClientTeam(client) != 2 || !IsPlayerAlive(client))
- {
- return Plugin_Continue;
- }
- new priWeapon = GetPlayerWeaponSlot(client, 0);
- if (!IsValidEntity(priWeapon)) return Plugin_Continue;
- decl String:sWeaponEx[32];
- GetEntityClassname(priWeapon, sWeaponEx, sizeof(sWeaponEx));
- if(StrEqual(sWeaponEx, "weapon_rifle_m60"))
- {
- if(GetEntProp(client, Prop_Send, "m_bAdrenalineActive", 1) > 0)
- {
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 1) > 0)
- {
- IsReduce[client] = false
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = true
- }
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 0) < 1)
- {
- IsReduce[client] = false
- IsReduceBase[client] = true
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- }
- }
- if(GetEntProp(client, Prop_Send, "m_isIncapacitated", 1) > 0)
- {
- IsReduce[client] = false
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- }
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 1) > 0)
- {
- IsReduce[client] = false
- IsReduceBase[client] = false
- IsWaterReduce[client] = true
- IsReduceWaterBase[client] = false
- }
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 0) < 1)
- {
- IsReduce[client] = true
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- if(GetEntProp(client, Prop_Send, "m_bAdrenalineActive", 1) > 0)
- {
- IsReduce[client] = false
- IsReduceBase[client] = true
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- }
- }
- }
- return Plugin_Continue;
- }
- public Action:ResetDelay(Handle:timer, any:client)
- {
- IsReduce[client] = false;
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- CanPlayerDrop[client] = true;
- }
- GameCheck()
- {
- decl String:GameName[16];
- GetConVarString(FindConVar("mp_gamemode"), GameName, sizeof(GameName));
- if (StrEqual(GameName, "survival", false))
- GameMode = 3;
- else if (StrEqual(GameName, "versus", false) || StrEqual(GameName, "teamversus", false) || StrEqual(GameName, "scavenge", false) || StrEqual(GameName, "teamscavenge", false))
- GameMode = 2;
- else if (StrEqual(GameName, "coop", false) || StrEqual(GameName, "realism", false))
- GameMode = 1;
- else
- {
- GameMode = 0;
- }
- GetGameFolderName(GameName, sizeof(GameName));
- if (StrEqual(GameName, "left4dead2", false))
- {
- l4d2=true;
- }
- else
- {
- l4d2=false;
- }
- }
- 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;
- new droppedEnt = GetEventInt(event, "propid");
- decl String:ent_name[64];
- if (IsValidEdict(droppedEnt))
- {
- GetEdictClassname(droppedEnt, ent_name, sizeof(ent_name));
- if (StrEqual(ent_name, "weapon_rifle_m60", false))
- {
- IsReduce[client] = false
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- }
- }
- }
- public Action:Event_PlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- if (!IsClientInGame(client) || GetClientTeam(client) != 2 || !IsPlayerAlive(client)) return;
- new entIndex = GetEventInt(event, "targetid");
- if (!IsValidEntity(entIndex)) return;
- decl String:sItemName[64];
- GetEdictClassname(entIndex, sItemName, sizeof(sItemName));
- if(StrEqual(sItemName, "weapon_rifle_m60"))
- {
- if(GetEntProp(client, Prop_Send, "m_bAdrenalineActive", 1) > 0)
- {
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 1) > 0)
- {
- IsReduce[client] = false
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = true
- }
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 0) < 1)
- {
- IsReduce[client] = false
- IsReduceBase[client] = true
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- }
- }
- }
- }
- public Action:bot_player_replace(Handle:event, const String:name[], bool:dontBroadcast)
- {
- //new bot = GetClientOfUserId(GetEventInt(event, "bot"));
- new client = GetClientOfUserId(GetEventInt(event, "player"));
- decl String:weapon[64];
- GetClientWeapon(client, weapon, sizeof(weapon));
- if(GetEntProp(client, Prop_Send, "m_bAdrenalineActive", 1) > 0)
- {
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 1) > 0)
- {
- IsReduce[client] = false
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = true
- }
- if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 0) < 1)
- {
- IsReduce[client] = false
- IsReduceBase[client] = true
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- }
- }
- else
- {
- IsReduce[client] = false;
- IsReduceBase[client] = false;
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- }
- }
- public Action:Event_JockeyRide(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(GetConVarInt(l4d_drop_enable)==0)return;
- new client = GetClientOfUserId(GetEventInt(event, "victim"));
- if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_jockey))
- {
- DropItem(client);
- }
- }
- public Action:Event_CarrySstart(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(GetConVarInt(l4d_drop_enable)==0)return;
- new client = GetClientOfUserId(GetEventInt(event, "victim"));
- if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_charger))
- {
- DropItem(client);
- }
- }
- public Action:Event_TongueGrab(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(GetConVarInt(l4d_drop_enable)==0)return;
- new client = GetClientOfUserId(GetEventInt(event, "victim"));
- if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_smoker))
- {
- DropItem(client);
- }
- }
- public Action:Event_LungePounce(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(GetConVarInt(l4d_drop_enable)==0)return;
- new client = GetClientOfUserId(GetEventInt(event, "victim"));
- if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_hunter))
- {
- DropItem(client);
- }
- }
- public Action:Event_PlayerLedgeGrab(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(GetConVarInt(l4d_drop_enable)==0)return;
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_grab))
- {
- DropItem(client)
- }
- }
- public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(GetConVarInt(l4d_drop_enable)==0)return;
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
- new exploded = GetEventBool(event, "exploded");
- if(exploded)
- {
- if (IsValidClient(attacker) && IsValidBoomer(attacker))
- {
- if (IsValidClient(client) && GetClientTeam(client) == 2 && !IsSurvivorPinned(client))
- {
- if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_boomer))
- {
- DropItem(client)
- }
- }
- }
- }
- }
- public Action:Event_IncapacitatedStart(Handle:event, const String:name[], bool:dontBroadcast)
- {
- if(GetConVarInt(l4d_drop_enable)==0)return;
- new client = GetClientOfUserId(GetEventInt(event, "userid"));
- if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_incap))
- {
- DropItem(client)
- }
- }
- public Action:Event_PlayerIncap(Handle:event, String:event_name[], bool:dontBroadcast)
- {
- new client = GetClientOfUserId(GetEventInt(event,"userid"));
- new attacker = GetClientOfUserId(GetEventInt(event,"attacker"));
- decl String:weapon[16];
- GetEventString(event, "weapon", weapon, 16);
- if(!StrEqual(weapon, "tank_claw")) return;
- if(IsValidTank(attacker) && !IsPlayerGhost(attacker))
- {
- if (IsValidClient(client) && GetClientTeam(client) == 2 && !IsSurvivorPinned(client))
- {
- if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_tank))
- {
- DropItem(client)
- }
- }
- }
- }
- public Action:Command_Drop(client, args)
- {
- if (client == 0 || GetClientTeam(client) != 2 || !IsPlayerAlive(client))return Plugin_Handled;
- Drop(client, true, 0,true);
- return Plugin_Handled;
- }
- GetCurrentWeaponSlot(client)
- {
- new slot=-1;
- decl String:weapon[32];
- GetClientWeapon(client,weapon , 32);
- //PrintToChatAll("%s",weapon);
- if (StrEqual(weapon, "weapon_pumpshotgun") || StrEqual(weapon, "weapon_autoshotgun") || StrEqual(weapon, "weapon_rifle") || StrEqual(weapon, "weapon_smg") || StrEqual(weapon, "weapon_hunting_rifle") || StrEqual(weapon, "weapon_sniper_scout") || StrEqual(weapon, "weapon_sniper_military") || StrEqual(weapon, "weapon_sniper_awp") || StrEqual(weapon, "weapon_smg_silenced") || StrEqual(weapon, "weapon_smg_mp5") || StrEqual(weapon, "weapon_shotgun_spas") || StrEqual(weapon, "weapon_shotgun_chrome") || StrEqual(weapon, "weapon_rifle_sg552") || StrEqual(weapon, "weapon_rifle_desert") || StrEqual(weapon, "weapon_rifle_ak47") || StrEqual(weapon, "weapon_grenade_launcher") || StrEqual(weapon, "weapon_rifle_m60"))
- slot=0;
- else if (StrEqual(weapon, "weapon_pistol") || StrEqual(weapon, "weapon_pistol_magnum") || StrEqual(weapon, "weapon_chainsaw") || StrEqual(weapon, "weapon_melee"))
- slot=1;
- else if (StrEqual(weapon, "weapon_pipe_bomb") || StrEqual(weapon, "weapon_molotov") || StrEqual(weapon, "weapon_vomitjar"))
- slot=2;
- else if (StrEqual(weapon, "weapon_first_aid_kit") || StrEqual(weapon, "weapon_defibrillator") || StrEqual(weapon, "weapon_upgradepack_explosive") || StrEqual(weapon, "weapon_upgradepack_incendiary"))
- slot=3;
- else if (StrEqual(weapon, "weapon_pain_pills") || StrEqual(weapon, "weapon_adrenaline"))
- slot=4;
- if(slot <0 )
- {
- for(new i=0; i<5; i++)
- {
- new s=GetPlayerWeaponSlot(client, i);
- if(s>0)
- {
- slot=i;
- break;
- }
- }
- }
- return slot;
- }
- Drop(client, bool:dropcurrent, count, bool:drop)
- {
- if(dropcurrent)
- {
- new s=GetCurrentWeaponSlot(client);
- if(s>=0)
- {
- DropSlot2(client, s, drop);
- }
- }
- if(count==0 && !dropcurrent)count=1;
- if(count>0)
- {
- new slot[5];
- new m=0;
- for(new i=0; i<5; i++)
- {
- if (GetPlayerWeaponSlot(client, i) > 0)
- {
- slot[m++]=i;
- }
- }
- if(m<=count)count=m;
- for(new i=0; i<count && m>0; i++)
- {
- new r=GetRandomInt(0, m-1);
- DropSlot2(client, slot[r], drop);
- slot[r]=slot[m-1];
- m--;
- }
- }
- }
- DropSlot2(client, slot, bool:drop=false)
- {
- if(l4d2)DropSlot_l4d2(client, slot, drop);
- //else DropSlot_l4d1(client, slot, drop,receiver);
- }
- #define MODEL_V_FIREAXE "models/weapons/melee/v_fireaxe.mdl"
- #define MODEL_V_FRYING_PAN "models/weapons/melee/v_frying_pan.mdl"
- #define MODEL_V_MACHETE "models/weapons/melee/v_machete.mdl"
- #define MODEL_V_BASEBALL_BAT "models/weapons/melee/v_bat.mdl"
- #define MODEL_V_CROWBAR "models/weapons/melee/v_crowbar.mdl"
- #define MODEL_V_CRICKET_BAT "models/weapons/melee/v_cricket_bat.mdl"
- #define MODEL_V_TONFA "models/weapons/melee/v_tonfa.mdl"
- #define MODEL_V_KATANA "models/weapons/melee/v_katana.mdl"
- #define MODEL_V_ELECTRIC_GUITAR "models/weapons/melee/v_electric_guitar.mdl"
- #define MODEL_V_GOLFCLUB "models/weapons/melee/v_golfclub.mdl"
- #define MODEL_V_SHIELD "models/weapons/melee/v_riotshield.mdl"
- #define MODEL_V_KNIFE "models/v_models/v_knife_t.mdl"
- // code from kwski43 [L4D2] Caught Item Drop http://forums.alliedmods.net/showthread.php?t=133610
- DropSlot_l4d2(client, slot, bool:drop=false)
- {
- new oldweapon=GetPlayerWeaponSlot(client, slot);
- if (oldweapon > 0)
- {
- new String:weapon[32];
- new ammo;
- new clip;
- new upgrade;
- new upammo;
- new ammoOffset = FindSendPropInfo("CTerrorPlayer", "m_iAmmo");
- GetEdictClassname(oldweapon, weapon, 32);
- if (slot == 0)
- {
- clip = GetEntProp(oldweapon, Prop_Send, "m_iClip1");
- upgrade = GetEntProp(oldweapon, Prop_Send, "m_upgradeBitVec");
- upammo = GetEntProp(oldweapon, 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") || StrEqual(weapon, "weapon_rifle_m60"))
- {
- 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);
- }
- else return;
- }
- new index = CreateEntityByName(weapon);
- //index=oldweapon;
- new bool:dual=false;
- if (slot == 1)
- {
- if (StrEqual(weapon, "weapon_melee"))
- {
- new String:item[150];
- GetEntPropString(oldweapon , Prop_Data, "m_ModelName", item, sizeof(item));
- //PrintToChat(client, "%s", item);
- if (StrEqual(item, MODEL_V_FIREAXE))
- {
- //DispatchKeyValue(index, "model", MODEL_V_FIREAXE);
- DispatchKeyValue(index, "melee_script_name", "fireaxe");
- }
- else if (StrEqual(item, MODEL_V_FRYING_PAN))
- {
- //DispatchKeyValue(index, "model", MODEL_V_FRYING_PAN);
- DispatchKeyValue(index, "melee_script_name", "frying_pan");
- }
- else if (StrEqual(item, MODEL_V_MACHETE))
- {
- //DispatchKeyValue(index, "model", MODEL_V_MACHETE);
- DispatchKeyValue(index, "melee_script_name", "machete");
- }
- else if (StrEqual(item, MODEL_V_BASEBALL_BAT))
- {
- //DispatchKeyValue(index, "model", MODEL_V_BASEBALL_BAT);
- DispatchKeyValue(index, "melee_script_name", "baseball_bat");
- }
- else if (StrEqual(item, MODEL_V_CROWBAR))
- {
- //DispatchKeyValue(index, "model", MODEL_V_CROWBAR);
- DispatchKeyValue(index, "melee_script_name", "crowbar");
- }
- else if (StrEqual(item, MODEL_V_CRICKET_BAT))
- {
- //DispatchKeyValue(index, "model", MODEL_V_CRICKET_BAT);
- DispatchKeyValue(index, "melee_script_name", "cricket_bat");
- }
- else if (StrEqual(item, MODEL_V_TONFA))
- {
- //DispatchKeyValue(index, "model", MODEL_V_TONFA);
- DispatchKeyValue(index, "melee_script_name", "tonfa");
- }
- else if (StrEqual(item, MODEL_V_KATANA))
- {
- //DispatchKeyValue(index, "model", MODEL_V_KATANA);
- DispatchKeyValue(index, "melee_script_name", "katana");
- }
- else if (StrEqual(item, MODEL_V_ELECTRIC_GUITAR))
- {
- //DispatchKeyValue(index, "model", MODEL_V_ELECTRIC_GUITAR);
- DispatchKeyValue(index, "melee_script_name", "electric_guitar");
- }
- else if (StrEqual(item, MODEL_V_GOLFCLUB))
- {
- //DispatchKeyValue(index, "model", MODEL_V_GOLFCLUB);
- DispatchKeyValue(index, "melee_script_name", "golfclub");
- }
- else if (StrEqual(item, MODEL_V_SHIELD))
- {
- //DispatchKeyValue(index, "model", MODEL_V_GOLFCLUB);
- DispatchKeyValue(index, "melee_script_name", "riotshield");
- }
- else if (StrEqual(item, MODEL_V_KNIFE))
- {
- //DispatchKeyValue(index, "model", MODEL_V_GOLFCLUB);
- DispatchKeyValue(index, "melee_script_name", "knife");
- }
- else return;
- }
- else if (StrEqual(weapon, "weapon_chainsaw"))
- {
- clip = GetEntProp(oldweapon, Prop_Send, "m_iClip1");
- }
- else if (StrEqual(weapon, "weapon_pistol_magnum"))
- {
- clip = GetEntProp(oldweapon, Prop_Send, "m_iClip1");
- }
- else return;
- }
- RemovePlayerItem(client, oldweapon);
- new Float:origin[3];
- new Float:ang[3];
- GetClientEyePosition(client,origin);
- GetClientEyeAngles(client, ang);
- GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
- NormalizeVector(ang,ang);
- if(drop)ScaleVector(ang, 300.0);
- else ScaleVector(ang, 300.0);
- ang[0] += GetRandomInt(-15, 15);
- ang[1] += GetRandomInt(-15, 15);
- IsReduce[client] = false;
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- DispatchSpawn(index);
- TeleportEntity(index, origin, NULL_VECTOR, ang);
- ActivateEntity(index);
- 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);
- }
- if (slot == 1)
- {
- if (StrEqual(weapon, "weapon_chainsaw") || StrEqual(weapon, "weapon_pistol") || StrEqual(weapon, "weapon_pistol_magnum"))
- {
- SetEntProp(index, Prop_Send, "m_iClip1", clip);
- }
- if(dual)
- {
- SetCommandFlags("give", GetCommandFlags("give") & ~FCVAR_CHEAT);
- FakeClientCommand(client, "give pistol");
- SetCommandFlags("give", GetCommandFlags("give") | FCVAR_CHEAT);
- }
- }
- }
- }
- //The following code is from l4d2_drop, http://forums.alliedmods.net/showthread.php?p=1136497
- public Action:DropItem(client)
- {
- if (client == 0 || GetClientTeam(client) != 2 || !IsPlayerAlive(client))
- return Plugin_Handled;
- new String:weapon[32];
- GetClientWeapon(client, weapon, 32);
- if (StrEqual(weapon, "weapon_pumpshotgun") || StrEqual(weapon, "weapon_autoshotgun") || StrEqual(weapon, "weapon_rifle") || StrEqual(weapon, "weapon_smg") || StrEqual(weapon, "weapon_hunting_rifle") || StrEqual(weapon, "weapon_sniper_scout") || StrEqual(weapon, "weapon_sniper_military") || StrEqual(weapon, "weapon_sniper_awp") || StrEqual(weapon, "weapon_smg_silenced") || StrEqual(weapon, "weapon_smg_mp5") || StrEqual(weapon, "weapon_shotgun_spas") || StrEqual(weapon, "weapon_shotgun_chrome") || StrEqual(weapon, "weapon_rifle_sg552") || StrEqual(weapon, "weapon_rifle_desert") || StrEqual(weapon, "weapon_rifle_ak47"))
- DropSlot(client, 0);
- else if (StrEqual(weapon, "weapon_grenade_launcher") || StrEqual(weapon, "weapon_rifle_m60"))
- DropSlot(client, 0);
- else if (StrEqual(weapon, "weapon_pipe_bomb") || StrEqual(weapon, "weapon_molotov") || StrEqual(weapon, "weapon_vomitjar"))
- DropSlot(client, 2);
- else if (StrEqual(weapon, "weapon_first_aid_kit") || StrEqual(weapon, "weapon_defibrillator") || StrEqual(weapon, "weapon_upgradepack_explosive") || StrEqual(weapon, "weapon_upgradepack_incendiary"))
- DropSlot(client, 3);
- else if (StrEqual(weapon, "weapon_pain_pills") || StrEqual(weapon, "weapon_adrenaline"))
- DropSlot(client, 4);
- return Plugin_Handled;
- }
- public DropSlot(client, slot)
- {
- 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") || StrEqual(weapon, "weapon_rifle_m60"))
- {
- 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];
- new Float:ang[3];
- GetClientEyePosition(client,origin);
- GetClientEyeAngles(client, ang);
- GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
- NormalizeVector(ang,ang);
- if (l4d2)ScaleVector(ang, 300.0);
- IsReduce[client] = false;
- IsReduceBase[client] = false
- IsWaterReduce[client] = false
- IsReduceWaterBase[client] = false
- DispatchSpawn(index);
- TeleportEntity(index, origin, NULL_VECTOR, ang);
- 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 IsValidTank(client)
- {
- if (IsValidClient(client) && GetClientTeam(client) == TEAM_INFECTED)
- {
- new class = GetEntProp(client, Prop_Send, "m_zombieClass");
- if (class == ZC_TANK)
- return true;
- return false;
- }
- return false;
- }
- public IsValidBoomer(client)
- {
- if (IsValidClient(client) && GetClientTeam(client) == TEAM_INFECTED)
- {
- new class = GetEntProp(client, Prop_Send, "m_zombieClass");
- if (class == ZC_BOOMER)
- return true;
- return false;
- }
- return false;
- }
- public IsValidClient(client)
- {
- if (client <= 0)
- return false;
- if (client > MaxClients)
- return false;
- if (!IsClientInGame(client))
- return false;
- return true;
- }
- public IsPlayerGhost(client)
- {
- if (GetEntProp(client, Prop_Send, "m_isGhost")) return true;
- else return false;
- }
- public IsSurvivorPinned(client)
- {
- new attacker = GetEntPropEnt(client, Prop_Send, "m_pummelAttacker");
- if (attacker > 0 && attacker != client)
- return true;
- attacker = GetEntPropEnt(client, Prop_Send, "m_carryAttacker");
- if (attacker > 0 && attacker != client)
- return true;
- attacker = GetEntPropEnt(client, Prop_Send, "m_pounceAttacker");
- if (attacker > 0 && attacker != client)
- return true;
- attacker = GetEntPropEnt(client, Prop_Send, "m_tongueOwner");
- if (attacker > 0 && attacker != client)
- return true;
- attacker = GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker");
- if (attacker > 0 && attacker != client)
- return true;
- return false;
- }
Advertisement
Add Comment
Please, Sign In to add comment