#include <amxmodx>#include <amxmisc>#include <ns>/************************************************************************************** * Ready related functions & forfeitclock + refereeclock + fitoxchupala **************************************************************************************/new HL_RRSPECS = 0new HL_ALIENS = 1new HL_MARINES = 2new T_FFCLOCK = 69 //para fitoxnew g_gameStarted = 0new g_teamReady[4] // alien,marine,spect, unassigned?new g_FFCStarted = 0new g_FFCUsed = 0new FF_TIME = 600 // 10 minutos en seg ?// Command: say readypublic cmd_ready(id){ new team = get_user_team(id) new maxPlayers = 6 new name[30]; get_user_name(id, name, 29) // If game has started, requester is spec or team is already ready, skip process if ( g_gameStarted || (team == HL_MARINES && team != HL_ALIENS) || g_teamReady[team] ) { return PLUGIN_CONTINUE } // If pause is on, dont allow ready /*if ( g_pauseStatus ) { client_print(id, print_chat, "No rompas, el juego esta en pausa.") return PLUGIN_HANDLED } */ // Regenerate the player count new teamPlayers = 0 new Players[32] new playerCount, player get_players(Players, playerCount) for ( new i = 0; i < playerCount; i++ ) { if ( get_user_team(Players[i]) == team ) { teamPlayers++ } } // If teams are limited, check players if ( !ns_is_combat() && maxPlayers != 0 && teamPlayers != maxPlayers ) { client_print(id, print_chat, "Solo podes tirar ready con %d jugadores en el equipo. Chupala fitox.", maxPlayers) return PLUGIN_HANDLED } // Mark team ready g_teamReady[team] = 1 log_message("[ready] [%s] [%d:%s]", name, team, team == HL_MARINES ? "Soldaditos" : "Dinosaurios" ) // If both teams are ready... if ( g_teamReady[HL_MARINES] && g_teamReady[HL_ALIENS] ) { // Stop the clock func_stop_ffclock(0) // Set game started g_gameStarted = 1 //check function //server_cmd("sv_restartround 1",) // Set gametime //g_timeStarted = floatround(g_timeFetchedRemote + (get_gametime() - g_timeFetchedLocal), floatround_ceil) } // Otherwise start it else { func_start_ffclock() } return PLUGIN_CONTINUE}// Command: not readypublic cmd_notready(id){ new team = get_user_team(id) // Mark team unready if its aliens or marines if ( !g_gameStarted && team > HL_RRSPECS ) { g_teamReady[team] = 0 // Pause the forfeit clock if both teams are unready if ( !g_teamReady[HL_MARINES] && !g_teamReady[HL_ALIENS] ) { func_pause_ffclock() } } return PLUGIN_CONTINUE}// Command: amx_enslclock [mins] [secs] (add extra time to the forfeit clock)public cmd_enslclock(id, level, cid){ //check function to validate access //if ( !func_check_access(id, level, cid, 1) || g_gameStarted || !get_pcvar_num(g_cvar_ffclock) ) /*{ return PLUGIN_HANDLED } // Init variables new secs = 0 new strMins[R_LEN_MINS + 1]; read_argv(1, strMins, R_LEN_MINS); secs += str_to_num(strMins) * 60 new strSecs[R_LEN_MINS + 1]; read_argv(2, strSecs, R_LEN_MINS); secs += str_to_num(strSecs) new timeText[TT_LEN_OUTPUT + 1]; func_format_time(secs+0.0, timeText) new name[HL_LEN_NICK + 1]; get_user_name(id, name, HL_LEN_NICK) // Or add extra time g_FFCUsed -= secs client_print(0, print_chat, "Referee (%s) %s el forfeit clock en %s", name, secs < 0 ? "decremento" : "incremento", timeText) log_message("[clock] [%s] [%s]", name, timeText) */ return PLUGIN_HANDLED }// Function: start the forfeit clock// Requirements: 1 team is readypublic func_start_ffclock(){ // Do not start if the task exists if ( task_exists(T_FFCLOCK) || g_gameStarted ) { return PLUGIN_HANDLED } // Start the clock g_FFCStarted = get_gametime() set_task(1.0, "task_ffclock", T_FFCLOCK, "", 0, "b") // Print the start message new other = g_teamReady[HL_ALIENS] ? HL_MARINES : HL_ALIENS new timeText[TT_LEN_OUTPUT + 1]; func_format_time(FF_TIME - g_FFCUsed, timeText) client_print(0, print_chat, "Forfeit clock iniciado. Los %s tiene %s para tirar ready.", other == HL_MARINES ? "Soldaditos" : "Dinosaurios", timeText) log_message("[clock] [START] [%s] [%s]", timeText, other == HL_MARINES ? "Soldaditos" : "Dinosaurios") return PLUGIN_CONTINUE}// Function: pause the forfeit clockpublic func_pause_ffclock(){ // Exit if the task doesn't exist if ( !task_exists(T_FFCLOCK) ) { return PLUGIN_HANDLED } // Save the used forfeit time. If it is zero or negative, give 1min extra g_FFCUsed = floatround(get_gametime() - g_FFCStarted + g_FFCUsed, floatround_floor) g_FFCUsed = g_FFCUsed <= 0 ? floatround(FF_TIME) - 60 : g_FFCUsed remove_task(T_FFCLOCK) // Announce it new timeText[TT_LEN_OUTPUT + 1]; func_format_time(FF_TIME - g_FFCUsed, timeText) client_print(0, print_chat, "Forfeit clock pausado con %s .", timeText) log_message("[clock] [PAUSE] [%s]", timeText) return PLUGIN_CONTINUE}// Function: stop the forfeit clockpublic func_stop_ffclock(silent){ // If the task exists, stop it if ( task_exists(T_FFCLOCK) ) { remove_task(T_FFCLOCK) } // Reset timers g_FFCStarted = 0.0 g_FFCUsed = 0 // Announce it if not silent stop if ( !silent ) { client_print(0, print_console, "Forfeit clock se detuvo y se reiniciaron los tiempos.") } // Log the event log_message("[clock] [STOP]") return PLUGIN_CONTINUE}// Task: forfeit clockpublic task_ffclock(){ new timeText[TT_LEN_OUTPUT + 1] // Calculate the remaining time new Float:remaining = FF_TIME - get_gametime() + g_FFCStarted - g_FFCUsed // If the time is out, announce athe forfeit if ( remaining <= 0 ) { // Give the forfeit new forfeitTeam = !g_teamReady[HL_MARINES] ? HL_MARINES : HL_ALIENS client_print(0, print_chat, "Los (%s) la comieron por no tirar ready.",forfeitTeam == HL_MARINES ? "Soldaditos" : "Dinosaurios"]) // Remove the task, reset variables and quit remove_task(T_FFCLOCK) g_FFCStarted = 0.0 g_FFCUsed = 0 return PLUGIN_HANDLED } // Format unready team and timetext new team = !g_teamReady[HL_MARINES] ? HL_MARINES : HL_ALIENS func_format_time(remaining, timeText) // Announce the team lacking players new Players[32] new playerCount, player get_players(Players, playerCount) for ( new i = 0; i < playerCount; i++ ) { // Print it to everyone on the server { set_hudmessage(255, 0, 0, -1.0, 0.9, 0, 0.0, 0.9, 0.0, 0.0) show_hudmessage(Players[i], "%s tienen %s para tirar ready.", team == HL_MARINES ? "Soldaditos" : "Dinosaurios", timeText) } } // Print casual message every 30 seconds if ( floatround(remaining) % 30 == 0 ) { client_print(0, print_chat, "%s tienen %s para tirar ready.", team == HL_MARINES ? "Soldaditos" : "Dinosaurios", timeText) } return PLUGIN_CONTINUE}public func_format_time(time, timetext){ new segundos = time % 60 new minutos = (time - segundos)/60 //por las dudas que no haya division entera format(timetext,5,"%d:%d"minutos,segundos)}