bu kodu oldugu gibi kopyala ve zombieplague.sma dosyasinin icindeki make_a_zombie fonskiyonu ile deyistir.. hall olucak
Kod: Tümünü seç
new maks_zombi_sayisi = 4 // maksimum zombi sayisi
// 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(2.0, "make_zombie_task", TASK_MAKEZOMBIE)
return;
}
// Round started!
g_newround = false
// Set up some common vars
static forward_id, sound[64], iZombies, iMaxZombies
if ((mode == MODE_NONE && (!get_pcvar_num(cvar_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)
// Turn the remaining players into zombies
for (id = 1; id <= g_maxplayers; id++)
{
// Not alive
if (!g_isalive[id])
continue;
// Survivor or already a zombie
if (g_survivor[id] || g_zombie[id])
continue;
// Turn into a zombie
zombieme(id, 0, 0, 1, 0)
}
// Play survivor sound
ArrayGetString(sound_survivor, random_num(0, ArraySize(sound_survivor) - 1), sound, charsmax(sound))
PlaySound(sound);
// Show Survivor HUD notice
set_hudmessage(20, 20, 255, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SURVIVOR", g_playername[forward_id])
// Mode fully started!
g_modestarted = true
// Round start forward
ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SURVIVOR, forward_id);
}
else if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_SWARM) && random_num(1, get_pcvar_num(cvar_swarmchance)) == get_pcvar_num(cvar_swarm) && iPlayersnum >= get_pcvar_num(cvar_swarmminplayers)) || mode == MODE_SWARM)
{
// Swarm Mode
g_swarmround = true
g_lastmode = MODE_SWARM
// Make sure there are alive players on both teams (BUGFIX)
if (!fnGetAliveTs())
{
// Move random player to T team
id = fnGetRandomAlive(random_num(1, iPlayersnum))
remove_task(id+TASK_TEAM)
fm_cs_set_user_team(id, FM_CS_TEAM_T)
fm_user_team_update(id)
}
else if (!fnGetAliveCTs())
{
// Move random player to CT team
id = fnGetRandomAlive(random_num(1, iPlayersnum))
remove_task(id+TASK_TEAM)
fm_cs_set_user_team(id, FM_CS_TEAM_CT)
fm_user_team_update(id)
}
// Turn every T into a zombie
for (id = 1; id <= g_maxplayers; id++)
{
// Not alive
if (!g_isalive[id])
continue;
// Not a Terrorist
if (fm_cs_get_user_team(id) != FM_CS_TEAM_T)
continue;
// Turn into a zombie
zombieme(id, 0, 0, 1, 0)
}
// Play swarm sound
ArrayGetString(sound_swarm, random_num(0, ArraySize(sound_swarm) - 1), sound, charsmax(sound))
PlaySound(sound);
// Show Swarm HUD notice
set_hudmessage(20, 255, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_SWARM")
// Mode fully started!
g_modestarted = true
// Round start forward
ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_SWARM, 0);
}
else if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_MULTI) && random_num(1, get_pcvar_num(cvar_multichance)) == get_pcvar_num(cvar_multi) && floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil) >= 2 && floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil) < iPlayersnum && iPlayersnum >= get_pcvar_num(cvar_multiminplayers)) || mode == MODE_MULTI)
{
// Multi Infection Mode
g_lastmode = MODE_MULTI
// iMaxZombies is rounded up, in case there aren't enough players
iMaxZombies = floatround(iPlayersnum*get_pcvar_float(cvar_multiratio), floatround_ceil)
iZombies = 0
// Randomly turn iMaxZombies players into zombies
while (iZombies < iMaxZombies)
{
// Keep looping through all players
if (++id > g_maxplayers) id = 1
// Dead or already a zombie
if (!g_isalive[id] || g_zombie[id])
continue;
// Random chance
if (random_num(0, 1))
{
// Turn into a zombie
zombieme(id, 0, 0, 1, 0)
iZombies++
}
}
// Turn the remaining players into humans
for (id = 1; id <= g_maxplayers; id++)
{
// Only those of them who aren't zombies
if (!g_isalive[id] || g_zombie[id])
continue;
// Switch to CT
if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
{
remove_task(id+TASK_TEAM)
fm_cs_set_user_team(id, FM_CS_TEAM_CT)
fm_user_team_update(id)
}
}
// Play multi infection sound
ArrayGetString(sound_multi, random_num(0, ArraySize(sound_multi) - 1), sound, charsmax(sound))
PlaySound(sound);
// Show Multi Infection HUD notice
set_hudmessage(200, 50, 0, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_MULTI")
// Mode fully started!
g_modestarted = true
// Round start forward
ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_MULTI, 0);
}
else if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_PLAGUE) && random_num(1, get_pcvar_num(cvar_plaguechance)) == get_pcvar_num(cvar_plague) && floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil) >= 1
&& iPlayersnum-(get_pcvar_num(cvar_plaguesurvnum)+get_pcvar_num(cvar_plaguenemnum)+floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)) >= 1 && iPlayersnum >= get_pcvar_num(cvar_plagueminplayers)) || mode == MODE_PLAGUE)
{
// Plague Mode
g_plagueround = true
g_lastmode = MODE_PLAGUE
// Turn specified amount of players into Survivors
static iSurvivors, iMaxSurvivors
iMaxSurvivors = get_pcvar_num(cvar_plaguesurvnum)
iSurvivors = 0
while (iSurvivors < iMaxSurvivors)
{
// Choose random guy
id = fnGetRandomAlive(random_num(1, iPlayersnum))
// Already a survivor?
if (g_survivor[id])
continue;
// If not, turn him into one
humanme(id, 1, 0)
iSurvivors++
// Apply survivor health multiplier
fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_plaguesurvhpmulti)))
}
// Turn specified amount of players into Nemesis
static iNemesis, iMaxNemesis
iMaxNemesis = get_pcvar_num(cvar_plaguenemnum)
iNemesis = 0
while (iNemesis < iMaxNemesis)
{
// Choose random guy
id = fnGetRandomAlive(random_num(1, iPlayersnum))
// Already a survivor or nemesis?
if (g_survivor[id] || g_nemesis[id])
continue;
// If not, turn him into one
zombieme(id, 0, 1, 0, 0)
iNemesis++
// Apply nemesis health multiplier
fm_set_user_health(id, floatround(float(pev(id, pev_health)) * get_pcvar_float(cvar_plaguenemhpmulti)))
}
// iMaxZombies is rounded up, in case there aren't enough players
iMaxZombies = floatround((iPlayersnum-(get_pcvar_num(cvar_plaguenemnum)+get_pcvar_num(cvar_plaguesurvnum)))*get_pcvar_float(cvar_plagueratio), floatround_ceil)
iZombies = 0
// Randomly turn iMaxZombies players into zombies
while (iZombies < iMaxZombies)
{
// Keep looping through all players
if (++id > g_maxplayers) id = 1
// Dead or already a zombie or survivor
if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
continue;
// Random chance
if (random_num(0, 1))
{
// Turn into a zombie
zombieme(id, 0, 0, 1, 0)
iZombies++
}
}
// Turn the remaining players into humans
for (id = 1; id <= g_maxplayers; id++)
{
// Only those of them who arent zombies or survivor
if (!g_isalive[id] || g_zombie[id] || g_survivor[id])
continue;
// Switch to CT
if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
{
remove_task(id+TASK_TEAM)
fm_cs_set_user_team(id, FM_CS_TEAM_CT)
fm_user_team_update(id)
}
}
// Play plague sound
ArrayGetString(sound_plague, random_num(0, ArraySize(sound_plague) - 1), sound, charsmax(sound))
PlaySound(sound);
// Show Plague HUD notice
set_hudmessage(0, 50, 200, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_PLAGUE")
// Mode fully started!
g_modestarted = true
// Round start forward
ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_PLAGUE, 0);
}
else
{
// Single Infection Mode or Nemesis Mode
// Choose player randomly?
if (mode == MODE_NONE)
id = fnGetRandomAlive(random_num(1, iPlayersnum))
// Remember id for calling our forward later
forward_id = id
if ((mode == MODE_NONE && (!get_pcvar_num(cvar_preventconsecutive) || g_lastmode != MODE_NEMESIS) && random_num(1, get_pcvar_num(cvar_nemchance)) == get_pcvar_num(cvar_nem) && iPlayersnum >= get_pcvar_num(cvar_nemminplayers)) || mode == MODE_NEMESIS)
{
// Nemesis Mode
g_nemround = true
g_lastmode = MODE_NEMESIS
// Turn player into nemesis
zombieme(id, 0, 1, 0, 0)
}
else
{
// Single Infection Mode
g_lastmode = MODE_INFECTION
// Turn player into the first zombie
for (new i = 0; i < maks_zombi_sayisi; i++)
zombieme(id, 0, 0, 0, 0)
}
// Remaining players should be humans (CTs)
for (id = 1; id <= g_maxplayers; id++)
{
// Not alive
if (!g_isalive[id])
continue;
// First zombie/nemesis
if (g_zombie[id])
continue;
// Switch to CT
if (fm_cs_get_user_team(id) != FM_CS_TEAM_CT) // need to change team?
{
remove_task(id+TASK_TEAM)
fm_cs_set_user_team(id, FM_CS_TEAM_CT)
fm_user_team_update(id)
}
}
if (g_nemround)
{
// Play Nemesis sound
ArrayGetString(sound_nemesis, random_num(0, ArraySize(sound_nemesis) - 1), sound, charsmax(sound))
PlaySound(sound);
// Show Nemesis HUD notice
set_hudmessage(255, 20, 20, HUD_EVENT_X, HUD_EVENT_Y, 1, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "%L", LANG_PLAYER, "NOTICE_NEMESIS", g_playername[forward_id])
// Mode fully started!
g_modestarted = true
// Round start forward
ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_NEMESIS, forward_id);
}
else
{
// Show First Zombie HUD notice
set_hudmessage(255, 0, 0, HUD_EVENT_X, HUD_EVENT_Y, 0, 0.0, 5.0, 1.0, 1.0, -1)
ShowSyncHudMsg(0, g_MsgSync, "%L",LANG_PLAYER, "NOTICE_FIRST", g_playername[forward_id])
// Mode fully started!
g_modestarted = true
// Round start forward
ExecuteForward(g_fwRoundStart, g_fwDummyResult, MODE_INFECTION, forward_id);
}
}
// Start ambience sounds after a mode begins
if ((g_ambience_sounds[AMBIENCE_SOUNDS_NEMESIS] && g_nemround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SURVIVOR] && g_survround) || (g_ambience_sounds[AMBIENCE_SOUNDS_SWARM] && g_swarmround) || (g_ambience_sounds[AMBIENCE_SOUNDS_PLAGUE] && g_plagueround) || (g_ambience_sounds[AMBIENCE_SOUNDS_INFECTION] && !g_nemround && !g_survround && !g_swarmround && !g_plagueround))
{
remove_task(TASK_AMBIENCESOUNDS)
set_task(2.0, "ambience_sound_effects", TASK_AMBIENCESOUNDS)
}
}