Advertisement
Filiq_

Untitled

Dec 13th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.89 KB | None | 0 0
  1. /*
  2. CREDITE:
  3. ConnorMcLeod - pentru bullet damage
  4. */
  5.  
  6.  
  7. #include <amxmodx>
  8. #include <hamsandwich>
  9. #include <cstrike>
  10. #include <fun>
  11.  
  12. // --------------------------------------------
  13. // ------------- DE EDITAT ---------------
  14. // --------------------------------------------
  15. new const TAG[] = "[SERVERUL_TAU]"; // TAGUL IN CHAT CARE APARE
  16. new const CONTACT[] = "O ADRESA DE CONTACT";
  17.  
  18. #define is_user_vip(%1) (get_user_flags(%1) & read_flags("AICI PUI FLAGUL VIP-ului"))
  19. // --------------------------------------------
  20. // ------------- DE EDITAT ---------------
  21. // --------------------------------------------
  22.  
  23. #define PLUGIN_NAME "VIP System"
  24. #define PLUGIN_NAME_PAUSED "VIP System [OPRIT]"
  25. #define PLUGIN_VERSION "1.0"
  26. #define PLUGIN_AUTHOR "YONTU"
  27.  
  28. #define is_user_valid(%1) (1 <= %1 <= max_players)
  29.  
  30. enum cvars
  31. {
  32. hp_spawn = 0,
  33. ap_spawn,
  34. hp_kill,
  35. hp_hs,
  36. hp_max,
  37. money_kill,
  38. money_hs,
  39. show_vip_tab,
  40. show_bullet_dmg
  41. }
  42.  
  43. new cvar[cvars], rounds = 0;
  44. new max_players;
  45. new g_iPlayerPos[33], g_iPlayerCol[33];
  46.  
  47. // NU SCHIMBA
  48. new const Float:g_flCoords[][] =
  49. {
  50. {0.50, 0.40},
  51. {0.56, 0.44},
  52. {0.60, 0.50},
  53. {0.56, 0.56},
  54. {0.50, 0.60},
  55. {0.44, 0.56},
  56. {0.40, 0.50},
  57. {0.44, 0.44}
  58. }
  59.  
  60. // NU SCHIMBA VALORILE DEJA EXISTENTE. Poti adauga mai multe culori, respectand matricea
  61. new const g_iColors[][] =
  62. {
  63. {0, 127, 255}, // blue
  64. {255, 127, 0}, // orange
  65. {127, 0, 255}, // purple
  66. {255, 0, 0}, // red
  67. {255, 100, 150}, // pink
  68. {0, 255, 0} // green
  69. }
  70.  
  71. public plugin_init()
  72. {
  73. new path[64];
  74. get_localinfo("amxx_configsdir", path, charsmax(path));
  75. formatex(path, charsmax(path), "%s/vip_maps.ini", path);
  76.  
  77. new file = fopen(path, "r+");
  78.  
  79. if(!file_exists(path))
  80. {
  81. write_file(path, "; VIP-UL ESTE DEZACTIVAT PE URMATOARELE HARTI: ");
  82. write_file(path, "; Exemplu de adaugare HARTA:^n; ^"harta^"^n^nfy_snow^ncss_bycastor");
  83. }
  84.  
  85. new mapname[32];
  86. get_mapname(mapname, charsmax(mapname));
  87.  
  88. new text[121], maptext[32], bool:remove_vip = false;
  89. while(!feof(file))
  90. {
  91. fgets(file, text, charsmax(text));
  92. trim(text);
  93.  
  94. if(text[0] == ';' || !strlen(text))
  95. {
  96. continue;
  97. }
  98.  
  99. parse(text, maptext, charsmax(maptext));
  100.  
  101. if(equal(maptext, mapname))
  102. {
  103. log_amx("Am dezactivat pluginul 'VIP' pe harta %s.", maptext);
  104. remove_vip = true;
  105. break;
  106. }
  107.  
  108. }
  109. fclose(file);
  110.  
  111. if(!remove_vip)
  112. {
  113. register_plugin(PLUGIN_NAME, PLUGIN_VERSION, PLUGIN_AUTHOR);
  114.  
  115. register_event("DeathMsg", "event_DeathMsg", "a");
  116. register_event("Damage", "event_Damage", "b", "2>0", "3=0");
  117. register_event("HLTV", "event_NewRound", "a", "1=0", "2=0");
  118. register_event("TextMsg", "event_textmsg", "a", "2=#Game_will_restart_in")
  119.  
  120. RegisterHam(Ham_Spawn, "player", "fw_PlayerSpawnPost", 1);
  121.  
  122. register_message(get_user_msgid("ScoreAttrib"), "msg_ScoreAttrib");
  123.  
  124. register_clcmd("say /vips", "CmdVipsOnline");
  125. register_clcmd("say_team /vips", "CmdVipsOnline");
  126. register_clcmd("say vips", "CmdVipsOnline");
  127. register_clcmd("say_team vips", "CmdVipsOnline");
  128.  
  129. register_clcmd("say vreauvip", "CmdPrintAttributes");
  130. register_clcmd("say_team vreauvip", "CmdPrintAttributes");
  131. register_clcmd("say /vreauvip", "CmdPrintAttributes");
  132. register_clcmd("say_team /vreauvip", "CmdPrintAttributes");
  133.  
  134. cvar[hp_spawn] = register_cvar("vip_hp_spawn", "100"); // 0 = dezactivat
  135. cvar[ap_spawn] = register_cvar("vip_ap_spawn", "100"); // 0 = dezactivat
  136. cvar[show_vip_tab] = register_cvar("vip_show_tab", "1"); // 0 = dezactivat
  137. cvar[show_bullet_dmg] = register_cvar("vip_show_bullet_dmg", "1"); // 0 = dezactivat
  138. cvar[hp_kill] = register_cvar("vip_hp_kill", "5"); // 0 = dezactivat
  139. cvar[hp_hs] = register_cvar("vip_hp_hs", "10"); // 0 = dezactivat
  140. cvar[hp_max] = register_cvar("vip_hp_max", "100"); // 0 = viata infinita
  141. cvar[money_kill] = register_cvar("vip_money_kill", "150"); // 0 = dezactivat
  142. cvar[money_hs] = register_cvar("vip_money_hs", "300"); // 0 = dezactivat
  143.  
  144. max_players = get_maxplayers();
  145. }
  146. else
  147. {
  148. register_plugin(PLUGIN_NAME_PAUSED, PLUGIN_VERSION, PLUGIN_AUTHOR);
  149. pause("ade");
  150. }
  151.  
  152. register_cvar("vip_", PLUGIN_VERSION, FCVAR_SPONLY|FCVAR_SERVER);
  153. set_cvar_string("vip_", PLUGIN_VERSION);
  154. }
  155.  
  156. public CmdVipsOnline(id)
  157. {
  158. if(!is_user_connected(id))
  159. return PLUGIN_CONTINUE;
  160.  
  161. new adminnames[33][32], message[256], i, count, len;
  162. len = format(message, charsmax(message), "!4%s!3 VIPS ONLINE: ", TAG);
  163. for(i = 1 ; i <= max_players; i++)
  164. {
  165. if(is_user_connected(i) && is_user_vip(i))
  166. get_user_name(i, adminnames[count++], charsmax(adminnames[]));
  167. }
  168.  
  169. if(count > 0)
  170. {
  171. for(i = 0; i < count; i++)
  172. {
  173. len += format(message[len], 255 -len, "!4%s!1%s ", adminnames[i], i < (count -1) ? " | " : "");
  174. }
  175. ColorChat(id, message);
  176. }
  177. else
  178. {
  179. len += format(message[len], 255 -len, "!4No one !")
  180. ColorChat(id, message);
  181. }
  182.  
  183. return PLUGIN_CONTINUE;
  184. }
  185.  
  186. public CmdPrintAttributes(id)
  187. {
  188. if(!is_user_connected(id)) return;
  189. show_motd(id, "vip.txt", "Beneficii VIP");
  190. }
  191.  
  192. public event_DeathMsg()
  193. {
  194. new killer = read_data(1), hs = read_data(3);
  195. if(is_user_alive(killer) && is_user_vip(killer))
  196. {
  197. if(killer == read_data(2)) return PLUGIN_HANDLED;
  198.  
  199. new cache = hs ? get_pcvar_num(cvar[hp_hs]) : get_pcvar_num(cvar[hp_kill]);
  200. if(cache != 0) set_user_health(killer, min(get_user_health(killer) + cache, get_pcvar_num(cvar[hp_max])));
  201.  
  202. cache = hs ? get_pcvar_num(cvar[money_hs]) : get_pcvar_num(cvar[money_kill]);
  203. if(cache != 0) cs_set_user_money(killer, min(cs_get_user_money(killer) + cache, 16000));
  204. }
  205.  
  206. return PLUGIN_CONTINUE;
  207. }
  208.  
  209. public event_Damage(victim)
  210. {
  211. if(!get_pcvar_num(cvar[show_bullet_dmg]))
  212. return PLUGIN_CONTINUE;
  213.  
  214. new id = get_user_attacker(victim);
  215. if(is_user_valid(id))
  216. {
  217. if(is_user_alive(id) && !is_user_vip(id))
  218. return PLUGIN_HANDLED;
  219.  
  220. if(read_data(4) || read_data(5) || read_data(6))
  221. {
  222. new iPos = ++g_iPlayerPos[id];
  223. if(iPos == sizeof(g_flCoords))
  224. iPos = g_iPlayerPos[id] = 0;
  225.  
  226. new iCol = ++g_iPlayerCol[id];
  227. if(iCol == sizeof(g_iColors))
  228. iCol = g_iPlayerCol[id] = 0;
  229.  
  230. set_hudmessage(g_iColors[iCol][0], g_iColors[iCol][1], g_iColors[iCol][2], Float:g_flCoords[iPos][0], Float:g_flCoords[iPos][1], 0, 0.1, 2.5, 0.02, 0.02, -1);
  231. show_hudmessage(id, "%d", read_data(2));
  232. }
  233. }
  234.  
  235. return PLUGIN_CONTINUE;
  236. }
  237.  
  238. public event_NewRound()
  239. {
  240. rounds++;
  241. }
  242.  
  243. public event_textmsg()
  244. {
  245. rounds = 0;
  246. }
  247.  
  248. public fw_PlayerSpawnPost(id)
  249. {
  250. if(is_user_vip(id) && is_user_alive(id))
  251. {
  252. set_task(0.25, "give_items", id + 212);
  253. return HAM_IGNORED;
  254. }
  255.  
  256. return HAM_IGNORED;
  257. }
  258.  
  259. public give_items(taskid)
  260. {
  261. new id = taskid - 212;
  262. if(!is_user_alive(id))
  263. return;
  264.  
  265. new cache = get_pcvar_num(cvar[hp_spawn])
  266. if(cache != 0) set_user_health(id, cache);
  267.  
  268. cache = get_pcvar_num(cvar[ap_spawn]);
  269. if(cache != 0) cs_set_user_armor(id, cache, CS_ARMOR_VESTHELM);
  270.  
  271. if(rounds >= 3) ShowVipMenu(id);
  272. }
  273.  
  274. public msg_ScoreAttrib(msgid, dest, id)
  275. {
  276. if(!get_pcvar_num(cvar[show_vip_tab]))
  277. return PLUGIN_CONTINUE;
  278.  
  279. new id = get_msg_arg_int(1);
  280. if(is_user_connected(id) && is_user_vip(id))
  281. set_msg_arg_int(2, ARG_BYTE, is_user_alive(id) ? (1<<2) : (1<<0));
  282.  
  283. return PLUGIN_CONTINUE;
  284. }
  285.  
  286. public ShowVipMenu(id)
  287. {
  288. if(!is_user_connected(id))
  289. return PLUGIN_HANDLED;
  290.  
  291. if(!is_user_vip(id))
  292. {
  293. ColorChat(id, "!4%s!1 Imi pare rau, dar nu ai acces la meniul pentru!3 membrii VIP!1.", TAG);
  294. ColorChat(id, "!4%s!1 Poti cumpara VIP, contactand adresa Y!M:!3 %s!1.", TAG, CONTACT);
  295. return PLUGIN_HANDLED;
  296. }
  297.  
  298. give_item(id, "weapon_hegrenade");
  299. give_item(id, "weapon_flashbang");
  300. give_item(id, "weapon_flashbang");
  301. drop_weapons(id, 2);
  302. give_item(id, "weapon_deagle");
  303. cs_set_user_bpammo(id, CSW_DEAGLE, 35);
  304.  
  305. new menu = menu_create("\rMeniu VIP", "VipMenuHandler");
  306. menu_additem(menu, "M4A1 + Echipament", "1");
  307. menu_additem(menu, "AK-47 + Echipament", "2");
  308. menu_additem(menu, "AWP + Echipament", "3");
  309.  
  310. menu_setprop(menu, MPROP_EXIT, MEXIT_ALL);
  311. menu_display(id, menu, 0);
  312.  
  313. return PLUGIN_CONTINUE;
  314. }
  315.  
  316. public VipMenuHandler(id, menu, item)
  317. {
  318. if(!is_user_connected(id) || item == MENU_EXIT)
  319. {
  320. menu_destroy(menu);
  321. return PLUGIN_HANDLED;
  322. }
  323.  
  324. new data[6], namei[64], access, CallBack;
  325. menu_item_getinfo(menu, item, access, data, charsmax(data), namei, charsmax(namei), CallBack);
  326. new key = str_to_num(data);
  327.  
  328. switch(key)
  329. {
  330. case 1:
  331. {
  332. drop_weapons(id, 1);
  333. give_item(id, "weapon_m4a1");
  334. cs_set_user_bpammo(id, CSW_M4A1, 120);
  335.  
  336. ColorChat(id, "!4%s!1 Ai ales!3 M4A1!1 +!3 Deagle!1 +!3 Set grenade!1 (!31 HE!1 + !32 FB!1).", TAG);
  337. }
  338.  
  339. case 2:
  340. {
  341. drop_weapons(id, 1);
  342. give_item(id, "weapon_ak47");
  343. cs_set_user_bpammo(id, CSW_AK47, 120);
  344.  
  345. ColorChat(id, "!4%s!1 Ai ales!3 AK47!1 +!3 Deagle!1 +!3 Set grenade!1 (!31 HE!1 + !32 FB!1).", TAG);
  346. }
  347.  
  348. case 3:
  349. {
  350. drop_weapons(id, 1);
  351. give_item(id, "weapon_awp");
  352. cs_set_user_bpammo(id, CSW_AWP, 30);
  353.  
  354. ColorChat(id, "!4%s!1 Ai ales!3 AWP!1 +!3 Deagle!1 +!3 Set grenade!1 (!31 HE!1 + !32 FB!1).", TAG);
  355. }
  356. }
  357.  
  358. menu_destroy(menu);
  359. return PLUGIN_HANDLED;
  360. }
  361.  
  362. const PRIMARY_WEAPONS_BIT_SUM = (1<<CSW_SCOUT)|(1<<CSW_XM1014)|(1<<CSW_MAC10)|(1<<CSW_AUG)|(1<<CSW_UMP45)|(1<<CSW_SG550)|(1<<CSW_GALIL)|(1<<CSW_FAMAS)|(1<<CSW_AWP)|(1<<CSW_MP5NAVY)|(1<<CSW_M249)|(1<<CSW_M3)|(1<<CSW_M4A1)|(1<<CSW_TMP)|(1<<CSW_G3SG1)|(1<<CSW_SG552)|(1<<CSW_AK47)|(1<<CSW_P90);
  363. const SECONDARY_WEAPONS_BIT_SUM = (1<<CSW_P228)|(1<<CSW_ELITE)|(1<<CSW_FIVESEVEN)|(1<<CSW_USP)|(1<<CSW_GLOCK18)|(1<<CSW_DEAGLE);
  364.  
  365. // Drop primary/secondary weapons
  366. stock drop_weapons(id, dropwhat)
  367. {
  368. // Get user weapons
  369. static weapons[32], num, i, weaponid, wname[32];
  370. num = 0; // reset passed weapons count (bugfix)
  371. get_user_weapons(id, weapons, num);
  372.  
  373. // Loop through them and drop primaries or secondaries
  374. for (i = 0; i < num; i++)
  375. {
  376. // Prevent re-indexing the array
  377. weaponid = weapons[i];
  378.  
  379. if((dropwhat == 1 && ((1<<weaponid) & PRIMARY_WEAPONS_BIT_SUM)) || (dropwhat == 2 && ((1<<weaponid) & SECONDARY_WEAPONS_BIT_SUM)))
  380. {
  381. // Get weapon entity
  382. get_weaponname(weaponid, wname, charsmax(wname));
  383. engclient_cmd(id, "drop", wname);
  384. }
  385. }
  386. }
  387.  
  388. stock ColorChat(id, String[], any:...)
  389. {
  390. static szMesage[192];
  391. vformat(szMesage, charsmax(szMesage), String, 3);
  392.  
  393. replace_all(szMesage, charsmax(szMesage), "!1", "^1");
  394. replace_all(szMesage, charsmax(szMesage), "!3", "^3");
  395. replace_all(szMesage, charsmax(szMesage), "!4", "^4");
  396.  
  397. static g_msg_SayText = 0;
  398. if(!g_msg_SayText)
  399. g_msg_SayText = get_user_msgid("SayText");
  400.  
  401. new Players[32], iNum = 1, i;
  402.  
  403. if(id) Players[0] = id;
  404. else get_players(Players, iNum, "ch");
  405.  
  406. for(--iNum; iNum >= 0; iNum--)
  407. {
  408. i = Players[iNum];
  409.  
  410. message_begin(MSG_ONE_UNRELIABLE, g_msg_SayText, _, i);
  411. write_byte(i);
  412. write_string(szMesage);
  413. message_end();
  414. }
  415. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement