Advertisement
Guest User

Untitled

a guest
Nov 13th, 2022
46
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.05 KB | None | 0 0
  1. /* -----------------------------------------
  2. Credits: Only for Raulitop, for the hook say :3
  3.  
  4. Version With Saved NFVAULT
  5. ------------------------------- */
  6.  
  7. #include <amxmisc>
  8. #include <fakemeta>
  9. #include <nfvault>
  10.  
  11. new const PLUGIN[] = "Ranges CS:GO"
  12. #define VERSION "1.0"
  13. new const AUTHOR[] = "kikizon"
  14.  
  15. /* =============================================
  16. |= [START MODIFIED SECTION] =|
  17. ==============================================*/
  18. /* ====================================
  19. *[CONST]*
  20. =====================================*/
  21. new const Prefix[] = "!g[RANK]!y" // Prefix in say
  22. new const Sonido[] = "rango/up.wav" // Sound Range UP
  23. /* ====================================
  24. *[CONST NAMES OF RANGES]*
  25. =====================================*/
  26. enum _:DATA
  27. {
  28. NAMES[30],
  29. FRAGS
  30. }
  31. new const Ranges[][DATA] = {
  32. { "Początkowy", 10 },
  33. { "Silver I", 20 },
  34. { "Silver II", 30 },
  35. { "Silver III", 50 },
  36. { "Silver IV", 70 },
  37. { "Silver Elite", 80 },
  38. { "Silver Elite Master", 90 },
  39. { "Gold NovaI", 100 },
  40. { "Gold Nova II", 120 },
  41. { "Gold Nova III", 130 },
  42. { "Gold Nova Master", 140 },
  43. { "Master Guardian I",150 },
  44. { "Master Guardian II", 170 },
  45. { "Master Guardian Elite", 180 },
  46. { "Distinguished Master Guardian", 190 },
  47. { "Legendary Eagle", 200 },
  48. { "Legendary Eagle Master", 210 },
  49. { "Supreme Master First Class", 220 },
  50. { "The Global Elite", 250 }
  51. }
  52.  
  53. /* =============================================
  54. |= [END MODIFIED SECTION] =|
  55. ==============================================*/
  56. /* ====================================
  57. *[VARIABLES]*
  58. =====================================*/
  59. new g_range[33], g_frags[33]
  60. new SyncHUD, g_maxplayers, g_msgTeamInfo, g_msgSayText, g_playername[33][32];
  61. #define TASK_HUD 2100
  62. #define ID_HUD (taskid - TASK_HUD)
  63. #define XD is_user_connected(id) || !is_user_bot(id) || !is_user_hltv(id)
  64. new VaultRanges[128], szRanges[180], szKey[30]
  65.  
  66. /* ====================================
  67. *[Cvars]*
  68. =====================================*/
  69. new cvar_Hud, cvar_knifex2, cvar_hsx2
  70. /* ====================================
  71. *[INIT]*
  72. =====================================*/
  73. public plugin_init() {
  74. register_plugin(PLUGIN, VERSION, AUTHOR)
  75.  
  76. register_event("DeathMsg", "Event_DeathMsg", "a")
  77. register_logevent("logevent_round_end", 2, "1=Round_End")
  78.  
  79. register_clcmd("say", "message_saytext")
  80. register_clcmd("say_team", "message_sayteam")
  81.  
  82.  
  83. /* =============================================
  84. |= [START MODIFIED SECTION] =|
  85. ==============================================*/
  86. cvar_Hud = register_cvar("ranges_hud", "1") // 1 - Show HUD | 0 - No Show
  87. cvar_knifex2 = register_cvar("ranges_knifex2", "0") // 1 - x2 frags with knife | 0 - NO :v
  88. cvar_hsx2 = register_cvar("ranges_hsx2", "0") // 1 - x2 HeadShot Frags | 0 - NO :v
  89. /* =============================================
  90. |= [END MODIFIED SECTION] =|
  91. ==============================================*/
  92.  
  93.  
  94. SyncHUD = CreateHudSyncObj()
  95. g_maxplayers = get_maxplayers()
  96. g_msgTeamInfo = get_user_msgid("TeamInfo")
  97. g_msgSayText = get_user_msgid("SayText")
  98.  
  99. nfv_file("Ranges", VaultRanges, charsmax(VaultRanges))
  100. }
  101. /* ====================================
  102. *[PRECACHE]*
  103. =====================================*/
  104. public plugin_precache()
  105. precache_sound(Sonido)
  106. /* ===================================
  107. *[HUD]*
  108. =====================================*/
  109.  
  110. }
  111. /* ==================================
  112. [PUTINSERVER]
  113. ===================================*/
  114. public client_putinserver(id) {
  115. get_user_name( id, g_playername[ id ], charsmax( g_playername[ ] ) );
  116. g_range[id] = 0
  117. g_frags[id] = 0
  118.  
  119. load(id)
  120.  
  121. if(get_pcvar_num(cvar_Hud))
  122. set_task(1.0, "HUD", id+TASK_HUD, _, _, "b")
  123. }
  124. /* ==================================
  125. [DISCONNECT]
  126. ===================================*/
  127. public client_disconnect(id) {
  128. if(XD) Save(id);
  129.  
  130. remove_task(id+TASK_HUD)
  131. }
  132.  
  133. /* ==================================
  134. [ROUND END]
  135. ===================================*/
  136. public logevent_round_end() {
  137. for(new id = 1; id <= g_maxplayers; id++) {
  138. if(XD)
  139. Save(id);
  140. }
  141. }
  142. /* ==================================
  143. [DEATHMSG]
  144. ===================================*/
  145. public Event_DeathMsg() {
  146. new attacker = read_data(1)
  147. new victim = read_data(2)
  148. new hs = read_data(3)
  149. new weaponid = get_user_weapon(attacker)
  150.  
  151. if(victim == attacker) return;
  152.  
  153. if(is_user_alive(attacker)) {
  154. g_frags[attacker]++
  155.  
  156. if(get_pcvar_num(cvar_knifex2)) {
  157. if(weaponid == CSW_KNIFE)
  158. g_frags[attacker]++
  159. }
  160. if(get_pcvar_num(cvar_hsx2)) {
  161. if(hs) g_frags[attacker]++
  162. }
  163. IncreaseRanges(attacker)
  164. }
  165. }
  166. /* ================================
  167. [UPDATE RANK]
  168. =================================*/
  169. IncreaseRanges(id) {
  170. new Increase = false
  171.  
  172. while(g_frags[id] >= Ranges[g_range[id]][FRAGS]) {
  173. Increase = true
  174. g_range[id]++
  175. }
  176.  
  177. if(Increase) {
  178. chatcolor(id, "%s Gratulacje CSowiczu, awansowales na nowa range: !g[ %s ]", Prefix, Ranges[g_range[id]][NAMES])
  179. client_cmd(id, "spk %s", Sonido)
  180. Increase = false
  181. }
  182. }
  183. /*=====================================
  184. *[SAY]*
  185. =====================================*/
  186. public message_saytext(id) {
  187. static said[192]
  188. read_args(said, charsmax(said))
  189. remove_quotes(said)
  190.  
  191. if (said[0] == '@' || said[0] == '%' || said[0] == '/' || said[0] == '.' || said[0] == '!' || equal (said, ""))
  192. return PLUGIN_HANDLED
  193.  
  194. if (!ValidMessage(said, 1)) return PLUGIN_CONTINUE;
  195.  
  196. static color[11], name[32], alive[11]
  197. get_user_team(id,color,charsmax(color))
  198. get_user_name(id,name,charsmax(name))
  199.  
  200. if (is_user_alive (id)) {
  201. alive = ""
  202. } else {
  203. alive = "[Dead]"
  204. }
  205.  
  206. if (is_user_admin(id)) {
  207. if (get_user_flags(id) & ADMIN_KICK)
  208. format(said, charsmax(said), "^x01%s^x04%s ^x03%s ^x04: %s", alive, Ranges[g_range[id]][NAMES], name, said)
  209. } else {
  210. format(said, charsmax(said), "^x01%s^04%s ^x03%s ^x01: %s", alive, Ranges[g_range[id]][NAMES], name, said)
  211. }
  212.  
  213. static i, team[11]
  214. for (i = 1; i <= g_maxplayers; i++) {
  215. if (!is_user_connected(i)) continue
  216. get_user_name(id,name,charsmax(name))
  217.  
  218. if (is_user_admin(i) || is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i)) {
  219. get_user_team(i, team, charsmax(team))
  220. changeTeamInfo(i, color)
  221. writeMessage(i, said)
  222. changeTeamInfo(i, team)
  223. }
  224. }
  225. return PLUGIN_HANDLED_MAIN;
  226. }
  227.  
  228. public message_sayteam(id)
  229. {
  230. static said[192]
  231. read_args(said, charsmax(said))
  232. remove_quotes(said)
  233.  
  234. if (said[0] == '@' || said[0] == '%' || said[0] == '/' || said[0] == '.' || said[0] == '!' || equal (said, ""))
  235. return PLUGIN_HANDLED
  236.  
  237. if (!ValidMessage(said, 1)) return PLUGIN_CONTINUE;
  238.  
  239. static playerTeam, playerTeamName[19]
  240. playerTeam = get_user_team(id)
  241.  
  242. switch (playerTeam) {
  243. case 1: copy (playerTeamName, 6, "TE")
  244. case 2: copy (playerTeamName, 8, "CT")
  245. default: copy (playerTeamName, 11, "SPEC")
  246. }
  247.  
  248. static color[11], name[32], alive[11]
  249. get_user_team(id,color,charsmax(color))
  250. get_user_name(id,name,charsmax(name))
  251.  
  252. if (is_user_alive (id)) {
  253. alive = ""
  254. } else {
  255. alive = "[Dead]"
  256. }
  257.  
  258. if (is_user_admin(id)) {
  259. if (get_user_flags(id) & ADMIN_RCON)
  260. format(said, charsmax(said), "^x01%s [ %s ] ^x04%s ^x03%s ^x04: %s", alive, playerTeam, Ranges[g_range[id]], name, said)
  261. } else {
  262. format(said, charsmax(said), "^x01%s [ %s ] ^04%s ^x03%s ^x01: %s", alive, playerTeam, Ranges[g_range[id]],name, said)
  263. }
  264.  
  265. static i, team[11]
  266. for (i = 1; i <= g_maxplayers; i++) {
  267. if (!is_user_connected(i)) continue;
  268. get_user_name(id,name,charsmax(name))
  269.  
  270. if (get_user_team(i) == playerTeam || is_user_admin(i)) {
  271. if (is_user_alive(id) && is_user_alive(i) || !is_user_alive(id) && !is_user_alive(i)) {
  272. get_user_team(i, team, charsmax(team))
  273. changeTeamInfo(i, color)
  274. writeMessage(i, said)
  275. changeTeamInfo(i, team)
  276. }
  277. }
  278. }
  279. return PLUGIN_HANDLED_MAIN;
  280. }
  281. public changeTeamInfo(player, team[]) {
  282. message_begin(MSG_ONE, g_msgTeamInfo, _, player)
  283. write_byte(player)
  284. write_string(team)
  285. message_end()
  286. }
  287.  
  288.  
  289.  
  290.  
  291. public writeMessage(player, message[]) {
  292. message_begin(MSG_ONE, g_msgSayText, {0, 0, 0}, player)
  293. write_byte(player)
  294. write_string(message)
  295. message_end()
  296. }
  297. /* ===================================
  298. *[SAVE]*
  299. =====================================*/
  300. Save(id) {
  301. formatex(szKey, charsmax(szKey), "data_ranges")
  302. formatex(szRanges, charsmax(szRanges), "%d %d", g_frags[id], g_range[id])
  303.  
  304. nfv_set_data(VaultRanges, szKey, g_playername[id], szRanges)
  305. }
  306.  
  307. load(id) {
  308. new g_load_c1[25], g_load_c2[25]
  309. formatex(szKey, charsmax(szKey), "data_ranges")
  310.  
  311. if(!nfv_get_data(VaultRanges, szKey, g_playername[id], szRanges, sizeof(szRanges) - 1)) return;
  312.  
  313. parse(szRanges, g_load_c1, charsmax(g_load_c1), g_load_c2, charsmax(g_load_c2))
  314.  
  315. g_frags[id] = str_to_num(g_load_c1)
  316. g_range[id] = str_to_num(g_load_c2)
  317. }
  318. /* ===================================
  319. *[STOCKS]*
  320. =====================================*/
  321. // stock of chatcolor
  322. stock chatcolor(id, const input[], any:...) {
  323. new count = 1, players[32];
  324. static msg[191];
  325. vformat(msg, 190, input, 3);
  326.  
  327. replace_all(msg, 190, "!g", "^4"); // Green
  328. replace_all(msg, 190, "!y", "^1"); // Default
  329. replace_all(msg, 190, "!t", "^3"); // Color of team
  330.  
  331. if (id) players[0] = id; else get_players(players, count, "ch"); {
  332. for (new i = 0; i < count; i++) {
  333. if (is_user_connected(players[i])) {
  334. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);
  335. write_byte(players[i]);
  336. write_string(msg);
  337. message_end();
  338. }
  339. }
  340. }
  341. }
  342. // Stock to Know If the message is valid
  343. stock ValidMessage(text[], maxcount) {
  344. static len, i, count
  345. len = strlen(text)
  346. count = 0
  347.  
  348. if (!len)
  349. return false;
  350.  
  351. for (i = 0; i < len; i++) {
  352. if (text[i] != ' ') {
  353. count++
  354. if (count >= maxcount)
  355. return true;
  356. }
  357. }
  358. return false;
  359. }
  360. /* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
  361. *{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang3082\\ f0\\ fs16 \n\\ par }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement