hlmod.hu

Magyar Half-Life Mód közösség!
Pontos idő: 2024.06.05. 23:19



Jelenlévő felhasználók

Jelenleg 238 felhasználó van jelen :: 0 regisztrált, 0 rejtett és 238 vendég

A legtöbb felhasználó (1565 fő) 2020.11.21. 11:26-kor tartózkodott itt.

Regisztrált felhasználók: nincs regisztrált felhasználó az elmúlt 5 percben aktív felhasználók alapján

Utoljára aktív
Ahhoz hogy lásd ki volt utoljára aktív, be kell jelentkezned.



Az oldal teljeskörű
használatához regisztrálj.

Regisztráció

Kereső


Új téma nyitása  Hozzászólás a témához  [ 1 hozzászólás ] 
Szerző Üzenet
 Hozzászólás témája: Admin gag razzor féle
HozzászólásElküldve: 2016.10.21. 18:17 
Offline
Tag

Csatlakozott: 2012.05.14. 15:23
Hozzászólások: 51
Megköszönt másnak: 10 alkalommal
Megköszönték neki: 1 alkalommal
Van nekem egy admin_gag amely modosítottam egy kicsit a a lang részeknél + print_colort raktam be a chat_color helyett,
Az a gond hogy nem megy a némítás chat része, Megtudja valaki nézni, hogy mi a hibája?

Köszönöm előre is:)

itt a script:
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <engine>
  4.  
  5. #define PLUGIN "ADMIN Gag"
  6. #define VERSION "1.0"
  7. #define AUTHOR "RaZzoR"
  8.  
  9. #define GAG_FLAG ADMIN_BAN
  10. #define GAG_IMMUNITY ADMIN_IMMUNITY
  11.  
  12. #define DICTIONARY "admin_gag.txt"
  13.  
  14. new const gag_file_name[] = "nemitott_jatekos.txt"
  15.  
  16. enum _:GagData {
  17.     gag_name[32],
  18.     gag_steamid[35],
  19.     gag_length,
  20.     ungag_time[32],
  21.     gag_reason[128]
  22. }
  23.  
  24. new Trie:g_trie
  25. new Array:g_array
  26. new total_gags, g_ungag_entity
  27. new gag_file[64], Float:get_gag_time[33], tempid[33]
  28.  
  29. new gag_immunity, gag_ungagcheck
  30.  
  31. public plugin_init() {
  32.     register_plugin(PLUGIN, VERSION, AUTHOR)
  33.    
  34.     register_dictionary(DICTIONARY)
  35.    
  36.     gag_immunity = register_cvar("gag_immunity", "1")
  37.     gag_ungagcheck = register_cvar("gag_ungagcheck", "1.0")
  38.  
  39.     register_clcmd("amx_gag", "gag_menu")
  40.     register_clcmd("amx_ungag", "ungag_menu")      
  41.  
  42.     register_clcmd("GAG_TIME", "clcmd_time")
  43.     register_clcmd("GAG_REASON", "clcmd_reason")
  44.  
  45.     register_concmd("gag_authid", "concmd_gag_authid", GAG_FLAG, "<nev, #userid, authid> <ido percben> <ok>")
  46.     register_concmd("gag_ip", "concmd_gag_ip", GAG_FLAG, "<nev, #userid, authid> <ido percben> <ok>")
  47.     register_concmd("gag_add", "concmd_gag_add", GAG_FLAG, "<nev> <authid vagy ip> <ido percben> <ok>")
  48.     register_concmd("gag_list", "concmd_gag_list", GAG_FLAG, "[start] -- megmutat minden nemitast")
  49.     register_concmd("ungag", "concmd_ungag", GAG_FLAG, "<authid vagy ip>")
  50.  
  51.     get_datadir(gag_file, sizeof(gag_file) - 1)
  52.     format(gag_file, sizeof(gag_file) - 1, "%s/%s", gag_file, gag_file_name)
  53.  
  54.     g_trie = TrieCreate()
  55.     g_array = ArrayCreate(GagData)
  56.  
  57.     LoadGags()
  58. }
  59.  
  60. public plugin_cfg() create_ungag_entity()
  61.  
  62. public client_PostThink(id) {
  63.     static authid[35]
  64.     get_user_authid(id, authid, sizeof(authid) - 1)
  65.    
  66.     static ip[35]
  67.     get_user_ip(id, ip, sizeof(ip) - 1, 1)
  68.  
  69.     static array_pos   
  70.     if(TrieGetCell(g_trie, authid, array_pos) || TrieGetCell(g_trie, ip, array_pos)) set_speak(id, SPEAK_MUTED)
  71.     else set_speak(id, SPEAK_LISTENALL)
  72. }
  73.    
  74. public create_ungag_entity() {
  75.     static failtimes
  76.    
  77.     g_ungag_entity = create_entity("info_target")
  78.    
  79.     if(!is_valid_ent(g_ungag_entity)) {
  80.         ++failtimes
  81.        
  82.         log_amx("[HIBA] Nem sikerült elkészíteni a némító feloldó entity-t (%i/10)", failtimes)
  83.        
  84.         if(failtimes < 10) set_task(1.0, "create_ungag_entity")
  85.         else log_amx("[HIBA] Nem lehet elkészíteni a némító feloldó entity-t!")
  86.        
  87.         return
  88.     }
  89.    
  90.     entity_set_string(g_ungag_entity, EV_SZ_classname, "ungag_entity")
  91.     entity_set_float(g_ungag_entity, EV_FL_nextthink, get_gametime() + 1.0)
  92.    
  93.     register_think("ungag_entity", "UnGag_Check")
  94. }
  95.  
  96. public UnGag_Check(entity)
  97. {
  98.     if(entity != g_ungag_entity) return
  99.    
  100.     if(total_gags > 0)
  101.     {
  102.         static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7]
  103.         format_time(_hours, sizeof(_hours) - 1, "%H")
  104.         format_time(_minutes, sizeof(_minutes) - 1, "%M")
  105.         format_time(_seconds, sizeof(_seconds) - 1, "%S")
  106.         format_time(_month, sizeof(_month) - 1, "%m")
  107.         format_time(_day, sizeof(_day) - 1, "%d")
  108.         format_time(_year, sizeof(_year) - 1, "%Y")
  109.        
  110.        
  111.         new c_hours = str_to_num(_hours)
  112.         new c_minutes = str_to_num(_minutes)
  113.         new c_seconds = str_to_num(_seconds)
  114.         new c_month = str_to_num(_month)
  115.         new c_day = str_to_num(_day)
  116.         new c_year = str_to_num(_year)
  117.        
  118.         static load_ungag_time[32]
  119.         static u_hours, u_minutes, u_seconds, u_month, u_day, u_year
  120.        
  121.         for(new i = 0; i < total_gags; i++) {
  122.             static data[GagData]
  123.             ArrayGetArray(g_array, i, data)
  124.            
  125.             if(data[gag_length] == 0) continue
  126.            
  127.             copy(load_ungag_time, sizeof(load_ungag_time) - 1, data[ungag_time])
  128.  
  129.             replace_all(load_ungag_time, sizeof(load_ungag_time) - 1, ":", " ")
  130.             replace_all(load_ungag_time, sizeof(load_ungag_time) - 1, "/", " ")
  131.            
  132.             parse(load_ungag_time,\
  133.                 _hours, sizeof(_hours) - 1,\
  134.                 _minutes, sizeof(_minutes) - 1,\
  135.                 _seconds, sizeof(_seconds) - 1,\
  136.                 _month, sizeof(_month) - 1,\
  137.                 _day, sizeof(_day) - 1,\
  138.                 _year, sizeof(_year) - 1
  139.                 )
  140.            
  141.             u_hours = str_to_num(_hours)
  142.             u_minutes = str_to_num(_minutes)
  143.             u_seconds = str_to_num(_seconds)
  144.             u_month = str_to_num(_month)
  145.             u_day = str_to_num(_day)
  146.             u_year = str_to_num(_year)
  147.            
  148.             if( u_year < c_year
  149.             || u_year == c_year && u_month < c_month
  150.             || u_year == c_year && u_month == c_month && u_day < c_day
  151.             || u_year == c_year && u_month == c_month && u_day == c_day && u_hours < c_hours
  152.             || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes < c_minutes
  153.             || u_year == c_year && u_month == c_month && u_day == c_day && u_hours == c_hours && u_minutes == c_minutes && u_seconds <= c_seconds ) {
  154.                
  155.                     print_color(0, "^3%s^1 [^4%s^1] ^4némítás ideje letelt^1! [Némítás Oka: ^4%s^1] ", data[gag_name], data[gag_steamid], data[gag_reason])
  156.                     RemoveGag(i, data[gag_steamid])
  157.                     i--
  158.             }
  159.         }
  160.     }
  161.    
  162.     entity_set_float(g_ungag_entity, EV_FL_nextthink, get_gametime() + get_pcvar_float(gag_ungagcheck))
  163. }
  164.  
  165. public concmd_gag_authid(id, level, cid) {
  166.     if(!cmd_access(id, level, cid, 4)) return PLUGIN_HANDLED
  167.    
  168.     static arg[128]
  169.     read_argv(1, arg, sizeof(arg) - 1)
  170.    
  171.     new target = cmd_target(id, arg, GetTargetFlags(id))
  172.     if(!target) return PLUGIN_HANDLED
  173.    
  174.     static target_authid[35]
  175.     get_user_authid(target, target_authid, sizeof(target_authid) - 1)
  176.  
  177.     if(TrieKeyExists(g_trie, target_authid)) {
  178.         console_print(id, "Steam ID [%s] már le van némítva!", target_authid)
  179.         return PLUGIN_HANDLED
  180.     }
  181.  
  182.     read_argv(2, arg, sizeof(arg) - 1)
  183.     new Float:length = str_to_float(arg)
  184.  
  185.     static ungag_time2[64], gag_time2[64]
  186.  
  187.     if(length == 0.0) formatex(ungag_time2, sizeof(ungag_time2) - 1, "Örök némítás")
  188.     else GenerateUnGagTime(length, ungag_time2, sizeof(ungag_time2) - 1)
  189.  
  190.     read_argv(3, arg, sizeof(arg) - 1)
  191.  
  192.     static admin_name[64], target_name[32]
  193.     get_user_name(id, admin_name, sizeof(admin_name) - 1)
  194.     get_user_name(target, target_name, sizeof(target_name) - 1)
  195.    
  196.     static admin_authid[35]
  197.     get_user_authid(id, admin_authid, sizeof(admin_authid) - 1)
  198.  
  199.     GagAdd(target_name, target_authid, arg, floatround(length * 60.0, floatround_floor), ungag_time2)
  200.  
  201.     GetGagTime(id, length, gag_time2, sizeof(gag_time2) - 1)
  202.    
  203.     print_color(0, "^4ADMIN ^1lenémította ^3%s^1-t. [Oka: ^4%s^1] [Ideje: ^4%s^1] [Lejárata: ^4%s^1]", target_name, arg, gag_time2, ungag_time2)
  204.    
  205.     return PLUGIN_HANDLED
  206. }
  207.  
  208. public concmd_gag_ip(id, level, cid) {
  209.     if(!cmd_access(id, level, cid, 4)) return PLUGIN_HANDLED
  210.    
  211.     static arg[128]
  212.     read_argv(1, arg, sizeof(arg) - 1)
  213.    
  214.     new target = cmd_target(id, arg, GetTargetFlags(id))
  215.     if(!target) return PLUGIN_HANDLED
  216.    
  217.     static target_ip[35]
  218.     get_user_ip(target, target_ip, sizeof(target_ip) - 1, 1)
  219.  
  220.     if(TrieKeyExists(g_trie, target_ip)) {
  221.         console_print(id, "IP [%s] már le van némítva!", target_ip)
  222.         return PLUGIN_HANDLED
  223.     }
  224.  
  225.     read_argv(2, arg, sizeof(arg) - 1)
  226.     new Float:length = str_to_float(arg)
  227.  
  228.     static ungag_time2[64], gag_time2[64]
  229.  
  230.     if(length == 0.0) formatex(ungag_time2, sizeof(ungag_time2) - 1, "Örök némítás")
  231.     else GenerateUnGagTime(length, ungag_time2, sizeof(ungag_time2) - 1)
  232.  
  233.     read_argv(3, arg, sizeof(arg) - 1)
  234.  
  235.     static admin_name[64], target_name[32]
  236.     get_user_name(id, admin_name, sizeof(admin_name) - 1)
  237.     get_user_name(target, target_name, sizeof(target_name) - 1)
  238.    
  239.     static admin_authid[35]
  240.     get_user_authid(id, admin_authid, sizeof(admin_authid) - 1)
  241.  
  242.     GagAdd(target_name, target_ip, arg, floatround(length * 60.0, floatround_floor), ungag_time2)
  243.  
  244.     GetGagTime(id, length, gag_time2, sizeof(gag_time2) - 1)
  245.     print_color(0,"^4ADMIN ^1lenémította ^3%s^1-t. [Oka: ^4%s^1] [Ideje: ^4%s^1] [Lejárata: ^4%s^1]", target_name, arg, gag_time2, ungag_time2)
  246.    
  247.     return PLUGIN_HANDLED
  248. }
  249.  
  250. public concmd_gag_add(id, level, cid) {
  251.     if(!cmd_access(id, level, cid, 5)) return PLUGIN_HANDLED
  252.  
  253.     static target_name[128], target_authid[128], gagtime[128], reason[128]
  254.     read_argv(1, target_name, sizeof(target_name) - 1)
  255.     read_argv(2, target_authid, sizeof(target_authid) - 1)
  256.     read_argv(3, gagtime, sizeof(gagtime) - 1)
  257.     read_argv(4, reason, sizeof(reason) - 1)
  258.    
  259.     new bool:is_ip = bool:(containi(target_authid, ".") != -1)
  260.  
  261.     if(TrieKeyExists(g_trie, target_authid)) {
  262.         console_print(id, "%L", id, is_ip ? "ALREADY_GAGGED_IP" : "ALREADY_GAGGED_STEAMID", target_authid)
  263.         return PLUGIN_HANDLED
  264.     }
  265.  
  266.     new Float:length = str_to_float(gagtime)
  267.     static ungag_time2[64], gag_time2[64]
  268.  
  269.     if(length == 0.0) formatex(ungag_time2, sizeof(ungag_time2) - 1, "Örök némítás")
  270.     else GenerateUnGagTime(length, ungag_time2, sizeof(ungag_time2) - 1)
  271.  
  272.     static admin_name[64]
  273.     get_user_name(id, admin_name, sizeof(admin_name) - 1)
  274.    
  275.     static admin_authid[35]
  276.     get_user_authid(id, admin_authid, sizeof(admin_authid) - 1)
  277.  
  278.     GagAdd(target_name, target_authid, reason, floatround(length * 60.0, floatround_floor), ungag_time2)
  279.  
  280.     GetGagTime(id, length, gag_time2, sizeof(gag_time2) - 1)
  281.    
  282.     print_color(0,"^4ADMIN ^1lenémította ^3%s^1-t. [Oka: ^4%s^1] [Ideje: ^4%s^1] [Lejárata: ^4%s^1]", target_name, reason, gag_time2, ungag_time2)  
  283.  
  284.     return PLUGIN_HANDLED
  285. }  
  286.  
  287. public concmd_ungag(id, level, cid) {
  288.     if(!cmd_access(id, level, cid, 2)) return PLUGIN_HANDLED
  289.    
  290.     static arg[35]
  291.     read_argv(1, arg, sizeof(arg) - 1)
  292.  
  293.     if(TrieKeyExists(g_trie, arg)) {
  294.         static array_pos;
  295.         TrieGetCell(g_trie, arg, array_pos);
  296.        
  297.         static data[GagData]
  298.         ArrayGetArray(g_array, array_pos, data)
  299.        
  300.         static admin_name[64]
  301.         get_user_name(id, admin_name, sizeof(admin_name) - 1)
  302.        
  303.         static authid[35]
  304.         get_user_authid(id, authid, sizeof(authid) - 1)
  305.        
  306.         print_color(0, "^4ADMIN ^1feloldotta a némítását neki: ^3%s ^1. [Némítás Oka: ^4%s^1]", data[gag_name], data[gag_reason])
  307.        
  308.         RemoveGag(array_pos, data[gag_steamid])
  309.        
  310.         return PLUGIN_HANDLED
  311.     }
  312.  
  313.     console_print(id, "Nem található némítás!", arg)
  314.  
  315.     return PLUGIN_HANDLED
  316. }
  317.  
  318. public concmd_gag_list(id, level, cid) {
  319.     if(!cmd_access(id, level, cid, 1)) return PLUGIN_HANDLED
  320.    
  321.     if(!total_gags) {
  322.         console_print(id, "Nem található némítás!")
  323.         return PLUGIN_HANDLED;
  324.     }
  325.    
  326.     static start
  327.     if(read_argc() > 1) {
  328.         static arg[5]
  329.         read_argv(1, arg, sizeof(arg) - 1)
  330.        
  331.         start = min(str_to_num(arg), total_gags) - 1
  332.     }
  333.    
  334.     else start = 0
  335.    
  336.     new last = min(start + 10, total_gags)
  337.    
  338.     if(id == 0) server_cmd("echo ^"%L^"", id, "GAG_LIST_NUM", start + 1, last)
  339.     else console_print(id, "%L", id, "GAG_LIST_NUM", start + 1, last)
  340.    
  341.     for(new i = start; i < last; i++) {
  342.         static data[GagData]
  343.         ArrayGetArray(g_array, i, data)
  344.        
  345.         PrintGagInfosToConsole(id, data[gag_name], data[gag_steamid], data[gag_length], data[gag_reason], data[ungag_time])
  346.     }
  347.    
  348.     if(++last < total_gags) {
  349.         if(id == 0) server_cmd("echo ^"%L^"", id, "GAG_LIST_NEXT", last)
  350.         else console_print(id, "%L", id, "GAG_LIST_NEXT", last)
  351.     }
  352.    
  353.     return PLUGIN_HANDLED
  354. }  
  355.  
  356. public gag_menu(id) {
  357.     if(!(get_user_flags(id) & GAG_FLAG))
  358.         return PLUGIN_HANDLED
  359.    
  360.     new menu_line[99], menu_newline[99], id_data[64]
  361.     format(menu_line, charsmax(menu_line), "\rJokeAlmighty \yTíltó Menü^n\r[\yKit szeretnél letiltani?\r]")
  362.    
  363.     new menu = menu_create(menu_line, "gag_menu_handler")
  364.    
  365.     new players[32], name[32], num
  366.     get_players(players, num, "c")
  367.    
  368.     for(new i = 0; i <num; i++) {
  369.         new pid = players[i]
  370.         get_user_name(pid, name, 31)
  371.         num_to_str(pid, id_data, sizeof(id_data))
  372.        
  373.         format(menu_newline, charsmax(menu_newline), "%s", name)
  374.         menu_additem(menu, menu_newline, id_data, 0)
  375.     }
  376.    
  377.     menu_display(id, menu, 0)
  378.     return PLUGIN_CONTINUE
  379. }
  380.  
  381. public ungag_menu(id) {
  382.     if(!(get_user_flags(id) & GAG_FLAG))
  383.         return PLUGIN_HANDLED
  384.  
  385.     if(!total_gags) {
  386.        
  387.         print_color(id, "^4Nem található feloldható némítás!")
  388.        
  389.         return PLUGIN_HANDLED
  390.     }
  391.    
  392.     new menu_line[99], menu_newline[99]
  393.     format(menu_line, charsmax(menu_line), "\rJokeAlmighty \yFeloldó Menü^n\r[\yKit szeretnél feloldani?\r]")
  394.    
  395.     new menu = menu_create(menu_line, "ungag_menu_handler")
  396.    
  397.     for(new i = 0; i < total_gags; i++) {
  398.         static data[GagData]
  399.         ArrayGetArray(g_array, i, data)
  400.        
  401.         format(menu_newline, charsmax(menu_newline), "\r[\y%s\r]\w||\r[\y%s\r]\w||\r[\y%s\r]", data[gag_name] , data[gag_steamid], data[gag_reason])
  402.         menu_additem(menu, menu_newline, data[gag_steamid], 0)
  403.     }
  404.    
  405.     menu_display(id, menu, 0)
  406.     return PLUGIN_CONTINUE
  407. }
  408.  
  409. public gag_menu_handler(id, menu, item) {
  410.     if(item == MENU_EXIT) {
  411.         menu_destroy(menu)
  412.         return PLUGIN_HANDLED
  413.     }
  414.    
  415.     new data[64], szName[64]
  416.     new access, callback
  417.     menu_item_getinfo(menu, item, access, data,charsmax(data), szName,charsmax(szName), callback)
  418.    
  419.     tempid[id] = str_to_num(data)
  420.    
  421.     static authid[35]
  422.     get_user_authid(tempid[id], authid, sizeof(authid) - 1)
  423.    
  424.     static ip[35]
  425.     get_user_ip(tempid[id], ip, sizeof(ip) - 1, 1)
  426.     static array_pos   
  427.    
  428.     if(get_user_flags(tempid[id]) & GAG_IMMUNITY) {
  429.        
  430.             print_color(id, "^1Ez a játésok ^4ADMIN^1, őt nem tudod lenémítani! Válassz máskit!")
  431.            
  432.             gag_menu(id)
  433.             return PLUGIN_HANDLED
  434.     }
  435.     else if(TrieGetCell(g_trie, authid, array_pos) || TrieGetCell(g_trie, ip, array_pos)) {
  436.         static data[GagData]
  437.         ArrayGetArray(g_array, array_pos, data)
  438.  
  439.         static gag_length2[64]
  440.         new Float:gag_len = float(data[gag_length]) / 60.0
  441.         GetGagTime(id, gag_len, gag_length2, sizeof(gag_length2) - 1)
  442.        
  443.         print_color(id, "^4Ez a játékos már le van némítva! ^1[Oka: ^4%s^1] [Ideje: ^4%s^1] [Lejárata: ^4%s^1]", data[gag_reason], gag_length2, data[ungag_time])
  444.        
  445.         return PLUGIN_HANDLED
  446.     }
  447.    
  448.     else {
  449.    
  450.             print_color(id, "^4Írd be az időt!   ^1(percben)^4!")
  451.            
  452.             client_cmd(id, "messagemode GAG_TIME")
  453.     }
  454.    
  455.     return PLUGIN_CONTINUE
  456. }
  457.  
  458. public ungag_menu_handler(id, menu, item) {
  459.     if(item == MENU_EXIT) {
  460.         menu_destroy(menu)
  461.         return PLUGIN_HANDLED
  462.     }
  463.    
  464.     new data[64], szName[64]
  465.     new access, callback
  466.     menu_item_getinfo(menu, item, access, data, charsmax(data), szName, charsmax(szName), callback)
  467.  
  468.     client_cmd(id, "ungag ^"%s^"", data)
  469.  
  470.     return PLUGIN_CONTINUE
  471. }
  472.  
  473. public clcmd_time(id) {
  474.     if(!(get_user_flags(id) & GAG_FLAG))
  475.         return PLUGIN_HANDLED
  476.  
  477.     new gag_times[33][100]
  478.     read_args(gag_times[id], 99)
  479.     remove_quotes(gag_times[id])
  480.  
  481.     get_gag_time[id] = str_to_float(gag_times[id])
  482.    
  483.     print_color(id, "^4Írd be az okot!")
  484.    
  485.     client_cmd(id, "messagemode GAG_REASON")
  486.    
  487.     return PLUGIN_HANDLED
  488. }
  489.  
  490. public clcmd_reason(id) {
  491.     if(!(get_user_flags(id) & GAG_FLAG))
  492.         return PLUGIN_HANDLED
  493.  
  494.     new get_gag_reason[33][100]
  495.     read_args(get_gag_reason[id], 99)
  496.     remove_quotes(get_gag_reason[id])
  497.    
  498.     static target_authid[32]
  499.     get_user_authid(tempid[id], target_authid, sizeof(target_authid) - 1)
  500.  
  501.     client_cmd(id, "gag_authid ^"%s^" ^"%f^" ^"%s^"", target_authid, get_gag_time[id], get_gag_reason[id])
  502.    
  503.     return PLUGIN_HANDLED
  504. }
  505.  
  506. public gag_say(id) {
  507.     static authid[35]
  508.     get_user_authid(id, authid, sizeof(authid) - 1)
  509.    
  510.     static ip[35]
  511.     get_user_ip(id, ip, sizeof(ip) - 1, 1)
  512.  
  513.     static array_pos   
  514.     if(TrieGetCell(g_trie, authid, array_pos) || TrieGetCell(g_trie, ip, array_pos)) {
  515.         static data[GagData]
  516.         ArrayGetArray(g_array, array_pos, data)
  517.  
  518.         static gag_length2[64]
  519.         new Float:gag_len = float(data[gag_length]) / 60.0
  520.         GetGagTime(id, gag_len, gag_length2, sizeof(gag_length2) - 1)
  521.        
  522.         print_color(id, "^4Le vagy némítva! ^1[Oka: ^4%s^1] [Ideje: ^4%s^1] [Lejárata: ^4%s^1]", data[gag_reason], gag_length2, data[ungag_time])
  523.        
  524.         return PLUGIN_HANDLED
  525.     }
  526.    
  527.     return PLUGIN_CONTINUE
  528. }
  529.  
  530. public PrintGagInfosToConsole(index, const target_name[], const target_steamid[], const target_length, const target_reason[], const target_ungag_time[]) {
  531.     static gag_length2[64]
  532.     new bool:is_ip = bool:(containi(target_steamid, ".") != -1)
  533.    
  534.     if(index == 0) {
  535.         server_print("************************************************")
  536.         server_print("Nemitas Informacio")
  537.         server_print("Nev: %s", target_name)
  538.         server_print("%L: %s", index, !is_ip ? "GAG_STEAMID" : "GAG_IP", target_steamid)
  539.         server_print("Ok: %s", target_reason)
  540.         if(target_length > 0) {
  541.             new Float:gag_len = float(target_length) / 60.0
  542.             GetGagTime(index, gag_len, gag_length2, sizeof(gag_length2) - 1)
  543.  
  544.             server_print("Nemitas ideje: %s", gag_length2)
  545.         }
  546.         server_print("Nemitas feloldasa: %s", target_ungag_time)
  547.         server_print("************************************************")
  548.     }
  549.    
  550.     else {
  551.         console_print(index, "************************************************")
  552.         console_print(index, "Nemitas Informacio")
  553.         console_print(index, "Nev: %s", target_name)
  554.         console_print(index, "%L: %s", index, !is_ip ? "GAG_STEAMID" : "GAG_IP", target_steamid)
  555.         console_print(index, "Ok: %s", target_reason)
  556.         if(target_length > 0) {
  557.             new Float:gag_len = float(target_length) / 60.0
  558.             GetGagTime(index, gag_len, gag_length2, sizeof(gag_length2) - 1)
  559.  
  560.             console_print(index, "Nemitss ideje: %s", gag_length2)
  561.         }
  562.         console_print(index, "Nemitas feloldasa: %s", target_ungag_time)
  563.         console_print(index, "************************************************")
  564.     }
  565. }
  566.  
  567. public LoadGags() {
  568.     if(total_gags) {
  569.         TrieClear(g_trie)
  570.         ArrayClear(g_array)
  571.         total_gags = 0
  572.     }
  573.    
  574.     if(file_exists(gag_file)) {
  575.         new f = fopen(gag_file, "rt")
  576.         static filedata[512], length[10]
  577.        
  578.         static data[GagData]
  579.         while(!feof(f)){
  580.             fgets(f, filedata, sizeof(filedata) - 1)
  581.            
  582.             if(!filedata[0]) continue
  583.            
  584.             parse(filedata,\
  585.                 data[gag_steamid], sizeof(data[gag_steamid]) - 1,\
  586.                 data[gag_name], sizeof(data[gag_name]) - 1,\
  587.                 length, sizeof(length) - 1,\
  588.                 data[ungag_time], sizeof(data[ungag_time]) - 1,\
  589.                 data[gag_reason], sizeof(data[gag_reason]) - 1
  590.                 )
  591.            
  592.             data[gag_length] = str_to_num(length)
  593.            
  594.             ArrayPushArray(g_array, data)
  595.             TrieSetCell(g_trie, data[gag_steamid], total_gags)
  596.                    
  597.             total_gags++
  598.         }
  599.        
  600.         fclose(f)
  601.     }
  602. }
  603.  
  604. public RemoveGag(pos, const authid[]) {
  605.     TrieDeleteKey(g_trie, authid)
  606.     ArrayDeleteItem(g_array, pos)
  607.    
  608.     total_gags--
  609.    
  610.     new f = fopen(gag_file, "wt")
  611.     new data[GagData]
  612.  
  613.     for(new i = 0; i < total_gags; i++ ) {
  614.         ArrayGetArray(g_array, i, data)
  615.         TrieSetCell(g_trie, data[gag_steamid], i)
  616.        
  617.         fprintf(f, "^"%s^" ^"%s^" %i ^"%s^" ^"%s^"^n",\
  618.             data[gag_steamid],\
  619.             data[gag_name],\
  620.             data[gag_length],\
  621.             data[ungag_time],\
  622.             data[gag_reason]
  623.             )
  624.     }
  625.    
  626.     fclose(f)
  627. }
  628.  
  629. public GagAdd(const target_name[], const target_steamid[], const reason[], const length, const ungag_time3[]) {
  630.     new f = fopen(gag_file, "a+")
  631.    
  632.     fprintf(f, "^"%s^" ^"%s^" %i ^"%s^" ^"%s^"^n",\
  633.         target_steamid,\
  634.         target_name,\
  635.         length,\
  636.         ungag_time3,\
  637.         reason
  638.         )
  639.    
  640.     fclose(f)
  641.  
  642.     static data[GagData]
  643.     copy(data[gag_name], sizeof(data[gag_name]) - 1, target_name)
  644.     copy(data[gag_steamid], sizeof(data[gag_steamid]) - 1, target_steamid)
  645.     data[gag_length] = length
  646.     copy(data[ungag_time], sizeof(data[ungag_time]) - 1, ungag_time3)
  647.     copy(data[gag_reason], sizeof(data[gag_reason]) - 1, reason)
  648.    
  649.     TrieSetCell(g_trie, target_steamid, total_gags)
  650.     ArrayPushArray(g_array, data)
  651.    
  652.     total_gags++
  653. }
  654.  
  655. GetGagTime(index, Float:gagtime, length[], len) {
  656.     new minutes = floatround(gagtime, floatround_floor)
  657.     new seconds = floatround(floatfract(gagtime) * 60, floatround_floor)
  658.     new hours = 0
  659.     new days = 0
  660.    
  661.     while(minutes >= 60) {
  662.         minutes -= 60
  663.         hours++
  664.     }
  665.    
  666.     while(hours >= 24) {
  667.         hours -= 24
  668.         days++
  669.     }
  670.    
  671.     new bool:add_before
  672.     if(seconds) {
  673.         formatex(length, len, "%i Másodperc", seconds)
  674.         add_before = true
  675.     }
  676.  
  677.     if(minutes) {
  678.         if(add_before) format(length, len, "%i Perc, %s", minutes, length)
  679.  
  680.         else{
  681.             formatex(length, len, "%i Perc", minutes)          
  682.             add_before = true
  683.         }
  684.     }
  685.  
  686.     if(hours) {
  687.         if(add_before) format(length, len, "%i Óra, %s", hours, length)
  688.  
  689.         else{
  690.             formatex(length, len, "%i Óra", hours, index, "GAG_HOURS")        
  691.             add_before = true
  692.         }
  693.     }
  694.  
  695.     if(days) {
  696.         if(add_before) format(length, len, "%i %L, %s", days, index, "GAG_DAYS", length)
  697.  
  698.         else {
  699.             formatex(length, len, "%i Nap", days, index, "GAG_DAYS")           
  700.             add_before = true
  701.         }
  702.     }
  703.  
  704.     if(!add_before) formatex(length, len, "Nap")
  705. }
  706.  
  707. GetTargetFlags(index) {
  708.     static const flags_no_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS)
  709.     static const flags_immunity = (CMDTARGET_ALLOW_SELF|CMDTARGET_NO_BOTS|CMDTARGET_OBEY_IMMUNITY)
  710.    
  711.     switch(get_pcvar_num(gag_immunity)) {
  712.         case 1: return flags_immunity
  713.         case 2: return access(index, GAG_IMMUNITY) ? flags_no_immunity : flags_immunity
  714.     }
  715.    
  716.     return flags_no_immunity
  717. }
  718.    
  719. GenerateUnGagTime(const Float:input, output[], const len) {
  720.     static _hours[5], _minutes[5], _seconds[5], _month[5], _day[5], _year[7]
  721.     format_time(_hours, sizeof(_hours) - 1, "%H")
  722.     format_time(_minutes, sizeof(_minutes) - 1, "%M")
  723.     format_time(_seconds, sizeof(_seconds) - 1, "%S")
  724.     format_time(_month, sizeof(_month) - 1, "%m")
  725.     format_time(_day, sizeof(_day) - 1, "%d")
  726.     format_time(_year, sizeof(_year) - 1, "%Y")
  727.  
  728.     new hours = str_to_num(_hours)
  729.     new month = str_to_num(_month)
  730.     new day = str_to_num(_day)
  731.     new year = str_to_num(_year)
  732.  
  733.     new minutes = floatround(input, floatround_floor) + str_to_num(_minutes)
  734.     new seconds = floatround(floatfract(input) * 60, floatround_floor)
  735.  
  736.     while(minutes >= 60) {
  737.         minutes -= 60
  738.         hours++
  739.     }
  740.  
  741.     while(hours >= 24) {
  742.         hours -= 24
  743.         day++
  744.     }
  745.  
  746.     new max_days = GetDaysInMonth(month, year)
  747.     while(day > max_days) {
  748.         day -= max_days
  749.         month++
  750.     }
  751.  
  752.     while(month > 12) {
  753.         month -= 12
  754.         year++
  755.     }
  756.  
  757.     seconds += str_to_num(_seconds)
  758.     if(seconds > 59) {
  759.         seconds -= 60
  760.         if(minutes < 59) minutes++
  761.  
  762.         else {
  763.             minutes = 0
  764.             if(hours < 23) hours++
  765.  
  766.             else {
  767.                 hours = 0
  768.                 if(day < max_days) day++
  769.  
  770.                 else {
  771.                     day = 1
  772.                     if(month < 12) month++
  773.  
  774.                     else {
  775.                         month = 1
  776.                         year++
  777.                     }
  778.                 }
  779.             }
  780.         }
  781.     }  
  782.  
  783.     formatex(output, len, "%i:%02i:%02i %i/%i/%i", hours, minutes, seconds, month, day, year)
  784. }
  785.  
  786. GetDaysInMonth(month, year=0) {
  787.     switch(month) {
  788.         case 1: return 31 // January
  789.         case 2: return ((year % 4) == 0) ? 29 : 28 // February
  790.         case 3: return 31; // March
  791.         case 4: return 30; // April
  792.         case 5: return 31; // May
  793.         case 6: return 30; // June
  794.         case 7: return 31; // July
  795.         case 8: return 31; // August
  796.         case 9: return 30; // September
  797.         case 10: return 31; // October
  798.         case 11: return 30; // November
  799.         case 12: return 31; // December
  800.     }
  801.      
  802.     return 30
  803. }
  804.  
  805. stock print_color(const id, const input[], any:...)
  806. {
  807.         new count = 1, players[32]
  808.         static msg[191]
  809.         vformat(msg, 190, input, 3)
  810.  
  811.         replace_all(msg, 190, "!g", "^4")
  812.         replace_all(msg, 190, "!y", "^1")
  813.         replace_all(msg, 190, "!t", "^3")
  814.  
  815.         if (id) players[0] = id; else get_players(players, count, "ch")
  816.         {
  817.                 for (new i = 0; i < count; i++)
  818.                 {
  819.                         if (is_user_connected(players[i]))
  820.                         {
  821.                                 message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i])
  822.                                 write_byte(players[i])
  823.                                 write_string(msg)
  824.                                 message_end()
  825.                         }
  826.                 }
  827.         }
  828.         return PLUGIN_HANDLED
  829. }


Hozzászólás jelentése
Vissza a tetejére
   
Hozzászólások megjelenítése:  Rendezés  
Új téma nyitása  Hozzászólás a témához  [ 1 hozzászólás ] 


Ki van itt

Jelenlévő fórumozók: nincs regisztrált felhasználó valamint 14 vendég


Nyithatsz új témákat ebben a fórumban.
Válaszolhatsz egy témára ebben a fórumban.
Nem szerkesztheted a hozzászólásaidat ebben a fórumban.
Nem törölheted a hozzászólásaidat ebben a fórumban.
Nem küldhetsz csatolmányokat ebben a fórumban.

Keresés:
Ugrás:  
Powered by phpBB® Forum Software © phpBB Limited
Magyar fordítás © Magyar phpBB Közösség
Portal: Kiss Portal Extension © Michael O'Toole