PHP Code:
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#pragma semicolon 1
#define PLUGIN "Gather Plugin"
#define VERSION "1.3.1"
#define AUTHOR "R3X"
#define CHANGE 0 // if 1 -> change nicks when tags not defined by .tag
#define FIRSTTEAM "Team A" // Tag #1 If .tag not set
#define SECONDTEAM "Team B" // Tag #2 If .tag not set
new bool:g_started;
new bool:g_exec;
new g_score_ct[2];
new g_score_t[2];
new g_half;
new bool:g_changetags[2]= {
true,
true
};
new g_tags[2][65]= {
"",
""
};
new const g_cmds[][]= {
"kick",
"ban",
"banip",
"ff",
"demo",
"start",
"restart",
"stop",
"map",
"tag",
"cancel",
"warmup"
};
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_concmd("amx_tagt", "tagChange", ADMIN_BAN, "<T tagname>");
register_concmd("amx_tagct", "tagChange", ADMIN_BAN, "<CT tagname>");
register_clcmd("chooseteam","changeTeam");
register_clcmd("say", "chatFilter", ADMIN_BAN);
register_clcmd("say .score","showScore");
register_event("TeamScore", "teamScore", "a");
}
public changeTeam(id)
{
if(g_started)
{
client_print(id, print_chat,"[Match] Do not change team during match!");
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
public chatFilter(id) {
if(!(get_user_flags(id) & ADMIN_BAN))
return PLUGIN_HANDLED;
new message[128];
read_argv(1, message, 127);
for(new i=0;i<sizeof(g_cmds);i++) {
new cmd[33];
formatex(cmd,32,".%s",g_cmds[i]);
if(containi(message,cmd) == 0) {
callBack(id,i);
return PLUGIN_HANDLED;
}
}
return PLUGIN_CONTINUE;
}
public showMatchEnd() {
switch( g_half ) {
case 1: {
server_cmd("say Half finished!");
server_cmd("say Please switch your team now!");
}
case 2: {
server_cmd("say The match is over.");
server_cmd("say Thanks for playing!");
prepareMatch();
}
}
g_exec=false;
}
prepareMatch() {
//game not started
g_started = false;
g_half = 0;
//reset score
g_score_ct[0] = 0;
g_score_ct[1] = 0;
g_score_t[0] = 0;
g_score_t[1] = 0;
//clear tags
g_changetags[0] = true;
g_changetags[1] = true;
g_tags[0] = "";
g_tags[1] = "";
}
public restartRound(arg[]) {
new id = arg[0];
new args[1];
args[0] = id+1;
g_exec = true;
switch( id ) {
case 0: {
server_cmd("say Match start in:");
server_cmd("say 5");
}
case 1,2: {
server_cmd("say %d",5-id);
server_cmd("sv_restartround 1");
}
case 3: server_cmd("say 2");
case 4: {
server_cmd("say 1");
server_cmd("sv_restartround 1");
set_task(2.0, "restartRound", 0, args,1);
}
case 5: {
server_cmd("say Game is ON !");
server_cmd("say LIVE ! LIVE ! LIVE !");
server_cmd("say Good Luck and Have Fun!");
set_hudmessage(255, 255, 255, -1.0, 0.2, 0, 6.0, 3.0);
show_hudmessage(0, "Game is LIVE^n^nStart of half: %d",g_half);
g_exec=false;
}
}
if(id < 4)
set_task(1.0, "restartRound", 0, args,1);
}
public callBack(id, cID) {
new message[128], cmd[33], arg[65], arg2[65];
read_argv (1, message, 128);
parse(message,cmd,32,arg,64,arg2,64);
replace(cmd,32,".","");
switch(cID) {
case 0: { // Kick Player
console_cmd(id,"amx_kick %s", arg);
}
case 1: { // Ban Player
new bantime=str_to_num(arg2);
if(bantime==0)
bantime=1;
console_cmd(id,"amx_ban %s %d", arg, bantime);
}
case 2: { // BanIP Player
new bantime=str_to_num(arg2);
if(bantime==0)
bantime=1;
console_cmd(id,"amx_banip %s %d", arg, bantime);
}
case 3: { // Set FriendlyFire
if(equali(arg,"on")) {
console_cmd(id,"amx_cvar mp_friendlyfire 1");
}
else if(equali(arg,"off")) {
console_cmd(id,"amx_cvar mp_friendlyfire 0");
}
}
case 4: { // Record Demo
new demoname[71];
new datetime[31],mapname[21];
get_time("%d-%m-%Y-%H-%M-%S", datetime, 30);
get_mapname(mapname,20);
formatex(demoname,70,"demo-%s-%s.dem",mapname,datetime);
new player = cmd_target(id, arg, 0);
if(player==0)
client_print(id,print_chat,"[Record Demo] '%s' Not found!",arg);
else {
console_cmd(player,"record %s",demoname);
new name[36];
get_user_name(player,name,35);
client_print(id,print_chat,"[Record Demo] Player found: '%s'",name);
}
}
case 5: { // Start Match
if(g_half==2 && !g_started) {
client_print(id, print_chat,"[Match] You can`t start 3rd period");
return PLUGIN_HANDLED;
}
if(g_exec) {
client_print(id, print_chat,"[Match] During executing...");
return PLUGIN_HANDLED;
}
if(g_started) {
client_print(id, print_chat,"[Match] Started -- type .stop before");
return PLUGIN_HANDLED;
}
if(equal(g_tags[0],"")) {
copy(g_tags[0], 20 ,FIRSTTEAM);
g_changetags[0]=false;
}
if(equal(g_tags[1],"")) {
copy(g_tags[1], 20 ,SECONDTEAM);
g_changetags[1]=false;
}
// Exec configs & set bools.
server_cmd("exec war.cfg");
checkAll();
new args[1];
args[0]=0;
restartRound(args);
if(g_half==0)
g_half=1;
else if(g_half==1)
g_half=2;
g_started=true;
}
case 6: { // Restart
if(g_exec) {
client_print(id, print_chat,"[Match] During executing...");
return PLUGIN_HANDLED;
}
if(!g_started) {
client_print(id, print_chat,"[Match] Not started -- type .start before");
return PLUGIN_HANDLED;
}
new args[1];
args[0] = 0;
restartRound(args);
g_score_ct[g_half-1] = 0;
g_score_t[g_half-1] = 0;
g_started = true;
}
case 7: { // Stop match.
if(g_exec)
{
client_print(id, print_chat,"[Match] During executing...");
return PLUGIN_HANDLED;
}
if(!g_started)
{
client_print(id, print_chat,"[Match] Not started -- type .start before");
return PLUGIN_HANDLED;
}
g_exec = true;
server_cmd("exec warmup.cfg");
server_cmd("sv_restartround 3");
set_task(4.0,"showMatchEnd");
g_started = false;
}
case 8: { // Changelevel
console_cmd(id,"amx_map %s", arg);
}
case 9: { // Tag System
if(!(g_half==0 || (g_half==2 && !g_started))) {
client_print(id, print_chat,"[Remove Tags] You can`t do this now");
return PLUGIN_HANDLED;
}
if(equali(arg, "OFF")) {
new ct[21],t[21];
if(g_half == 0 || g_half == 1) {
copy(ct ,20, g_tags[0]);
copy(t ,20, g_tags[1]);
}
else if(g_half == 2) {
copy(ct ,20, g_tags[1]);
copy(t ,20, g_tags[0]);
}
untagThem(CS_TEAM_CT, ct);
untagThem(CS_TEAM_T, t);
g_tags[0]="";
g_tags[1]="";
}
else if(equal(arg,"") || equal(arg2,"")) {
client_print(id,print_chat,"Current tags:");
client_print(id,print_chat,"^tCT: %s",g_tags[0]);
client_print(id,print_chat,"^tT : %s",g_tags[1]);
client_print(id,print_chat,"Using: .tag CT|T <tag> or .tag OFF");
}
else if(equali(arg,"CT")) {
client_cmd(id,"amx_tagct %s", arg2);
}
else if(equali(arg,"T")) {
client_cmd(id,"amx_tagt %s", arg2);
}
else {
client_print(id,print_chat,"Using: .tag CT|T <tag> or .tag OFF");
}
}
case 10: { // Cancel Game.
if(g_half == 0) {
client_print(id, print_chat,"Match not started");
return PLUGIN_HANDLED;
}
prepareMatch();
server_cmd("sv_restartround 3");
server_cmd("say !! Game cancelled !!");
server_cmd("say !! Game cancelled !!");
}
case 11: {//Warmup
server_cmd("exec warmup.cfg");
server_cmd("say !! Warmup !!");
}
}
return PLUGIN_HANDLED;
}
public showScore(id) {
if(g_half == 0)
client_print(id, print_chat,"Wait for start of match");
else
client_print(id, print_chat,"[%s] %d:%d [%s]",g_tags[0],g_score_ct[0]+g_score_ct[1], g_score_t[0]+g_score_t[1],g_tags[1]);
return PLUGIN_HANDLED;
}
public teamScore() {
if(!g_started)
return PLUGIN_CONTINUE;
new team[32];
read_data(1, team, 31);
if (g_half == 1) { // first half
if (team[0] == 'C')
g_score_ct[0] = read_data(2);
else if (team[0] == 'T')
g_score_t[0] = read_data(2);
}
else if (g_half == 2) { // second half
if (team[0] == 'C')
g_score_t[1] = read_data(2);
else if (team[0] == 'T')
g_score_ct[1] = read_data(2);
}
return PLUGIN_CONTINUE;
}
public tagChange(id,level,cid) {
if (!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED;
new cmd[11], tag[21];
read_argv (0, cmd, 10);
read_argv (1, tag, 20);
if(equali("amx_tagt",cmd)) {
setGTags(1,tag);
tagThem(CS_TEAM_T);
}
else if(equali("amx_tagct",cmd)) {
setGTags(2, tag);
tagThem(CS_TEAM_CT);
}
return PLUGIN_HANDLED;
}
public tagPlayer(id) {
new CsTeams:p_team=cs_get_user_team(id);
new name[36];
get_user_name(id,name,35);
new tag[21];
new a = 0;
if(g_half==0 || (g_half==1 && g_started)) {
if(p_team==CS_TEAM_CT)
a=0;
else if(p_team==CS_TEAM_T)
a=1;
}
else if(g_half==2 || (g_half==1 && !g_started)) {
if(p_team==CS_TEAM_CT)
a=1;
else if(p_team==CS_TEAM_T)
a=0;
}
if(!g_changetags[a] && CHANGE==0)
return;
copy(tag ,20, g_tags[a]);
if(contain(name,tag)!=0)
client_cmd(id, "name ^"%s%s^"",tag,name);
}
tagThem(CsTeams:team) {
new Players[32], playerCount, player;
get_players(Players, playerCount);
for (new i=0; i<playerCount; i++) {
player = Players[i];
new CsTeams:p_team=cs_get_user_team(player);
if(p_team == team) {
tagPlayer(player);
}
}
}
untagThem(CsTeams:team, tag[21]) {
new Players[32], playerCount, i, player;
get_players(Players, playerCount);
for (i=0; i<playerCount; i++) {
player = Players[i];
new CsTeams:p_team=cs_get_user_team(player);
new name[36];
get_user_name(player,name,35);
if(p_team == team) {
if(contain(name,tag)==0) {
replace(name, 35, tag,"");
client_cmd(player,"name ^"%s^"",name);
}
}
}
new type=0;
if(team==CS_TEAM_T)
type=1;
else if(team==CS_TEAM_CT)
type=2;
setGTags(type, "");
}
setGTags(type, tag[21]) {
if(g_half==0 || g_half==1) {
switch( type ) {
case 1: copy(g_tags[1],64,tag);
case 2: copy(g_tags[0],64,tag);
}
}
if(g_half==2) {
switch( type ) {
case 1: copy(g_tags[0],64,tag);
case 2: copy(g_tags[1],64,tag);
}
}
}
public client_infochanged(id) {
if(equal(g_tags[0],"") || equal(g_tags[1],""))
return;
set_task(1.0, "tagPlayer",id);
}
public checkAll() {
tagThem(CS_TEAM_CT);
tagThem(CS_TEAM_T);
}