public Action:StartFight()
{
// check if one player left server
if (ctid == 0 || tid == 0)
{
return;
}
// check if there are only two players
alivect = 0, alivet = 0;
for (new i = 1; i <= MaxClients; i++)
{
new team;
if (IsClientInGame(i) && IsPlayerAlive(i))
{
team = GetClientTeam(i);
if (team == 3) { alivect++; }
else if (team == 2) { alivet++; }
}
}
// check if there are only two players and round has
// not ended or bomb is not planted
if (alivect != 1 || alivet != 1 || bombplanted)
{
return;
}
// start fight
isFighting = true;
Trace("Fight is started.");
if (!IsPlayerAlive(ctid) || !IsPlayerAlive(tid) || (GetClientCount() < g_minplayers))
{
CancelFight();
return;
}
Trace("Removing all weapons on the map.");
// remove all weapons from the map
RemoveAllWeapons();
// play fight song
if (songsfound > 0)
{
new randomsong = 0;
if (songsfound > 1)
{
randomsong = GetRandomInt(0, songsfound - 1);
}
strcopy(song, sizeof(song), fightsong[randomsong]);
new clients[MaxClients];
new total = 0;
for (new i=1; i<=MaxClients; i++)
{
if (IsClientInGame(i) && g_soundPrefs[i])
{
clients[total++] = i;
}
}
if (total)
{
Trace("Starting fight song.");
EmitSound(clients, total, song,
_, SNDCHAN_AUTO, SNDLEVEL_NORMAL, SND_NOFLAGS, SNDVOL_NORMAL, SNDPITCH_NORMAL);
}
}
Trace("Starting beacons.");
// start beacons
CreateTimer(2.0, StartBeacon, ctid, TIMER_REPEAT);
CreateTimer(1.0, StartBeaconT, tid);
// remove weapons from players
PrintHintTextToAll("%t", "Removing weapons");
WeaponHandler(ctid, 3);
WeaponHandler(tid, 2);
// switch alltalk
if (g_alltalk)
{
g_alltalkenabled = GetConVarBool(sv_alltalk);
if ( !g_alltalkenabled )
{
SetConVarInt(sv_alltalk, 1);
}
g_alltalkenabled = !g_alltalkenabled;
}
// switch blocking
if ( g_block )
{
if ( sm_noblock == INVALID_HANDLE )
{
sm_noblock = FindConVar("sm_noblock");
}
if ( sm_noblock != INVALID_HANDLE )
{
g_blockenabled = !GetConVarBool(sm_noblock);
if ( !g_blockenabled )
{
SetConVarInt(sm_noblock, 0);
}
g_blockenabled = !g_blockenabled;
}
}
// teleport players
if (g_useteleport)
{
SetEntData(ctid, g_iHealth, 400);
SetEntData(tid, g_iHealth, 400);
new Float:ctvec[3];
new Float:tvec[3];
new Float:distance[1];
GetClientAbsOrigin(ctid,Float:ctvec);
GetClientAbsOrigin(tid,Float:tvec);
distance[0] = GetVectorDistance(ctvec, tvec, true);
if (distance[0] >= 600000.0)
{
teleloc = ctvec;
CreateTimer(0.1, SlapTimer, _, TIMER_REPEAT);
CreateTimer(0.5, TeleportTimer);
}
else if (g_locatorbeam)
{
CreateTimer(0.1, DrawBeamsTimer, _, TIMER_REPEAT);
}
}
else if (g_locatorbeam)
{
CreateTimer(0.1, DrawBeamsTimer, _, TIMER_REPEAT);
}
// display prepare to fight
CreateTimer(1.0, Countdown, _, TIMER_REPEAT);
}