Blancoo Postat Mai 3 Postat Mai 3 Descarcare: Versiune: 1.3 Link oficial: #include <amxmodx> #include <amxmisc> #include <nvault> #define STEAM_FLAG "b" // flagul de setat in users.ini #define MIN_PLAYTIME 1 // cate ore sa joace pentru flag new g_vault new g_connect_time[33] new bool:g_added_to_users[33] new bool:g_using_dproto = false new bool:g_using_reunion = false public plugin_init() { register_plugin("STEAM SLOT", "1.3", "Blancoo") register_clcmd("say /steam", "cmd_steam") g_vault = nvault_open("playtime") if(g_vault == INVALID_HANDLE) set_fail_state("Error opening nvault!") check_modules() } public plugin_end() { new iPlayers[32], iNum get_players(iPlayers, iNum) for(new i = 0; i < iNum; i++) { if(is_user_connected(iPlayers[i]) && is_user_steam(iPlayers[i])) save_playtime(iPlayers[i]) } nvault_close(g_vault) } public client_putinserver(id) { g_connect_time[id] = get_systime() g_added_to_users[id] = false load_playtime(id) } public client_disconnected(id) save_playtime(id) public cmd_steam(id) { if(!is_user_steam(id)) { client_print_color(id, print_team_default, "^4[AMXX]^1 You must be using Steam to use this command.") return PLUGIN_HANDLED } new playtime = get_systime() - g_connect_time[id] if(playtime < MIN_PLAYTIME * 3600) { client_print_color(id, print_team_default, "^4[AMXX]^1 You need at least %d hour(s) of playtime to use this command.", MIN_PLAYTIME) return PLUGIN_HANDLED } if(g_added_to_users[id]) { client_print_color(id, print_team_default, "^4[AMXX]^1 Your SteamID has already been added to users.ini.") return PLUGIN_HANDLED } static steamid[35] get_user_authid(id, steamid, charsmax(steamid)) if(add_to_users_ini(steamid)) { client_print_color(id, print_team_default, "^4[AMXX]^1 Your SteamID has been added to users.ini with the '%s' flag.", STEAM_FLAG ) g_added_to_users[id] = true } else client_print_color(id, print_team_default, "^4[AMXX]^1 Failed to add your SteamID to users.ini.") return PLUGIN_HANDLED } stock bool:add_to_users_ini(const steamid[]) { new file = fopen("addons/amxmodx/configs/users.ini", "at") if(!file) return false fprintf(file, "^"%s^" ^"^" ^"%s^" ^"ce^"^n", steamid, STEAM_FLAG) fclose(file) return true } stock load_playtime(id) { static steamid[35] get_user_authid(id, steamid, charsmax(steamid)) static data[16] if(nvault_get(g_vault, steamid, data, charsmax(data))) g_connect_time[id] = get_systime() - str_to_num(data) else g_connect_time[id] = get_systime() } stock save_playtime(id) { static steamid[35] get_user_authid(id, steamid, charsmax(steamid)) static data[16] num_to_str(get_systime() - g_connect_time[id], data, charsmax(data)) nvault_set(g_vault, steamid, data) } stock bool:is_user_steam(id) { if(g_using_dproto) return is_user_steam_dproto(id) else if(g_using_reunion) return is_user_steam_reunion(id) return false } stock bool:is_user_steam_dproto(id) { static dp_pointer if(dp_pointer || (dp_pointer = get_cvar_pointer("dp_r_id_provider"))) { server_cmd("dp_clientinfo %d", id) server_exec() return (get_pcvar_num(dp_pointer) == 2) ? true : false } return false } stock bool:is_user_steam_reunion(id) return (is_user_steam(id)) ? true : false stock check_modules() { if(get_cvar_pointer("dp_r_id_provider")) g_using_dproto = true else if(module_exists("reunion")) g_using_reunion = true else {/*dau un pumn la o doamna easter egg :)*/} } Update 1.3: Fixuri si imbunatatiri * E mai ok cu get_systime() parerea mea get_systime() este timpul curent unix g_connect_time[id] este timpul cand jucatorul s-a conectat x = get_systime() - g_connect_time[id] calculeaza cate secunde a jucat (timpul curent - timpul conectarii) Exemplu: 1672531200 - 1672524000 = 7200 secunde (2 ore) !! Daca am gresit astept reply sa pot fixa, thanks ! Citează
Postări Recomandate
Alătură-te conversației
Poți posta acum și să te înregistrezi mai târziu. Dacă ai un cont, autentifică-te acum pentru a posta cu contul tău.