Advertisement
Guest User

Untitled

a guest
Jul 18th, 2019
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.08 KB | None | 0 0
  1. /* Copyright © 2019, PartialCloning
  2.  
  3. This software is free software;
  4. you can redistribute it and/or modify it under the terms of the
  5. GNU General Public License as published by the Free Software Foundation.
  6.  
  7. This program is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11.  
  12. You should have received a copy of the GNU General Public License
  13. along with this software; if not, write to the
  14. Free Software Foundation, Inc., 59 Temple Place - Suite 330,
  15. Boston, MA 02111-1307, USA.
  16.  
  17. I, PartialCloning, retain ownership of anything I write.
  18. (the GPL grants you all the rights you could need).
  19. */
  20.  
  21. #include <amxmodx>
  22. #include <amxmisc>
  23. #include <cstrike>
  24. #include <csx>
  25. #include <engine>
  26. #include <fakemeta>
  27. #include <hamsandwich>
  28.  
  29. #define VIP_ACCESS ADMIN_LEVEL_H
  30. #define HUD_RED 0
  31. #define HUD_GREEN 255
  32. #define HUD_BLUE 0
  33. #define HUD_X 0.05
  34. #define HUD_Y 0.55
  35. #define HUD_TIME 6.0
  36.  
  37. enum GoldWeaponsEnum {GOLD_V[64], GOLD_P[64], GOLD_W[64]};
  38. new const g_szGoldWeapon[][GoldWeaponsEnum] =
  39. {
  40. {"", "", ""}, //CSW_NONE
  41. {"", "", ""}, //CSW_P228
  42. {"", "", ""}, //CSW_GLOCK (Unused by game, See CSW_GLOCK18)
  43. {"", "", ""}, //CSW_SCOUT
  44. {"", "", ""}, //CSW_HEGRENADE
  45. {"", "", ""}, //CSW_XM1014
  46. {"", "", ""}, //CSW_C4 (You can't buy a C4)
  47. {"", "", ""}, //CSW_MAC10
  48. {"", "", ""}, //CSW_AUG
  49. {"", "", ""}, //CSW_SMOKEGRENADE
  50. {"", "", ""}, //CSW_ELITE
  51. {"", "", ""}, //CSW_FIVESEVEN
  52. {"", "", ""}, //CSW_UMP45
  53. {"", "", ""}, //CSW_SG550
  54. {"", "", ""}, //CSW_GALIL
  55. {"", "", ""}, //CSW_FAMAS
  56. {"", "", ""}, //CSW_USP
  57. {"", "", ""}, //CSW_GLOCK18
  58. {"models/weapons/gold/v_awp.mdl", "models/weapons/gold/p_awp.mdl", "models/weapons/gold/w_awp.mdl"}, //CSW_AWP
  59. {"", "", ""}, //CSW_MP5NAVY
  60. {"", "", ""}, //CSW_M249
  61. {"", "", ""}, //CSW_M3
  62. {"models/weapons/gold/v_m4a1.mdl", "models/weapons/gold/p_m4a1.mdl", "models/weapons/gold/w_m4a1.mdl"}, //CSW_M4A1
  63. {"", "", ""}, //CSW_TMP
  64. {"", "", ""}, //CSW_G3SG1
  65. {"", "", ""}, //CSW_FLASHBANG
  66. {"models/weapons/gold/v_deagle.mdl", "models/weapons/gold/p_deagle.mdl", "models/weapons/gold/w_deagle.mdl"}, //CSW_DEAGLE
  67. {"", "", ""}, //CSW_SG552
  68. {"models/weapons/gold/v_ak47.mdl", "models/weapons/gold/p_ak47.mdl", "models/weapons/gold/w_ak47.mdl"}, //CSW_AK47
  69. {"", "", ""}, //CSW_KNIFE
  70. {"", "", ""}, //CSW_P90
  71. };
  72.  
  73. #define IMPULSECODE_GOLD 1234504321
  74. new FMSetModelID, bool:g_bBoughtGolden[33];
  75.  
  76. public plugin_precache()
  77. {
  78. for(new i = CSW_P228; i < sizeof(g_szGoldWeapon); i++)
  79. {
  80. if(g_szGoldWeapon[i][GOLD_V][0] != EOS)
  81. precache_model(g_szGoldWeapon[i][GOLD_V]);
  82.  
  83. if(g_szGoldWeapon[i][GOLD_P][0] != EOS)
  84. precache_model(g_szGoldWeapon[i][GOLD_P]);
  85.  
  86. if(g_szGoldWeapon[i][GOLD_W][0] != EOS)
  87. precache_model(g_szGoldWeapon[i][GOLD_W]);
  88. }
  89. }
  90.  
  91. public plugin_init()
  92. {
  93. register_plugin("VIP", "1.0", "Partial Cloning");
  94.  
  95. register_clcmd("say", "CMD_Say", VIP_ACCESS, "@<text> - Displays HUD message.", 0);
  96. register_clcmd("say_team /vip", "CMD_VIPs");
  97. register_clcmd("say_team /vips", "CMD_VIPs");
  98. register_clcmd("say /vip", "CMD_VIPs");
  99. register_clcmd("say /vips", "CMD_VIPs");
  100. register_clcmd("say_team vip", "CMD_VIPs");
  101. register_clcmd("say_team vips", "CMD_VIPs");
  102. register_clcmd("say vip", "CMD_VIPs");
  103. register_clcmd("say vips", "CMD_VIPs");
  104.  
  105. register_clcmd("say vm", "CMD_vipmenu");
  106. register_clcmd("say vipmenu", "CMD_vipmenu");
  107. register_clcmd("say /vm", "CMD_vipmenu");
  108. register_clcmd("say /vipmenu", "CMD_vipmenu");
  109. register_clcmd("say_team /vipmenu", "CMD_vipmenu");
  110. register_clcmd("say_team /vm", "CMD_vipmenu");
  111. register_clcmd("say_team vm", "CMD_vipmenu");
  112. register_clcmd("say_team /vipmenu", "CMD_vipmenu");
  113.  
  114. register_clcmd("say wantvip", "cmdMOTD", -1);
  115. register_clcmd("say /wantvip", "cmdMOTD", -1);
  116. register_clcmd("say_team wantvip", "cmdMOTD", -1);
  117. register_clcmd("say_team /wantvip", "cmdMOTD", -1);
  118.  
  119. new szWeapon[32];
  120. for(new i = CSW_P228; i < CSW_P90; i++)
  121. {
  122. if(g_szGoldWeapon[i][GOLD_V][0] == EOS || !get_weaponname(i, szWeapon, charsmax(szWeapon)))
  123. continue;
  124.  
  125. RegisterHam(Ham_Item_Deploy, szWeapon, "Ham_WeaponDeploy_Post", true);
  126. RegisterHam(Ham_Item_AddToPlayer, szWeapon, "Ham_AddWeaponToPlayer_Post", true);
  127.  
  128. }
  129.  
  130. RegisterHam(Ham_Spawn, "weaponbox", "Ham_WeaponBoxSpawn_Post", true);
  131. RegisterHam(Ham_Touch, "weaponbox", "Ham_TouchWeaponbox");
  132. RegisterHam(Ham_Spawn, "player", "HamOnPlayerSpawnPost", 1);
  133. }
  134.  
  135. public client_putinserver(id)
  136. {
  137. if(get_user_flags(id) & VIP_ACCESS)
  138. set_task(2.0, "TaskAnnounceConnect", id);
  139. }
  140.  
  141. public client_disconnected(id)
  142. {
  143. g_bBoughtGolden[id] = false;
  144. remove_task(id);
  145. }
  146.  
  147. public TaskAnnounceConnect(id)
  148. {
  149. set_hudmessage(HUD_RED, HUD_GREEN, HUD_BLUE, HUD_X, HUD_Y, 0, HUD_TIME, HUD_TIME, 0.5, 0.15);
  150. show_hudmessage(0, "VIP ^"%n^" Connected!^nThank you for supporting the server!", id);
  151. }
  152.  
  153. public CMD_Say(id, Level)
  154. {
  155. if(!access(id, Level))
  156. return PLUGIN_CONTINUE;
  157.  
  158. new Message[192];
  159. read_argv(1, Message, charsmax(Message));
  160.  
  161. if(Message[0] != '@')
  162. return PLUGIN_CONTINUE;
  163.  
  164. read_args(Message, charsmax(Message));
  165. remove_quotes(Message);
  166.  
  167. static Y;
  168. if(++Y > 6 || Y < 3)
  169. Y = 3;
  170.  
  171. set_hudmessage(HUD_RED, HUD_GREEN, HUD_BLUE, HUD_X, HUD_Y + (float(Y) / 35.0), 0, HUD_TIME, HUD_TIME, 0.5, 0.15);
  172. show_hudmessage(0, "%n : %s", id, Message[1]);
  173. client_print(0, print_notify, "%n : %s", id, Message[1]);
  174.  
  175. return PLUGIN_HANDLED;
  176. }
  177.  
  178. public Ham_WeaponDeploy_Post(Entity)
  179. {
  180. if(pev(Entity, pev_impulse) != IMPULSECODE_GOLD)
  181. return HAM_IGNORED;
  182.  
  183. new CSW = get_ent_data(Entity, "CBasePlayerItem", "m_iId");
  184.  
  185. if(g_szGoldWeapon[CSW][GOLD_V][0] == EOS)
  186. return HAM_IGNORED;
  187.  
  188. new id = get_ent_data_entity(Entity, "CBasePlayerItem", "m_pPlayer");
  189. if(!(get_user_flags(id) & VIP_ACCESS))
  190. return HAM_IGNORED;
  191.  
  192. set_pev(id, pev_viewmodel2, g_szGoldWeapon[CSW][GOLD_V][0]);
  193.  
  194. if(g_szGoldWeapon[CSW][GOLD_P][0] != EOS)
  195. set_pev(id, pev_weaponmodel2, g_szGoldWeapon[CSW][GOLD_P][0]);
  196.  
  197. return HAM_IGNORED;
  198. }
  199.  
  200. public Ham_AddWeaponToPlayer_Post(Entity, id)
  201. {
  202. if(g_bBoughtGolden[id])
  203. {
  204. g_bBoughtGolden[id] = false;
  205. set_pev(Entity, pev_impulse, IMPULSECODE_GOLD);
  206. }
  207.  
  208. return HAM_IGNORED;
  209. }
  210.  
  211. public Ham_WeaponBoxSpawn_Post()
  212. {
  213. FMSetModelID = register_forward(FM_SetModel, "FakeMeta_SetModel");
  214. }
  215.  
  216. public FakeMeta_SetModel(Entity)
  217. {
  218. unregister_forward(FM_SetModel, FMSetModelID);
  219.  
  220. if(pev_valid(Entity) != 2)
  221. return FMRES_IGNORED;
  222.  
  223. new Weapon, CSW;
  224. for(new i = CS_WEAPONSLOT_PRIMARY; i <= CS_WEAPONSLOT_C4; i++)
  225. {
  226. Weapon = get_ent_data_entity(Entity, "CWeaponBox", "m_rgpPlayerItems", i);
  227.  
  228. if(pev_valid(Weapon) != 2 || pev(Weapon, pev_impulse) != IMPULSECODE_GOLD || g_szGoldWeapon[(CSW = get_ent_data(Weapon, "CBasePlayerItem", "m_iId"))][GOLD_W][0] == EOS)
  229. continue;
  230.  
  231. engfunc(EngFunc_SetModel, Entity, g_szGoldWeapon[CSW][GOLD_W]);
  232. return FMRES_SUPERCEDE;
  233. }
  234.  
  235. return FMRES_IGNORED;
  236. }
  237.  
  238. public grenade_throw(id, Grenade, CSW)
  239. {
  240. if(g_szGoldWeapon[CSW][GOLD_V][0] == EOS|| g_szGoldWeapon[CSW][GOLD_W][0] == EOS)
  241. return;
  242.  
  243. new szViewModel[32];
  244. pev(id, pev_viewmodel2, szViewModel, charsmax(szViewModel));
  245.  
  246. if(equal(szViewModel, g_szGoldWeapon[CSW][GOLD_V]))
  247. engfunc(EngFunc_SetModel, Grenade, g_szGoldWeapon[CSW][GOLD_W]);
  248. }
  249.  
  250. public Ham_TouchWeaponbox(Entity, id)
  251. {
  252. if(!(1 <= id <= MaxClients) || !is_user_alive(id) || pev_valid(Entity) != 2 || !(pev(Entity, pev_flags) & FL_ONGROUND))
  253. return HAM_IGNORED;
  254.  
  255. new Weapon; static Float:flPrinTime[33];
  256. for(new i = CS_WEAPONSLOT_PRIMARY; i <= CS_WEAPONSLOT_C4; i++)
  257. {
  258. Weapon = get_ent_data_entity(Entity, "CWeaponBox", "m_rgpPlayerItems", i);
  259.  
  260. if(pev_valid(Weapon) != 2 || pev(Weapon, pev_impulse) != IMPULSECODE_GOLD || g_szGoldWeapon[get_ent_data(Weapon, "CBasePlayerItem", "m_iId")][GOLD_W][0] == EOS)
  261. continue;
  262.  
  263. if(!(get_user_flags(id) & VIP_ACCESS))
  264. {
  265. if(flPrinTime[id] < get_gametime())
  266. {
  267. flPrinTime[id] = get_gametime() + 1.9;
  268. client_print(id, print_center, "You must be VIP to use gold weapons!");
  269. }
  270.  
  271. return HAM_SUPERCEDE;
  272. }
  273. }
  274.  
  275. return HAM_IGNORED;
  276. }
  277.  
  278. public CS_OnBuy(id, Item)
  279. {
  280. if(Item >= sizeof(g_szGoldWeapon) || !(get_user_flags(id) & VIP_ACCESS))
  281. return PLUGIN_CONTINUE;
  282.  
  283. if(g_szGoldWeapon[Item][GOLD_V][0] != EOS || g_szGoldWeapon[Item][GOLD_W][0] != EOS)
  284. g_bBoughtGolden[id] = true;
  285.  
  286. return PLUGIN_CONTINUE;
  287. }
  288.  
  289. public CMD_vipmenu(id)
  290. {
  291. client_print(id, print_chat, "The VIP system does NOT have a vipmenu, type /wantvip to see what your VIP options are. ")
  292. }
  293. public CMD_VIPs(id)
  294. {
  295. new Message[256], Names[33][32], Players[32], Num, Count, Len;
  296.  
  297. get_players(Players, Num, "h");
  298. for(new i = 0; i < Num; i++)
  299. {
  300. if(get_user_flags(Players[i]) & VIP_ACCESS)
  301. get_user_name(Players[i], Names[Count++], charsmax(Names));
  302. }
  303.  
  304. if(Count > 0)
  305. {
  306. Len = formatex(Message, charsmax(Message), "VIPs Online: ");
  307.  
  308. for(new i; i < Count; i++)
  309. {
  310. Len += formatex(Message[Len], charsmax(Message) - Len, "%s%s", Names[i], i < (Count - 1) ? ", " : "");
  311.  
  312. if(Len > 96)
  313. {
  314. client_print_color(id, print_team_default, "^4%s", Message);
  315. Len = 0;
  316. }
  317. }
  318.  
  319. client_print_color(id, print_team_default, "^4%s", Message);
  320. }
  321. else
  322. client_print_color(id, print_team_default, "^4No VIPs online.");
  323. }
  324.  
  325. public cmdMOTD(id)
  326. {
  327. show_motd(id, "vipmotd.txt", "MOTD");
  328. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement