#include <amxmodx>
#include <cstrike>
#include <hamsandwich>
new bool:g_spec[33], g_spec_reason[33][32], g_seconds[33];
new const TAG[] = "TEST";
#define NORMAL
//#define DEATHRUN
//#define RESPAWN
#if !defined DEATHRUN
new g_teamstocat[33];
#endif
public plugin_init()
{
register_plugin("Spec & Reason", "2.0", "cyby")
register_clcmd("say", "spec_say")
register_clcmd("amx_showspecs", "show_specs")
}
public spec_say(id)
{
if(!g_spec[id])
{
#if defined DEATHRUN
if(cs_get_user_team(id) == CS_TEAM_CT)
{
#endif
static citim_mesaj[64]
read_args(citim_mesaj, charsmax(citim_mesaj))
remove_quotes(citim_mesaj)
new comanda[16], motiv[22];
strbreak(citim_mesaj, comanda, charsmax(comanda), motiv, charsmax(motiv))
if(equal(comanda, "/spec", 5))
spec_me(id, motiv)
#if defined DEATHRUN
}
#endif
}
if(g_spec[id] && cs_get_user_team(id) == CS_TEAM_SPECTATOR)
{
static msj[192];
read_args(msj, charsmax(msj) - 1);
remove_quotes(msj);
if(equal(msj, "/back"))
back_to_game(id)
}
}
public spec_me(id, arg[])
{
static motiv[20], time[2];
strbreak(arg, motiv, 19, time, 1)
if (!motiv[0] || !time[0])
{
color(id, ".v[%s].g Comanda trebuie folosita astfel: /spec motiv timp.", TAG)
return
}
static timpul;
timpul = str_to_num(time)
if(timpul > 9)
{
color(id, ".v[%s].g Timpul situat spec nu trebuie sa treaca de 9 minute.", TAG)
return
}
if (timpul <= 0)
{
color(id, ".v[%s].g Valoarea introdusa de tine este invalida.", TAG)
return
}
static nume[32];
get_user_name(id, nume, charsmax(nume) - 1)
g_seconds[id] = timpul * 60 - 1;
set_task(1.0, "second_part", id)
g_spec_reason[id] = motiv
g_spec[id] = true
if(is_user_alive(id))
user_silentkill(id)
#if !defined DEATHRUN
g_teamstocat[id] = get_user_team(id)
#endif
cs_set_user_team(id, CS_TEAM_SPECTATOR)
color(0, ".v[%s].e %s.g se muta la spectator pe motivul:.e %s.g. El revine la joc in:.e %d.g minut%s.", TAG, nume, motiv, timpul, timpul < 2 ? "" : "e")
}
public second_part(id)
{
if(!is_user_connected(id) || is_user_alive(id) || !g_spec[id])
return
if(g_seconds[id] >= 1)
{
if(g_seconds[id] >= 60)
{
client_print(id, print_center, "Vei reveni la joc in %d minut%s si %d secund%s.", (g_seconds[id] / 60), (g_seconds[id] / 60) < 2 ? "" : "e", (g_seconds[id] % 60), (g_seconds[id] % 60) < 2 ? "a" : "e")
}
else
{
client_print(id, print_center, "Vei reveni la joc in %d secund%s.", g_seconds[id], g_seconds[id] < 2 ? "a" : "e")
}
g_seconds[id]--
set_task(1.0, "second_part", id)
}
else
{
g_seconds[id] = 0
client_print(id, print_center, "Revii indata la joc.")
back_to_game(id)
return;
}
}
public back_to_game(id)
{
if(!is_user_connected(id) || !g_spec[id])
return
static nume[32];
get_user_name(id, nume, charsmax(nume) - 1)
color(0, ".v[%s].e %s.g revine la joc!", TAG, nume)
#if defined DEATHRUN
cs_set_user_team(id, CS_TEAM_CT)
#else
switch(g_teamstocat[id])
{
case 1: cs_set_user_team(id, CS_TEAM_T)
case 2: cs_set_user_team(id, CS_TEAM_CT)
}
g_teamstocat[id] = 0
#endif
g_spec[id] = false
remove_task(id);
#if defined RESPAWN
set_task(0.5, "respawn_player", id)
#endif
}
#if defined RESPAWN
public respawn_player(id)
{
if(!is_user_connected(id) || is_user_alive(id))
return
ExecuteHamB(Ham_CS_RoundRespawn, id);
}
#endif
public client_putinserver(id)
{
g_spec[id] = false
#if !defined DEATHRUN
g_teamstocat[id] = 0
#endif
}
public client_disconnect(id)
{
remove_task(id);
g_spec[id] = false
#if !defined DEATHRUN
g_teamstocat[id] = 0
#endif
}
public show_specs(id)
{
static Total[32], iNum, iPlayer, Nume[32];
get_players(Total, iNum, "ch");
console_print(id, "Jucatorii setati pe spectator sunt:")
for(new i = 0; i < iNum; i++)
{
iPlayer = Total;
if(g_spec[iPlayer])
{
get_user_name(iPlayer, Nume, charsmax(Nume) - 1);
#if !defined DEATHRUN
new tine[20];
switch(g_teamstocat[iPlayer])
{
case 1: formatex(tine, charsmax(tine) - 1, "TERRORIST")
case 2: formatex(tine, charsmax(tine) - 1, "COUNTER-TERRORIST")
}
if(g_seconds[iPlayer] >= 60)
console_print(id, "%s | Motiv: %s | Timp: %d minut%s, %d secund%s | ECHIPA: %s.", Nume, g_spec_reason[iPlayer], (g_seconds[iPlayer] / 60), (g_seconds[iPlayer] / 60) < 2 ? "" : "e", (g_seconds[iPlayer] % 60), (g_seconds[iPlayer] % 60) < 2 ? "a" : "e", tine)
else
console_print(id, "%s | Motiv: %s | Timp: %d secund%s. | ECHIPA: %s.", Nume, g_spec_reason[iPlayer], (g_seconds[iPlayer] % 60), (g_seconds[iPlayer] % 60) < 2 ? "a" : "e", tine)
#else
if(g_seconds[iPlayer] >= 60)
console_print(id, "%s | Motiv: %s | Timp: %d minut%s, %d secund%s.", Nume, g_spec_reason[iPlayer], (g_seconds[iPlayer] / 60), (g_seconds[iPlayer] / 60) < 2 ? "" : "e", (g_seconds[iPlayer] % 60), (g_seconds[iPlayer] % 60) < 2 ? "a" : "e")
else
console_print(id, "%s | Motiv: %s | Timp: %d secund%s.", Nume, g_spec_reason[iPlayer], (g_seconds[iPlayer] % 60), (g_seconds[iPlayer] % 60) < 2 ? "a" : "e")
#endif
}
}
console_print(id, "Lista completa.")
return PLUGIN_HANDLED;
}
stock color(const id, const input[], any:...)
{
new count = 1, players[32]
static msg[191]
vformat(msg, 190, input, 3)
replace_all(msg, 190, ".v", "^4")
replace_all(msg, 190, ".g", "^1")
replace_all(msg, 190, ".e", "^3")
if(id) players[0] = id; else get_players(players, count, "ch")
{
for(new i = 0; i < count; i++)
{
if(is_user_connected(players))
{
message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players)
write_byte(players);
write_string(msg);
message_end();
}
}
}
}