Guest User

da

a guest
Dec 12th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 18.14 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <celltrie>
  4. #include <cstrike>
  5.  
  6. #define VERSION "4.0"
  7. #define FLAG_LOAD ADMIN_CFG
  8. #define MAX_PREFIXES 33
  9. #define MAX_BAD_PREFIXES 100
  10.  
  11. new teamInfo;
  12. new g_bad_prefix,g_custom, g_custom_flag, g_say_characters, g_prefix_characters;
  13. new pre_ips_count = 0, pre_names_count = 0, pre_steamids_count, pre_flags_count = 0, bad_prefix_count = 0, i, temp_cvar[2];
  14. new configs_dir[64], file_prefixes[128], file_bad_prefixes[128], text[128], prefix[32], type[2], key[32], length, line = 0, error[256];
  15. new g_saytxt, g_maxplayers, CsTeams:g_team;
  16. new g_typed[192], g_name[32];
  17. new Trie:pre_ips_collect, Trie:pre_names_collect, Trie:pre_steamids_collect, Trie:pre_flags_collect, Trie:bad_prefixes_collect, Trie:client_prefix;
  18. new str_id[16], temp_key[35], temp_prefix[32], temp_value;
  19. new bool:g_toggle[33];
  20. new strName[191]
  21. new strText[191]
  22.  
  23. new const say_team_info[2][CsTeams][] =
  24. {
  25. {"*SPEC* ", "*DEAD* ", "*DEAD* ", "*SPEC* "},
  26. {"", "", "", ""}
  27. }
  28.  
  29. new const sayteam_team_info[2][CsTeams][] =
  30. {
  31. {"(Spectator) ", "*DEAD*(Terrorist) ", "*DEAD*(Counter-Terrorist) ", "(Spectator) "},
  32. {"(Spectator) ", "(Terrorist) ", "(Counter-Terrorist) ", "(Spectator) "}
  33. }
  34.  
  35. new const forbidden_say_symbols[] = {
  36. "/",
  37. "!",
  38. "%",
  39. "$"
  40. }
  41.  
  42. new const forbidden_prefixes_symbols[] = {
  43. "/",
  44. "\\\\",
  45. "%",
  46. "$",
  47. ".",
  48. ":",
  49. "?",
  50. "!",
  51. "@",
  52. "#",
  53. "%"
  54. }
  55.  
  56. new const separator[] = "************************************************"
  57. new const in_prefix[] = "[AdminPrefixes]"
  58.  
  59. public plugin_init()
  60. {
  61. register_plugin("Admin Prefixes", VERSION, "m0skVi4a ;]")
  62.  
  63. g_bad_prefix = register_cvar("ap_bad_prefixes", "1")
  64. g_custom = register_cvar("ap_custom_current", "1")
  65. g_custom_flag = register_cvar("ap_custom_current_flag", "b")
  66. g_say_characters = register_cvar("ap_say_characters", "1")
  67. g_prefix_characters = register_cvar("ap_prefix_characters", "1")
  68.  
  69. g_saytxt = get_user_msgid ("SayText")
  70. g_maxplayers = get_maxplayers()
  71. teamInfo = get_user_msgid ("TeamInfo")
  72.    
  73. register_concmd("ap_reload_prefixes", "LoadPrefixes")
  74. register_concmd("ap_reload_badprefixes", "LoadBadPrefixes")
  75. register_concmd("ap_put", "SetPlayerPrefix")
  76. register_clcmd("say", "HookSay")
  77. register_clcmd("say_team", "HookSayTeam")
  78.  
  79. pre_ips_collect = TrieCreate()
  80. pre_names_collect = TrieCreate()
  81. pre_steamids_collect = TrieCreate()
  82. pre_flags_collect = TrieCreate()
  83. bad_prefixes_collect = TrieCreate()
  84. client_prefix = TrieCreate()
  85.  
  86. register_dictionary("admin_prefixes.txt")
  87.  
  88. get_configsdir(configs_dir, charsmax(configs_dir))
  89. formatex(file_prefixes, charsmax(file_prefixes), "%s/ap_prefixes.ini", configs_dir)
  90. formatex(file_bad_prefixes, charsmax(file_bad_prefixes), "%s/ap_bad_prefixes.ini", configs_dir)
  91.  
  92. LoadPrefixes(0)
  93. LoadBadPrefixes(0)
  94. }
  95.  
  96. public LoadPrefixes(id)
  97. {
  98. if(!(get_user_flags(id) & FLAG_LOAD))
  99. {
  100. console_print(id, "%L", LANG_SERVER, "PREFIX_PERMISSION", in_prefix)
  101. return PLUGIN_HANDLED
  102. }
  103.  
  104. TrieClear(pre_ips_collect)
  105. TrieClear(pre_names_collect)
  106. TrieClear(pre_steamids_collect)
  107. TrieClear(pre_flags_collect)
  108.  
  109. line = 0, length = 0, pre_flags_count = 0, pre_ips_count = 0, pre_names_count = 0;
  110.  
  111. if(!file_exists(file_prefixes))
  112. {
  113. formatex(error, charsmax(error), "%L", LANG_SERVER, "PREFIX_NOT_FOUND", in_prefix, file_prefixes)
  114. set_fail_state(error)
  115. }
  116.  
  117. server_print(separator)
  118.  
  119. while(read_file(file_prefixes, line++ , text, charsmax(text), length) && (pre_ips_count + pre_names_count + pre_steamids_count + pre_flags_count) <= MAX_PREFIXES)
  120. {
  121. if(!text[0] || text[0] == '^n' || text[0] == ';' || (text[0] == '/' && text[1] == '/'))
  122. continue
  123.  
  124. parse(text, type, charsmax(type), key, charsmax(key), prefix, charsmax(prefix))
  125. trim(prefix)
  126.  
  127. if(!type[0] || !prefix[0] || !key[0])
  128. continue
  129.  
  130. replace_all(prefix, charsmax(prefix), "!g", "^x04")
  131. replace_all(prefix, charsmax(prefix), "!t", "^x03")
  132. replace_all(prefix, charsmax(prefix), "!n", "^x01")
  133.  
  134. switch(type[0])
  135. {
  136. case 'f':
  137. {
  138. pre_flags_count++
  139. TrieSetString(pre_flags_collect, key, prefix)
  140. server_print("%L", LANG_SERVER, "PREFIX_LOAD_FLAG", in_prefix, prefix, key[0])
  141. }
  142. case 'i':
  143. {
  144. pre_ips_count++
  145. TrieSetString(pre_ips_collect, key, prefix)
  146. server_print("%L", LANG_SERVER, "PREFIX_LOAD_IP", in_prefix, prefix, key)
  147. }
  148. case 's':
  149. {
  150. pre_steamids_count++
  151. TrieSetString(pre_steamids_collect, key, prefix)
  152. server_print("%L", LANG_SERVER, "PREFIX_LOAD_STEAMID", in_prefix, prefix, key)
  153. }
  154. case 'n':
  155. {
  156. pre_names_count++
  157. TrieSetString(pre_names_collect, key, prefix)
  158. server_print("%L", LANG_SERVER, "PREFIX_LOAD_NAME", in_prefix, prefix, key)
  159. }
  160. default:
  161. {
  162. continue
  163. }
  164. }
  165. }
  166.  
  167. if(pre_flags_count <= 0 && pre_ips_count <= 0 && pre_steamids_count <= 0 && pre_names_count <= 0)
  168. {
  169. server_print("%L", LANG_SERVER, "PREFIX_NO", in_prefix)
  170. }
  171.  
  172. get_user_name(id, g_name, charsmax(g_name))
  173. server_print("%L", LANG_SERVER, "PREFIX_LOADED_BY", in_prefix, g_name)
  174. console_print(id, "%L", LANG_SERVER, "PREFIX_LOADED", in_prefix)
  175.  
  176. server_print(separator)
  177.  
  178. for(new i = 1; i <= g_maxplayers; i++)
  179. {
  180. num_to_str(i, str_id, charsmax(str_id))
  181. TrieDeleteKey(client_prefix, str_id)
  182. PutPrefix(i)
  183. }
  184.  
  185. return PLUGIN_HANDLED
  186. }
  187.  
  188. public LoadBadPrefixes(id)
  189. {
  190. if(!get_pcvar_num(g_bad_prefix))
  191. {
  192. console_print(id, "%L", LANG_SERVER, "BADP_OFF", in_prefix)
  193. return PLUGIN_HANDLED
  194. }
  195.  
  196. if(!(get_user_flags(id) & FLAG_LOAD))
  197. {
  198. console_print(id, "%L", LANG_SERVER, "BADP_PERMISSION", in_prefix)
  199. return PLUGIN_HANDLED
  200. }
  201.  
  202. TrieClear(bad_prefixes_collect)
  203.  
  204. line = 0, length = 0, bad_prefix_count = 0;
  205.  
  206. if(!file_exists(file_bad_prefixes))
  207. {
  208. console_print(id, "%L", LANG_SERVER, "BADP_NOT_FOUND", in_prefix, file_bad_prefixes)
  209. return PLUGIN_HANDLED  
  210. }
  211.  
  212. server_print(separator)
  213.  
  214. while(read_file(file_bad_prefixes, line++ , text, charsmax(text), length) && bad_prefix_count <= MAX_BAD_PREFIXES)
  215. {
  216. if(!text[0] || text[0] == '^n' || text[0] == ';' || (text[0] == '/' && text[1] == '/'))
  217. continue
  218.  
  219. parse(text, prefix, charsmax(prefix))
  220.  
  221. if(!prefix[0])
  222. continue
  223.  
  224. bad_prefix_count++
  225. TrieSetCell(bad_prefixes_collect, prefix, 1)
  226. server_print("%L", LANG_SERVER, "BADP_LOAD", in_prefix, prefix)
  227. }
  228.  
  229. if(bad_prefix_count <= 0)
  230. {
  231. server_print("%L", LANG_SERVER, "BADP_NO", in_prefix)
  232. }
  233.  
  234. get_user_name(id, g_name, charsmax(g_name))
  235. server_print("%L", LANG_SERVER, "BADP_LOADED_BY", in_prefix, g_name)
  236. console_print(id, "%L", LANG_SERVER, "BADP_LOADED", in_prefix)
  237.  
  238. server_print(separator)
  239.  
  240. return PLUGIN_HANDLED
  241. }
  242.  
  243. public client_putinserver(id)
  244. {
  245. g_toggle[id] = true
  246. num_to_str(id, str_id, charsmax(str_id))
  247. TrieSetString(client_prefix, str_id, "")
  248. PutPrefix(id)
  249. }
  250.  
  251. public HookSay(id)
  252. {
  253.     read_args(g_typed, charsmax(g_typed))
  254.     remove_quotes(g_typed)
  255.  
  256.     trim(g_typed)
  257.  
  258.     if(equal(g_typed, "") || !is_user_connected(id))
  259.     return PLUGIN_HANDLED_MAIN
  260.  
  261.     if(equal(g_typed, "/prefix"))
  262.     {
  263.     if(g_toggle[id])
  264.     {
  265.     g_toggle[id] = false
  266.     client_print(id, print_chat, "%L", LANG_SERVER, "PREFIX_OFF", in_prefix)
  267.     }
  268.     else
  269.     {
  270.     g_toggle[id] = true
  271.     client_print(id, print_chat, "%L", LANG_SERVER, "PREFIX_ON", in_prefix)
  272.     }
  273.  
  274.     return PLUGIN_HANDLED_MAIN
  275.     }
  276.  
  277.     if(!g_toggle[id])
  278.     return PLUGIN_CONTINUE
  279.  
  280.     num_to_str(id, str_id, charsmax(str_id))
  281.  
  282.     if((TrieGetString(client_prefix, str_id, temp_prefix, charsmax(temp_prefix)) && get_pcvar_num(g_say_characters) == 1) || (!TrieGetString(client_prefix, str_id, temp_prefix, charsmax(temp_prefix)) && get_pcvar_num(g_say_characters) == 2) || get_pcvar_num(g_say_characters) == 3)
  283.     {
  284.     if(check_say_characters(g_typed))
  285.     return PLUGIN_HANDLED_MAIN
  286.     }
  287.  
  288.     get_user_name(id, g_name, charsmax(g_name));
  289.     g_team = cs_get_user_team(id);
  290.     static color[10];
  291.     if(is_user_admin(id))
  292.     {
  293.         if(temp_prefix[0])
  294.         {
  295.             get_user_team (id, color, 9)
  296.             format (strName, 191, "%s^x03%s", say_team_info[is_user_alive(id)][g_team],temp_prefix, g_name)
  297.             format (strText, 191, "%^x04s", g_typed)
  298.         }else{
  299.             get_user_team (id, color, 9)
  300.             format (strName, 191, "%s^x04%s^x03%s", say_team_info[is_user_alive(id)][g_team], g_name)
  301.             format (strText, 191, "^x04%s", g_typed)
  302.         }
  303.     }else{
  304.         if(temp_prefix[0])
  305.         {
  306.             get_user_team (id, color, 9)
  307.             format (strName, 191, "%s^x03%s", say_team_info[is_user_alive(id)][g_team],temp_prefix, g_name)
  308.             format (strText, 191, "%s", g_typed)
  309.         }else{
  310.             get_user_team (id, color, 9)
  311.             format (strName, 191, "%s^x04%s^x03%s", say_team_info[is_user_alive(id)][g_team], g_name)
  312.             format (strText, 191, "%s", g_typed)
  313.         }
  314.     }
  315.     format (g_typed, 191, "%s^x01 :  %s", strName, strText)
  316.     sendMessage (color);
  317.     return PLUGIN_CONTINUE
  318. }
  319.  
  320. public HookSayTeam(id)
  321. {
  322.     read_args(g_typed, charsmax(g_typed))
  323.     remove_quotes(g_typed)
  324.  
  325.     trim(g_typed)
  326.  
  327.     if(equal(g_typed, "") || !is_user_connected(id))
  328.     return PLUGIN_HANDLED_MAIN
  329.  
  330.     if(equal(g_typed, "/prefix"))
  331.     {
  332.         if(g_toggle[id])
  333.         {
  334.             g_toggle[id] = false
  335.             client_print(id, print_chat, "%L", LANG_SERVER, "PREFIX_OFF", in_prefix)
  336.         }
  337.         else
  338.         {
  339.             g_toggle[id] = true
  340.             client_print(id, print_chat, "%L", LANG_SERVER, "PREFIX_ON", in_prefix)
  341.         }
  342.         return PLUGIN_HANDLED_MAIN
  343.     }
  344.  
  345.     if(!g_toggle[id])
  346.         return PLUGIN_CONTINUE
  347.  
  348.     num_to_str(id, str_id, charsmax(str_id))
  349.     if((TrieGetString(client_prefix, str_id, temp_prefix, charsmax(temp_prefix)) && get_pcvar_num(g_say_characters) == 1) || (!TrieGetString(client_prefix, str_id, temp_prefix, charsmax(temp_prefix)) && get_pcvar_num(g_say_characters) == 2) || get_pcvar_num(g_say_characters) == 3)
  350.     {
  351.         if(check_say_characters(g_typed))
  352.             return PLUGIN_HANDLED_MAIN
  353.     }
  354.  
  355.     get_user_name(id, g_name, charsmax(g_name))
  356.     g_team = cs_get_user_team(id)
  357.     static color[10];
  358.     if(is_user_admin(id))
  359.     {
  360.         if(temp_prefix[0])
  361.         {
  362.             get_user_team (id, color, 9)
  363.             format (strName, 191, "%s^x03%s", sayteam_team_info[is_user_alive(id)][g_team],temp_prefix, g_name)
  364.             format (strText, 191, "%^x04s", g_typed)
  365.         }else{
  366.             get_user_team (id, color, 9)
  367.             format (strName, 191, "%s^x04%s^x03%s", sayteam_team_info[is_user_alive(id)][g_team], g_name)
  368.             format (strText, 191, "^x04%s", g_typed)
  369.         }
  370.     }else{
  371.         if(temp_prefix[0])
  372.         {
  373.             get_user_team (id, color, 9)
  374.             format (strName, 191, "%s^x03%s", sayteam_team_info[is_user_alive(id)][g_team],temp_prefix, g_name)
  375.             format (strText, 191, "%s", g_typed)
  376.         }else{
  377.             get_user_team (id, color, 9)
  378.             format (strName, 191, "%s^x04%s^x03%s", sayteam_team_info[is_user_alive(id)][g_team], g_name)
  379.             format (strText, 191, "%s", g_typed)
  380.         }
  381.     }
  382.     new tm = get_user_team(id);
  383.     format (g_typed, 191, "%s^x01 :  %s", strName, strText);
  384.     sendTeamMessage (color,tm);
  385.     return PLUGIN_CONTINUE;
  386. }
  387.  
  388. public SetPlayerPrefix(id)
  389. {
  390.     if(!get_pcvar_num(g_custom) || !get_pcvar_string(g_custom_flag, temp_cvar, charsmax(temp_cvar)))
  391.     {
  392.     console_print(id, "%L", LANG_SERVER, "CUSTOM_OFF", in_prefix)
  393.     return PLUGIN_HANDLED
  394.     }
  395.  
  396.     if(!(get_user_flags(id) & read_flags(temp_cvar)))
  397.     {
  398.     console_print(id, "%L", LANG_SERVER, "CUSTOM_PERMISSION", in_prefix)
  399.     return PLUGIN_HANDLED
  400.     }
  401.  
  402.     new input[128], target;
  403.     new arg_type[2], arg_prefix[32], arg_key[35];
  404.     new temp_str[16];
  405.  
  406.     read_args(input, charsmax(input))
  407.     remove_quotes(input)
  408.     parse(input, arg_type, charsmax(arg_type), arg_key, charsmax(arg_key), arg_prefix, charsmax(arg_prefix))
  409.     trim(arg_prefix)
  410.  
  411.     if(get_pcvar_num(g_bad_prefix) && is_bad_prefix(arg_prefix) && !equali(arg_prefix, ""))
  412.     {
  413.     console_print(id, "%L", LANG_SERVER, "CUSTOM_FORBIDDEN", in_prefix, arg_prefix)
  414.     return PLUGIN_HANDLED
  415.     }
  416.  
  417.     if(get_pcvar_num(g_prefix_characters) && check_prefix_characters(arg_prefix))
  418.     {
  419.     console_print(id, "%L", LANG_SERVER, "CUSTOM_SYMBOL", in_prefix, arg_prefix, forbidden_prefixes_symbols[i])
  420.     return PLUGIN_HANDLED
  421.     }
  422.  
  423.     switch(arg_type[0])
  424.     {
  425.     case 'f':
  426.     {
  427.     target = 0
  428.     temp_str = "Flag"
  429.     }
  430.     case 'i':
  431.     {
  432.     target = find_player("d", arg_key)
  433.     temp_str = "IP"
  434.     }
  435.     case 's':
  436.     {
  437.     target = find_player("c", arg_key)
  438.     temp_str = "SteamID"
  439.     }
  440.     case 'n':
  441.     {
  442.     target = find_player("a", arg_key)
  443.     temp_str = "Name"
  444.     }
  445.     default:
  446.     {
  447.     console_print(id, "%L", LANG_SERVER, "CUSTOM_INVALID", in_prefix, arg_type)
  448.     return PLUGIN_HANDLED
  449.     }
  450.     }
  451.  
  452.     get_user_name(id, g_name, charsmax(g_name))
  453.  
  454.     if(equali(arg_prefix, ""))
  455.     {
  456.     find_and_delete(arg_type, arg_key)
  457.  
  458.     if(target)
  459.     {
  460.     PutPrefix(target)
  461.     }
  462.  
  463.     console_print(id, "%L", LANG_SERVER, "CUSTOM_REMOVE", in_prefix, temp_str, arg_key)
  464.     server_print("%L", LANG_SERVER, "CUSTOM_REMOVE_INFO", in_prefix, g_name, temp_str, arg_key)
  465.     return PLUGIN_HANDLED
  466.     }
  467.  
  468.     find_and_delete(arg_type, arg_key)
  469.  
  470.     formatex(text, charsmax(text), "^"%s^" ^"%s^" ^"%s^"", arg_type, arg_key, arg_prefix)
  471.     write_file(file_prefixes, text, -1)
  472.  
  473.     switch(arg_type[0])
  474.     {
  475.     case 'f':
  476.     {
  477.     TrieSetString(pre_flags_collect, arg_key, arg_prefix)
  478.     }
  479.     case 'i':
  480.     {
  481.     TrieSetString(pre_ips_collect, arg_key, arg_prefix)
  482.     }
  483.     case 's':
  484.     {
  485.     TrieSetString(pre_steamids_collect, arg_key, arg_prefix)
  486.     }
  487.     case 'n':
  488.     {
  489.     TrieSetString(pre_names_collect, arg_key, arg_prefix)
  490.     }
  491.     }
  492.  
  493.     if(target)
  494.     {
  495.     num_to_str(target, str_id, charsmax(str_id))
  496.     TrieSetString(client_prefix, str_id, arg_prefix)
  497.     }
  498.  
  499.     console_print(id, "%L", LANG_SERVER, "CUSTOM_CHANGE", in_prefix, temp_str, arg_key, arg_prefix)
  500.     server_print("%L", LANG_SERVER, "CUSTOM_CHANGE_INFO", in_prefix, g_name, temp_str, arg_key, arg_prefix)
  501.  
  502.     return PLUGIN_HANDLED
  503. }
  504.  
  505. public client_infochanged(id)
  506. {
  507. if(!is_user_connected(id))
  508. return PLUGIN_CONTINUE
  509.  
  510. new g_old_name[32];
  511.  
  512. get_user_info(id, "name", g_name, charsmax(g_name))
  513. get_user_name(id, g_old_name, charsmax(g_old_name))
  514.  
  515. if(!equal(g_name, g_old_name))
  516. {
  517. num_to_str(id, str_id, charsmax(str_id))
  518. TrieSetString(client_prefix, str_id, "")
  519. set_task(0.5, "PutPrefix", id)
  520. return PLUGIN_HANDLED
  521. }
  522.  
  523. return PLUGIN_CONTINUE
  524. }
  525.  
  526. public PutPrefix(id)
  527. {
  528. num_to_str(id, str_id, charsmax(str_id))
  529. TrieSetString(client_prefix, str_id, "")
  530.  
  531. new sflags[32], temp_flag[2];
  532. get_flags(get_user_flags(id), sflags, charsmax(sflags))
  533.  
  534. for(new i = 0; i <= charsmax(sflags); i++)
  535. {
  536. formatex(temp_flag, charsmax(temp_flag), "%c", sflags[i])
  537.  
  538. if(TrieGetString(pre_flags_collect, temp_flag, temp_prefix, charsmax(temp_prefix)))
  539. {
  540. TrieSetString(client_prefix, str_id, temp_prefix)
  541. }
  542. }
  543.  
  544. get_user_ip(id, temp_key, charsmax(temp_key), 1)
  545.  
  546. if(TrieGetString(pre_ips_collect, temp_key, temp_prefix, charsmax(temp_prefix)))
  547. {
  548. TrieSetString(client_prefix, str_id, temp_prefix)
  549. }
  550.  
  551. get_user_authid(id, temp_key, charsmax(temp_key))
  552.  
  553. if(TrieGetString(pre_steamids_collect, temp_key, temp_prefix, charsmax(temp_prefix)))
  554. {
  555. TrieSetString(client_prefix, str_id, temp_prefix)
  556. }
  557.  
  558. get_user_name(id, temp_key, charsmax(temp_key))
  559.  
  560. if(TrieGetString(pre_names_collect, temp_key, temp_prefix, charsmax(temp_prefix)))
  561. {
  562. TrieSetString(client_prefix, str_id, temp_prefix)
  563. }
  564.  
  565. return PLUGIN_HANDLED
  566. }
  567.  
  568. bool:check_say_characters(const check_message[])
  569. {
  570. for(new i = 0; i < charsmax(forbidden_say_symbols); i++)
  571. {
  572. if(check_message[0] == forbidden_say_symbols[i])
  573. {
  574. return true
  575. }
  576. }
  577. return false
  578. }
  579.  
  580. bool:check_prefix_characters(const check_prefix[])
  581. {
  582. for(i = 0; i < charsmax(forbidden_prefixes_symbols); i++)
  583. {
  584. if(containi(check_prefix, forbidden_prefixes_symbols[i]) != -1)
  585. {
  586. return true
  587. }
  588. }
  589. return false
  590. }
  591.  
  592. bool:is_bad_prefix(const check_prefix[])
  593. {
  594. if(TrieGetCell(bad_prefixes_collect, check_prefix, temp_value))
  595. {
  596. return true
  597. }
  598. return false
  599. }
  600.  
  601. find_and_delete(const arg_type[], const arg_key[])
  602. {
  603. line = 0, length = 0;
  604.  
  605. while(read_file(file_prefixes, line++ , text, charsmax(text), length))
  606. {
  607. if(!text[0] || text[0] == '^n' || text[0] == ';' || (text[0] == '/' && text[1] == '/'))
  608. continue
  609.  
  610. parse(text, type, charsmax(type), key, charsmax(key), prefix, charsmax(prefix))
  611. trim(prefix)
  612.  
  613. if(!type[0] || !prefix[0] || !key[0])
  614. continue
  615.  
  616. if(!equal(arg_type, type) || !equal(arg_key, key))
  617. continue
  618.  
  619. write_file(file_prefixes, "", line - 1)
  620. }
  621.  
  622. switch(arg_type[0])
  623. {
  624. case 'f':
  625. {
  626. TrieDeleteKey(pre_flags_collect, arg_key)
  627. }
  628. case 'i':
  629. {
  630. TrieDeleteKey(pre_ips_collect, arg_key)
  631. }
  632. case 's':
  633. {
  634. TrieDeleteKey(pre_steamids_collect, arg_key)
  635. }
  636. case 'n':
  637. {
  638. TrieDeleteKey(pre_names_collect, arg_key)
  639. }
  640. }
  641. }
  642. //taked from admin_chat_color
  643. public sendMessage (color[])
  644. {
  645.     new teamName[10]
  646.     for (new player = 1; player < g_maxplayers; player++)
  647.     {
  648.         if (!is_user_connected(player))
  649.             continue
  650.  
  651.         get_user_team (player, teamName, 9) // Stores user's team name to change back after sending the message
  652.         changeTeamInfo (player, color)      // Changes user's team according to color choosen
  653.         writeMessage (player, g_typed)      // Writes the message on player's chat
  654.         changeTeamInfo (player, teamName)   // Changes user's team back to original    
  655.     }
  656. }
  657.  
  658. public sendTeamMessage (color[], playerTeam)
  659. {
  660.     new teamName[10]
  661.     for (new player = 1; player < g_maxplayers; player++)
  662.     {
  663.         if (!is_user_connected(player))
  664.             continue
  665.  
  666.         if (get_user_team(player) == playerTeam)
  667.         {
  668.             get_user_team (player, teamName, 9) // Stores user's team name to change back after sending the message
  669.             changeTeamInfo (player, color)      // Changes user's team according to color choosen
  670.             writeMessage (player, g_typed)      // Writes the message on player's chat
  671.             changeTeamInfo (player, teamName)   // Changes user's team back to original
  672.         }
  673.     }
  674. }
  675.  
  676. public changeTeamInfo (player, team[])
  677. {
  678.     message_begin (MSG_ONE, teamInfo, _, player)    // Tells to to modify teamInfo (Which is responsable for which time player is)
  679.     write_byte (player)             // Write byte needed
  680.     write_string (team)             // Changes player's team
  681.     message_end()                   // Also Needed
  682. }
  683.  
  684. public writeMessage (player, message[])
  685. {
  686.     message_begin (MSG_ONE, g_saytxt, {0, 0, 0}, player)    // Tells to modify sayText (Which is responsable for writing colored messages)
  687.     write_byte (player)                 // Write byte needed
  688.     write_string (message)              // Effectively write the message, finally, afterall
  689.     message_end ()                      // Needed as always
  690. }
Add Comment
Please, Sign In to add comment