#pragma tabsize 0
#include <sourcemod>
#include <sdktools_functions>
#include <cstrike>
#define PROJECT_FULLNAME "[ PL ] MapTime TeamSwap"
bool bSwapTeam;
new startMoney;
new cashOffset;
public Plugin myinfo = { name = PROJECT_FULLNAME, author = "Ravskiy1 [vk.com/ravskiy1]", version = "0.1", };
public OnPluginStart() { HookEvent("round_end", RoundEnd); cashOffset = FindSendPropInfo("CCSPlayer","m_iAccount"); }
public OnMapStart() { bSwapTeam = false; }
public RoundEnd(Event hEvent, const char[] sEvName, bool bDontBroadcast)
{
int iMapTime, iMapTimeLeft;
GetMapTimeLimit(iMapTime);
GetMapTimeLeft(iMapTimeLeft);
if ((iMapTimeLeft/60 <= iMapTime/2) && bSwapTeam == false)
{
bSwapTeam = true;
int iTRoundWIN = CS_GetTeamScore(2), iCTRoundWIN = CS_GetTeamScore(3);
for (int i = 1; i <= MaxClients; i++)
{
if (i && IsClientInGame (i) && IsClientConnected(i) && !IsClientSourceTV(i))
{
int iPlayerTeam = GetClientTeam(i);
if (iPlayerTeam == 2) { CS_SwitchTeam(i, 3); ResetWeapon(iPlayerTeam); ResetCash(iPlayerTeam); }
else if (iPlayerTeam == 3) { CS_SwitchTeam(i, 2); ResetWeapon(iPlayerTeam); ResetCash(iPlayerTeam); }
}
}
CS_SetTeamScore(2, iCTRoundWIN);
CS_SetTeamScore(3, iTRoundWIN);
PrintToChatAll("\x07000000[\x07ff0000Старички\x07000000] \x07FFFFFFСмена команд местами после окончания половины карты.");
}
}
ResetCash(client)
{
startMoney = GetConVarInt(FindConVar("mp_startmoney"));
SetEntData(client,cashOffset,startMoney,4,true);
}
ResetWeapon(client)
{
new team = GetClientTeam(client);
new weaponentity;
new grenade;
// SLOTS
// 0 - PRIMARY ARMOR
// 1 - SECUNDARY ARMOR
// 2 - KNIFE
// 3 - GRENADES - flashbang, hegrenade, smokegrenade
// 4 - C4
for(new slotweapon = 0; slotweapon <= 3; slotweapon++)
{
weaponentity = GetPlayerWeaponSlot(client,slotweapon);
if(IsValidEntity(weaponentity))
{
if (slotweapon != 2)
{
RemovePlayerItem(client,weaponentity);
if(slotweapon == 3)
{
grenade = GetPlayerWeaponSlot(client,slotweapon);
while(IsValidEntity(grenade))
{
RemovePlayerItem(client,grenade);
grenade = GetPlayerWeaponSlot(client,slotweapon);
}
}
}
}
}
if(team == CS_TEAM_CT)
{
GivePlayerItem(client,"weapon_usp");
}
else if(team == CS_TEAM_T)
{
GivePlayerItem(client,"weapon_glock");
}
}