Advertisement
Diskretor

Untitled

Sep 14th, 2018
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 8.08 KB | None | 0 0
  1. #include <sourcemod>
  2. #include <sdktools>
  3.  
  4. #pragma semicolon 1
  5.  
  6. #define FL_PISTOL_PRIMARY (1<<6) //Is 1 when you have a primary weapon and dual pistols
  7. #define FL_PISTOL (1<<7) //Is 1 when you have dual pistols
  8.  
  9. #define MODEL_BILL "models/survivors/survivor_namvet.mdl"
  10. #define MODEL_FRANCIS "models/survivors/survivor_biker.mdl"
  11. #define MODEL_LOUIS "models/survivors/survivor_manager.mdl"
  12. #define MODEL_ZOEY "models/survivors/survivor_teenangst.mdl"
  13.  
  14. #define PLUGIN_VERSION "1.5"
  15.  
  16. public Plugin:myinfo =
  17. {
  18. name = "L4D Drop Weapon",
  19. author = "Frustian, Figa, (edited by Dragokas & SilverShot)",
  20. description = "Allows players to drop the weapon they are holding, or another weapon they have",
  21. version = PLUGIN_VERSION,
  22. url = ""
  23. }
  24.  
  25. /*
  26. Fork by Dragokas
  27.  
  28. 1.5.
  29. - Fixed exploit for infinite pipe/molotov (thanks to SilverShot)
  30.  
  31. 1.3.
  32. - Removed F3 key binding
  33.  
  34. 1.3
  35. - Added IsClientInGame() check.
  36. */
  37.  
  38. new Handle:g_hSpecify;
  39.  
  40. public OnPluginStart()
  41. {
  42. CreateConVar("l4d_drop_version", PLUGIN_VERSION, "Drop Weapon Version",FCVAR_DONTRECORD);
  43. g_hSpecify = CreateConVar("l4d_drop_specify", "1", "Allow people to drop weapons they have, but are not using",FCVAR_NOTIFY);
  44. RegConsoleCmd("sm_drop", Command_Drop);
  45. LoadTranslations("drop.phrases");
  46. }
  47. public Action:Command_Drop(client, args)
  48. {
  49. if (client == 0 || !IsClientInGame(client))
  50. return Plugin_Handled;
  51.  
  52. if (GetClientTeam(client) != 2 || !IsPlayerAlive(client))
  53. return Plugin_Handled;
  54.  
  55. new String:weapon[32];
  56. if (args > 1)
  57. {
  58. ReplyToCommand(client, "[SM] Usage: sm_drop [weapon]");
  59. return Plugin_Handled;
  60. }
  61.  
  62. if (args == 1)
  63. {
  64. if (GetConVarInt(g_hSpecify))
  65. {
  66. GetCmdArg(1, weapon, 32);
  67. if ((StrContains(weapon, "pump") != -1 || StrContains(weapon, "auto") != -1 || StrContains(weapon, "shot") != -1 || StrContains(weapon, "rifle") != -1 || StrContains(weapon, "smg") != -1 || StrContains(weapon, "uzi") != -1 || StrContains(weapon, "m16") != -1 || StrContains(weapon, "hunt") != -1) && GetPlayerWeaponSlot(client, 0) != -1)
  68. DropSlot(client, 0);
  69. else if ((StrContains(weapon, "pistol") != -1) && GetPlayerWeaponSlot(client, 1) != -1)
  70. DropSlot(client, 1);
  71. else if ((StrContains(weapon, "pipe") != -1 || StrContains(weapon, "mol") != -1) && GetPlayerWeaponSlot(client, 2) != -1) {
  72. if (!UsePipeExploit(client))
  73. DropSlot(client, 2);
  74. }
  75. else if ((StrContains(weapon, "kit") != -1 || StrContains(weapon, "pack") != -1 || StrContains(weapon, "med") != -1) && GetPlayerWeaponSlot(client, 3) != -1)
  76. DropSlot(client, 3);
  77. else if ((StrContains(weapon, "pill") != -1) && GetPlayerWeaponSlot(client, 4) != -1)
  78. DropSlot(client, 4);
  79. else
  80. PrintToChat(client, "%t", "drop_nothing", weapon);
  81. }
  82. else
  83. ReplyToCommand(client, "%t", "drop_specify");
  84. return Plugin_Handled;
  85. }
  86. GetClientWeapon(client, weapon, 32);
  87. if (StrEqual(weapon, "weapon_pumpshotgun") || StrEqual(weapon, "weapon_autoshotgun") || StrEqual(weapon, "weapon_rifle") || StrEqual(weapon, "weapon_smg") || StrEqual(weapon, "weapon_hunting_rifle"))
  88. DropSlot(client, 0);
  89. else if (StrEqual(weapon, "weapon_pistol"))
  90. DropSlot(client, 1);
  91. else if (StrEqual(weapon, "weapon_pipe_bomb") || StrEqual(weapon, "weapon_molotov")) {
  92. if (!UsePipeExploit(client))
  93. DropSlot(client, 2);
  94. }
  95. else if (StrEqual(weapon, "weapon_first_aid_kit"))
  96. DropSlot(client, 3);
  97. else if (StrEqual(weapon, "weapon_pain_pills"))
  98. DropSlot(client, 4);
  99. return Plugin_Handled;
  100. }
  101.  
  102. bool UsePipeExploit(int client)
  103. {
  104. int seq = GetEntProp(client, Prop_Send, "m_nSequence");
  105.  
  106. char Model[100];
  107. GetClientModel(client, Model, sizeof(Model));
  108.  
  109. if ((StrEqual(Model, MODEL_BILL, false) && seq == 24) ||
  110. (StrEqual(Model, MODEL_FRANCIS, false) && seq == 26) ||
  111. (StrEqual(Model, MODEL_LOUIS, false) && seq == 25) ||
  112. (StrEqual(Model, MODEL_ZOEY, false) && seq == 24)) {
  113.  
  114. MsgExploit(client);
  115. PrintToChatAll("Model is: %s, Seq = %i", Model, seq);
  116. return true;
  117. }
  118. return false;
  119. }
  120.  
  121. void MsgExploit(int client)
  122. {
  123. PrintToChatAll("%N tried to use exploit (drop grenade/molotov) !!!", client);
  124. }
  125.  
  126. public DropSlot(client, slot)
  127. {
  128. if (GetPlayerWeaponSlot(client, slot) > 0)
  129. {
  130. decl String:username[MAX_NAME_LENGTH];
  131. GetClientName(client, username, sizeof(username));
  132. new String:sWeapon[32];
  133. new ammo;
  134. new clip;
  135. new ammoOffset = FindSendPropInfo("CTerrorPlayer", "m_iAmmo");
  136. GetEdictClassname(GetPlayerWeaponSlot(client, slot), sWeapon, 32);
  137. if (slot == 0)
  138. {
  139. clip = GetEntProp(GetPlayerWeaponSlot(client, 0), Prop_Send, "m_iClip1");
  140. ClientCommand(client, "vocalize PlayerSpotOtherWeapon");
  141. if (StrEqual(sWeapon, "weapon_pumpshotgun"))
  142. {
  143. ammo = GetEntData(client, ammoOffset+(6*4));
  144. SetEntData(client, ammoOffset+(6*4), 0);
  145. PrintToChatAll("%t", "drop_pumpshotgun", username);
  146. }
  147. else if (StrEqual(sWeapon, "weapon_autoshotgun"))
  148. {
  149. ammo = GetEntData(client, ammoOffset+(6*4));
  150. SetEntData(client, ammoOffset+(6*4), 0);
  151. PrintToChatAll("%t", "drop_autoshotgun", username);
  152. }
  153. else if (StrEqual(sWeapon, "weapon_smg"))
  154. {
  155. ammo = GetEntData(client, ammoOffset+(5*4));
  156. SetEntData(client, ammoOffset+(5*4), 0);
  157. PrintToChatAll("%t", "drop_smg", username);
  158. }
  159. else if (StrEqual(sWeapon, "weapon_rifle"))
  160. {
  161. ammo = GetEntData(client, ammoOffset+(3*4));
  162. SetEntData(client, ammoOffset+(3*4), 0);
  163. PrintToChatAll("%t", "drop_rifle", username);
  164. }
  165. else if (StrEqual(sWeapon, "weapon_hunting_rifle"))
  166. {
  167. ammo = GetEntData(client, ammoOffset+(2*4));
  168. SetEntData(client, ammoOffset+(2*4), 0);
  169. PrintToChatAll("%t", "drop_hunting_rifle", username);
  170. }
  171. }
  172. if (slot == 1)
  173. {
  174. if ((GetEntProp(client, Prop_Send, "m_iAddonBits") & (FL_PISTOL|FL_PISTOL_PRIMARY)) > 0)
  175. {
  176. clip = GetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1");
  177. RemovePlayerItem(client, GetPlayerWeaponSlot(client, 1));
  178. SetCommandFlags("give", GetCommandFlags("give") & ~FCVAR_CHEAT);
  179. FakeClientCommand(client, "give pistol", sWeapon);
  180. SetCommandFlags("give", GetCommandFlags("give") | FCVAR_CHEAT);
  181. if (clip < 15)
  182. SetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1", 0);
  183. else
  184. SetEntProp(GetPlayerWeaponSlot(client, 1), Prop_Send, "m_iClip1", clip-15);
  185. new index = CreateEntityByName(sWeapon);
  186. new Float:cllocation[3];
  187. GetEntPropVector(client, Prop_Send, "m_vecOrigin", cllocation);
  188. cllocation[2]+=20;
  189. TeleportEntity(index,cllocation, NULL_VECTOR, NULL_VECTOR);
  190. DispatchSpawn(index);
  191. ActivateEntity(index);
  192. PrintToChatAll("%t", "drop_pistol", username);
  193. ClientCommand(client, "vocalize PlayerSpotPistol");
  194. }
  195. else
  196. PrintToChat(client, "%t", "drop_last_pistol");
  197. return;
  198. }
  199. if (slot == 2)
  200. {
  201. if (StrEqual(sWeapon, "weapon_pipe_bomb"))
  202. {
  203. PrintToChatAll("%t", "drop_pipe_bomb", username);
  204. ClientCommand(client, "vocalize PlayerSpotGrenade");
  205. }
  206. else if (StrEqual(sWeapon, "weapon_molotov"))
  207. {
  208. PrintToChatAll("%t", "drop_molotov", username);
  209. ClientCommand(client, "vocalize PlayerSpotMolotov");
  210. }
  211. }
  212. if (slot == 3)
  213. {
  214. if (StrEqual(sWeapon, "weapon_first_aid_kit"))
  215. {
  216. PrintToChatAll("%t", "drop_first_aid_kit", username);
  217. ClientCommand(client, "vocalize PlayerSpotFirstAid");
  218. }
  219. }
  220. if (slot == 4)
  221. {
  222. if (StrEqual(sWeapon, "weapon_pain_pills"))
  223. {
  224. PrintToChatAll("%t", "drop_pills", username);
  225. ClientCommand(client, "vocalize PlayerSpotPills");
  226. }
  227. }
  228. new index = CreateEntityByName(sWeapon);
  229. new Float:cllocation[3];
  230. GetEntPropVector(client, Prop_Send, "m_vecOrigin", cllocation);
  231. cllocation[2]+=20;
  232. TeleportEntity(index,cllocation, NULL_VECTOR, NULL_VECTOR);
  233. DispatchSpawn(index);
  234. ActivateEntity(index);
  235. RemovePlayerItem(client, GetPlayerWeaponSlot(client, slot));
  236. if (slot == 0)
  237. {
  238. SetEntProp(index, Prop_Send, "m_iExtraPrimaryAmmo", ammo);
  239. SetEntProp(index, Prop_Send, "m_iClip1", clip);
  240. }
  241. }
  242. }
  243. public OnClientPostAdminCheck(client)
  244. {
  245. // ClientCommand(client, "bind f3 sm_drop");
  246. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement