Advertisement
Guest User

Untitled

a guest
Feb 20th, 2020
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.76 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <cstrike>
  3. #include <engine>
  4. #include <fakemeta>
  5. #include <fun>
  6. #include <hamsandwich>
  7. #include <stripweapons>
  8. #include <ColorChat>
  9.  
  10. #define FLAG ADMIN_LEVEL_H
  11.  
  12. new Array:gArray, bool:gVip[33], jumps[33], weaponID;
  13.  
  14. new const onlineCommandVIP[][] =
  15. {
  16. "/vips",
  17. "vips",
  18. "/vipy",
  19. "vipy"
  20. };
  21.  
  22. new const motdCommandVIP[][] =
  23. {
  24. "/vip",
  25. "vip"
  26. };
  27.  
  28. new const vipPrefix[] = "[^x04VIP^x01]";
  29.  
  30. public plugin_init()
  31. {
  32. register_plugin("Paintball: Vip", "1.0", "AMXX.PL");
  33.  
  34. register_forward(FM_CmdStart, "cmdStartPre");
  35.  
  36. RegisterHam(Ham_Spawn, "player", "spawnedEventPre", 1);
  37.  
  38. register_message(get_user_msgid("ScoreAttrib"), "vipStatus");
  39.  
  40. registerCommands(onlineCommandVIP, sizeof(onlineCommandVIP), "showVips");
  41. registerCommands(motdCommandVIP, sizeof(motdCommandVIP), "descrVIP");
  42.  
  43. register_message(get_user_msgid("SayText"), "handleSayText");
  44.  
  45. set_task(30.0, "information", .flags = "b");
  46.  
  47. gArray = ArrayCreate(64, 32);
  48. }
  49.  
  50. public client_authorized(index, const authid[])
  51. {
  52. if(get_user_flags(index) & FLAG)
  53. {
  54. client_authorized_vip(index);
  55. }
  56. }
  57.  
  58. public client_authorized_vip(index)
  59. {
  60. gVip[index] = true;
  61.  
  62. new name[64], gName[64];
  63. new gSize = ArraySize(gArray);
  64.  
  65. get_user_name(index, name, charsmax(name));
  66.  
  67. for(new i = 0; i < gSize; i++)
  68. {
  69. ArrayGetString(gArray, i, gName, charsmax(gName));
  70. }
  71.  
  72. ArrayPushString(gArray, gName);
  73. return PLUGIN_CONTINUE;
  74. }
  75.  
  76. public client_disconnected(index)
  77. {
  78. if(gVip[index])
  79. {
  80. client_disconnect_vip(index);
  81. }
  82. }
  83.  
  84. public client_disconnect_vip(index)
  85. {
  86. gVip[index] = false;
  87.  
  88. new name[64], gName[64],
  89. gSize = ArraySize(gArray);
  90.  
  91. get_user_name(index, name, charsmax(name));
  92.  
  93. for(new i = 0; i < gSize; i++)
  94. {
  95. ArrayGetString(gArray, i, name, charsmax(gName));
  96.  
  97. if(equal(name, gName))
  98. {
  99. ArrayDeleteItem(gArray, i);
  100. break;
  101. }
  102. }
  103. }
  104.  
  105. public cmdStartPre(index, uc_handle)
  106. {
  107. if(gVip[index])
  108. {
  109. if(is_user_alive(index))
  110. {
  111. cmdStartPreVip(index, uc_handle);
  112. }
  113. }
  114. }
  115.  
  116. public cmdStartPreVip(index, uc_handle)
  117. {
  118. new flags = pev(index, pev_flags);
  119.  
  120. if((get_uc(uc_handle, UC_Buttons) & IN_JUMP) && !(flags & FL_ONGROUND) && !(pev(index, pev_oldbuttons) & IN_JUMP) && jumps[index] > 0)
  121. {
  122. new Float:velocity[3];
  123.  
  124. --jumps[index];
  125.  
  126. pev(index, pev_velocity, velocity);
  127. velocity[2] = random_float(265.0, 285.0);
  128. set_pev(index, pev_velocity, velocity);
  129. }
  130. else if(flags & FL_ONGROUND && jumps[index] != -1)
  131. {
  132. jumps[index] = 1;
  133. }
  134. }
  135.  
  136. public spawnedEventPre(index)
  137. {
  138. if(gVip[index])
  139. {
  140. if(is_user_alive(index))
  141. {
  142. spawnedEventPreVip(index);
  143. }
  144. }
  145. }
  146.  
  147. public spawnedEventPreVip(index)
  148. {
  149. jumps[index] = 1;
  150.  
  151. StripWeapons(index, Primary);
  152.  
  153. give_item(index, "weapon_p90");
  154. give_item(index, "ammo_57mm");
  155.  
  156. weaponID = find_ent_by_owner(-1, "weapon_p90", index);
  157.  
  158. if(weaponID)
  159. {
  160. cs_set_weapon_ammo(weaponID, 50);
  161. }
  162. cs_set_user_bpammo(index, CSW_P90, 160);
  163. }
  164.  
  165. public vipStatus()
  166. {
  167. new index = get_msg_arg_int(1);
  168.  
  169. if(is_user_alive(index) && gVip[index])
  170. {
  171. set_msg_arg_int(2, ARG_BYTE, get_msg_arg_int(2) | 4);
  172. }
  173. }
  174.  
  175. public showVips(index)
  176. {
  177. new name[64], message[192],
  178. gSize = ArraySize(gArray);
  179.  
  180. for(new i = 0; i < gSize; i++)
  181. {
  182. ArrayGetString(gArray, i, name, charsmax(name));
  183.  
  184. add(message, charsmax(message), name);
  185.  
  186. if(i == gSize -1)
  187. {
  188. add(message, charsmax(message), ".");
  189. }
  190. else
  191. {
  192. add(message, charsmax(message), ",");
  193. }
  194. }
  195. ColorChat(index, NORMAL, "%s Vipy dostepne na serwerze:^x04 %s", vipPrefix, message);
  196. }
  197.  
  198. public clinet_infochanged(index)
  199. {
  200. if(gVip[index])
  201. {
  202. new name[64], gName[64];
  203.  
  204. get_user_info(index, "name", name, charsmax(name));
  205. get_user_name(index, gName, charsmax(gName));
  206.  
  207. if(!equal(name, gName))
  208. {
  209. new gSize = ArraySize(gArray),
  210. szName[64];
  211.  
  212. for(new i = 0; i < gSize; i++)
  213. {
  214. ArrayGetString(gArray, i, szName, charsmax(szName));
  215.  
  216. if(equal(szName, gName))
  217. {
  218. ArrayDeleteItem(gArray, i);
  219. break;
  220. }
  221. }
  222. }
  223. }
  224. }
  225.  
  226. public plugin_end()
  227. {
  228. ArrayDestroy(gArray);
  229. }
  230.  
  231. public descrVIP(index)
  232. {
  233. show_motd(index, "vip.txt", "Infomracje o vip'ie");
  234. }
  235.  
  236. public information(index)
  237. {
  238. ColorChat(index, NORMAL, "%s Aby dowiedzic sie co posiada^x04 VIP^x01, wpisz na say'u^x03 /vip^x01", vipPrefix);
  239. }
  240.  
  241. public handleSayText(msgId, msgDest, msgEnt) {
  242.  
  243. new id = get_msg_arg_int(1);
  244.  
  245. if(!is_user_connected(id) || !gVip[id]) return PLUGIN_CONTINUE;
  246.  
  247. new szTmp[192], szTmp2[192];
  248. get_msg_arg_string(2, szTmp, charsmax(szTmp));
  249.  
  250. new szPrefix[64] = "^x04[VIP]";
  251.  
  252. if(!equal(szTmp,"#Cstrike_Chat_All")){
  253. add(szTmp2, charsmax(szTmp2), "^x01");
  254. add(szTmp2, charsmax(szTmp2), szPrefix);
  255. add(szTmp2, charsmax(szTmp2), " ");
  256. add(szTmp2, charsmax(szTmp2), szTmp);
  257. }
  258. else{
  259. new szPlayerName[64];
  260. get_user_name(id, szPlayerName, charsmax(szPlayerName));
  261.  
  262. get_msg_arg_string(4, szTmp, charsmax(szTmp));
  263. set_msg_arg_string(4, "");
  264.  
  265. add(szTmp2, charsmax(szTmp2), "^x01");
  266. add(szTmp2, charsmax(szTmp2), szPrefix);
  267. add(szTmp2, charsmax(szTmp2), "^x03 ");
  268. add(szTmp2, charsmax(szTmp2), szPlayerName);
  269. add(szTmp2, charsmax(szTmp2), "^x01 : ");
  270. add(szTmp2, charsmax(szTmp2), szTmp)
  271. }
  272.  
  273. set_msg_arg_string(2, szTmp2);
  274.  
  275. return PLUGIN_CONTINUE;
  276. }
  277.  
  278. stock registerCommands(const array[][], arraySize, function[])
  279. {
  280. #if !defined ForRange
  281. #define ForRange(%1,%2,%3) for(new %1 = %2; %1 <= %3; %1++)
  282. #define ForArray(%1,%2) for(new %1 = 0; %1 < gSizeof %2; %1++)
  283. #endif
  284.  
  285. new newCommand[33];
  286.  
  287. ForRange(i, 0, arraySize - 1)
  288. {
  289. ForRange(j, 0, 1)
  290. {
  291. formatex(newCommand, charsmax(newCommand), "%s %s", !j ? "say" : "say_team", array[i]);
  292. register_clcmd(newCommand, function);
  293. }
  294. }
  295. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement