Code:
#include < amxmodx >
#include < cstrike >
public plugin_init( )
{
register_plugin( "Block jointeam", "0.1", "Crey" );
}
public client_command( client )
{
static const szJoinCommand[ ] = "jointeam";
static szCommand[ 10 ];
read_argv( 0, szCommand, 9 );
if( equal( szCommand, szJoinCommand )
&& CS_TEAM_T <= cs_get_user_team( client ) <= CS_TEAM_CT )
{
console_print( client, "You cannot use jointeam while on a team! BOT!" );
return PLUGIN_HANDLED;
}
return PLUGIN_CONTINUE;
}
Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <colorchat>
#include <fun>
#define PLUGIN "Spec Switch"
#define VERSION "0.1.3"
#define AUTHOR "many"
new CsTeams:zTeam[33]
new zDeath[33]
new bool:type_spec[33] = false
new g_cvar
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
/* Cvar */
g_cvar = register_cvar("amx_specmode", "0") // 0 - enable use to all, 1 - enable use only ADMINs
/* Client Commands */
register_clcmd("say /spec", "cmdSpec", ADMIN_ALL, "- go to spectator")
register_clcmd("say_team /spec", "cmdSpec", ADMIN_ALL, "- go to spectator")
register_clcmd("say /back", "cmdBack", ADMIN_ALL, "- go back to your team")
register_clcmd("say_team /back", "cmdBack", ADMIN_ALL, "- go back to your team")
register_clcmd("say /ct","TeamCT")
register_clcmd("say /t","TeamT")
}
public cmdSpec(id)
{
if(!get_pcvar_num(g_cvar)) Spec(id)
else if( get_pcvar_num(g_cvar) && (get_user_flags(id) & ADMIN_KICK)) Spec(id)
else if( get_pcvar_num(g_cvar) && !(get_user_flags(id) & ADMIN_KICK)) PrintUserNotAdmin(id)
}
public cmdBack(id)
{
if (type_spec[id] && cs_get_user_team(id) == CS_TEAM_SPECTATOR && zTeam[id] != CS_TEAM_SPECTATOR ) Back(id)
else if( get_pcvar_num(g_cvar) && !(get_user_flags(id) & ADMIN_KICK) ) PrintUserNotAdmin(id)
}
public Spec(id)
{
zDeath[id] = cs_get_user_deaths(id)
if (cs_get_user_team(id) == CS_TEAM_SPECTATOR)
return
else{
type_spec[id] = true
zTeam[id] = cs_get_user_team(id)
cs_set_user_team(id, CS_TEAM_SPECTATOR)
user_silentkill(id)
client_print(id,print_chat,"Type /back to return from Spectator")
}
return
}
public TeamCT(id)
{
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
{
cs_set_user_team(id, CS_TEAM_CT)
}
}
public TeamT(id)
{
if(cs_get_user_team(id) == CS_TEAM_SPECTATOR)
{
cs_set_user_team(id, CS_TEAM_T)
}
}
public Back(id)
{
cs_set_user_team(id, zTeam[id])
cs_set_user_deaths(id, zDeath[id])
}
public FirstRespawn(id)
{
cs_user_spawn(id)
if (cs_get_user_team(id) == CS_TEAM_T){
give_item(id,"weapon_knife")
give_item(id,"weapon_glock18")
give_item(id,"ammo_9mm")
}
if (cs_get_user_team(id) == CS_TEAM_CT){
give_item(id,"weapon_knife")
give_item(id,"weapon_usp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
}
}
public SecondRespawn(id)
{
cs_user_spawn(id)
if (cs_get_user_team(id) == CS_TEAM_T){
give_item(id,"weapon_knife")
give_item(id,"weapon_glock18")
give_item(id,"ammo_9mm")
}
if (cs_get_user_team(id) == CS_TEAM_CT){
give_item(id,"weapon_knife")
give_item(id,"weapon_usp")
give_item(id,"ammo_45acp")
give_item(id,"ammo_45acp")
}
}
PrintUserNotAdmin(id)
{
client_print(id,print_chat,"Only Admins can use /spec, /back command")
}
public PrintRule(id)
{
if ( is_user_connected(id) && !is_user_bot(id) && !is_user_hltv(id) ){
ColorChat(id,GREEN,"^4[^3The Legion DeathMatch^4] ^4Type ^3/spec ^4if you want to go ^3Spectator")
ColorChat(id,GREEN,"^4[^3The Legion DeathMatch^4] ^4Type ^3/back ^4to return from ^3Spectator")
}
}
public client_putinserver(id)
{
if(!get_pcvar_num(g_cvar)) Rule(id)
else if( get_pcvar_num(g_cvar) && (get_user_flags(id) & ADMIN_KICK)) Rule(id)
}
public client_disconnected(id) type_spec[id] = false
public client_connect(id) type_spec[id] = false
public Rule(id) set_task(20.0, "PrintRule", id)