Код за потвърждение: Избери целия код
/*
*
* CSDM Teambalancer V1.0 by DA
* Date: 03.04.2008
*
*
* Description:
* This plugin balance the teams in CS 1.6 without to end the round. It was made for CSDM (Deathmatch) Servers
*
*
* Installation:
* Download the sma file and compile it
* Load the compiled csdm_teambalancer.amxx to your plugins folder
* Add a line "csdm_teambalancer.amxx" (without quotes) to your plugins.ini
* If you want to play a sound to the player who switched by the plugin then copy the massteleporttarget.wav to your /sound/misc/ folder and add this to your amxx.cfg: amx_tsound 1
* Change the map or restart the Server
*
*
* SVAR's:
* amx_tfreq (Default: 50) - All 50 (Default) death the plugin checks the players and switch they
* amx_tmaxplayers (Default: 4) - Max players on the server that it works
* amx_tsound (Default: 0) - Plays a sound to the player if he will be changed
*
*
* Credits:
* Jim for some code and the idea
* Geesu for the sound file from wc3ft
*
*
*/
#include <amxmodx>
#include <cstrike>
#include <ColorChat>
#include <dhudmessage>
#define PLUGIN "CSDM Teambalancer"
#define AUTHOR "DA"
#define VERSION "1.0"
#define TeamT 1
#define TeamCT 2
new counter=0;
public plugin_precache()
{
if ((get_cvar_num("amx_tsound")) != 1)
return PLUGIN_CONTINUE;
precache_sound("misc/massteleporttarget.wav");
return PLUGIN_CONTINUE;
}
public on_death()
{
counter++;
if (counter >= (get_cvar_num("amx_tmaxfreq")))
{
if (get_playersnum() >= (get_cvar_num("amx_tmaxplayers")))
{
counter = 0;
check_balance();
}
}
}
public check_balance()
{
new players[32], tnum, ctnum;
get_players(players, tnum, "ce", "TERRORIST");
get_players(players, ctnum, "ce", "CT");
if ((tnum - ctnum) >= 2) transfer_player(TeamT);
if ((ctnum - tnum) >= 2) transfer_player(TeamCT);
}
transfer_player(team)
{
new name[32], players[32], scores[32];
new player, playercount, bestscore, theone, i;
get_players(players, playercount, "ce", team == TeamT ? "TERRORIST" : "CT");
for (i=0; i<playercount; i++)
{
player = players[i];
scores[i] = get_user_frags(player) - get_user_deaths(player);
}
bestscore = -9999;
for (i=0; i<playercount; i++)
{
if (scores[i] > bestscore)
{
bestscore = scores[i];
theone = players[i];
}
}
cs_set_user_team(theone, team == TeamT ? CS_TEAM_CT : CS_TEAM_T);
if (get_cvar_num("amx_tsound") == 1)
client_cmd(theone, "speak misc/MassTeleportTarget");
set_hudmessage(255, 140, 0, -1.0, 0.40, 2, 0.02, 5.0, 0.01, 0.1, 2);
show_hudmessage(theone,"You have been transferred to %s", team == TeamT ? "CT" : "Terrorist");
get_user_name(theone,name,31);
set_dhudmessage(random(255), random(255), random(255), -1.0, 0.7, 1, 0.1, 4.0, 0.1, 0.1)
show_dhudmessage(0, "%s has been transferred to %s.", name, team == TeamT ? "CT" : "Terrorist");
console_print(0,"%s has been transferred to %s.", name, team == TeamT ? "CT" : "Terrorist");
}
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR);
register_cvar("amx_tmaxfreq", "50");
register_cvar("amx_tmaxplayer", "4");
register_cvar("amx_tsound", "1");
register_event("DeathMsg", "on_death", "a");
}