#include <amxmodx>
#include <amxmisc>
#include <hamsandwich>
#include <cstrike>
#include <fun>
#define PLUGIN "KF Plugin"
#define VERSION "v1.0"
#define AUTHOR "CSmiLeFaCe"
new const tag[]="WEBDiyo";
new bool:g_bKnifeRound;
new bool:g_bVotingProcess;
new g_Votes[ 2 ];
new g_pSwapVote;
new g_pNoslash;
new kisinindegeriT[33];
new kisinindegeriCT[33];
new csmilefacetpyeriT;
new csmilefacetpyeriCT;
new g_kfteleport;
new bool:kfround = false
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR);
register_event("HLTV","new_round","a","1=0","2=0");
csmilefacetpyeriT = 1
csmilefacetpyeriCT = 1
register_clcmd( "say /kf", "CmdKnifeRound", ADMIN_BAN, "Bicak Turunu Baslatma" );
register_clcmd( "say /kr", "CmdKnifeRound", ADMIN_BAN, "Bicak Turunu Baslatma" );
register_clcmd( "say !kf", "CmdKnifeRound", ADMIN_BAN, "Bicak Turunu Baslatma" );
register_clcmd( "say !kr", "CmdKnifeRound", ADMIN_BAN, "Bicak Turunu Baslatma" );
register_clcmd( "say .kf", "CmdKnifeRound", ADMIN_BAN, "Bicak Turunu Baslatma" );
register_clcmd( "say .kr", "CmdKnifeRound", ADMIN_BAN, "Bicak Turunu Baslatma" );
register_clcmd( "say /kniferound", "CmdKnifeRound", ADMIN_BAN, "Bicak Turunu Baslatma" );
register_clcmd( "say /takimlaridegiss", "CmdSwapTeams", ADMIN_BAN, "Bicak Turunu Kapat" );
register_concmd("say /kfteleport", "cmdkfteleport", ADMIN_CVAR)
register_concmd("say .kfteleport", "cmdkfteleport", ADMIN_CVAR)
register_concmd("say !kfteleport", "cmdkfteleport", ADMIN_CVAR)
register_clcmd( "shield", "BlockCmds" );
register_clcmd( "cl_rebuy", "BlockCmds" );
register_event( "CurWeapon", "EventCurWeapon", "be", "2!29" );
register_logevent( "EventRoundEnd", 2, "0=World triggered", "1=Round_Draw", "1=Round_End" );
register_menucmd( register_menuid( "\rTakim Degisikligi?" ), 1023, "MenuCommandTE" );
register_menucmd( register_menuid( "\bTakim Degisikligi?" ), 1023, "MenuCommandCT" );
RegisterHam( Ham_Weapon_PrimaryAttack, "weapon_knife", "HamKnifePrimAttack" );
}
public new_round(id)
{
if (kfround == true) {
chat_color(0,"!yRound : !gKF Round");
chat_color(0,"!ySkor : !gCounter-Terrorists !t: - !y| !gTerrorists !y: !t: -")
}
return PLUGIN_HANDLED
}
public teleport( id ) {
new szMapName[ 32 ], iCTOrigin[ 3 ], iTOrigin[ 3 ];
get_mapname( szMapName, charsmax( szMapName ) );
if( equali( szMapName, "de_dust2" ) )
{
switch(kisinindegeriT[id]){
case 1: {
iTOrigin = { 1344, 1197, 36 };
}
case 2: {
iTOrigin = { 1404, 1203, 36 };
}
case 3: {
iTOrigin = { 1452, 1206, 36 };
}
case 4: {
iTOrigin = { 1494, 1210, 36 };
}
case 5: {
iTOrigin = { 1546, 1189, 95 };
}
}
switch(kisinindegeriCT[id]){
case 1: {
iCTOrigin = { 1340, 2061, 108 };
}
case 2: {
iCTOrigin = { 1388, 2054, 108 };
}
case 3: {
iCTOrigin = { 1439, 2051, 108 };
}
case 4: {
iCTOrigin = { 1478, 2053, 108 };
}
case 5: {
iCTOrigin = { 1528, 2060, 108 };
}
}
}
if( equali( szMapName, "de_inferno" ) )
{
switch(kisinindegeriT[id]){
case 1: {
iTOrigin = { 733, -220, 204 };
}
case 2: {
iTOrigin = { 775, -225, 204 };
}
case 3: {
iTOrigin = { 814, -229, 204 };
}
case 4: {
iTOrigin = { 865, -228, 204 };
}
case 5: {
iTOrigin = { 920, -222, 220 };
}
}
switch(kisinindegeriCT[id]){
case 1: {
iCTOrigin = { 725, 406, 204 };
}
case 2: {
iCTOrigin = { 770, 409, 204 };
}
case 3: {
iCTOrigin = { 817, 402, 204 };
}
case 4: {
iCTOrigin = { 855, 401, 204 };
}
case 5: {
iCTOrigin = { 911, 405, 220 };
}
}
}
if( cs_get_user_team(id) == CS_TEAM_T ){
set_user_origin( id, iTOrigin );
}
else{
set_user_origin( id, iCTOrigin );
}
}
public EventCurWeapon( id ) {
if( g_bKnifeRound ) engclient_cmd( id, "weapon_knife" );
return PLUGIN_CONTINUE;
}
public CmdRestartRound( id, level, cid ) {
if ( !cmd_access( id, level, cid, 1 ) ) return PLUGIN_HANDLED;
g_bKnifeRound = false;
server_cmd( "sv_restartround 1" );
return PLUGIN_CONTINUE;
}
public CmdKnifeRound( id, level, cid ) {
if( !cmd_access( id, level, cid, 1 ) ) return PLUGIN_HANDLED;
CmdRestartRound( id, level, cid );
kfround = true
set_task( 1.9, "KnifeRoundStart", id );
set_cvar_string("mp_freezetime", "7");
return PLUGIN_CONTINUE;
}
public CmdSwapTeams( id,level,cid ) {
if( !cmd_access( id, level, cid, 1 ) ) return PLUGIN_HANDLED;
SwapTeams( );
CmdRestartRound( id, level, cid );
return PLUGIN_CONTINUE;
}
public KnifeRoundStart( ) {
g_bKnifeRound = true;
g_bVotingProcess = false;
new players[ 32 ], num;
get_players( players, num );
for( new i = 0; i < num ; i++ )
{
new item = players[ i ];
EventCurWeapon( item );
new id
id = item
numaraata(item)
if (get_pcvar_num(g_kfteleport) == 1 ) {
teleport( id )
}
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Knife Round Basladi")
}
kfround = false
return PLUGIN_CONTINUE;
}
public numaraata(id) {
if( cs_get_user_team(id) == CS_TEAM_CT ){
if(csmilefacetpyeriCT == 1){
kisinindegeriCT[id] = 1
kisinindegeriT[id] = 0
csmilefacetpyeriCT = 2
}
else if(csmilefacetpyeriCT == 2){
kisinindegeriCT[id] = 2
kisinindegeriT[id] = 0
csmilefacetpyeriCT = 3
}
else if(csmilefacetpyeriCT == 3){
kisinindegeriCT[id] = 3
kisinindegeriT[id] = 0
csmilefacetpyeriCT = 4
}
else if(csmilefacetpyeriCT == 4){
kisinindegeriCT[id] = 4
kisinindegeriT[id] = 0
csmilefacetpyeriCT = 5
}
else if(csmilefacetpyeriCT == 5){
kisinindegeriCT[id] = 5
kisinindegeriT[id] = 0
csmilefacetpyeriCT = 1
}
}
if( cs_get_user_team(id) == CS_TEAM_T ){
if(csmilefacetpyeriT == 1){
kisinindegeriT[id] = 1
kisinindegeriCT[id] = 0
csmilefacetpyeriT = 2
}
else if(csmilefacetpyeriT == 2){
kisinindegeriT[id] = 2
kisinindegeriCT[id] = 0
csmilefacetpyeriT = 3
}
else if(csmilefacetpyeriT == 3){
kisinindegeriT[id] = 3
kisinindegeriCT[id] = 0
csmilefacetpyeriT = 4
}
else if(csmilefacetpyeriT == 4){
kisinindegeriT[id] = 4
kisinindegeriCT[id] = 0
csmilefacetpyeriT = 5
}
else if(csmilefacetpyeriT == 5){
kisinindegeriT[id] = 5
kisinindegeriCT[id] = 0
csmilefacetpyeriT = 1
}
}
}
public SwapTeams( ) {
for( new i = 1; i <= get_maxplayers(); i++ ) {
if( is_user_connected( i ) )
{
switch( cs_get_user_team( i ) )
{
case CS_TEAM_T: cs_set_user_team( i, CS_TEAM_CT );
case CS_TEAM_CT: cs_set_user_team( i, CS_TEAM_T );
}
}
}
}
public EventRoundEnd( ) {
if( g_bKnifeRound && get_pcvar_num( g_pSwapVote ) ) {
new players[ 32 ], num;
get_players( players, num, "ae", "TERRORIST" );
if(!num)
{
chat_color(0,"!g[%s] !tCounter-Terrorists Simdi Kendi Arasinda Oylayacak!", tag );
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Kazanan Counter-Terrorists Takimi")
set_task( 6.0, "vote_ct" );
for( new i = 1; i <= get_maxplayers(); i++ ) {
if( get_user_team( i ) == 1 ) {
chat_color(i,"!g[%s] !y Yapilan Oylamalari Takimin Goremez.", tag );
}
}
}
else
{
chat_color(0,"!g[%s] !tTerrorists Simdi Kendi Arasinda Oylayacak!", tag );
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Kazanan Terrorists Takimi")
set_task( 6.0, "vote_t" );
for( new i = 1; i <= get_maxplayers(); i++ ) {
if( get_user_team( i ) == 2 ) {
chat_color(i,"!g[%s] !y Yapilan Oylamalari Takimin Goremez.", tag );
}
}
}
}
return PLUGIN_CONTINUE;
}
public vote_t( ) {
for( new i = 1; i <= get_maxplayers(); i++ ) {
if( is_user_alive( i ) && cs_get_user_team( i ) == CS_TEAM_T )
{
ShowMenuKFTE( i );
}
}
g_bKnifeRound = false;
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 10 Saniye")
set_task( 1.0, "kfdokuz" );
}
public vote_ct( ) {
for( new i = 1; i <= get_maxplayers(); i++ ) {
if( is_user_alive( i ) && cs_get_user_team( i ) == CS_TEAM_CT )
{
ShowMenuKFCT( i );
}
}
g_bKnifeRound = false;
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 10 Saniye")
set_task( 1.0, "kfdokuz" );
}
public ShowMenuKFTE( id ) {
g_bVotingProcess = true;
if( g_bVotingProcess ) {
new szMenuBody[ 256 ], keys;
new nLen = format( szMenuBody, 255, "\rTakim Degisikligi?^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\r1. \wEvet" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\r2. \wHayir" );
keys = ( 1<<0 | 1<<1 | 1<<9 );
show_menu( id, keys, szMenuBody, -1 );
}
return PLUGIN_CONTINUE;
}
public MenuCommandTE( id, key ) {
if( !g_bVotingProcess ) return PLUGIN_HANDLED;
new szName[ 32 ];
get_user_name( id, szName, charsmax( szName ) );
for( new i = 1; i <= get_maxplayers(); i++ ) {
if( is_user_alive( i ) && cs_get_user_team( i ) == CS_TEAM_T )
{
switch( key )
{
case 0:
{
g_Votes[ 0 ]++;
chat_color(i,"!g[%s] !y%s !tevet dedi.", tag, szName );
}
case 1:
{
g_Votes[ 1 ]++;
chat_color(i,"!g[%s] !y%s !thayir dedi.", tag, szName );
}
}
}
}
return PLUGIN_HANDLED;
}
public ShowMenuKFCT( id ) {
g_bVotingProcess = true;
if( g_bVotingProcess ) {
new szMenuBody[ 256 ], keys;
new nLen = format( szMenuBody, 255, "\bTakim Degisikligi?^n" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\r1. \wEvet" );
nLen += format( szMenuBody[nLen], 255-nLen, "^n\r2. \wHayir" );
keys = ( 1<<0 | 1<<1 | 1<<9 );
show_menu( id, keys, szMenuBody, -1 );
}
return PLUGIN_CONTINUE;
}
public MenuCommandCT( id, key ) {
if( !g_bVotingProcess ) return PLUGIN_HANDLED;
new szName[ 32 ];
get_user_name( id, szName, charsmax( szName ) );
for( new i = 1; i <= get_maxplayers(); i++ ) {
if( is_user_alive( i ) && cs_get_user_team( i ) == CS_TEAM_CT )
{
switch( key )
{
case 0:
{
g_Votes[ 0 ]++;
chat_color(i,"!g[%s] !y%s !tevet dedi.", tag, szName );
}
case 1:
{
g_Votes[ 1 ]++;
chat_color(i,"!g[%s] !y%s !thayir dedi.", tag, szName );
}
}
}
}
return PLUGIN_HANDLED;
}
public finishvote( ) {
if( !g_bVotingProcess ) return PLUGIN_HANDLED;
server_cmd( "sv_restartround 1" );
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 0 Saniye^n Bundan Sonra Girilen Oylar Sayilmayacaktir!")
remove_task()
if ( g_Votes[ 0 ] > g_Votes[ 1 ] )
{
chat_color(0,"!g[%s] !yKazanan takim kendi aralarinda oylama sonucu !tdegistirilsin dedi.", tag );
SwapTeams( );
}
else
{
chat_color(0,"!g[%s] !yKazanan takim kendi aralarinda oylama sonucu !tdegistirilmesin dedi.", tag );
}
g_Votes[ 0 ] = 0;
g_Votes[ 1 ] = 0;
g_bVotingProcess = false;
return PLUGIN_HANDLED;
}
public HamKnifePrimAttack( iEnt ) {
if( g_bKnifeRound && get_pcvar_num( g_pNoslash ) )
{
ExecuteHamB( Ham_Weapon_SecondaryAttack, iEnt );
return HAM_SUPERCEDE;
}
return HAM_IGNORED;
}
public BlockCmds( ) {
if( g_bKnifeRound ) {
return PLUGIN_HANDLED_MAIN;
}
return PLUGIN_CONTINUE;
}
public kfdokuz () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 9 Saniye")
set_task( 1.0, "kfsekiz" );
}
public kfsekiz () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 8 Saniye")
set_task( 1.0, "kfyedi" );
}
public kfyedi () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 7 Saniye")
set_task( 1.0, "kfalti" );
}
public kfalti () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 6 Saniye")
set_task( 1.0, "kfbes" );
}
public kfbes () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 5 Saniye")
set_task( 1.0, "kfdort" );
}
public kfdort () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 4 Saniye")
set_task( 1.0, "kfuc" );
}
public kfuc () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 3 Saniye")
set_task( 1.0, "kfiki" );
}
public kfiki () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 2 Saniye")
set_task( 1.0, "kfbir" );
}
public kfbir () {
set_hudmessage(0, 160, 0, -1.0, 0.28, 0, 6.0, 12.0)
show_hudmessage(0, "Oylamanin Bitmesine 1 Saniye")
set_task( 1.0, "finishvote" );
}
#if AMXX_VERSION_NUM < 183
stock chat_color(const id, const input[], any:...){
new count=1,players[32];
static msg[191]; vformat(msg,charsmax(msg),input,3);
replace_all(msg,charsmax(msg),"!g","^x01"); // Default Renk(Sarı)
replace_all(msg,charsmax(msg),"!n","^x04"); // Yeşil Renk
replace_all(msg,charsmax(msg),"!t","^x03"); // Takım Renk( CT mavi , T kırmızı )
if(id) players[0]=id; else get_players(players,count,"ch");{
for(new i=0;i<count;i++){
if(is_user_connected(players[i])){
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
write_byte(players[i]),write_string(msg),message_end();
}
}
}
}
#else
stock chat_color(const id,const input[],any:...){
static msg[191]; vformat(msg,charsmax(msg),input,3);
replace_all(msg,charsmax(msg),"!g","^x01"),replace_all(msg,charsmax(msg),"!n","^x04"),replace_all(msg,charsmax(msg),"!t","^x03");
client_print_color(id,id,msg);
}
#endif