FlacoBey

Untitled

Jan 8th, 2019
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 32.18 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3. #include <sdkhooks>
  4.  
  5. #define TEAM_INFECTED           3
  6. #define ZC_BOOMER               2
  7. #define ZC_TANK                 8
  8.  
  9. new bool:CanPlayerDrop[MAXPLAYERS+1];
  10.  
  11. new Handle:l4d_drop_probability_hunter;
  12. new Handle:l4d_drop_probability_boomer;
  13. new Handle:l4d_drop_probability_smoker;
  14. new Handle:l4d_drop_probability_jockey
  15. new Handle:l4d_drop_probability_charger;
  16. new Handle:l4d_drop_probability_tank
  17. new Handle:l4d_drop_probability_grab;
  18. new Handle:l4d_drop_probability_incap;
  19. new Handle:l4d_drop_enable= INVALID_HANDLE;
  20. //new Handle:h_ClientTimer[MAXPLAYERS+1] = INVALID_HANDLE;
  21. new bool:l4d2=false;
  22. new GameMode;
  23.  
  24. new bool:IsConnected[MAXPLAYERS]
  25. new bool:IsReduce[MAXPLAYERS]
  26. new bool:IsWaterReduce[MAXPLAYERS]
  27. new bool:IsReduceBase[MAXPLAYERS]
  28. new bool:IsReduceWaterBase[MAXPLAYERS]
  29.  
  30. #define IsClientValidConnected(%1) (1<=%1<=MaxClients && IsConnected[%1])
  31. #define IsClientValidAlive(%1) (1<=%1<=MaxClients && IsReduce[%1])
  32. #define IsValiddAliveAndInWater(%1) (1<=%1<=MaxClients && IsWaterReduce[%1])
  33. #define IsAlive(%1) (1<=%1<=MaxClients && IsReduceBase[%1])
  34. #define IsAliveAndInWater(%1) (1<=%1<=MaxClients && IsReduceWaterBase[%1])
  35.  
  36.  
  37. public Plugin:myinfo =
  38. {
  39.     name = "L4D2 Realism Drop",
  40.     author = "Pan Xiaohai & Frustian & kwski43 & NoBody",
  41.     description = "<- Description ->",
  42.     version = "1.1",
  43.     url = "<- URL ->"
  44. }
  45.  
  46. public OnPluginStart()
  47. {
  48.     GameCheck();
  49.     l4d_drop_enable = CreateConVar("l4d_drop_enable", "1", " 0:disable item drop, 1:eanble ", FCVAR_NONE);
  50.     l4d_drop_probability_hunter = CreateConVar("l4d_drop_hunter", "30.0", "drop probability by hunter pounce", FCVAR_NONE);
  51.     l4d_drop_probability_boomer = CreateConVar("l4d_drop_boomer", "10.0", "boomer explode", FCVAR_NONE);
  52.     l4d_drop_probability_smoker = CreateConVar("l4d_drop_smoker", "30.0", "smoker drag", FCVAR_NONE);
  53.     l4d_drop_probability_jockey = CreateConVar("l4d_drop_jockey", "30.0", "jockey ride", FCVAR_NONE);
  54.     l4d_drop_probability_charger = CreateConVar("l4d_drop_charger", "30.0", "charger carray", FCVAR_NONE);
  55.     l4d_drop_probability_tank = CreateConVar("l4d_drop_tank", "30.0", "tank punch", FCVAR_NONE);
  56.     l4d_drop_probability_grab = CreateConVar("l4d_drop_ledge_grab", "30.0", "ledge grab", FCVAR_NONE);
  57.     l4d_drop_probability_incap = CreateConVar("l4d_drop_incap", "20.0", "incapacitated", FCVAR_NONE);
  58.    
  59.     if(GameMode!=2)
  60.     {
  61.         if(l4d2)
  62.         {
  63.             HookEvent("jockey_ride", Event_JockeyRide, EventHookMode_Post);
  64.             HookEvent("charger_carry_start", Event_CarrySstart, EventHookMode_Post);
  65.         }
  66.         HookEvent("tongue_grab",  Event_TongueGrab, EventHookMode_Post);
  67.         HookEvent("player_ledge_grab", Event_PlayerLedgeGrab, EventHookMode_Post);
  68.         HookEvent("lunge_pounce", Event_LungePounce, EventHookMode_Post);
  69.         HookEvent("player_now_it", PlayerDeath);
  70.         HookEvent("player_incapacitated_start", Event_IncapacitatedStart, EventHookMode_Post);
  71.         HookEvent("player_use", Event_PlayerUse);
  72.         HookEvent("weapon_drop", Event_WeaponDrop);
  73.         HookEvent("bot_player_replace", bot_player_replace);
  74.         HookEvent("player_incapacitated", Event_PlayerIncap, EventHookMode_Post);
  75.         //HookEvent("player_hurt", Event_PlayerHurt, EventHookMode_Pre);
  76.          
  77.         AutoExecConfig(true, "l4d12_drop");
  78.     }
  79. }
  80.  
  81. public OnClientPutInServer(client)
  82. {
  83.     CanPlayerDrop[client] = true;
  84.     IsConnected[client] = true;
  85. }
  86.  
  87. public OnClientDisconnect(client)
  88. {
  89.     IsReduce[client] = false
  90.     IsReduceBase[client] = false
  91.     IsWaterReduce[client] = false
  92.     IsReduceWaterBase[client] = false
  93. }
  94.  
  95. public Action:OnPlayerRunCmd(client, &buttons, &impuls, Float:vel[3], Float:angles[3], &weapon)
  96. {
  97.     if(CanPlayerDrop[client] == false && (buttons & IN_SPEED) && (buttons & IN_RELOAD))
  98.     {
  99.         return Plugin_Continue;
  100.     }
  101.  
  102.     if(GetClientTeam(client) == 2 && !IsFakeClient(client) && IsPlayerAlive(client) && (buttons & IN_SPEED) && (buttons & IN_RELOAD))
  103.     {
  104.         CanPlayerDrop[client] = false;
  105.         CreateTimer(0.5, ResetDelay, client);
  106.         Command_Drop(client, 0)
  107.     }
  108.    
  109.     if (!IsClientInGame(client) || GetClientTeam(client) != 2 || !IsPlayerAlive(client))
  110.     {
  111.         return Plugin_Continue;
  112.     }
  113.    
  114.     new priWeapon = GetPlayerWeaponSlot(client, 0);
  115.     if (!IsValidEntity(priWeapon)) return Plugin_Continue;
  116.    
  117.     decl String:sWeaponEx[32];
  118.     GetEntityClassname(priWeapon, sWeaponEx, sizeof(sWeaponEx));
  119.    
  120.     if(StrEqual(sWeaponEx, "weapon_rifle_m60"))
  121.     {
  122.         if(GetEntProp(client, Prop_Send, "m_bAdrenalineActive", 1) > 0)
  123.         {
  124.             if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 1) > 0)
  125.             {
  126.                 IsReduce[client] = false
  127.                 IsReduceBase[client] = false
  128.                 IsWaterReduce[client] = false
  129.                 IsReduceWaterBase[client] = true
  130.             }
  131.             if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 0) < 1)
  132.             {
  133.                 IsReduce[client] = false
  134.                 IsReduceBase[client] = true
  135.                 IsWaterReduce[client] = false
  136.                 IsReduceWaterBase[client] = false
  137.             }
  138.         }
  139.         if(GetEntProp(client, Prop_Send, "m_isIncapacitated", 1) > 0)
  140.         {
  141.             IsReduce[client] = false
  142.             IsReduceBase[client] = false
  143.             IsWaterReduce[client] = false
  144.             IsReduceWaterBase[client] = false
  145.         }
  146.         if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 1) > 0)
  147.         {
  148.             IsReduce[client] = false
  149.             IsReduceBase[client] = false
  150.             IsWaterReduce[client] = true
  151.             IsReduceWaterBase[client] = false
  152.         }
  153.         if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 0) < 1)
  154.         {
  155.             IsReduce[client] = true
  156.             IsReduceBase[client] = false
  157.             IsWaterReduce[client] = false
  158.             IsReduceWaterBase[client] = false
  159.            
  160.             if(GetEntProp(client, Prop_Send, "m_bAdrenalineActive", 1) > 0)
  161.             {
  162.                 IsReduce[client] = false
  163.                 IsReduceBase[client] = true
  164.                 IsWaterReduce[client] = false
  165.                 IsReduceWaterBase[client] = false
  166.             }
  167.         }
  168.     }
  169.    
  170.     return Plugin_Continue;
  171. }
  172.  
  173. public Action:ResetDelay(Handle:timer, any:client)
  174. {
  175.     IsReduce[client] = false;
  176.     IsReduceBase[client] = false
  177.     IsWaterReduce[client] = false
  178.     IsReduceWaterBase[client] = false
  179.     CanPlayerDrop[client] = true;
  180. }
  181.  
  182. GameCheck()
  183. {
  184.     decl String:GameName[16];
  185.     GetConVarString(FindConVar("mp_gamemode"), GameName, sizeof(GameName));
  186.    
  187.     if (StrEqual(GameName, "survival", false))
  188.         GameMode = 3;
  189.     else if (StrEqual(GameName, "versus", false) || StrEqual(GameName, "teamversus", false) || StrEqual(GameName, "scavenge", false) || StrEqual(GameName, "teamscavenge", false))
  190.         GameMode = 2;
  191.     else if (StrEqual(GameName, "coop", false) || StrEqual(GameName, "realism", false))
  192.         GameMode = 1;
  193.     else
  194.     {
  195.         GameMode = 0;
  196.     }
  197.  
  198.     GetGameFolderName(GameName, sizeof(GameName));
  199.     if (StrEqual(GameName, "left4dead2", false))
  200.     {
  201.         l4d2=true;
  202.     }
  203.     else
  204.     {
  205.         l4d2=false;
  206.     }
  207. }
  208.  
  209. public Action:Event_WeaponDrop(Handle:event, const String:name[], bool:dontBroadcast)
  210. {
  211.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  212.    
  213.     if (client == 0 || !IsClientConnected(client) || !IsClientInGame(client) || GetClientTeam(client) != 2) return;
  214.    
  215.     new droppedEnt = GetEventInt(event, "propid");
  216.    
  217.     decl String:ent_name[64];
  218.    
  219.     if (IsValidEdict(droppedEnt))
  220.     {
  221.         GetEdictClassname(droppedEnt, ent_name, sizeof(ent_name));
  222.        
  223.         if (StrEqual(ent_name, "weapon_rifle_m60", false))
  224.         {
  225.             IsReduce[client] = false
  226.             IsReduceBase[client] = false
  227.             IsWaterReduce[client] = false
  228.             IsReduceWaterBase[client] = false
  229.         }
  230.     }
  231. }
  232.  
  233. public Action:Event_PlayerUse(Handle:event, const String:name[], bool:dontBroadcast)
  234. {
  235.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  236.  
  237.     if (!IsClientInGame(client) || GetClientTeam(client) != 2 || !IsPlayerAlive(client)) return;
  238.  
  239.     new entIndex = GetEventInt(event, "targetid");
  240.     if (!IsValidEntity(entIndex)) return;
  241.  
  242.     decl String:sItemName[64];
  243.     GetEdictClassname(entIndex, sItemName, sizeof(sItemName));
  244.    
  245.     if(StrEqual(sItemName, "weapon_rifle_m60"))
  246.     {
  247.         if(GetEntProp(client, Prop_Send, "m_bAdrenalineActive", 1) > 0)
  248.         {
  249.             if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 1) > 0)
  250.             {
  251.                 IsReduce[client] = false
  252.                 IsReduceBase[client] = false
  253.                 IsWaterReduce[client] = false
  254.                 IsReduceWaterBase[client] = true
  255.             }
  256.             if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 0) < 1)
  257.             {
  258.                 IsReduce[client] = false
  259.                 IsReduceBase[client] = true
  260.                 IsWaterReduce[client] = false
  261.                 IsReduceWaterBase[client] = false
  262.             }
  263.         }
  264.     }
  265. }
  266.  
  267. public Action:bot_player_replace(Handle:event, const String:name[], bool:dontBroadcast)
  268. {
  269.     //new bot = GetClientOfUserId(GetEventInt(event, "bot"));
  270.     new client = GetClientOfUserId(GetEventInt(event, "player"));
  271.    
  272.     decl String:weapon[64];
  273.    
  274.     GetClientWeapon(client, weapon, sizeof(weapon));
  275.  
  276.     if(GetEntProp(client, Prop_Send, "m_bAdrenalineActive", 1) > 0)
  277.     {
  278.         if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 1) > 0)
  279.         {
  280.             IsReduce[client] = false
  281.             IsReduceBase[client] = false
  282.             IsWaterReduce[client] = false
  283.             IsReduceWaterBase[client] = true
  284.         }
  285.         if (GetEntProp(client, Prop_Data, "m_nWaterLevel", 0) < 1)
  286.         {
  287.             IsReduce[client] = false
  288.             IsReduceBase[client] = true
  289.             IsWaterReduce[client] = false
  290.             IsReduceWaterBase[client] = false
  291.         }
  292.     }
  293.     else
  294.     {
  295.         IsReduce[client] = false;
  296.         IsReduceBase[client] = false;
  297.         IsWaterReduce[client] = false
  298.         IsReduceWaterBase[client] = false
  299.     }
  300. }
  301.  
  302. public Action:Event_JockeyRide(Handle:event, const String:name[], bool:dontBroadcast)
  303. {
  304.     if(GetConVarInt(l4d_drop_enable)==0)return;
  305.     new client = GetClientOfUserId(GetEventInt(event, "victim"));
  306.     if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_jockey))
  307.     {
  308.         DropItem(client);
  309.     }
  310. }
  311.  
  312. public Action:Event_CarrySstart(Handle:event, const String:name[], bool:dontBroadcast)
  313. {
  314.     if(GetConVarInt(l4d_drop_enable)==0)return;
  315.     new client = GetClientOfUserId(GetEventInt(event, "victim"));
  316.     if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_charger))
  317.     {
  318.         DropItem(client);
  319.     }
  320. }
  321.  
  322. public Action:Event_TongueGrab(Handle:event, const String:name[], bool:dontBroadcast)
  323. {
  324.     if(GetConVarInt(l4d_drop_enable)==0)return;
  325.     new client = GetClientOfUserId(GetEventInt(event, "victim"));
  326.     if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_smoker))
  327.     {
  328.         DropItem(client);
  329.     }
  330. }
  331.  
  332. public Action:Event_LungePounce(Handle:event, const String:name[], bool:dontBroadcast)
  333. {
  334.     if(GetConVarInt(l4d_drop_enable)==0)return;
  335.     new client = GetClientOfUserId(GetEventInt(event, "victim"));
  336.     if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_hunter))
  337.     {
  338.         DropItem(client);
  339.     }
  340. }
  341.  
  342. public Action:Event_PlayerLedgeGrab(Handle:event, const String:name[], bool:dontBroadcast)
  343. {
  344.     if(GetConVarInt(l4d_drop_enable)==0)return;
  345.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  346.     if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_grab))
  347.     {
  348.         DropItem(client)
  349.     }
  350. }
  351.  
  352. public Action:PlayerDeath(Handle:event, const String:name[], bool:dontBroadcast)
  353. {
  354.     if(GetConVarInt(l4d_drop_enable)==0)return;
  355.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  356.     new attacker = GetClientOfUserId(GetEventInt(event, "attacker"));
  357.     new exploded = GetEventBool(event, "exploded");
  358.      
  359.     if(exploded)
  360.     {
  361.         if (IsValidClient(attacker) && IsValidBoomer(attacker))
  362.         {
  363.             if (IsValidClient(client) && GetClientTeam(client) == 2 && !IsSurvivorPinned(client))
  364.             {
  365.                 if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_boomer))
  366.                 {
  367.                     DropItem(client)
  368.                 }
  369.             }
  370.         }
  371.     }
  372. }
  373.  
  374. public Action:Event_IncapacitatedStart(Handle:event, const String:name[], bool:dontBroadcast)
  375. {
  376.     if(GetConVarInt(l4d_drop_enable)==0)return;
  377.     new client = GetClientOfUserId(GetEventInt(event, "userid"));
  378.     if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_incap))
  379.     {
  380.         DropItem(client)
  381.     }
  382. }
  383.  
  384. public Action:Event_PlayerIncap(Handle:event, String:event_name[], bool:dontBroadcast)
  385. {
  386.     new client = GetClientOfUserId(GetEventInt(event,"userid"));
  387.     new attacker = GetClientOfUserId(GetEventInt(event,"attacker"));
  388.    
  389.     decl String:weapon[16];
  390.     GetEventString(event, "weapon", weapon, 16);
  391.     if(!StrEqual(weapon, "tank_claw")) return;
  392.    
  393.     if(IsValidTank(attacker) && !IsPlayerGhost(attacker))
  394.     {
  395.         if (IsValidClient(client) && GetClientTeam(client) == 2 && !IsSurvivorPinned(client))
  396.         {
  397.             if(GetRandomFloat(0.0, 100.0)<GetConVarFloat(l4d_drop_probability_tank))
  398.             {
  399.                 DropItem(client)
  400.             }
  401.         }
  402.     }
  403. }
  404.  
  405. public Action:Command_Drop(client, args)
  406. {
  407.     if (client == 0 || GetClientTeam(client) != 2 || !IsPlayerAlive(client))return Plugin_Handled;
  408.    
  409.     Drop(client, true, 0,true);
  410.     return Plugin_Handled;
  411. }
  412.  
  413. GetCurrentWeaponSlot(client)
  414. {
  415.     new slot=-1;
  416.    
  417.     decl String:weapon[32];
  418.     GetClientWeapon(client,weapon , 32);
  419.     //PrintToChatAll("%s",weapon);
  420.    
  421.     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"))
  422.         slot=0;
  423.     else if (StrEqual(weapon, "weapon_pistol") || StrEqual(weapon, "weapon_pistol_magnum") || StrEqual(weapon, "weapon_chainsaw") || StrEqual(weapon, "weapon_melee"))
  424.         slot=1;
  425.     else if (StrEqual(weapon, "weapon_pipe_bomb") || StrEqual(weapon, "weapon_molotov") || StrEqual(weapon, "weapon_vomitjar"))
  426.         slot=2;
  427.     else if (StrEqual(weapon, "weapon_first_aid_kit") || StrEqual(weapon, "weapon_defibrillator") || StrEqual(weapon, "weapon_upgradepack_explosive") || StrEqual(weapon, "weapon_upgradepack_incendiary"))
  428.         slot=3;
  429.     else if (StrEqual(weapon, "weapon_pain_pills") || StrEqual(weapon, "weapon_adrenaline"))
  430.         slot=4;
  431.  
  432.     if(slot <0 )
  433.     {
  434.      
  435.         for(new i=0; i<5; i++)
  436.         {
  437.             new s=GetPlayerWeaponSlot(client, i);
  438.             if(s>0)
  439.             {
  440.                 slot=i;
  441.                 break;
  442.             }
  443.         }
  444.     }
  445.     return slot;
  446. }
  447.  
  448. Drop(client, bool:dropcurrent, count, bool:drop)
  449. {
  450.     if(dropcurrent)
  451.     {
  452.         new s=GetCurrentWeaponSlot(client);
  453.         if(s>=0)
  454.         {
  455.             DropSlot2(client, s, drop);
  456.         }
  457.     }
  458.     if(count==0 && !dropcurrent)count=1;
  459.     if(count>0)
  460.     {
  461.         new slot[5];
  462.         new m=0;
  463.         for(new i=0; i<5; i++)
  464.         {
  465.             if (GetPlayerWeaponSlot(client, i) > 0)
  466.             {
  467.                 slot[m++]=i;
  468.             }
  469.         }
  470.         if(m<=count)count=m;
  471.         for(new i=0; i<count && m>0; i++)
  472.         {
  473.             new r=GetRandomInt(0, m-1);
  474.             DropSlot2(client, slot[r], drop);
  475.             slot[r]=slot[m-1];
  476.             m--;
  477.         }
  478.     }
  479. }
  480.  
  481. DropSlot2(client, slot, bool:drop=false)
  482. {
  483.     if(l4d2)DropSlot_l4d2(client, slot, drop);
  484.     //else DropSlot_l4d1(client, slot, drop,receiver);
  485. }
  486.  
  487. #define MODEL_V_FIREAXE "models/weapons/melee/v_fireaxe.mdl"
  488. #define MODEL_V_FRYING_PAN "models/weapons/melee/v_frying_pan.mdl"
  489. #define MODEL_V_MACHETE "models/weapons/melee/v_machete.mdl"
  490. #define MODEL_V_BASEBALL_BAT "models/weapons/melee/v_bat.mdl"
  491. #define MODEL_V_CROWBAR "models/weapons/melee/v_crowbar.mdl"
  492. #define MODEL_V_CRICKET_BAT "models/weapons/melee/v_cricket_bat.mdl"
  493. #define MODEL_V_TONFA "models/weapons/melee/v_tonfa.mdl"
  494. #define MODEL_V_KATANA "models/weapons/melee/v_katana.mdl"
  495. #define MODEL_V_ELECTRIC_GUITAR "models/weapons/melee/v_electric_guitar.mdl"
  496. #define MODEL_V_GOLFCLUB "models/weapons/melee/v_golfclub.mdl"
  497. #define MODEL_V_SHIELD "models/weapons/melee/v_riotshield.mdl"
  498. #define MODEL_V_KNIFE "models/v_models/v_knife_t.mdl"
  499.  
  500. // code from kwski43 [L4D2] Caught Item Drop http://forums.alliedmods.net/showthread.php?t=133610
  501. DropSlot_l4d2(client, slot, bool:drop=false)
  502. {
  503.     new oldweapon=GetPlayerWeaponSlot(client, slot);
  504.     if (oldweapon > 0)
  505.     {
  506.         new String:weapon[32];
  507.         new ammo;
  508.         new clip;
  509.         new upgrade;
  510.         new upammo;
  511.         new ammoOffset = FindSendPropInfo("CTerrorPlayer", "m_iAmmo");
  512.         GetEdictClassname(oldweapon, weapon, 32);
  513.  
  514.         if (slot == 0)
  515.         {
  516.             clip = GetEntProp(oldweapon, Prop_Send, "m_iClip1");
  517.             upgrade = GetEntProp(oldweapon, Prop_Send, "m_upgradeBitVec");
  518.             upammo = GetEntProp(oldweapon, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded");
  519.             if (StrEqual(weapon, "weapon_rifle") || StrEqual(weapon, "weapon_rifle_sg552") || StrEqual(weapon, "weapon_rifle_desert") || StrEqual(weapon, "weapon_rifle_ak47"))
  520.             {
  521.                 ammo = GetEntData(client, ammoOffset+(12));
  522.                 SetEntData(client, ammoOffset+(12), 0);
  523.             }
  524.             else if (StrEqual(weapon, "weapon_smg") || StrEqual(weapon, "weapon_smg_silenced") || StrEqual(weapon, "weapon_smg_mp5"))
  525.             {
  526.                 ammo = GetEntData(client, ammoOffset+(20));
  527.                 SetEntData(client, ammoOffset+(20), 0);
  528.             }
  529.             else if (StrEqual(weapon, "weapon_pumpshotgun") || StrEqual(weapon, "weapon_shotgun_chrome"))
  530.             {
  531.                 ammo = GetEntData(client, ammoOffset+(28));
  532.                 SetEntData(client, ammoOffset+(28), 0);
  533.             }
  534.             else if (StrEqual(weapon, "weapon_autoshotgun") || StrEqual(weapon, "weapon_shotgun_spas"))
  535.             {
  536.                 ammo = GetEntData(client, ammoOffset+(32));
  537.                 SetEntData(client, ammoOffset+(32), 0);
  538.             }
  539.             else if (StrEqual(weapon, "weapon_hunting_rifle"))
  540.             {
  541.                 ammo = GetEntData(client, ammoOffset+(36));
  542.                 SetEntData(client, ammoOffset+(36), 0);
  543.             }
  544.             else if (StrEqual(weapon, "weapon_sniper_scout") || StrEqual(weapon, "weapon_sniper_military") || StrEqual(weapon, "weapon_sniper_awp") || StrEqual(weapon, "weapon_rifle_m60"))
  545.             {
  546.                 ammo = GetEntData(client, ammoOffset+(40));
  547.                 SetEntData(client, ammoOffset+(40), 0);
  548.             }
  549.             else if (StrEqual(weapon, "weapon_grenade_launcher"))
  550.             {
  551.                 ammo = GetEntData(client, ammoOffset+(68));
  552.                 SetEntData(client, ammoOffset+(68), 0);
  553.             }
  554.             else return;
  555.         }
  556.         new index = CreateEntityByName(weapon);
  557.         //index=oldweapon;
  558.         new bool:dual=false;
  559.         if (slot == 1)
  560.         {
  561.             if (StrEqual(weapon, "weapon_melee"))
  562.             {
  563.                 new String:item[150];
  564.                 GetEntPropString(oldweapon , Prop_Data, "m_ModelName", item, sizeof(item));
  565.                 //PrintToChat(client, "%s", item);
  566.                 if (StrEqual(item, MODEL_V_FIREAXE))
  567.                 {
  568.                     //DispatchKeyValue(index, "model", MODEL_V_FIREAXE);
  569.                     DispatchKeyValue(index, "melee_script_name", "fireaxe");
  570.                 }
  571.                 else if (StrEqual(item, MODEL_V_FRYING_PAN))
  572.                 {
  573.                     //DispatchKeyValue(index, "model", MODEL_V_FRYING_PAN);
  574.                     DispatchKeyValue(index, "melee_script_name", "frying_pan");
  575.                 }
  576.                 else if (StrEqual(item, MODEL_V_MACHETE))
  577.                 {
  578.                     //DispatchKeyValue(index, "model", MODEL_V_MACHETE);
  579.                     DispatchKeyValue(index, "melee_script_name", "machete");
  580.                 }
  581.                 else if (StrEqual(item, MODEL_V_BASEBALL_BAT))
  582.                 {
  583.                     //DispatchKeyValue(index, "model", MODEL_V_BASEBALL_BAT);
  584.                     DispatchKeyValue(index, "melee_script_name", "baseball_bat");
  585.                 }
  586.                 else if (StrEqual(item, MODEL_V_CROWBAR))
  587.                 {
  588.                     //DispatchKeyValue(index, "model", MODEL_V_CROWBAR);
  589.                     DispatchKeyValue(index, "melee_script_name", "crowbar");
  590.                 }
  591.                 else if (StrEqual(item, MODEL_V_CRICKET_BAT))
  592.                 {
  593.                     //DispatchKeyValue(index, "model", MODEL_V_CRICKET_BAT);
  594.                     DispatchKeyValue(index, "melee_script_name", "cricket_bat");
  595.                 }
  596.                 else if (StrEqual(item, MODEL_V_TONFA))
  597.                 {
  598.                     //DispatchKeyValue(index, "model", MODEL_V_TONFA);
  599.                     DispatchKeyValue(index, "melee_script_name", "tonfa");
  600.                 }
  601.                 else if (StrEqual(item, MODEL_V_KATANA))
  602.                 {
  603.                     //DispatchKeyValue(index, "model", MODEL_V_KATANA);
  604.                     DispatchKeyValue(index, "melee_script_name", "katana");
  605.                 }
  606.                 else if (StrEqual(item, MODEL_V_ELECTRIC_GUITAR))
  607.                 {
  608.                     //DispatchKeyValue(index, "model", MODEL_V_ELECTRIC_GUITAR);
  609.                     DispatchKeyValue(index, "melee_script_name", "electric_guitar");
  610.                 }
  611.                 else if (StrEqual(item, MODEL_V_GOLFCLUB))
  612.                 {
  613.                     //DispatchKeyValue(index, "model", MODEL_V_GOLFCLUB);
  614.                     DispatchKeyValue(index, "melee_script_name", "golfclub");
  615.                 }
  616.                 else if (StrEqual(item, MODEL_V_SHIELD))
  617.                 {
  618.                     //DispatchKeyValue(index, "model", MODEL_V_GOLFCLUB);
  619.                     DispatchKeyValue(index, "melee_script_name", "riotshield");
  620.                 }
  621.                 else if (StrEqual(item, MODEL_V_KNIFE))
  622.                 {
  623.                     //DispatchKeyValue(index, "model", MODEL_V_GOLFCLUB);
  624.                     DispatchKeyValue(index, "melee_script_name", "knife");
  625.                 }
  626.                 else return;
  627.             }
  628.             else if (StrEqual(weapon, "weapon_chainsaw"))
  629.             {
  630.                 clip = GetEntProp(oldweapon, Prop_Send, "m_iClip1");
  631.             }
  632.             else if (StrEqual(weapon, "weapon_pistol_magnum"))
  633.             {
  634.                 clip = GetEntProp(oldweapon, Prop_Send, "m_iClip1");
  635.             }
  636.             else return;
  637.         }
  638.        
  639.         RemovePlayerItem(client, oldweapon);
  640.        
  641.         new Float:origin[3];
  642.         new Float:ang[3];
  643.         GetClientEyePosition(client,origin);
  644.         GetClientEyeAngles(client, ang);
  645.         GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
  646.         NormalizeVector(ang,ang);
  647.         if(drop)ScaleVector(ang, 300.0);
  648.         else ScaleVector(ang, 300.0);
  649.        
  650.         ang[0] += GetRandomInt(-15, 15);
  651.         ang[1] += GetRandomInt(-15, 15);
  652.        
  653.         IsReduce[client] = false;
  654.         IsReduceBase[client] = false
  655.         IsWaterReduce[client] = false
  656.         IsReduceWaterBase[client] = false
  657.        
  658.         DispatchSpawn(index);
  659.         TeleportEntity(index, origin, NULL_VECTOR, ang);
  660.         ActivateEntity(index);
  661.  
  662.         if (slot == 0)
  663.         {
  664.             SetEntProp(index, Prop_Send, "m_iExtraPrimaryAmmo", ammo);
  665.             SetEntProp(index, Prop_Send, "m_iClip1", clip);
  666.             SetEntProp(index, Prop_Send, "m_upgradeBitVec", upgrade);
  667.             SetEntProp(index, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", upammo);
  668.         }
  669.  
  670.         if (slot == 1)
  671.         {
  672.             if (StrEqual(weapon, "weapon_chainsaw") || StrEqual(weapon, "weapon_pistol") || StrEqual(weapon, "weapon_pistol_magnum"))
  673.             {
  674.                 SetEntProp(index, Prop_Send, "m_iClip1", clip);
  675.             }
  676.             if(dual)
  677.             {
  678.                 SetCommandFlags("give", GetCommandFlags("give") & ~FCVAR_CHEAT);
  679.                 FakeClientCommand(client, "give pistol");
  680.                 SetCommandFlags("give", GetCommandFlags("give") | FCVAR_CHEAT);
  681.             }
  682.         }
  683.     }
  684. }
  685.  
  686. //The following code is from l4d2_drop, http://forums.alliedmods.net/showthread.php?p=1136497
  687. public Action:DropItem(client)
  688. {
  689.     if (client == 0 || GetClientTeam(client) != 2 || !IsPlayerAlive(client))
  690.         return Plugin_Handled;
  691.  
  692.     new String:weapon[32];
  693.     GetClientWeapon(client, weapon, 32);
  694.  
  695.     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"))
  696.         DropSlot(client, 0);
  697.     else if (StrEqual(weapon, "weapon_grenade_launcher") || StrEqual(weapon, "weapon_rifle_m60"))
  698.         DropSlot(client, 0);
  699.     else if (StrEqual(weapon, "weapon_pipe_bomb") || StrEqual(weapon, "weapon_molotov") || StrEqual(weapon, "weapon_vomitjar"))
  700.         DropSlot(client, 2);
  701.     else if (StrEqual(weapon, "weapon_first_aid_kit") || StrEqual(weapon, "weapon_defibrillator") || StrEqual(weapon, "weapon_upgradepack_explosive") || StrEqual(weapon, "weapon_upgradepack_incendiary"))
  702.         DropSlot(client, 3);
  703.     else if (StrEqual(weapon, "weapon_pain_pills") || StrEqual(weapon, "weapon_adrenaline"))
  704.         DropSlot(client, 4);
  705.  
  706.     return Plugin_Handled;
  707. }
  708.  
  709. public DropSlot(client, slot)
  710. {
  711.     if (GetPlayerWeaponSlot(client, slot) > 0)
  712.     {
  713.         new String:weapon[32];
  714.         new ammo;
  715.         new clip;
  716.         new upgrade;
  717.         new upammo;
  718.         new ammoOffset = FindSendPropInfo("CTerrorPlayer", "m_iAmmo");
  719.         GetEdictClassname(GetPlayerWeaponSlot(client, slot), weapon, 32);
  720.  
  721.         if (slot == 0)
  722.         {
  723.             clip = GetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_iClip1");
  724.             upgrade = GetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_upgradeBitVec");
  725.             upammo = GetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_nUpgradedPrimaryAmmoLoaded");
  726.             if (StrEqual(weapon, "weapon_rifle") || StrEqual(weapon, "weapon_rifle_sg552") || StrEqual(weapon, "weapon_rifle_desert") || StrEqual(weapon, "weapon_rifle_ak47"))
  727.             {
  728.                 ammo = GetEntData(client, ammoOffset+(12));
  729.                 SetEntData(client, ammoOffset+(12), 0);
  730.             }
  731.             else if (StrEqual(weapon, "weapon_smg") || StrEqual(weapon, "weapon_smg_silenced") || StrEqual(weapon, "weapon_smg_mp5"))
  732.             {
  733.                 ammo = GetEntData(client, ammoOffset+(20));
  734.                 SetEntData(client, ammoOffset+(20), 0);
  735.             }
  736.             else if (StrEqual(weapon, "weapon_pumpshotgun") || StrEqual(weapon, "weapon_shotgun_chrome"))
  737.             {
  738.                 ammo = GetEntData(client, ammoOffset+(28));
  739.                 SetEntData(client, ammoOffset+(28), 0);
  740.             }
  741.             else if (StrEqual(weapon, "weapon_autoshotgun") || StrEqual(weapon, "weapon_shotgun_spas"))
  742.             {
  743.                 ammo = GetEntData(client, ammoOffset+(32));
  744.                 SetEntData(client, ammoOffset+(32), 0);
  745.             }
  746.             else if (StrEqual(weapon, "weapon_hunting_rifle"))
  747.             {
  748.                 ammo = GetEntData(client, ammoOffset+(36));
  749.                 SetEntData(client, ammoOffset+(36), 0);
  750.             }
  751.             else if (StrEqual(weapon, "weapon_sniper_scout") || StrEqual(weapon, "weapon_sniper_military") || StrEqual(weapon, "weapon_sniper_awp") || StrEqual(weapon, "weapon_rifle_m60"))
  752.             {
  753.                 ammo = GetEntData(client, ammoOffset+(40));
  754.                 SetEntData(client, ammoOffset+(40), 0);
  755.             }
  756.             else if (StrEqual(weapon, "weapon_grenade_launcher"))
  757.             {
  758.                 ammo = GetEntData(client, ammoOffset+(68));
  759.                 SetEntData(client, ammoOffset+(68), 0);
  760.             }
  761.         }
  762.         new index = CreateEntityByName(weapon);
  763.         new Float:origin[3];
  764.         new Float:ang[3];
  765.         GetClientEyePosition(client,origin);
  766.         GetClientEyeAngles(client, ang);
  767.         GetAngleVectors(ang, ang, NULL_VECTOR,NULL_VECTOR);
  768.         NormalizeVector(ang,ang);
  769.         if (l4d2)ScaleVector(ang, 300.0);
  770.        
  771.         IsReduce[client] = false;
  772.         IsReduceBase[client] = false
  773.         IsWaterReduce[client] = false
  774.         IsReduceWaterBase[client] = false
  775.        
  776.         DispatchSpawn(index);
  777.         TeleportEntity(index, origin, NULL_VECTOR, ang);
  778.         ActivateEntity(index);
  779.        
  780.         RemovePlayerItem(client, GetPlayerWeaponSlot(client, slot));
  781.  
  782.         if (slot == 0)
  783.         {
  784.             SetEntProp(index, Prop_Send, "m_iExtraPrimaryAmmo", ammo);
  785.             SetEntProp(index, Prop_Send, "m_iClip1", clip);
  786.             SetEntProp(index, Prop_Send, "m_upgradeBitVec", upgrade);
  787.             SetEntProp(index, Prop_Send, "m_nUpgradedPrimaryAmmoLoaded", upammo);
  788.         }
  789.     }
  790. }
  791.  
  792. public IsValidTank(client)
  793. {
  794.     if (IsValidClient(client) && GetClientTeam(client) == TEAM_INFECTED)
  795.     {
  796.         new class = GetEntProp(client, Prop_Send, "m_zombieClass");
  797.        
  798.         if (class == ZC_TANK)
  799.             return true;
  800.        
  801.         return false;
  802.     }
  803.    
  804.     return false;
  805. }
  806.  
  807. public IsValidBoomer(client)
  808. {
  809.     if (IsValidClient(client) && GetClientTeam(client) == TEAM_INFECTED)
  810.     {
  811.         new class = GetEntProp(client, Prop_Send, "m_zombieClass");
  812.        
  813.         if (class == ZC_BOOMER)
  814.             return true;
  815.        
  816.         return false;
  817.     }
  818.    
  819.     return false;
  820. }
  821.  
  822. public IsValidClient(client)
  823. {
  824.     if (client <= 0)
  825.         return false;
  826.        
  827.     if (client > MaxClients)
  828.         return false;
  829.        
  830.     if (!IsClientInGame(client))
  831.         return false;
  832.  
  833.     return true;
  834. }
  835.  
  836. public IsPlayerGhost(client)
  837. {
  838.     if (GetEntProp(client, Prop_Send, "m_isGhost")) return true;
  839.         else return false;
  840. }
  841.  
  842. public IsSurvivorPinned(client)
  843. {
  844.     new attacker = GetEntPropEnt(client, Prop_Send, "m_pummelAttacker");
  845.     if (attacker > 0 && attacker != client)
  846.         return true;
  847.        
  848.     attacker = GetEntPropEnt(client, Prop_Send, "m_carryAttacker");
  849.     if (attacker > 0 && attacker != client)
  850.         return true;
  851.        
  852.     attacker = GetEntPropEnt(client, Prop_Send, "m_pounceAttacker");
  853.     if (attacker > 0 && attacker != client)
  854.         return true;
  855.        
  856.     attacker = GetEntPropEnt(client, Prop_Send, "m_tongueOwner");
  857.     if (attacker > 0 && attacker != client)
  858.         return true;
  859.        
  860.     attacker = GetEntPropEnt(client, Prop_Send, "m_jockeyAttacker");
  861.     if (attacker > 0 && attacker != client)
  862.         return true;
  863.        
  864.     return false;
  865. }
Advertisement
Add Comment
Please, Sign In to add comment