- // Make a Zombie Function
- make_a_zombie(mode, id)
- {
- // Get alive players count
- static iPlayersnum
- iPlayersnum = fnGetAlive()
- // Not enough players, come back later!
- if (iPlayersnum < 1)
- {
- set_task(10.0, "make_zombie_task", TASK_MAKEZOMBIE)
- return;
- }
- #if defined AMBIENCE_SOUNDS
- // Start ambience sounds after a mode begins
- remove_task(TASK_AMBIENCESOUNDS)
- set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
- #endif
- // Get prevent consecutive modes setting
- static preventconsecutive
- preventconsecutive = get_pcvar_num(cvar_preventconsecutive)
- g_newround = false
- g_survround = false
- g_weskround = false
- g_nemround = false
- g_swarmround = false
- g_plagueround = false
- g_armageddonround = false
- g_synapsisround = false
- // Set up some common vars
- static forward_id, name[32], iZombies, iMaxZombies
- if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_SURVIVOR) && random_num(1, get_pcvar_num(cvar_survchance)) == get_pcvar_num(cvar_surv) && iPlayersnum >= get_pcvar_num(cvar_survminplayers)) || mode == MODE_SURVIVOR)
- {
- // Survivor Mode
- g_survround = true
- g_lastmode = MODE_SURVIVOR
- // Choose player randomly?
- if (mode == MODE_NONE)
- id = fnGetRandomAlive(random_num(1, iPlayersnum))
- // Remember id for calling our forward later
- forward_id = id
- // Turn player into a survivor
- humanme(id, 1, 0)
- // Show health task
- set_task(1.0, "ShowHealth", id+TASK_HEALTH, _, _, "b")
- // Turn the remaining players into zombies
- for (id = 1; id <= g_maxplayers; id++)
- {
- // Not alive
- if (!is_user_alive(id))
- continue;
- // Survivor or already a zombie
- if (g_survivor[id] || g_zombie[id])
- continue;
- // Turn into a zombie
- zombieme(id, 0, 0, 1)
- }
- // Play survivor sound
- PlaySound(sound_survivor[random_num(0, sizeof sound_survivor -1)]);
- // Get player's name
- get_user_name(forward_id, name, sizeof name - 1)
- // Show Survivor HUD notice
- set_hudmessage(0, 180, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
- ShowSyncHudMsg(0, g_MsgSync, "..::Modo Survivor::..^n%s ha sido convertido en Survivor!", name)
- message_begin(MSG_BROADCAST, g_msgScreenFade) // Open The Function
- write_short((1<<12)*1) // Duration
- write_short(1<<12) // Hold Time
- write_short(0x0000) // Fade Type
- write_byte(0) // Color Red
- write_byte(180) // Color Green
- write_byte(255) // Color Blue
- write_byte(100) // Alpha
- message_end() // Close The Function
- // Round start forward
- ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SURVIVOR, forward_id);
- }
- else if ((mode == MODE_NONE && (!preventconsecutive || g_lastmode != MODE_L4D) && random_num(1, get_pcvar_num(cvar_l4dchance)) == get_pcvar_num(cvar_l4d) && floatround((iPlayersnum-2)*get_pcvar_float(cvar_l4dratio), floatround_ceil) >= 1 && iPlayersnum >= get_pcvar_num(cvar_l4dminplayers)) || mode == MODE_L4D)//[registramos si no es alguno de los otros modos realiza una pregunta si es compatible con todas las cvars creadas por nosotros (pd. pcvar_float es una cvar permanente, pcvar_num es una cvar numerica)]
- {
- //Modo L4D
- g_l4dround = true // Establecemos la ronda del modo l4d como true
- g_swarmround = true // Establecemos la ronda del modo swarm como true para que no se infecten a los humanos
- for (id = 1; id <= g_maxplayers; id++)//[para todos los jugadores que esten conectados]
- {
- // si no esta vivo
- if (!is_user_alive(id))
- continue;//[no continuar]
- // si es un zombie
- if (g_zombie[id])
- continue;
- // Convertir en zombie
- zombieme(id, 0, 0, 1)
- // Convierte a todos en zombies a menos que no este vivo o que ya sea zombie
- }
- // Convertir 4 de los zombies en Humanos
- for ( new i = 0; i < 4; i++ )//[para que sean 4 jugadores los que se conviertan en humanos]
- {
- id = fnGetRandomAlive( random_num( 1, iPlayersnum ) )//[este code sirve para elegir a alguien al azar]
- if ( g_zombie[id] )//[ si no es zombie]
- humanme( id, 0 ) //[los convierte en humano solo a 4 recuerden]
- else//[sino]
- i--//[no lo convertimos en humano]
- }
- // Establecemos el sonido del modo plague como el del l4d
- PlaySound(sound_plague[random_num(0, sizeof sound_plague -1)]); // podemos cambiarlo por cualquier otro sonido de otro modo o registrar uno propio
- // Mostramos la noticia del modo en un HuD
- set_hudmessage(0, 50, 200, -1.0, 0.17, 1, 0.0, 5.0, 1.0, 1.0, -1)//[aqui se muestra el color y la posicion]
- ShowSyncHudMsg(0, g_MsgSync, "..::Modo Left 4 Dead::..")//[muestra el hud por un tiempito diciendo el mensaje del lang_player registrado como notice_l4d]
- // Ejecutamos la ronda de modo L4D
- ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_L4D, 0);
- }