Advertisement
Guest User

Untitled

a guest
Jul 15th, 2019
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.44 KB | None | 0 0
  1. #pragma newdecls required
  2.  
  3. #include <sourcemod>
  4. #include <sdktools>
  5.  
  6. int iWeapon[2048 + 1], iAmmo[MAXPLAYERS + 1][2][2];
  7. bool iCookies[MAXPLAYERS + 1][2], iState[MAXPLAYERS + 1], IsMelee[MAXPLAYERS + 1][2], IsDual[MAXPLAYERS + 1][2];
  8. char sClassnameWeapon[MAXPLAYERS + 1][2][36];
  9.  
  10. public void OnPluginStart()
  11. {
  12. AddCommandListener(HookPlayerChat, "say");
  13. RegConsoleCmd("s", cSwitch);
  14. RegConsoleCmd("sm_s", cSwitch);
  15. }
  16.  
  17. public Action HookPlayerChat(int iClient, const char[] sCommand, int iArgs)
  18. {
  19. if (StrEqual(sCommand, "say") || StrEqual(sCommand, "say_team"))
  20. {
  21. char sArg[2];
  22. GetCmdArg(1, sArg, sizeof(sArg));
  23. if(strcmp(sArg, "s") == 0)
  24. {
  25. cSwitch(iClient, 0);
  26. return Plugin_Continue;
  27. }
  28. }
  29. return Plugin_Continue;
  30. }
  31.  
  32. public Action cSwitch (int client, int args)
  33. {
  34. int iSlot = GetPlayerWeaponSlot(client, 1), AmmoType, Ammo, iClip;
  35.  
  36. if(!iState[client])
  37. {
  38. if(!iCookies[client][0])
  39. {
  40. if(IsValidEntity(iSlot))
  41. {
  42. GetEntityClassname(iSlot, sClassnameWeapon[client][0], sizeof sClassnameWeapon[][]);
  43. if(strcmp(sClassnameWeapon[client][0], "weapon_melee") == 0)
  44. {
  45. IsMelee[client][0] = true;
  46. GetEntPropString(iSlot, Prop_Data, "m_strMapSetScriptName", sClassnameWeapon[client][0], sizeof sClassnameWeapon[][]);
  47. }
  48. else if(strcmp(sClassnameWeapon[client][0], "weapon_pistol") == 0 && GetEntProp(iSlot, Prop_Send, "m_hasDualWeapons"))
  49. IsDual[client][0] = true;
  50.  
  51. if(!IsMelee[client][0])
  52. {
  53. AmmoType = GetEntProp(iSlot, Prop_Send, "m_iPrimaryAmmoType");
  54. Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
  55. iClip = GetEntProp(iSlot, Prop_Send, "m_iClip1");
  56. }
  57.  
  58. iAmmo[client][0][0] = iClip;
  59. iAmmo[client][0][1] = Ammo;
  60.  
  61. RemovePlayerItem(client, iSlot);
  62. AcceptEntityInput(iSlot, "kill");
  63. iCookies[client][0] = true;
  64. if(iCookies[client][1])
  65. {
  66. iSlot = GetPlayerWeaponSlot(client, 1);
  67. if(!IsValidEntity(iSlot))
  68. {
  69. if(!IsMelee[client][1])
  70. {
  71. if(IsDual[client][1])
  72. {
  73. int entity;
  74. for(int i; i <= 2; i++)
  75. {
  76. entity = CreateEntityByName(sClassnameWeapon[client][1]);
  77. DispatchSpawn(entity);
  78. if(IsValidEntity(entity))
  79. {
  80. AcceptEntityInput(entity, "Use", client);
  81. }
  82. }
  83.  
  84. iWeapon[entity] = GetClientUserId(client);
  85. CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
  86. iCookies[client][1] = false;
  87. IsDual[client][1] = false;
  88. }
  89. else
  90. {
  91. int entity = CreateEntityByName(sClassnameWeapon[client][1]);
  92. DispatchSpawn(entity);
  93. if(IsValidEntity(entity))
  94. {
  95. AcceptEntityInput(entity, "Use", client);
  96. iCookies[client][1] = false;
  97. }
  98. iWeapon[entity] = GetClientUserId(client);
  99. CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
  100. }
  101. }
  102. else
  103. {
  104. int entity = MeleeAwfull(sClassnameWeapon[client][1]);
  105. AcceptEntityInput(entity, "Use", client);
  106. iCookies[client][1] = false;
  107. IsMelee[client][1] = false;
  108. }
  109. }
  110. }
  111. }
  112. }
  113. else
  114. {
  115. iSlot = GetPlayerWeaponSlot(client, 1);
  116. if(!IsValidEntity(iSlot))
  117. {
  118. if(!IsMelee[client][0])
  119. {
  120. if(IsDual[client][0])
  121. {
  122. int entity;
  123. for(int i; i <= 2; i++)
  124. {
  125. entity = CreateEntityByName(sClassnameWeapon[client][0]);
  126. DispatchSpawn(entity);
  127. if(IsValidEntity(entity))
  128. {
  129. AcceptEntityInput(entity, "Use", client);
  130. }
  131. }
  132.  
  133. iWeapon[entity] = GetClientUserId(client);
  134. CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
  135. iCookies[client][0] = false;
  136. IsDual[client][0] = false;
  137. }
  138. else
  139. {
  140. int entity = CreateEntityByName(sClassnameWeapon[client][0]);
  141. DispatchSpawn(entity);
  142. if(IsValidEntity(entity))
  143. {
  144. AcceptEntityInput(entity, "Use", client);
  145. iCookies[client][0] = false;
  146. }
  147. iWeapon[entity] = GetClientUserId(client);
  148. CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
  149. }
  150. }
  151. else
  152. {
  153. int entity = MeleeAwfull(sClassnameWeapon[client][0]);
  154. AcceptEntityInput(entity, "Use", client);
  155. iCookies[client][0] = false;
  156. IsMelee[client][0] = false;
  157. }
  158. }
  159. }
  160. iState[client] = true;
  161. }
  162. else
  163. {
  164. if(!iCookies[client][1])
  165. {
  166. if(IsValidEntity(iSlot))
  167. {
  168. GetEntityClassname(iSlot, sClassnameWeapon[client][1], sizeof sClassnameWeapon[][]);
  169. if(strcmp(sClassnameWeapon[client][1], "weapon_melee") == 0)
  170. {
  171. IsMelee[client][1] = true;
  172. GetEntPropString(iSlot, Prop_Data, "m_strMapSetScriptName", sClassnameWeapon[client][1], sizeof sClassnameWeapon[][]);
  173. }
  174. else if(strcmp(sClassnameWeapon[client][1], "weapon_pistol") == 0 && GetEntProp(iSlot, Prop_Send, "m_hasDualWeapons"))
  175. {
  176. IsDual[client][1] = true;
  177. }
  178.  
  179. if(!IsMelee[client][1])
  180. {
  181. AmmoType = GetEntProp(iSlot, Prop_Send, "m_iPrimaryAmmoType");
  182. Ammo = GetEntProp(client, Prop_Send, "m_iAmmo", _, AmmoType);
  183. iClip = GetEntProp(iSlot, Prop_Send, "m_iClip1");
  184. }
  185.  
  186. iAmmo[client][1][0] = iClip;
  187. iAmmo[client][1][1] = Ammo;
  188.  
  189. RemovePlayerItem(client, iSlot);
  190. AcceptEntityInput(iSlot, "kill");
  191. iCookies[client][1] = true;
  192. if(iCookies[client][0])
  193. {
  194. iSlot = GetPlayerWeaponSlot(client, 1);
  195. if(!IsMelee[client][0])
  196. {
  197. if(IsDual[client][0])
  198. {
  199. int entity;
  200. for(int i; i <= 2; i++)
  201. {
  202. entity = CreateEntityByName(sClassnameWeapon[client][0]);
  203. DispatchSpawn(entity);
  204. if(IsValidEntity(entity))
  205. {
  206. AcceptEntityInput(entity, "Use", client);
  207. }
  208. }
  209. iWeapon[entity] = GetClientUserId(client);
  210. CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
  211. iCookies[client][0] = false;
  212. IsDual[client][0] = false;
  213. }
  214. else
  215. {
  216. int entity = CreateEntityByName(sClassnameWeapon[client][0]);
  217. DispatchSpawn(entity);
  218. if(IsValidEntity(entity))
  219. {
  220. AcceptEntityInput(entity, "Use", client);
  221. iCookies[client][0] = false;
  222. }
  223. iWeapon[entity] = GetClientUserId(client);
  224. CreateTimer(0.02, tXclip, EntIndexToEntRef(entity));
  225. }
  226. }
  227. else
  228. {
  229. int entity = MeleeAwfull(sClassnameWeapon[client][0]);
  230. AcceptEntityInput(entity, "Use", client);
  231. iCookies[client][0] = false;
  232. IsMelee[client][0] = false;
  233. }
  234. }
  235. }
  236. }
  237. else
  238. {
  239. iSlot = GetPlayerWeaponSlot(client, 1);
  240. if(!IsValidEntity(iSlot))
  241. {
  242. if(!IsMelee[client][1])
  243. {
  244. if(IsDual[client][1])
  245. {
  246. int entity;
  247. for(int i; i <= 2; i++)
  248. {
  249. entity = CreateEntityByName(sClassnameWeapon[client][1]);
  250. DispatchSpawn(entity);
  251. if(IsValidEntity(entity))
  252. {
  253. AcceptEntityInput(entity, "Use", client);
  254. }
  255. }
  256. iWeapon[entity] = GetClientUserId(client);
  257. CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
  258. iCookies[client][1] = false;
  259. IsDual[client][1] = false;
  260. }
  261. else
  262. {
  263. int entity = CreateEntityByName(sClassnameWeapon[client][1]);
  264. DispatchSpawn(entity);
  265. if(IsValidEntity(entity))
  266. {
  267. AcceptEntityInput(entity, "Use", client);
  268. iCookies[client][1] = false;
  269. }
  270. iWeapon[entity] = GetClientUserId(client);
  271. CreateTimer(0.02, tXclip2, EntIndexToEntRef(entity));
  272. }
  273. }
  274. else
  275. {
  276. int entity = MeleeAwfull(sClassnameWeapon[client][1]);
  277. AcceptEntityInput(entity, "Use", client);
  278. iCookies[client][1] = false;
  279. IsMelee[client][1] = false;
  280. }
  281. }
  282. }
  283. iState[client] = false;
  284. }
  285. return Plugin_Handled;
  286. }
  287.  
  288. public Action tXclip(Handle timer, int entity)
  289. {
  290. entity = EntRefToEntIndex(entity);
  291. if(entity != INVALID_ENT_REFERENCE)
  292. {
  293. int iAmmoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
  294. if(iAmmoType)
  295. {
  296. int Clip, Ammo, client;
  297. client = GetClientOfUserId(iWeapon[entity]);
  298. Clip = iAmmo[client][0][0];
  299. Ammo = iAmmo[client][0][1];
  300.  
  301. int iCurrentWeapon = GetPlayerWeaponSlot(client, 1);
  302. SetEntProp(client, Prop_Send, "m_iAmmo", Ammo, _, iAmmoType);
  303. SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", Clip);
  304. }
  305. }
  306. }
  307.  
  308. public Action tXclip2(Handle timer, int entity)
  309. {
  310. entity = EntRefToEntIndex(entity);
  311. if(entity != INVALID_ENT_REFERENCE)
  312. {
  313. int iAmmoType = GetEntProp(entity, Prop_Send, "m_iPrimaryAmmoType");
  314. if(iAmmoType)
  315. {
  316. int Clip, Ammo, client;
  317. client = GetClientOfUserId(iWeapon[entity]);
  318. Clip = iAmmo[client][1][0];
  319. Ammo = iAmmo[client][1][1];
  320.  
  321. int iCurrentWeapon = GetPlayerWeaponSlot(client, 1);
  322. SetEntProp(client, Prop_Send, "m_iAmmo", Ammo, _, iAmmoType);
  323. SetEntProp(iCurrentWeapon, Prop_Send, "m_iClip1", Clip);
  324. }
  325. }
  326. }
  327.  
  328. int MeleeAwfull(const char[] Melee)
  329. {
  330. int iMWeapon = CreateEntityByName("weapon_melee");
  331.  
  332. if (IsValidEntity(iMWeapon))
  333. {
  334. DispatchKeyValue(iMWeapon, "melee_script_name", Melee);
  335. DispatchSpawn(iMWeapon);
  336.  
  337. char ModelName[128];
  338. GetEntPropString(iMWeapon, Prop_Data, "m_ModelName", ModelName, sizeof ModelName);
  339.  
  340. if (StrContains( ModelName, "hunter", false ) != -1)
  341. AcceptEntityInput(iMWeapon, "kill");
  342. }
  343. return iMWeapon;
  344. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement