Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <amxmodx>
- #include <amxmisc>
- #include <cstrike>
- #include <hamsandwich>
- #include <fakemeta>
- #include <fakemeta_util>
- #include <fun>
- #include <engine>
- #include <xs>
- #include <csx>
- #include <fun>
- #include <fvault>
- #pragma tabsize 0
- #pragma compress 1
- new MAXPLAYERS
- new his_type[33]
- new bool:isBlocked[ 33 ][ 33 ]
- #define CHAT_TAG "^3[^4KnifeDuels^3]^1 " // add a space right after if you want one between the tag and the messages
- #define ARENA_ENT_NAME "entity_arena" // this is the arena's entity name
- // here you can set the maximum number of arenas that can be used ingame
- #define MAX_ARENAS 4
- new const arena_names[][] = {
- "",
- "A", // 1st arena
- "B", // 2nd arena
- "C", // 3rd arena
- "D" // 4th arena
- }
- enum
- {
- SCOREATTRIB_ARG_PLAYERID = 1,
- SCOREATTRIB_ARG_FLAGS
- }
- enum ( <<= 1 )
- {
- SCOREATTRIB_FLAG_NONE = 0,
- SCOREATTRIB_FLAG_DEAD = 1,
- SCOREATTRIB_FLAG_BOMB,
- SCOREATTRIB_FLAG_VIP
- }
- // some arena codes...
- #define ARENA_CODE 305924
- #define FAKE_CODE 6969696969
- #define CENTER_CODE 9696969696
- #define EXTRA_CODE 911911911
- // task code for advert
- #define TASK_AD 34585029
- #define TASK_DUEL 34585029
- #define TASK_GIVEUP 34585029
- #define TASK_OFFLINE 34585029
- // some movement defines
- #define MOVE_UP 0
- #define MOVE_DOWN 1
- #define MOVE_RIGHT 2
- #define MOVE_LEFT 3
- #define MOVE_FRONT 4
- #define MOVE_BACK 5
- // Arena ground size
- #define ARENA_MINS Float:{-150.0,-62.0,-1.5}
- #define ARENA_MAXS Float:{10.0,62.0,1.5}
- // arena coords offcourse, this is used to build the arena.
- new const Float:ARENA_COORDS[][2] = {
- {0.0,0.0},
- {100.0,0.0},
- {0.0,100.0},
- {100.0,100.0},
- {-100.0,0.0},
- {0.0,-100.0},
- {-100.0,-100.0},
- {-100.0,100.0},
- {100.0,-100.0},
- {200.0,0.0},
- {200.0,100.0},
- {200.0,-100.0}
- }
- enum {
- BLUE_SIDE = 0,
- RED_SIDE = 1,
- LEFT_SIDE = 2,
- RIGHT_SIDE = 3,
- TOP_SIDE = 4
- }
- new const ARENA_FILE[] = "%s/duel_arena/%s.cfg"
- new user_can_spawn[33];
- // if you want to disable a sound, rename it with "common/null.wav"
- new const DUEL_SOUNDS[][] = {
- "ambience/goal_1.wav", // 0 round win
- "x/nih_die2.wav", // 1 round lose
- "ambience/des_wind1.wav", // 2 round draw
- "buttons/bell1.wav", // 3 round start
- "buttons/blip1.wav" , // 4 accepted duel
- "weapons/headshot2.wav", // 5 Countdown
- "events/tutor_msg.wav" // 6 "Go!"
- }
- new const ARENA_MODELS[][] = {
- "models/Duel/Duel_Arena.mdl", // Arena's ground
- "models/Duel/Duel_Arena.mdl" // Arena's walls
- }
- new const MAP_FIX[][] = {
- "35hp_2"
- }
- new Float:MAP_FIX_Z_COORD[] = {
- -864.253723
- }
- new const g_szKnifeSound[] = "weapons/knife_hitwall1.wav";
- new Float:g_fHit[33];
- new iHitCount[33]
- new cvar_count = 0
- new Head_shot[33][33]
- new fakes;
- new is_in_duel[33],his_countdown[33],is_frozen[33],his_challenger[33],his_asker[33],arena_number[33],his_wins[33],his_name[33][64];
- new rounds[MAX_ARENAS+1],Float:arena_coord[MAX_ARENAS+1][3]; // using +1 just incase...
- new Float:his_spawn[33][3],got_spawn[33],Float:his_angle[33][3],Float:his_original_spawn[33][3];
- new next_empty_arena,total_arenas;
- new map_name[32]
- new cvar_z_fix,cvar_sounds,cvar_rounds,cvar_kills,cvar_cooldown,cvar_time
- new Float:max_size[3],Float:min_size[3];
- new selected = 1,Float:move_size[33],his_timer[33],his_offline[33],his_HS[33];
- new map_default_hp;
- new map_id = -1;
- new his_previous_team[33];
- // using these for less cpu usage.
- new IS_BUGGED_MAP = 0,MAP_FIX_ENABLED,SOUNDS_ENABLED,MAX_ROUNDS,MAX_KILLS,MAX_COUNTDOWN,MAX_TIME;
- new bool:gBackStabing[33];
- const OFFSET_WEAPONOWNER = 41
- const OFFSET_LINUX_WEAPONS = 4
- #define P_NAME "Knife Duels"
- #define P_VERS "1.0"
- #define P_AUTH "raizo"
- #define P_REQ "- Global Knife Arena -"
- new killed_forward;
- new cvar_gamename;
- /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- #define ROUND_START_TASK 3215468
- #define RUSH_TAG "^3[^4Knife Rush^3]^1 "
- #define RUSH_ENT_NAME "rush_arena"
- #define MAX_RUSH_ARENAS 8
- new const rush_arena_names[][] = {
- "",
- "A",
- "B",
- "C",
- "D",
- "E",
- "F",
- "G",
- "H"
- }
- #define RUSH_ARENA_CODE 305924
- #define RUSH_FAKE_CODE 6969696969
- #define RUSH_CENTER_CODE 9696969696
- #define RUSH_EXTRA_CODE 911911911
- #define MOVE_ARENA_UP 0
- #define MOVE_ARENA_DOWN 1
- #define MOVE_ARENA_RIGHT 2
- #define MOVE_ARENA_LEFT 3
- #define MOVE_ARENA_FRONT 4
- #define MOVE_ARENA_BACK 5
- #define RUSH_ARENA_MINS Float:{-350.0, -10.0, 0.0}
- #define RUSH_ARENA_MAXS Float:{370.0, 10.0, 10.0}
- new const Float:RUSH_ARENA_COORDS[][2] =
- {
- {0.0,0.0}
- }
- new const RUSH_ARENA_FILE[] = "%s/rush_arena/%s.cfg"
- // if you want to disable a sound, rename it with "common/null.wav"
- new const RUSH_SOUNDS[][] = {
- "ambience/goal_1.wav", // 0 round win
- "x/nih_die2.wav", // 1 round lose
- "ambience/des_wind1.wav", // 2 round draw
- "buttons/bell1.wav", // 3 round start
- "buttons/blip1.wav" , // 4 accepted duel
- "common/null.wav", // 5 Countdown
- "common/null.wav" // 6 "Go!"
- }
- new const RUSH_MODELS[][] = {
- "models/Duel/Rush_Arena.mdl", // Arena's ground
- "models/Duel/Rush_Arena.mdl" // Arena's walls
- }
- new const MAP_RUSH_FIX[][] = {
- "1hp"
- }
- new Float:MAP_RUSH_FIX_Z_COORD[] = {
- -864.253723
- }
- new Headshot[33][33];
- new fakearenas, Prevent_Noobs[32];
- new is_in_rush[33],his_rush_countdown[33],is_user_frozen[33],the_challenger[33],the_asker[33],rush_arena_number[33],the_wins[33]
- new rush_rounds[MAX_RUSH_ARENAS+1],Float:rush_arena_coord[MAX_RUSH_ARENAS+1][3];
- new Float:his_player_spawn[33][3],got_player_spawn[33],Float:his_player_angle[33][3],Float:his_original_player_spawn[33][3];
- new next_empty_rush_arena,total_rush_arenas;
- new MAX_RUSH_PLAYERS,the_maPLUGIN_NAME[48]
- new cvar_zone_fix,cvar_user_sounds,cvar_user_rounds,cvar_user_kills,cvar_user_cooldown,cvar_user_time
- new Float:max_arena_size[3],Float:min_arena_size[3];
- new selected_arenas = 1,Float:move_arena_size[33],the_timer[33],THE_HS[33];
- new the_default_hp;
- new the_map_id = -1;
- new his_previous_user_team[33];
- // using these for less cpu usage.
- new IS_BUGGED_RUSH_MAP = 0,MAP_RUSH_FIX_ENABLED,SOUNDS_RUSH_ENABLED,MAX_USER_RUSH_ROUNDS,MAX_USER_KILLS,MAX_USER_COUNTDOWN,MAX_USER_TIME;
- new Float:fVelocity[3], cvar_user_run;
- new bool:his_rush_toucher[33];
- //////////////////////////////////////////////////////////
- enum _:RankData
- {
- Rank_Kills,
- Rank_Name[ 32 ],
- Rank_SteamID[ 35 ]
- };
- new const g_szVaultName[ ] = "Knife_Duels_Rank";
- new pCvar_Top;
- ///////////////////////////////////////////////////////////
- public plugin_init()
- {
- register_plugin(P_NAME, P_VERS, P_AUTH)
- register_clcmd("say /origin","print_coords")
- register_clcmd("say /arena","editor_menu")
- register_clcmd("say /rarena","editor_rush_menu")
- register_clcmd("say /duel", "First_Menu");
- register_clcmd("say /kdc", "First_Menu");
- register_clcmd("say /block", "BlockMenu");
- register_clcmd("say /dup", "give_up_player");
- register_clcmd("say /rup", "give_up_rush_player");
- cvar_z_fix = register_cvar("duel_map_fix","1")
- cvar_sounds = register_cvar("duel_sounds","1")
- cvar_rounds = register_cvar("duel_rounds","20")
- cvar_kills = register_cvar("duel_kills","10")
- cvar_cooldown = register_cvar("duel_cooldown","1")
- cvar_time = register_cvar("duel_max_nokill_time","120")
- cvar_count = register_cvar("duel_knifecount", "5");
- cvar_gamename = register_cvar( "duel_gamename", "Global Knife Arena" );
- cvar_zone_fix = register_cvar("rush_z_MAP_RUSH_FIX","1")
- cvar_user_sounds = register_cvar("rush_sounds","1")
- cvar_user_rounds =register_cvar("rush_rounds","20")
- cvar_user_kills =register_cvar("rush_kills","10")
- cvar_user_cooldown = register_cvar("rush_cooldown","1")
- cvar_user_time = register_cvar("rush_max_nokill_time","30")
- cvar_user_run = register_cvar("rush_non_stop","0")
- //register_forward(FM_SetModel, "fw_SetModel")
- //RegisterHam(Ham_CS_RoundRespawn, "player", "Player_Respawn_pre", 0)
- RegisterHam(Ham_Spawn,"player","Player_spawn_post",1)
- RegisterHam(Ham_Killed, "player", "Player_Killed")
- RegisterHam(Ham_TakeDamage, "player", "Player_Take_Damage", 0)
- RegisterHam(Ham_TraceAttack, "player", "Ham_TraceAttack_player", 1)
- register_forward(FM_CmdStart, "Cmd_start" );
- register_forward(FM_EmitSound, "fwd_EmitSound", 1);
- register_forward(FM_GetGameDescription, "GameDesc" );
- register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
- register_forward(FM_PlayerPreThink,"FW_Prethink")
- register_event("HLTV", "round_start_event", "a", "1=0", "2=0")
- register_event("HLTV", "round_start_rush_event", "a", "1=0", "2=0")
- RegisterHam(Ham_Killed, "player", "Player_Rush_Killed")
- RegisterHam(Ham_TakeDamage, "player", "Player_Take_Damage_Rush", 0)
- register_forward( FM_CmdStart , "Cmd_start" );
- register_forward(FM_CmdStart,"Rush_Non_Stop");
- MAX_RUSH_PLAYERS = get_maxplayers();
- RegisterHam(Ham_Spawn,"player","Player_spawn_rush_post",1)
- RegisterHam(Ham_TraceAttack, "player", "Ham_TraceAttack_rushplayer", 1)
- register_touch(RUSH_ENT_NAME, "player", "forward_arena_touch");
- //register_touch(ARENA_ENT_NAME, "player", "forward_touch");
- register_forward(FM_CmdStart,"NonStop");
- get_mapname(map_name,charsmax(map_name))
- new size = sizeof(MAP_FIX)
- for(new i; i <size;i++)
- {
- if(equal(map_name,MAP_FIX[i]))
- {
- map_id = i
- IS_BUGGED_MAP = 1
- }
- }
- MAXPLAYERS = get_maxplayers();
- if(containi(map_name,"35hp") != -1)
- map_default_hp = 35
- else if(containi(map_name,"1hp") != -1)
- map_default_hp = 1
- else map_default_hp = 35
- load_arena_coords(-1)
- get_mapname(the_maPLUGIN_NAME,charsmax(the_maPLUGIN_NAME))
- new sizex = sizeof(MAP_RUSH_FIX)
- for(new i; i <sizex;i++)
- {
- if(equal(the_maPLUGIN_NAME,MAP_RUSH_FIX[i]))
- {
- the_map_id = i
- IS_BUGGED_RUSH_MAP = 1
- }
- }
- if(containi(the_maPLUGIN_NAME,"35hp") != -1)
- the_default_hp = 35
- else if(containi(the_maPLUGIN_NAME,"1hp") != -1)
- the_default_hp = 1
- else the_default_hp = 100
- load_RUSH_ARENA_COORDS(-1)
- new cfgdir[32], urlfile[64], cfgdirx[32], urlfilex[64]
- get_configsdir(cfgdir, charsmax(cfgdir))
- formatex(urlfile, charsmax(urlfile), "%s/duel_arena", cfgdir)
- if(!dir_exists(urlfile))
- {
- mkdir(urlfile)
- server_print("%sCreated new folder: %s",CHAT_TAG,urlfile)
- }
- get_configsdir(cfgdirx, charsmax(cfgdirx))
- formatex(urlfilex, charsmax(urlfilex), "%s/rush_arena", cfgdirx)
- if(!dir_exists(urlfilex))
- {
- mkdir(urlfilex)
- server_print("%sCreated new folder: %s",RUSH_TAG,urlfilex)
- }
- killed_forward = CreateMultiForward("duel_player_killed", ET_IGNORE, FP_CELL,FP_CELL);
- set_task(120.0,"Advertise",TASK_AD)
- register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib" );
- update_cvars();
- ////////////////////////////////////////////////////////////////////
- register_srvcmd( "reset_duel_rank", "CmdReset" );
- register_clcmd( "say /drank", "CmdRank" );
- register_clcmd( "say /dtop", "CmdTop" );
- RegisterHam(Ham_Killed, "player", "fw_PlayerKilled", 1);
- pCvar_Top = register_cvar( "amx_duels_top", "10" );
- /////////////////////////////////////////////////////////////////////
- }
- public FW_Prethink(id)
- {
- if (pev(id,pev_button) & IN_RELOAD && pev(id,pev_button) & IN_USE)
- First_Menu(id)
- if (pev(id,pev_button) & IN_ATTACK && pev(id,pev_button) & IN_ATTACK2)
- First_Menu(id)
- }
- public fwd_EmitSound(id, channel, const sound[])
- {
- if(!is_user_alive(id))
- return FMRES_IGNORED;
- if(!equal(sound, g_szKnifeSound))
- return FMRES_IGNORED;
- static Float:fGmTime;
- fGmTime = get_gametime();
- if((fGmTime - g_fHit[id]) >= 1.0)
- {
- iHitCount[id] = 0;
- g_fHit[id] = fGmTime;
- }
- ++iHitCount[id];
- g_fHit[id] = fGmTime;
- if((iHitCount[id] >= get_pcvar_num(cvar_count)))
- {
- First_Menu(id)
- iHitCount[id] = 0;
- }
- return FMRES_IGNORED;
- }
- #define MAX_WAYS 32
- enum Duel_Rush
- {
- Duel_Arena = 1,
- Rush_Arena
- }
- enum Duel_Types
- {
- Type_Slash = 1,
- Type_Stab,
- Type_Both
- }
- enum Duel_Configs
- {
- Duel_Rush:Arenas_On,
- Duel_Types:Types_On
- }
- new All_Configs[MAX_WAYS+1][Duel_Configs]
- new szTmp[192];
- new bool:Duel_Arena_Spawner[33] = false, bool:Rush_Arena_Spawner[33] = false;
- public bot(id)
- {
- if(is_user_alive(id))
- {
- Duel_Arena_Spawner[id] = false
- Rush_Arena_Spawner[id] = false
- Choose_Types_Arenas(id)
- Choose_Battle_Types(id)
- }
- }
- public First_Menu(id)
- {
- new menu = menu_create("\y[\r Knife Duels \y ]\w By raizo","First_Menu_Handle")
- formatex(szTmp,charsmax(szTmp),"Choose Arena \r%s",PartArenas(All_Configs[id][Arenas_On]));
- menu_additem(menu,szTmp,"1")
- formatex(szTmp,charsmax(szTmp),"Choose Types \r%s",PartTypes(All_Configs[id][Types_On]));
- menu_additem(menu,szTmp,"2")
- formatex(szTmp,charsmax(szTmp),"Choose players");
- menu_additem(menu,szTmp,"3")
- formatex(szTmp,charsmax(szTmp),"Appear in list %s",his_offline[id] ?"\yOff":"\rOn");
- menu_additem(menu,szTmp,"4")
- formatex(szTmp,charsmax(szTmp),"Block Player");
- menu_additem(menu,szTmp,"5")
- menu_display(id,menu)
- return PLUGIN_HANDLED;
- }
- public First_Menu_Handle(id,menu,item)
- {
- if(item == MENU_EXIT)
- {
- menu_destroy(menu);
- return PLUGIN_HANDLED;
- }
- new data[3], iName[64]
- new access, callback;
- menu_item_getinfo(menu, item, access, data,2, iName, 63, callback);
- new key = str_to_num(data)
- switch(key)
- {
- case 1:
- {
- All_Configs[id][Arenas_On] = ( ++All_Configs[id][Arenas_On] > (Duel_Rush:2) ) ? (Duel_Rush:1) :All_Configs[id][Arenas_On]
- }
- case 2:
- {
- All_Configs[id][Types_On] = ( ++All_Configs[id][Types_On] > (Duel_Types:3) ) ? (Duel_Types:1) :All_Configs[id][Types_On]
- }
- case 3:
- {
- if(Duel_Arena_Spawner[id])
- {
- duel_players_lists(id)
- }
- if(Rush_Arena_Spawner[id])
- {
- rush_players_list(id)
- }
- else
- {
- //nothing
- }
- return PLUGIN_HANDLED;
- }
- case 4:
- {
- toggle_offline(id)
- }
- case 5:
- {
- BlockMenu(id)
- return PLUGIN_HANDLED;
- }
- }
- menu_destroy(menu);
- First_Menu(id)
- bot(id)
- return PLUGIN_HANDLED;
- }
- PartArenas(Duel_Rush:part)
- {
- new szResult[64]
- switch(part)
- {
- case Duel_Arena: copy(szResult, charsmax(szResult), "Duel [ Platform ]");
- case Rush_Arena: copy(szResult, charsmax(szResult), "Rush [ Bridge ]");
- default: copy(szResult, charsmax(szResult), "");
- }
- return szResult;
- }
- PartTypes(Duel_Types:part)
- {
- new szResult[64]
- switch(part)
- {
- case Type_Slash: copy(szResult, charsmax(szResult), "Stab [ click 2 ]");
- case Type_Stab: copy(szResult, charsmax(szResult), "Slash [ click 1 ]");
- case Type_Both: copy(szResult, charsmax(szResult), "Both [ click 1 & 2 ]");
- default: copy(szResult, charsmax(szResult), "");
- }
- return szResult;
- }
- Choose_Types_Arenas(id)
- {
- switch(All_Configs[id][Arenas_On])
- {
- case Duel_Arena:
- {
- Duel_Arena_Spawner[id] = true
- }
- case Rush_Arena:
- {
- Rush_Arena_Spawner[id] = true
- }
- }
- return 0;
- }
- Choose_Battle_Types(id)
- {
- switch(All_Configs[id][Types_On])
- {
- case Type_Slash:
- {
- his_type[id] = 1
- }
- case Type_Stab:
- {
- his_type[id] = 2
- }
- case Type_Both:
- {
- his_type[id] = 0
- }
- }
- return 0;
- }
- /*public fw_SetModel(entity, model[])
- {
- if(!is_valid_ent(entity))
- return FMRES_IGNORED
- static szClassName[33]
- entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
- if(!equal(szClassName, "weaponbox"))
- return FMRES_IGNORED
- if(equal(model, "models/w_c4.mdl"))
- {
- remove_entity(entity)
- }
- return FMRES_IGNORED
- }*/
- public MessageScoreAttrib( iMsgId, iDest, iReceiver )
- {
- new id= get_msg_arg_int( SCOREATTRIB_ARG_PLAYERID );
- if(!is_user_connected(id))
- return;
- if(!is_user_alive(id))
- return;
- set_msg_arg_int( SCOREATTRIB_ARG_FLAGS, ARG_BYTE, SCOREATTRIB_FLAG_NONE);
- }
- /*public CurrentWeapon(id)
- {
- if(read_data(2) == CSW_C4)
- {
- if(is_user_alive(id))
- {
- strip_user_weapons(id)
- give_item(id,"weapon_knife")
- }
- }
- }
- stock get_weapon_owner(ent)
- {
- return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
- }
- public Player_Respawn_pre(id)
- {
- if(is_user_connected(id))
- {
- if(!user_can_spawn[id])
- {
- return HAM_SUPERCEDE
- }
- }
- return HAM_IGNORED
- }*/
- public Rush_Non_Stop(id)
- {
- if(is_in_rush[id] == 2 && get_pcvar_num(cvar_user_run) )
- {
- if(get_user_team(id) == 1)
- {
- fVelocity[0] = 250.0;
- fVelocity[1] = 0.0;
- fVelocity[2] = 0.0;
- set_pev( id, pev_velocity, fVelocity )
- }
- if(get_user_team(id) == 2)
- {
- fVelocity[0] = -250.0;
- fVelocity[1] = 0.0;
- fVelocity[2] = 0.0;
- set_pev( id, pev_velocity, fVelocity )
- }
- }
- }
- public plugin_natives()
- {
- register_library("knife_duels")
- register_native("is_user_in_duel","_is_user_in_duel")
- register_native("is_user_in_offline","_is_user_in_offline")
- register_native("is_user_dueling_user","_is_user_dueling_user")
- }
- public get_non_duelers_alive()
- {
- new count = 0
- for(new id; id < MAXPLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(is_user_alive(id) && !is_in_duel[id])
- {
- count++
- }
- }
- }
- return count
- }
- public respawn_everyone(taskid)
- {
- for(new id;id < MAXPLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(is_in_duel[id] !=2 && !is_user_alive(id))
- {
- if(cs_get_user_team(id) == CS_TEAM_CT || cs_get_user_team(id) == CS_TEAM_T)
- {
- ExecuteHam(Ham_CS_RoundRespawn, id);
- }
- }
- }
- }
- }
- public get_non_duelers_alive_CT()
- {
- new count = 0
- for(new id; id < MAXPLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(is_user_alive(id) && !is_in_duel[id] && cs_get_user_team(id) == CS_TEAM_CT)
- {
- count++
- }
- }
- }
- return count
- }
- public get_non_duelers_alive_T()
- {
- new count = 0
- for(new id; id < MAXPLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(is_user_alive(id) && !is_in_duel[id] && cs_get_user_team(id) == CS_TEAM_T)
- {
- count++
- }
- }
- }
- return count
- }
- public get_non_rushers_alive()
- {
- new count = 0
- for(new id; id < MAX_RUSH_PLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(is_user_alive(id) && !is_in_rush[id])
- {
- count++
- }
- }
- }
- return count
- }
- public _is_user_in_duel(plugin, iParams)
- {
- new id = get_param(1)
- if(!is_user_connected(id))
- return PLUGIN_CONTINUE
- if(is_in_duel[id] == 2)
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- public _is_user_in_offline(plugin, iParams)
- {
- new id = get_param(1)
- if(!is_user_connected(id))
- return PLUGIN_CONTINUE
- if(his_offline[id])
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- public _is_user_dueling_user(plugin, iParams)
- {
- new id = get_param(1)
- new enemy = get_param(2)
- if(!is_user_connected(id))
- return PLUGIN_CONTINUE
- if(!is_user_connected(enemy))
- return PLUGIN_CONTINUE
- if(is_in_duel[id] != 2 || is_in_duel[enemy] != 2)
- return PLUGIN_CONTINUE
- if(id == his_challenger[enemy] && enemy == his_challenger[id])
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- public forward_touch(ent, id)
- {
- if(!pev_valid(id))
- return;
- if(!pev_valid(ent))
- return;
- if(is_user_alive(id) && get_user_noclip(id))
- return;
- static class[32]
- pev(ent,pev_classname,class,charsmax(class));
- if(equal(class,ARENA_ENT_NAME))
- {
- if(is_in_duel[id] && !gBackStabing[id])
- {
- gBackStabing[id] = true;
- }
- if(is_user_alive(id) && !gBackStabing[id])
- {
- gBackStabing[id] = false;
- First_Menu(id)
- back_to_the_spawn(id)
- }
- }
- }
- public forward_arena_touch(ent, id)
- {
- if(!pev_valid(id))
- return;
- if(!pev_valid(ent))
- return;
- if(is_user_alive(id) && get_user_noclip(id))
- return;
- static class[32]
- pev(ent,pev_classname,class,charsmax(class));
- if(equal(class,RUSH_ENT_NAME))
- {
- if(is_in_rush[id] && !his_rush_toucher[id])
- {
- his_rush_toucher[id] = true;
- }
- if(is_user_alive(id) && !his_rush_toucher[id])
- {
- his_rush_toucher[id] = false;
- back_to_the_rush_spawn(id)
- }
- }
- return;
- }
- public Ham_TraceAttack_player(victim, attacker, Float:Damage, Float:Direction[3], ptr, Damagebits)
- {
- if(is_user_connected(attacker) && is_user_connected(victim))
- {
- Head_shot[attacker][victim] = bool:( get_tr2(ptr, TR_iHitgroup) == 1 )
- }
- }
- public Ham_TraceAttack_rushplayer(victim, attacker, Float:Damage, Float:Direction[3], ptr, Damagebits)
- {
- if(is_user_connected(attacker) && is_user_connected(victim))
- {
- Headshot[attacker][victim] = bool:( get_tr2(ptr, TR_iHitgroup) == 1 )
- }
- }
- public editor_menu(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED
- new flags = get_user_flags(id)
- if(!(flags & ADMIN_RCON))
- {
- client_print(id,print_chat,"You have no access to this command")
- return PLUGIN_HANDLED
- }
- new menu
- menu = menu_create( "\rArena spawner:", "Arenaspawner_handler" );
- new nameu[32];
- formatex(nameu,charsmax(nameu), "Add");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Remove");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Remove all");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Select");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Select all");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Move");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Save");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Load");
- menu_additem(menu, nameu, "", 0);
- menu_display(id, menu, 0 );
- return PLUGIN_HANDLED
- }
- public editor_rush_menu(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED
- new flags = get_user_flags(id)
- if(!(flags & ADMIN_RCON))
- {
- client_print(id,print_chat,"You have no access to this command")
- return PLUGIN_HANDLED
- }
- new menu
- menu = menu_create( "\rArena spawner:", "Arenaspawner_handler_menu" );
- new nameu[32];
- formatex(nameu,charsmax(nameu), "Add");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Remove");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Remove all");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Select");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Select all");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Move");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Save");
- menu_additem(menu, nameu, "", 0);
- formatex(nameu,charsmax(nameu), "Load");
- menu_additem(menu, nameu, "", 0);
- menu_display(id, menu, 0 );
- return PLUGIN_HANDLED
- }
- public Arenaspawner_handler( id, menu, item )
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy( menu );
- remove_the_fake_arena()
- return PLUGIN_HANDLED;
- }
- new szData[6], szName[64];
- new _access, item_callback;
- menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
- new arenas_found;
- arenas_found = fakes_count()
- if(equali(szName,"Add"))
- {
- if(next_fake_arena() != -1)
- {
- start_fake_build(id,-1)
- if(fakes_count())
- {
- if(selected > MAX_ARENAS || selected == -1)
- {
- selected = 1
- select_the_fake_arena(EXTRA_CODE+selected)
- }
- }
- }
- else client_print_color(id,"%s ^3Maximum arenas reached.^1",CHAT_TAG)
- }
- else if(equali(szName,"Remove"))
- {
- if(fakes_count())
- {
- if(selected > MAX_ARENAS || selected == -1)
- selected = 1
- delete_the_fake_arena(EXTRA_CODE+selected)
- if(fakes_count())
- next_selection()
- } else client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
- }
- else if(equali(szName,"Remove all"))
- {
- //remove_menu(id)
- remove_the_fake_arena()
- client_print_color(id,"%s ^3All arenas removed.",CHAT_TAG)
- }
- else if(equali(szName,"Select"))
- {
- if(fakes_count())
- {
- next_selection()
- } else client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
- }
- else if(equali(szName,"Select all"))
- {
- if(fakes_count())
- {
- selected = -1
- select_the_fake_arena(EXTRA_CODE+selected)
- } else client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
- }
- else if(equali(szName,"Move"))
- {
- if(fakes_count())
- {
- if(selected > MAX_ARENAS)
- selected = 1
- select_the_fake_arena(EXTRA_CODE+selected)
- menu_destroy( menu );
- move_menu(id,EXTRA_CODE+selected)
- return PLUGIN_CONTINUE;
- }
- else client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
- }
- else if(equali(szName,"Load"))
- {
- remove_the_fake_arena()
- load_arena_coords(id)
- //client_print_color(id, DontChange,"%s ^3Arena coords loaded.",CHAT_TAG)
- set_task(0.1,"delay_build",id)
- }
- else if(equali(szName,"Save"))
- {
- if(fakes_count())
- {
- save_arena_coords(id)
- remove_the_fake_arena()
- load_arena_coords(id)
- }
- else
- {
- client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
- }
- }
- if(!arenas_found && fakes_count())
- {
- next_selection()
- }
- menu_destroy( menu );
- editor_menu(id)
- return PLUGIN_CONTINUE;
- }
- public Arenaspawner_handler_menu( id, menu, item )
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy( menu );
- remove_the_rush_fake_arena()
- return PLUGIN_HANDLED;
- }
- new szData[6], szName[64];
- new _access, item_callback;
- menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
- new arenas_found;
- arenas_found = fake_rush_arenas_count()
- if(equali(szName,"Add"))
- {
- if(next_fake_rush_arena() != -1)
- {
- start_fake_rush_build(id,-1)
- if(fake_rush_arenas_count())
- {
- if(selected_arenas > MAX_RUSH_ARENAS || selected_arenas == -1)
- {
- selected_arenas = 1
- select_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
- }
- }
- } else client_print_color(id,"%s ^3Maximum arenas reached.^1",RUSH_TAG)
- }
- else if(equali(szName,"Remove"))
- {
- if(fake_rush_arenas_count())
- {
- if(selected_arenas > MAX_RUSH_ARENAS || selected_arenas == -1)
- selected_arenas = 1
- delete_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
- if(fake_rush_arenas_count())
- next_rush_arena_selection()
- } else client_print_color(id, "%s ^3No arenas found.",RUSH_TAG)
- }
- else if(equali(szName,"Remove all"))
- {
- //remove_rush_menu(id)
- remove_the_rush_fake_arena()
- client_print_color(id,"%s ^3All arenas removed.",RUSH_TAG)
- }
- else if(equali(szName,"Select"))
- {
- if(fake_rush_arenas_count())
- {
- next_rush_arena_selection()
- } else client_print_color(id,"%s ^3No arenas found.",RUSH_TAG)
- }
- else if(equali(szName,"Select all"))
- {
- if(fake_rush_arenas_count())
- {
- selected_arenas = -1
- select_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
- } else client_print_color(id,"%s ^3No arenas found.",RUSH_TAG)
- }
- else if(equali(szName,"Move"))
- {
- if(fake_rush_arenas_count())
- {
- if(selected_arenas > MAX_RUSH_ARENAS)
- selected_arenas = 1
- select_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
- menu_destroy( menu );
- move_rush_menu(id,RUSH_EXTRA_CODE+selected_arenas)
- return PLUGIN_CONTINUE;
- }
- else client_print_color(id,"%s ^3No arenas found.",RUSH_TAG)
- }
- else if(equali(szName,"Load"))
- {
- remove_the_rush_fake_arena()
- load_RUSH_ARENA_COORDS(id)
- //client_print_color(id,"%s ^3Arena coords loaded.",RUSH_TAG)
- set_task(0.1,"delay_build_rush",id)
- }
- else if(equali(szName,"Save"))
- {
- if(fake_rush_arenas_count())
- {
- save_RUSH_ARENA_COORDS(id)
- remove_the_rush_fake_arena()
- load_RUSH_ARENA_COORDS(id)
- }
- else
- {
- client_print_color(id,"%s ^3No arenas found.",RUSH_TAG)
- }
- }
- if(!arenas_found && fake_rush_arenas_count())
- {
- next_rush_arena_selection()
- }
- menu_destroy( menu );
- editor_rush_menu(id)
- return PLUGIN_CONTINUE;
- }
- stock next_selection()
- {
- if(selected == -1)
- {
- selected = 1
- }
- new size = MAX_ARENAS*3
- for(new slct=0;slct < size;slct++)
- {
- selected++
- if(selected > MAX_ARENAS)
- selected = 1
- if(fake_arena_exists(selected))
- {
- select_the_fake_arena(EXTRA_CODE+selected)
- return;
- }
- }
- }
- stock next_rush_arena_selection()
- {
- if(selected_arenas == -1)
- {
- selected_arenas = 1
- }
- new size = MAX_RUSH_ARENAS*3
- for(new slct=0;slct < size;slct++)
- {
- selected_arenas++
- if(selected_arenas > MAX_RUSH_ARENAS)
- selected_arenas = 1
- if(fake_rush_arena_exists(selected_arenas))
- {
- select_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
- return;
- }
- }
- }
- public fake_arena_exists(code)
- {
- new arenas_ent = -1
- new code_ent
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser2) == CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
- {
- code_ent = entity_get_int(arenas_ent,EV_INT_iuser3)-EXTRA_CODE
- if(code_ent == code)
- {
- return PLUGIN_HANDLED
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- public fake_rush_arena_exists(code)
- {
- new arenas_ent = -1
- new code_ent
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser2) == RUSH_CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
- {
- code_ent = entity_get_int(arenas_ent,EV_INT_iuser3)-RUSH_EXTRA_CODE
- if(code_ent == code)
- {
- return PLUGIN_HANDLED
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- public fakes_count()
- {
- new arenas_ent = -1
- new found = 0
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser2) == CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
- {
- found++
- }
- }
- return found
- }
- public fake_rush_arenas_count()
- {
- new arenas_ent = -1
- new found = 0
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser2) == RUSH_CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
- {
- found++
- }
- }
- return found
- }
- public arenas_count()
- {
- new found = 0
- for(new id;id < MAXPLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(is_in_duel[id] == 2)
- found++
- }
- }
- return found/2
- }
- public arenas_count_rush()
- {
- new found = 0
- for(new id;id < MAX_RUSH_PLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(is_in_rush[id] == 2)
- found++
- }
- }
- return found/2
- }
- public delay_build(id)
- {
- for(new i=1;i < total_arenas+1;i++)
- {
- start_fake_build(id,i)
- }
- if(fakes_count())
- {
- next_selection()
- }
- }
- public delay_build_rush(id)
- {
- for(new i=1;i < total_rush_arenas+1;i++)
- {
- start_fake_rush_build(id,i)
- }
- if(fake_rush_arenas_count())
- {
- next_rush_arena_selection()
- }
- }
- public move_menu(id,code)
- {
- new menu
- menu = menu_create( "\rMove arena:", "move_handler" );
- new nameu[32];
- new code_t[32];
- num_to_str(code,code_t,charsmax(code_t))
- formatex(nameu,charsmax(nameu), "Move up");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move down");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move front");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move back");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move right");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move left");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Remove the arena");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move size: %.2f",move_size[id]);
- menu_additem(menu, nameu, code_t, 0);
- menu_display(id, menu, 0 );
- return PLUGIN_HANDLED
- }
- public move_rush_menu(id,code)
- {
- new menu
- menu = menu_create( "\rMove arena:", "move_rush_handler" );
- new nameu[32];
- new code_t[32];
- num_to_str(code,code_t,charsmax(code_t))
- formatex(nameu,charsmax(nameu), "Move up");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move down");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move front");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move back");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move right");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move left");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Remove the arena");
- menu_additem(menu, nameu, code_t, 0);
- formatex(nameu,charsmax(nameu), "Move size: %.2f",move_arena_size[id]);
- menu_additem(menu, nameu, code_t, 0);
- menu_display(id, menu, 0 );
- return PLUGIN_HANDLED
- }
- public move_handler( id, menu, item )
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy( menu );
- set_task(0.1,"editor_menu",id)
- return PLUGIN_HANDLED;
- }
- new szData[32], szName[64];
- new _access, item_callback;
- menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
- new code = str_to_num(szData)
- if(equali(szName,"remove the arena"))
- {
- delete_the_fake_arena(code)
- menu_destroy( menu );
- editor_menu(id)
- unselect_the_fake_arena(0)
- return PLUGIN_CONTINUE;
- }
- else if(containi(szName,"move size:") != -1)
- {
- move_size[id]+= 10.0
- if(move_size[id] > 100.0)
- {
- move_size[id] = 10.0
- }
- }
- else if(equali(szName,"move up"))
- {
- move_the_fake_arena(id,code,MOVE_UP)
- }
- else if(equali(szName,"move down"))
- {
- move_the_fake_arena(id,code,MOVE_DOWN)
- }
- else if(equali(szName,"move right"))
- {
- move_the_fake_arena(id,code,MOVE_RIGHT)
- }
- else if(equali(szName,"move left"))
- {
- move_the_fake_arena(id,code,MOVE_LEFT)
- }
- else if(equali(szName,"move front"))
- {
- move_the_fake_arena(id,code,MOVE_FRONT)
- }
- else if(equali(szName,"move back"))
- {
- move_the_fake_arena(id,code,MOVE_BACK)
- }
- menu_destroy( menu );
- move_menu(id,code)
- return PLUGIN_CONTINUE;
- }
- public move_rush_handler( id, menu, item )
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy( menu );
- set_task(0.1,"editor_rush_menu",id)
- return PLUGIN_HANDLED;
- }
- new szData[32], szName[64];
- new _access, item_callback;
- menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
- new code = str_to_num(szData)
- if(equali(szName,"remove the arena"))
- {
- delete_the_fake_rush_arena(code)
- menu_destroy( menu );
- editor_rush_menu(id)
- unselect_the_fake_rush_arena(0)
- return PLUGIN_CONTINUE;
- }
- else if(containi(szName,"move size:") != -1)
- {
- move_arena_size[id]+= 10.0
- if(move_arena_size[id] > 100.0)
- {
- move_arena_size[id] = 10.0
- }
- }
- else if(equali(szName,"move up"))
- {
- move_the_rush_fake_arena(id,code,MOVE_ARENA_UP)
- }
- else if(equali(szName,"move down"))
- {
- move_the_rush_fake_arena(id,code,MOVE_ARENA_DOWN)
- }
- else if(equali(szName,"move right"))
- {
- move_the_rush_fake_arena(id,code,MOVE_ARENA_RIGHT)
- }
- else if(equali(szName,"move left"))
- {
- move_the_rush_fake_arena(id,code,MOVE_ARENA_LEFT)
- }
- else if(equali(szName,"move front"))
- {
- move_the_rush_fake_arena(id,code,MOVE_ARENA_FRONT)
- }
- else if(equali(szName,"move back"))
- {
- move_the_rush_fake_arena(id,code,MOVE_ARENA_BACK)
- }
- menu_destroy( menu );
- move_rush_menu(id,code)
- return PLUGIN_CONTINUE;
- }
- public save_arena_coords(id)
- {
- new found;
- new cfgdir[32], mapname[32], urlfile[64]
- get_configsdir(cfgdir, charsmax(cfgdir))
- get_mapname(mapname, charsmax(mapname))
- formatex(urlfile, charsmax(urlfile), ARENA_FILE, cfgdir, mapname)
- if (file_exists(urlfile))
- delete_file(urlfile)
- new lineset[128]
- new Float:origin[3]
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser2) == CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
- {
- found++
- pev(arenas_ent,pev_origin,origin);
- format(lineset, charsmax(lineset), "%.f %.f %.f", origin[0], origin[1], origin[2])
- write_file(urlfile, lineset,found)
- }
- }
- if(!found)
- client_print_color(id, "%s Couldn't save:^3No arenas found.",CHAT_TAG)
- else client_print_color(id,"%s %d ^3Arena coords saved.",CHAT_TAG,found)
- }
- public save_RUSH_ARENA_COORDS(id)
- {
- new found;
- new cfgdir[32], mapname[32], urlfile[64]
- get_configsdir(cfgdir, charsmax(cfgdir))
- get_mapname(mapname, charsmax(mapname))
- formatex(urlfile, charsmax(urlfile), RUSH_ARENA_FILE, cfgdir, mapname)
- if (file_exists(urlfile))
- delete_file(urlfile)
- new lineset[128]
- new Float:origin[3]
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser2) == RUSH_CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
- {
- found++
- pev(arenas_ent,pev_origin,origin);
- format(lineset, charsmax(lineset), "%.f %.f %.f", origin[0], origin[1], origin[2])
- write_file(urlfile, lineset,found)
- }
- }
- if(!found)
- client_print_color(id,"%s Couldn't save:^3No arenas found.",RUSH_TAG)
- else client_print_color(id,"%s %d ^3Arena coords saved.",RUSH_TAG,found)
- }
- public print_coords(id)
- {
- new Float:coord[3]
- pev(id,pev_origin,coord);
- client_print_color(id,"origin: ^3%.f %.f %.f",coord[0],coord[1],coord[2])
- return PLUGIN_HANDLED
- }
- public start_fake_build(id,zecode)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED
- new ext_code
- if(zecode == -1)
- {
- ext_code = next_fake_arena()
- if(ext_code == -1)
- return PLUGIN_HANDLED
- }
- else ext_code = zecode
- ext_code+=EXTRA_CODE
- static Float:origin[3];
- if(zecode == -1)
- get_user_hitpoint(id,origin)
- else
- {
- origin[0]=arena_coord[zecode][0]
- origin[1]=arena_coord[zecode][1]
- origin[2]=arena_coord[zecode][2]
- }
- /*origin[0] = 1002.911376
- origin[1] = -1561.421997
- origin[2] = 0.0*/
- new Float:fake_origin[3]
- static size
- size = sizeof(ARENA_COORDS)
- new ent_code = FAKE_CODE
- fakes++
- for(new coords;coords < size; coords++)
- {
- fake_origin[0] = origin[0]
- fake_origin[1] = origin[1]
- if(bugged_map())
- fake_origin[2]= MAP_FIX_Z_COORD[map_id]
- else fake_origin[2] = origin[2]
- //fake_origin[2]=-712.876892
- fake_origin[0]+=ARENA_COORDS[coords][0]*1.7
- fake_origin[1]+=ARENA_COORDS[coords][1]*1.53
- new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
- set_pev(ent,pev_classname,ARENA_ENT_NAME);
- engfunc(EngFunc_SetModel,ent,ARENA_MODELS[0]);
- entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
- engfunc(EngFunc_SetSize,ent,ARENA_MINS,ARENA_MAXS);
- entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
- entity_set_int(ent,EV_INT_iuser1,ent_code)
- entity_set_int(ent,EV_INT_iuser3,ext_code)
- engfunc(EngFunc_SetOrigin,ent,fake_origin);
- stuck_check(fake_origin,120.0)
- static Float:rvec[3];
- pev(ent,pev_v_angle,rvec);
- rvec[0]=90.0;
- set_pev(ent,pev_angles,rvec);
- if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == 100.0)
- {
- fake_origin[0] += max_size[0]
- fake_origin[1] += max_size[1]
- //create_wall(LEFT_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
- }
- if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == -100.0)
- {
- fake_origin[0] += max_size[2]
- fake_origin[1] += min_size[0]
- //create_wall(RIGHT_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
- }
- if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == 0.0)
- {
- create_wall(TOP_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
- entity_set_int(ent,EV_INT_iuser2,CENTER_CODE)
- }
- else if(ARENA_COORDS[coords][0] == 200.0 && ARENA_COORDS[coords][1] == 0.0)
- {
- fake_origin[0] += min_size[1]
- //create_wall(BLUE_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
- }
- else if(ARENA_COORDS[coords][0] == -100.0 && ARENA_COORDS[coords][1] == 0.0)
- {
- fake_origin[0] += min_size[2]
- //create_wall(RED_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
- }
- set_rendering(ent,kRenderFxGlowShell,0,50,0,kRenderNormal,10)
- }
- select_the_fake_arena(ext_code)
- return PLUGIN_HANDLED;
- }
- public start_fake_rush_build(id,zecode)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED
- new ext_code
- if(zecode == -1)
- {
- ext_code = next_fake_rush_arena()
- if(ext_code == -1)
- return PLUGIN_HANDLED
- }
- else ext_code = zecode
- ext_code+=RUSH_EXTRA_CODE
- static Float:origin[3];
- if(zecode == -1)
- get_user_hitpoint_rush(id,origin)
- else
- {
- origin[0]=rush_arena_coord[zecode][0]
- origin[1]=rush_arena_coord[zecode][1]
- origin[2]=rush_arena_coord[zecode][2]
- }
- /*origin[0] = 1002.911376
- origin[1] = -1561.421997
- origin[2] = 0.0*/
- new Float:fake_origin[3]
- static size
- size = sizeof(RUSH_ARENA_COORDS)
- new ent_code = RUSH_FAKE_CODE
- fakearenas++
- for(new coords;coords < size; coords++)
- {
- fake_origin[0] = origin[0]
- fake_origin[1] = origin[1]
- if(bugged_rush_map())
- fake_origin[2]= MAP_RUSH_FIX_Z_COORD[the_map_id]
- else fake_origin[2] = origin[2]
- //fake_origin[2]=-712.876892
- fake_origin[0]+=RUSH_ARENA_COORDS[coords][0]*1.7
- fake_origin[1]+=RUSH_ARENA_COORDS[coords][1]*1.53
- new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
- set_pev(ent,pev_classname,RUSH_ENT_NAME);
- engfunc(EngFunc_SetModel,ent,RUSH_MODELS[0]);
- entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
- engfunc(EngFunc_SetSize,ent,RUSH_ARENA_MINS,RUSH_ARENA_MAXS);
- entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
- entity_set_int(ent,EV_INT_iuser1,ent_code)
- entity_set_int(ent,EV_INT_iuser3,ext_code)
- engfunc(EngFunc_SetOrigin,ent,fake_origin);
- stuck_rush_check(fake_origin,120.0)
- static Float:rvec[3];
- pev(ent,pev_v_angle,rvec);
- rvec[0]=0.0;
- set_pev(ent,pev_angles,rvec);
- if(RUSH_ARENA_COORDS[coords][0] == 0.0 && RUSH_ARENA_COORDS[coords][1] == 100.0)
- {
- fake_origin[0] += max_arena_size[0]
- fake_origin[1] += max_arena_size[1]
- }
- if(RUSH_ARENA_COORDS[coords][0] == 0.0 && RUSH_ARENA_COORDS[coords][1] == -100.0)
- {
- fake_origin[0] += max_arena_size[2]
- fake_origin[1] += min_arena_size[0]
- }
- if(RUSH_ARENA_COORDS[coords][0] == 0.0 && RUSH_ARENA_COORDS[coords][1] == 0.0)
- {
- entity_set_int(ent,EV_INT_iuser2,RUSH_CENTER_CODE)
- }
- else if(RUSH_ARENA_COORDS[coords][0] == 200.0 && RUSH_ARENA_COORDS[coords][1] == 0.0)
- {
- fake_origin[0] += min_arena_size[1]
- }
- else if(RUSH_ARENA_COORDS[coords][0] == -100.0 && RUSH_ARENA_COORDS[coords][1] == 0.0)
- {
- fake_origin[0] += min_arena_size[2]
- }
- set_rendering(ent,kRenderFxGlowShell,0,50,0,kRenderNormal,10)
- }
- select_the_fake_rush_arena(ext_code)
- return PLUGIN_HANDLED;
- }
- public move_the_fake_arena(id,code,moveto)
- {
- new num;
- num = code-EXTRA_CODE
- new arenas_ent=-1;
- new Float:origin[3];
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser3) == code || num == -1)
- {
- pev(arenas_ent,pev_origin,origin);
- switch(moveto)
- {
- case MOVE_UP:
- {
- origin[2]+=move_size[id]
- }
- case MOVE_DOWN:
- {
- origin[2]-=move_size[id]
- }
- case MOVE_RIGHT:
- {
- origin[1]+=move_size[id]
- }
- case MOVE_LEFT:
- {
- origin[1]-=move_size[id]
- }
- case MOVE_FRONT:
- {
- origin[0]+=move_size[id]
- }
- case MOVE_BACK:
- {
- origin[0]-=move_size[id]
- }
- }
- engfunc(EngFunc_SetOrigin,arenas_ent,origin);
- stuck_check(origin,360.0)
- }
- }
- }
- }
- public move_the_rush_fake_arena(id,code,moveto)
- {
- new num;
- num = code-RUSH_EXTRA_CODE
- new arenas_ent=-1;
- new Float:origin[3];
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser3) == code || num == -1)
- {
- pev(arenas_ent,pev_origin,origin);
- switch(moveto)
- {
- case MOVE_ARENA_UP:
- {
- origin[2]+=move_arena_size[id]
- }
- case MOVE_ARENA_DOWN:
- {
- origin[2]-=move_arena_size[id]
- }
- case MOVE_ARENA_RIGHT:
- {
- origin[1]+=move_arena_size[id]
- }
- case MOVE_ARENA_LEFT:
- {
- origin[1]-=move_arena_size[id]
- }
- case MOVE_ARENA_FRONT:
- {
- origin[0]+=move_arena_size[id]
- }
- case MOVE_ARENA_BACK:
- {
- origin[0]-=move_arena_size[id]
- }
- }
- engfunc(EngFunc_SetOrigin,arenas_ent,origin);
- stuck_rush_check(origin,360.0)
- }
- }
- }
- }
- public select_the_fake_arena(code)
- {
- new num;
- num = code-EXTRA_CODE
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
- {
- if(num == -1)
- set_rendering(arenas_ent,kRenderFxGlowShell,250,0,0,kRenderNormal,10)
- else if(entity_get_int(arenas_ent,EV_INT_iuser3) == code)
- set_rendering(arenas_ent,kRenderFxGlowShell,250,0,0,kRenderNormal,10)
- }
- }
- unselect_the_fake_arena(code)
- }
- public select_the_fake_rush_arena(code)
- {
- new num;
- num = code-RUSH_EXTRA_CODE
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
- {
- if(num == -1)
- set_rendering(arenas_ent,kRenderFxGlowShell,250,0,0,kRenderNormal,10)
- else if(entity_get_int(arenas_ent,EV_INT_iuser3) == code)
- set_rendering(arenas_ent,kRenderFxGlowShell,250,0,0,kRenderNormal,10)
- }
- }
- unselect_the_fake_rush_arena(code)
- }
- public unselect_the_fake_arena(code)
- {
- new num;
- num = code-EXTRA_CODE
- if(num == -1)
- return;
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE && entity_get_int(arenas_ent,EV_INT_iuser3) != code)
- set_rendering(arenas_ent,kRenderFxGlowShell,50,50,50,kRenderTransAdd,120)
- }
- }
- public unselect_the_fake_rush_arena(code)
- {
- new num;
- num = code-RUSH_EXTRA_CODE
- if(num == -1)
- return;
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE && entity_get_int(arenas_ent,EV_INT_iuser3) != code)
- set_rendering(arenas_ent,kRenderFxGlowShell,50,50,50,kRenderTransAdd,120)
- }
- }
- public delete_the_fake_arena(code)
- {
- new arenas_ent=-1;
- new found = 0
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE && entity_get_int(arenas_ent,EV_INT_iuser3) == code)
- {
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- found++
- }
- }
- if(found)
- {
- fakes--
- }
- }
- public delete_the_fake_rush_arena(code)
- {
- new arenas_ent=-1;
- new found = 0
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE && entity_get_int(arenas_ent,EV_INT_iuser3) == code)
- {
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- found++
- }
- }
- if(found)
- {
- fakearenas--
- }
- }
- public load_arena_coords(id)
- {
- // Check for spawns points of the current map
- new cfgdir[32], mapname[32], filepath[100], linedata[64]
- get_configsdir(cfgdir, charsmax(cfgdir))
- get_mapname(mapname, charsmax(mapname))
- formatex(filepath, charsmax(filepath), ARENA_FILE, cfgdir, mapname)
- new arena = 0
- total_arenas = 0
- // Load spawns points
- if (file_exists(filepath))
- {
- new file = fopen(filepath,"rt"), row[4][6]
- while (file && !feof(file))
- {
- fgets(file, linedata, charsmax(linedata))
- // invalid spawn
- if(!linedata[0] || str_count(linedata,' ') < 2) continue;
- arena++
- if (arena > MAX_ARENAS)
- {
- break
- }
- // get spawn point data
- parse(linedata,row[0],5,row[1],5,row[2],5)
- // origin
- arena_coord[arena][0] = floatstr(row[0])
- arena_coord[arena][1] = floatstr(row[1])
- if(bugged_map())
- arena_coord[arena][2] = MAP_FIX_Z_COORD[map_id]
- else arena_coord[arena][2] = floatstr(row[2])
- total_arenas = arena
- }
- if (file) fclose(file)
- }
- if(id != -1)
- {
- if(!total_arenas)
- {
- client_print_color(id,"%sCouldn't load: ^3No arenas found.",CHAT_TAG)
- }
- else
- {
- client_print_color(id,"%s%d ^3arena%s loaded.",CHAT_TAG,total_arenas, (total_arenas > 1 ? "s" : ""))
- }
- }
- }
- public load_RUSH_ARENA_COORDS(id)
- {
- // Check for spawns points of the current map
- new cfgdir[32], mapname[32], filepath[100], linedata[64]
- get_configsdir(cfgdir, charsmax(cfgdir))
- get_mapname(mapname, charsmax(mapname))
- formatex(filepath, charsmax(filepath), RUSH_ARENA_FILE, cfgdir, mapname)
- new arena = 0
- total_rush_arenas = 0
- // Load spawns points
- if (file_exists(filepath))
- {
- new file = fopen(filepath,"rt"), row[4][6]
- while (file && !feof(file))
- {
- fgets(file, linedata, charsmax(linedata))
- // invalid spawn
- if(!linedata[0] || str_count(linedata,' ') < 2) continue;
- arena++
- if (arena > MAX_RUSH_ARENAS)
- {
- break
- }
- // get spawn point data
- parse(linedata,row[0],5,row[1],5,row[2],5)
- // origin
- rush_arena_coord[arena][0] = floatstr(row[0])
- rush_arena_coord[arena][1] = floatstr(row[1])
- if(bugged_rush_map())
- rush_arena_coord[arena][2] = MAP_RUSH_FIX_Z_COORD[the_map_id]
- else rush_arena_coord[arena][2] = floatstr(row[2])
- total_rush_arenas = arena
- }
- if (file) fclose(file)
- }
- if(id != -1)
- {
- if(!total_rush_arenas)
- {
- client_print_color(id,"%sCouldn't load: ^3No arenas found.",RUSH_TAG)
- }
- else
- {
- client_print_color(id,"%s%d ^3arena%s loaded.",RUSH_TAG,total_rush_arenas, (total_rush_arenas > 1 ? "s" : ""))
- }
- }
- }
- stock bugged_map()
- {
- if(!MAP_FIX_ENABLED)
- return PLUGIN_CONTINUE
- if(IS_BUGGED_MAP)
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- stock bugged_rush_map()
- {
- if(!MAP_RUSH_FIX_ENABLED)
- return PLUGIN_CONTINUE
- if(IS_BUGGED_RUSH_MAP)
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- stock str_count(const str[], searchchar)
- {
- new count, i, len = strlen(str)
- for (i = 0; i <= len; i++)
- {
- if(str[i] == searchchar)
- count++
- }
- return count;
- }
- public Player_spawn_post(id)
- {
- Set_Entity_Invisible(id, 0)
- if(is_user_alive(id))
- {
- if(is_in_duel[id] != 2)
- {
- set_task(1.0,"get_spawn_origin",id)
- return;
- }
- if(is_in_duel[id] == 2)
- spawn_back(id)
- }
- }
- public Player_spawn_rush_post(id)
- {
- Set_Entity_Invisible(id, 0)
- if(is_user_alive(id))
- {
- if(is_in_rush[id] != 2)
- {
- set_task(1.0,"get_spawn_rush_origin",id)
- return;
- }
- if(is_in_rush[id] == 2)
- spawn_rush_back(id)
- }
- }
- public spawn_back(id)
- {
- entity_set_origin(id,his_spawn[id])
- set_user_health(id,map_default_hp)
- set_user_armor(id,0)
- set_user_godmode(id, 0)
- if(is_user_connected(his_challenger[id]))
- {
- check_teams(id,his_challenger[id])
- entity_set_origin(his_challenger[id],his_spawn[his_challenger[id]])
- set_user_health(his_challenger[id],map_default_hp)
- set_user_armor(his_challenger[id],0)
- entity_set_vector(id, EV_VEC_angles, his_angle[id])
- entity_set_int(id, EV_INT_fixangle, 1)
- entity_set_vector(his_challenger[id], EV_VEC_angles, his_angle[his_challenger[id]])
- entity_set_int(his_challenger[id], EV_INT_fixangle, 1)
- if(his_type[id] == 1)
- {
- his_type[his_challenger[id]] = 1
- }
- else if(his_type[id] == 2)
- {
- his_type[his_challenger[id]] = 2
- }
- else if(his_type[id] == 0)
- {
- his_type[his_challenger[id]] = 0
- }
- }
- }
- public spawn_rush_back(id)
- {
- entity_set_origin(id,his_player_spawn[id])
- set_user_health(id,the_default_hp)
- set_user_armor(id,0)
- set_user_godmode(id, 0)
- if(is_user_connected(the_challenger[id]))
- {
- check_rush_teams(id,the_challenger[id])
- entity_set_origin(the_challenger[id],his_player_spawn[the_challenger[id]])
- set_user_health(the_challenger[id],the_default_hp)
- set_user_armor(the_challenger[id],0)
- entity_set_vector(id, EV_VEC_angles, his_player_angle[id])
- entity_set_int(id, EV_INT_fixangle, 1)
- entity_set_vector(the_challenger[id], EV_VEC_angles, his_player_angle[the_challenger[id]])
- entity_set_int(the_challenger[id], EV_INT_fixangle, 1)
- if(his_type[id] == 1)
- {
- his_type[the_challenger[id]] = 1
- }
- else if(his_type[id] == 2)
- {
- his_type[the_challenger[id]] = 2
- }
- else if(his_type[id] == 0)
- {
- his_type[the_challenger[id]] = 0
- }
- }
- }
- public update_cvars()
- {
- MAP_FIX_ENABLED = get_pcvar_num(cvar_z_fix)
- SOUNDS_ENABLED = get_pcvar_num(cvar_sounds)
- MAX_ROUNDS = get_pcvar_num(cvar_rounds)
- MAX_KILLS = get_pcvar_num(cvar_kills)
- MAX_COUNTDOWN = get_pcvar_num(cvar_cooldown)
- MAX_TIME = get_pcvar_num(cvar_time)
- MAP_RUSH_FIX_ENABLED = get_pcvar_num(cvar_zone_fix)
- SOUNDS_RUSH_ENABLED = get_pcvar_num(cvar_user_sounds)
- MAX_USER_RUSH_ROUNDS = get_pcvar_num(cvar_user_rounds)
- MAX_USER_KILLS = get_pcvar_num(cvar_user_kills)
- MAX_USER_COUNTDOWN = get_pcvar_num(cvar_user_cooldown)
- MAX_USER_TIME = get_pcvar_num(cvar_user_time)
- }
- stock remove_allarenas()
- {
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- }
- fakes = 0
- }
- stock remove_all_rush_arenas()
- {
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- }
- fakearenas = 0
- }
- public get_all_arena_coords(id)
- {
- new Float:origin[3]
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser2) == CENTER_CODE)
- {
- pev(arenas_ent,pev_origin,origin);
- client_print(id,print_console,"%.f %.f %.f",origin[0],origin[1],origin[2])
- }
- }
- client_print_color(id, "%s ^4Coords printed in console.",CHAT_TAG)
- }
- public get_all_RUSH_ARENA_COORDS(id)
- {
- new Float:origin[3]
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser2) == RUSH_CENTER_CODE)
- {
- pev(arenas_ent,pev_origin,origin);
- client_print(id,print_console,"%.f %.f %.f",origin[0],origin[1],origin[2])
- }
- }
- client_print_color(id, "%s ^4Coords printed in console.",RUSH_TAG)
- }
- public remove_the_fake_arena()
- {
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- }
- fakes = 0
- }
- public remove_the_rush_fake_arena()
- {
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- }
- fakearenas = 0
- }
- public next_fake_arena()
- {
- if(fakes_count() >= MAX_ARENAS)
- return -1
- for(new i=1;i < MAX_ARENAS+1;i++)
- {
- if(!fake_arena_exists(i))
- {
- return i
- }
- }
- return -1
- /*new num = fakes
- num++
- return num*/
- }
- public next_fake_rush_arena()
- {
- if(fake_rush_arenas_count() >= MAX_RUSH_ARENAS)
- return -1
- for(new i=1;i < MAX_RUSH_ARENAS+1;i++)
- {
- if(!fake_rush_arena_exists(i))
- {
- return i
- }
- }
- return -1
- /*new num = fakearenas
- num++
- return num*/
- }
- public remove_the_arena(code)
- {
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == code)
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- }
- }
- public remove_the_rush_arena(code)
- {
- new arenas_ent=-1;
- while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
- {
- if(entity_get_int(arenas_ent,EV_INT_iuser1) == code)
- engfunc(EngFunc_RemoveEntity,arenas_ent)
- }
- }
- public start_build(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED
- if(is_in_duel[id] != 2)
- return PLUGIN_HANDLED
- if(!his_challenger[id])
- return PLUGIN_HANDLED
- if(!total_arenas)
- {
- return PLUGIN_HANDLED
- }
- static Float:origin[3];
- //get_user_hitpoint(id,origin)
- /*origin[0] = 1002.911376
- origin[1] = -1561.421997
- origin[2] = 0.0*/
- origin[0] = arena_coord[arena_number[id]][0]
- origin[1] = arena_coord[arena_number[id]][1]
- origin[2] = arena_coord[arena_number[id]][2]
- new Float:fake_origin[3]
- static size
- size = sizeof(ARENA_COORDS)
- new ent_code = arena_number[id]+ARENA_CODE
- for(new coords;coords < size; coords++)
- {
- fake_origin[0] = origin[0]
- fake_origin[1] = origin[1]
- fake_origin[2] = origin[2]
- //fake_origin[2]=-712.876892
- //fake_origin[2]=-864.253723
- fake_origin[0]+=ARENA_COORDS[coords][0]*1.7
- fake_origin[1]+=ARENA_COORDS[coords][1]*1.53
- new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
- set_pev(ent,pev_classname,ARENA_ENT_NAME);
- engfunc(EngFunc_SetModel,ent,ARENA_MODELS[0]);
- entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
- engfunc(EngFunc_SetSize,ent,ARENA_MINS,ARENA_MAXS);
- entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
- entity_set_int(ent,EV_INT_iuser1,ent_code)
- engfunc(EngFunc_SetOrigin,ent,fake_origin);
- static Float:rvec[3];
- pev(ent,pev_v_angle,rvec);
- rvec[0]=90.0;
- set_pev(ent,pev_angles,rvec);
- if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == 100.0)
- {
- create_wall(LEFT_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
- }
- if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == -100.0)
- {
- create_wall(RIGHT_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
- }
- if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == 0.0)
- {
- create_wall(TOP_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
- entity_set_int(ent,EV_INT_iuser2,CENTER_CODE)
- }
- else if(ARENA_COORDS[coords][0] == 200.0 && ARENA_COORDS[coords][1] == 0.0)
- {
- create_wall(BLUE_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
- if(cs_get_user_team(id) == CS_TEAM_CT)
- {
- set_spawn_positions(id,BLUE_SIDE,fake_origin,rvec)
- }
- else
- {
- if(his_challenger[id])
- {
- set_spawn_positions(his_challenger[id],BLUE_SIDE,fake_origin,rvec)
- }
- }
- //set_rendering(ent,kRenderFxGlowShell,0,0,200,kRenderNormal,10)
- }
- else if(ARENA_COORDS[coords][0] == -100.0 && ARENA_COORDS[coords][1] == 0.0)
- {
- create_wall(RED_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
- if(cs_get_user_team(id) == CS_TEAM_T)
- {
- set_spawn_positions(id,RED_SIDE,fake_origin,rvec)
- }
- else
- {
- if(his_challenger[id])
- {
- set_spawn_positions(his_challenger[id],RED_SIDE,fake_origin,rvec)
- }
- }
- //set_rendering(ent,kRenderFxGlowShell,200,0,0,kRenderNormal,10)
- }
- spawn_back(id)
- }
- return PLUGIN_HANDLED;
- }
- public start_rush_build(id)
- {
- if(!is_user_connected(id))
- return PLUGIN_HANDLED
- if(is_in_rush[id] != 2)
- return PLUGIN_HANDLED
- if(!the_challenger[id])
- return PLUGIN_HANDLED
- if(!total_rush_arenas)
- {
- return PLUGIN_HANDLED
- }
- static Float:origin[3];
- //get_user_hitpoint_rush(id,origin)
- /*origin[0] = 1002.911376
- origin[1] = -1561.421997
- origin[2] = 0.0*/
- origin[0] = rush_arena_coord[rush_arena_number[id]][0]
- origin[1] = rush_arena_coord[rush_arena_number[id]][1]
- origin[2] = rush_arena_coord[rush_arena_number[id]][2]
- new Float:fake_origin[3]
- static size
- size = sizeof(RUSH_ARENA_COORDS)
- new ent_code = rush_arena_number[id]+RUSH_ARENA_CODE
- for(new coords;coords < size; coords++)
- {
- fake_origin[0] = origin[0]
- fake_origin[1] = origin[1]
- fake_origin[2] = origin[2]
- //fake_origin[2]=-712.876892
- //fake_origin[2]=-864.253723
- fake_origin[0]+=RUSH_ARENA_COORDS[coords][0]*1.7
- fake_origin[1]+=RUSH_ARENA_COORDS[coords][1]*1.53
- new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
- set_pev(ent,pev_classname,RUSH_ENT_NAME);
- engfunc(EngFunc_SetModel,ent,RUSH_MODELS[0]);
- entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
- engfunc(EngFunc_SetSize,ent,RUSH_ARENA_MINS,RUSH_ARENA_MAXS);
- entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
- entity_set_int(ent,EV_INT_iuser1,ent_code)
- engfunc(EngFunc_SetOrigin,ent,fake_origin);
- static Float:rvec[3];
- pev(ent,pev_v_angle,rvec);
- rvec[0]=0.0;
- set_pev(ent,pev_angles,rvec);
- cs_set_user_team(id,CS_TEAM_T)
- cs_set_user_team(the_challenger[id],CS_TEAM_CT)
- set_spawn_positions_rush(id,fake_origin)
- set_spawn_positions_rush(the_challenger[id],fake_origin)
- spawn_rush_back(id)
- }
- return PLUGIN_HANDLED;
- }
- public set_spawn_positions(id,side,Float:origin[3],Float:angle[3])
- {
- if(side == BLUE_SIDE)
- his_spawn[id][0] = origin[0]-20.0
- else his_spawn[id][0] = origin[0]-120.0
- his_spawn[id][1] = origin[1]
- his_spawn[id][2] = origin[2]+50.0
- entity_get_vector(id, EV_VEC_angles,his_angle[id])
- switch(side)
- {
- case RED_SIDE:
- {
- his_angle[id][1] = 0.0
- his_angle[id][0] = 0.0
- }
- case BLUE_SIDE:
- {
- his_angle[id][1] = 180.0
- his_angle[id][0] = 0.0
- }
- }
- got_spawn[id] = 1
- }
- public set_spawn_positions_rush(id,Float:origin[3])
- {
- if(get_user_team(id) == 1)
- {
- his_player_spawn[id][0] = origin[0]-320
- his_player_spawn[id][1] = origin[1]
- his_player_spawn[id][2] = origin[2]+50
- his_player_angle[id][1] = 0.0
- his_player_angle[id][0] = 0.0
- }
- if(get_user_team(id) == 2)
- {
- his_player_spawn[id][0] = origin[0]+320
- his_player_spawn[id][1] = origin[1]
- his_player_spawn[id][2] = origin[2]+50
- his_player_angle[id][1] = 180.0
- his_player_angle[id][0] = 0.0
- }
- entity_set_origin(id,his_player_spawn[id])
- }
- public client_PostThink(id)
- {
- if(is_in_rush[id] == 2)
- {
- new flags = entity_get_int(id, EV_INT_flags);
- new Float:origin[3], Float:dest[3];
- entity_get_vector(id, EV_VEC_origin, origin);
- dest[0] = origin[0];
- dest[1] = origin[1];
- dest[2] = origin[2] - 70.0;
- new ptr = create_tr2();
- engfunc(EngFunc_TraceHull, origin, dest, 0, flags & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, id, ptr);
- new Float:flFraction;
- get_tr2(ptr, TR_flFraction, flFraction);
- if( flFraction >= 1.0)
- {
- Prevent_Noobs[id] ++
- if(Prevent_Noobs[id] == 10 )
- {
- Prevent_Noobs[id] = 0;
- end_his_rush(id)
- }
- ExecuteHamB(Ham_CS_RoundRespawn, id)
- free_tr2(ptr);
- return;
- }
- get_tr2(ptr, TR_vecPlaneNormal, dest);
- free_tr2(ptr);
- }
- }
- public stuck_check(Float:origin[3],Float:radius)
- {
- new player=-1;
- while((player = find_ent_in_sphere(player,origin,radius)) != 0)
- {
- if(is_user_alive(player))
- {
- if(is_player_stuck(player) && is_in_duel[player] != 2)
- {
- back_to_the_spawn(player)
- }
- }
- }
- }
- public stuck_rush_check(Float:origin[3],Float:radius)
- {
- new player=-1;
- while((player = find_ent_in_sphere(player,origin,radius)) != 0)
- {
- if(is_user_alive(player))
- {
- if(is_player_stuck_rush(player) && is_in_rush[player] != 2)
- {
- back_to_the_rush_spawn(player)
- }
- }
- }
- }
- stock is_player_stuck(id)
- {
- static Float:originF[3]
- pev(id, pev_origin, originF)
- engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
- if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
- return true;
- return false;
- }
- stock is_player_stuck_rush(id)
- {
- static Float:originF[3]
- pev(id, pev_origin, originF)
- engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
- if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
- return true;
- return false;
- }
- public create_wall(type,alpha,solidity,code,code1,code2,Float:origin[3])
- {
- new Float:wall_maxsize[3];
- new Float:wall_minsize[3];
- new Float:rvec[3];
- new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
- pev(ent,pev_v_angle,rvec);
- switch(type)
- {
- case BLUE_SIDE:
- {
- wall_maxsize[0] = 2.0
- wall_minsize[0] = 0.0
- wall_maxsize[1] = 230.0
- wall_minsize[1] = -230.0
- wall_maxsize[2] = 150.0
- wall_minsize[2] = -1.0
- rvec[1]=180.0
- }
- case RED_SIDE:
- {
- wall_maxsize[0] = -150.0
- wall_minsize[0] = -152.0
- wall_maxsize[1] = 230.0
- wall_minsize[1] = -230.0
- wall_maxsize[2] = 150.0
- wall_minsize[2] = -1.0
- rvec[1]=180.0
- }
- case LEFT_SIDE:
- {
- wall_maxsize[0] = 360.0
- wall_minsize[0] = -300.0
- wall_maxsize[1] = 65.0
- wall_minsize[1] = 63.0
- wall_maxsize[2] = 150.0
- wall_minsize[2] = -1.0
- rvec[1]=90.0
- }
- case RIGHT_SIDE:
- {
- wall_maxsize[0] = 360.0
- wall_minsize[0] = -300.0
- wall_maxsize[1] = -63.0
- wall_minsize[1] = -65.0
- wall_maxsize[2] = 150.0
- rvec[1]=90.0
- }
- case TOP_SIDE:
- {
- wall_maxsize[0] = 360.0
- wall_minsize[0] = -300.0
- wall_maxsize[1] = 230.0
- wall_minsize[1] = -230.0
- wall_maxsize[2] = 150.0
- wall_minsize[2] = 148.0
- rvec[0]=90.0
- }
- }
- set_pev(ent,pev_angles,rvec);
- set_pev(ent,pev_classname,ARENA_ENT_NAME);
- engfunc(EngFunc_SetModel,ent,ARENA_MODELS[0]);
- set_pev(ent, pev_effects, EF_NODRAW)
- entity_set_int(ent, EV_INT_solid, solidity);
- engfunc(EngFunc_SetSize,ent,wall_minsize,wall_maxsize);
- entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
- entity_set_int(ent,EV_INT_iuser1,code)
- entity_set_int(ent,EV_INT_iuser2,code1)
- entity_set_int(ent,EV_INT_iuser3,code2)
- engfunc(EngFunc_SetOrigin,ent,origin);
- //set_rendering(ent,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,alpha)
- //set_rendering(ent, kRenderFxGlowShell, 255, 100, 0, kRenderTransColor, 1);
- }
- public get_spawn_origin(id)
- {
- pev(id,pev_origin,his_original_spawn[id]);
- }
- public get_spawn_rush_origin(id)
- {
- pev(id,pev_origin,his_original_player_spawn[id]);
- }
- stock get_user_hitpoint(id,Float:hOrigin[3]) {
- if(!is_user_alive(id))
- return 0;
- new Float:fOrigin[3],Float:fvAngle[3],Float:fvOffset[3],Float:fvOrigin[3],Float:feOrigin[3];
- new Float:fTemp[3];
- pev(id,pev_origin,fOrigin);
- pev(id,pev_v_angle,fvAngle);
- pev(id,pev_view_ofs,fvOffset);
- xs_vec_add(fOrigin,fvOffset,fvOrigin);
- engfunc(EngFunc_AngleVectors,fvAngle,feOrigin,fTemp,fTemp);
- xs_vec_mul_scalar(feOrigin,9999.9,feOrigin);
- xs_vec_add(fvOrigin,feOrigin,feOrigin);
- engfunc(EngFunc_TraceLine,fvOrigin,feOrigin,0,id);
- global_get(glb_trace_endpos,hOrigin);
- return 1;
- }
- stock get_user_hitpoint_rush(id,Float:hOrigin[3]) {
- if(!is_user_alive(id))
- return 0;
- new Float:fOrigin[3],Float:fvAngle[3],Float:fvOffset[3],Float:fvOrigin[3],Float:feOrigin[3];
- new Float:fTemp[3];
- pev(id,pev_origin,fOrigin);
- pev(id,pev_v_angle,fvAngle);
- pev(id,pev_view_ofs,fvOffset);
- xs_vec_add(fOrigin,fvOffset,fvOrigin);
- engfunc(EngFunc_AngleVectors,fvAngle,feOrigin,fTemp,fTemp);
- xs_vec_mul_scalar(feOrigin,9999.9,feOrigin);
- xs_vec_add(fvOrigin,feOrigin,feOrigin);
- engfunc(EngFunc_TraceLine,fvOrigin,feOrigin,0,id);
- global_get(glb_trace_endpos,hOrigin);
- return 1;
- }
- public plugin_precache()
- {
- new size;
- size = sizeof(ARENA_MODELS)
- for(new i; i< size; i++)
- {
- engfunc(EngFunc_PrecacheModel,ARENA_MODELS[i]);
- engfunc(EngFunc_PrecacheModel,RUSH_MODELS[i]);
- }
- }
- public round_start_event()
- {
- update_cvars();
- // using a variable to store player's names instead of regenerating it all the time...
- for(new id;id < MAXPLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- get_user_name(id,his_name[id],charsmax(his_name))
- }
- }
- }
- public round_start_rush_event()
- {
- update_cvars()
- // using a variable to store player's names instead of regenerating it all the time...
- for(new id;id < MAX_RUSH_PLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- get_user_name(id,his_name[id],charsmax(his_name))
- }
- }
- }
- public Advertise(task)
- {
- client_print_color(0,"^3[^4Global Knife^3] ^1Type ^3/duel ^1/drank ^3/dtop ^1to open ^4Duel Menu (rank & top)")
- set_task(120.0,"Advertise",TASK_AD)
- }
- public Cmd_start(id,hndle)
- {
- if(!is_user_alive(id))
- return FMRES_IGNORED
- if(!is_frozen[id])
- return FMRES_IGNORED
- new Buttons = get_uc(hndle,UC_Buttons)
- if(Buttons & IN_ATTACK)
- {
- Buttons &= ~IN_ATTACK
- set_uc( hndle , UC_Buttons , Buttons )
- return FMRES_SUPERCEDE
- }
- if(Buttons & IN_ATTACK2)
- {
- Buttons &= ~IN_ATTACK2
- set_uc( hndle , UC_Buttons , Buttons )
- return FMRES_SUPERCEDE
- }
- return FMRES_IGNORED
- }
- public Player_Take_Damage(victim, inflictor, attacker, Float:damage, damage_bits)
- {
- if(is_user_connected(attacker)) // we make sure the attacker is a player
- {
- if(is_in_duel[victim] == 2 || is_in_duel[attacker] == 2)
- {
- if(his_challenger[victim] != attacker || his_challenger[attacker] != victim)
- {
- // we protect the contenders from getting killed by other people or them killing others?
- return HAM_SUPERCEDE
- }
- }
- }
- return HAM_IGNORED
- }
- public Player_Take_Damage_Rush(victim, inflictor, attacker, Float:damage, damage_bits)
- {
- if(is_user_connected(attacker)) // we make sure the attacker is a player
- {
- if(is_in_rush[victim] == 2 || is_in_rush[attacker] == 2)
- {
- if(the_challenger[victim] != attacker || the_challenger[attacker] != victim)
- {
- // we protect the contenders from getting killed by other people or them killing others?
- return HAM_SUPERCEDE
- }
- }
- }
- return HAM_IGNORED
- }
- public client_putinserver(id)
- {
- get_user_name(id,his_name[id],charsmax(his_name))
- reset_values(id)
- move_size[id] = 10.0
- his_offline[id] = 0
- his_type[id] = 0
- his_previous_team[id] = 0
- reset_player_values(id)
- move_arena_size[id] = 10.0
- his_previous_user_team[id] = 0
- return PLUGIN_CONTINUE
- }
- public client_disconnect(id)
- {
- end_his_duel(id)
- end_his_rush(id)
- Duel_Arena_Spawner[id] = false
- Rush_Arena_Spawner[id] = false
- }
- public end_his_duel(id)
- {
- if(his_challenger[id])
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s^1's challenger ^4%s^1 has ^3left the game^1.",arena_names[arena_number[id]],his_name[his_challenger[id]],his_name[id])
- user_can_spawn[his_challenger[id]] = 1
- user_can_spawn[id] = 1
- if(arena_number[id] == arena_number[his_challenger[id]])
- remove_the_arena(arena_number[id] +ARENA_CODE)
- back_to_the_spawn(id)
- back_to_the_spawn(his_challenger[id])
- reset_values(his_challenger[id])
- }
- reset_values(id)
- }
- public end_his_rush(id)
- {
- if(the_challenger[id])
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s^1's challenger ^4%s^1 has ^3left the game^1.",rush_arena_names[rush_arena_number[id]],his_name[the_challenger[id]],his_name[id])
- if(rush_arena_number[id] == rush_arena_number[the_challenger[id]])
- remove_the_rush_arena(rush_arena_number[id] +RUSH_ARENA_CODE)
- back_to_the_rush_spawn(id)
- back_to_the_rush_spawn(the_challenger[id])
- reset_player_values(the_challenger[id])
- }
- reset_player_values(id)
- }
- public times_up_duel(id)
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s^1 and ^4%s^1 has taken long to ^3finish the battle^1.",arena_names[arena_number[id]],his_name[his_challenger[id]],his_name[id])
- if(his_challenger[id])
- {
- if(arena_number[id] == arena_number[his_challenger[id]])
- remove_the_arena(arena_number[id] +ARENA_CODE)
- user_kill(id,1)
- user_kill(his_challenger[id],1)
- //back_to_the_spawn(id)
- //back_to_the_spawn(his_challenger[id])
- reset_values(his_challenger[id])
- }
- reset_values(id)
- }
- public times_up_rush(id)
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s^1 ^1and ^4%s^1 has taken long to ^3finish the battle^1.",rush_arena_names[rush_arena_number[id]],his_name[the_challenger[id]],his_name[id])
- if(the_challenger[id])
- {
- if(rush_arena_number[id] == rush_arena_number[the_challenger[id]])
- remove_the_rush_arena(rush_arena_number[id] +RUSH_ARENA_CODE)
- user_kill(id,1)
- user_kill(the_challenger[id],1)
- back_to_the_rush_spawn(id)
- back_to_the_rush_spawn(the_challenger[id])
- reset_player_values(the_challenger[id])
- }
- reset_player_values(id)
- }
- public battle_timer(id)
- {
- if(is_user_connected(id))
- {
- if(is_in_duel[id] == 2)
- {
- his_timer[id]++
- if(his_timer[id] > MAX_TIME)
- {
- times_up_duel(id)
- }
- set_task(1.0,"battle_timer",id)
- }
- }
- }
- public battle_rush_timer(id)
- {
- if(is_user_connected(id))
- {
- if(is_in_rush[id] == 2)
- {
- the_timer[id]++
- if(the_timer[id] > MAX_USER_TIME)
- {
- times_up_rush(id)
- }
- set_task(1.0,"battle_rush_timer",id)
- }
- }
- }
- public toggle_offline(id)
- {
- switch(his_offline[id])
- {
- case 0:
- {
- his_offline[id] = 1
- client_print_color(id,"%s^4%s^1 disconnected from the duel list.",CHAT_TAG,his_name[id])
- }
- default:
- {
- his_offline[id] = 0
- client_print_color(id,"%s^4%s^1 connected to the duel list.",CHAT_TAG,his_name[id])
- }
- }
- }
- public give_up_player(id)
- {
- if(is_user_connected(his_challenger[id]))
- {
- client_print_color(0,"%s^4%s^3 got scared to face ^4%s^1 :)",CHAT_TAG,his_name[id],his_name[his_challenger[id]])
- if(arena_number[id] == arena_number[his_challenger[id]])
- remove_the_arena(arena_number[id] +ARENA_CODE)
- back_to_the_spawn(id)
- back_to_the_spawn(his_challenger[id])
- reset_values(his_challenger[id])
- }
- reset_values(id)
- }
- public give_up_rush_player(id)
- {
- if(is_user_connected(the_challenger[id]))
- {
- client_print_color(0,"%s^4%s^3 got scared to face ^4%s^3! :)",RUSH_TAG,his_name[id],his_name[the_challenger[id]])
- if(rush_arena_number[id] == rush_arena_number[the_challenger[id]])
- remove_the_rush_arena(rush_arena_number[id] +RUSH_ARENA_CODE)
- back_to_the_rush_spawn(id)
- back_to_the_rush_spawn(the_challenger[id])
- reset_player_values(the_challenger[id])
- }
- reset_player_values(id)
- }
- public reward_winner(id)
- {
- if(is_user_connected(id))
- {
- give_item(id, "weapon_hegrenade")
- gBackStabing[id] = false;
- client_print_color(id,"%s^4Congratulations!!!^1, You have ^3won this battle^1!",CHAT_TAG)
- if(SOUNDS_ENABLED)
- client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[0])
- /*if(cs_get_user_money(id)+15000 <= 16000)
- {
- cs_set_user_money(id,cs_get_user_money(id)+15000,1)
- } else cs_set_user_money(id,16000,1)*/
- }
- }
- public reward_rush_winner(id)
- {
- if(is_user_connected(id))
- {
- // here you can reward the winner with something
- client_print_color(id,"%s^4Congratulations!!!^1, You have ^3won this battle^1!",RUSH_TAG)
- if(SOUNDS_RUSH_ENABLED)
- client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[0])
- if(cs_get_user_money(id)+15000 <= 16000)
- {
- cs_set_user_money(id,cs_get_user_money(id)+15000,1)
- //client_print_color(id,"%s^4You've earned ^3$15000^4!",RUSH_TAG)
- } else cs_set_user_money(id,16000,1)
- }
- }
- public reward_loser(id)
- {
- if(is_user_connected(id))
- {
- back_to_the_spawn(id)
- gBackStabing[id] = false;
- client_print_color(id,"%sYou've ^3lost this battle^1!",CHAT_TAG)
- if(SOUNDS_ENABLED)
- client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[1])
- }
- }
- public reward_rush_loser(id)
- {
- if(is_user_connected(id))
- {
- // here you can reward the winner with something
- back_to_the_spawn(id)
- client_print_color(id,"%sYou've ^3lost this battle^1!",RUSH_TAG)
- if(SOUNDS_RUSH_ENABLED)
- client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[1])
- if(cs_get_user_money(id)-15000 >= 0)
- {
- cs_set_user_money(id,cs_get_user_money(id)-15000,1)
- //client_print_color(id,"%s^4You've lost ^3$15000^4!",RUSH_TAG)
- } else cs_set_user_money(id,0,1)
- }
- }
- public duel_players_lists(id)
- {
- if(!is_user_alive(id))
- {
- client_print_color(id,"%sYou can't challenge anyone when you're ^3dead1.",CHAT_TAG)
- return PLUGIN_HANDLED
- }
- if(his_offline[id])
- {
- client_print_color(id,"%sYou can't challenge people when you're ^3offline^1.",CHAT_TAG)
- return PLUGIN_HANDLED
- }
- if(is_user_connected(his_challenger[id]))
- {
- client_print_color(id,"%s^4%s ^1is still ^4fighting against you^1.",CHAT_TAG,his_name[his_challenger[id]])
- return PLUGIN_HANDLED
- }
- if(is_user_connected(his_asker[id]))
- {
- client_print_color(id,"%sYou can only ^3challenge one person^1 at the time, you've challenged ^4%s^1.",CHAT_TAG,his_name[his_asker[id]])
- return PLUGIN_HANDLED
- }
- if(!available_duelers(id))
- {
- client_print_color(id,"%sThere's ^4nobody^1 you can challenge.",CHAT_TAG)
- return PLUGIN_HANDLED
- }
- if(is_in_rush[id] == 2)
- {
- return PLUGIN_HANDLED
- }
- if(get_next_arena() == -1)
- {
- client_print_color(id,"%s^4Maximum arenas reached.",CHAT_TAG)
- return PLUGIN_HANDLED
- }
- new menu,menuformat[64];
- formatex(menuformat,charsmax(menuformat),"\w[\rGlobal Knife\w] \yKnifeDuels ^n\dArenas Free: %d/%d \w",arenas_count(),total_arenas)
- menu = menu_create( menuformat, "Duel_handler" );
- new tempid;
- new szName[32], szUserId[32],nameu[92],CsTeams:team;
- formatex(nameu,charsmax(nameu), "\yRefresh");
- menu_additem(menu, nameu,"rf_c", 0);
- menu_addblank(menu,0)
- //get_players( players, pnum, "c" );
- for ( new e; e<MAXPLAYERS; e++ )
- {
- if(!is_user_connected(e))
- continue;
- tempid = e
- team = cs_get_user_team(tempid)
- if(tempid != id && team != CS_TEAM_SPECTATOR && team != CS_TEAM_UNASSIGNED)// && !users_in_same_team(id,tempid))
- {
- get_user_name(tempid, szName, charsmax(szName));
- formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(tempid));
- if(his_offline[tempid])
- {
- formatex(nameu,charsmax(nameu), "%s \w[\dOffline\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- if(isBlocked[tempid][id])
- {
- formatex(nameu,charsmax(nameu), "%s \w[\rBlocked\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else if(!is_user_alive(tempid))
- {
- formatex(nameu,charsmax(nameu), "\d%s [DEAD]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else
- {
- if(is_in_duel[tempid] == 2)
- {
- formatex(nameu,charsmax(nameu), "%s \w[\rIn Duel\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else if(is_in_rush[tempid] == 2)
- {
- formatex(nameu,charsmax(nameu), "%s \w[\rIn Rush\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else if(is_in_duel[tempid] == 1)
- {
- formatex(nameu,charsmax(nameu), "%s \w[\yPending\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else
- {
- formatex(nameu,charsmax(nameu), "%s", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- }
- }
- }
- menu_display(id, menu, 0 );
- return PLUGIN_HANDLED
- }
- public rush_players_list(id)
- {
- if(!is_user_alive(id))
- {
- client_print_color(id,"%sYou can't challenge anyone when you're ^3dead1.",RUSH_TAG)
- return PLUGIN_HANDLED
- }
- if(his_offline[id])
- {
- client_print_color(id,"%sYou can't challenge people when you're ^3offline^1.",RUSH_TAG)
- return PLUGIN_HANDLED
- }
- if(his_offline[id])
- {
- client_print_color(id,"%sYou can't challenge people when you're ^3offline^1.",RUSH_TAG)
- return PLUGIN_HANDLED
- }
- if(is_user_connected(the_challenger[id]))
- {
- client_print_color(id,"%s^4%s ^1is still ^4fighting against you^1.",RUSH_TAG,his_name[the_challenger[id]])
- return PLUGIN_HANDLED
- }
- if(is_user_connected(the_asker[id]))
- {
- client_print_color(id,"%sYou can only ^3challenge one person^1 at the time, you've challenged ^4%s^1.",RUSH_TAG,his_name[the_asker[id]])
- return PLUGIN_HANDLED
- }
- if(!available_rush_duelers(id))
- {
- client_print_color(id,"%sThere's ^4nobody^1 you can challenge.",RUSH_TAG)
- return PLUGIN_HANDLED
- }
- if(get_next_rush_arena() == -1)
- {
- client_print_color(id,"%s^4Maximum arenas reached.",RUSH_TAG)
- return PLUGIN_HANDLED
- }
- if(is_in_duel[id] == 2)
- {
- client_print_color(id,"%sThis player ^4already^1 played in Duel",RUSH_TAG)
- return PLUGIN_HANDLED
- }
- new menu,menuformat[64];
- formatex(menuformat,charsmax(menuformat),"\w[\rGlobal Knife\w] \yKnifeRush ^n\dArenas Free: %d/%d \w",arenas_count_rush(),total_rush_arenas)
- menu = menu_create( menuformat, "Rush_handler" );
- new tempid;
- new szName[32], szUserId[32],nameu[92],CsTeams:team;
- formatex(nameu,charsmax(nameu), "\yRefresh");
- menu_additem(menu, nameu,"rf_c", 0);
- menu_addblank(menu,0)
- //get_players( players, pnum, "c" );
- for ( new e; e<MAX_RUSH_PLAYERS; e++ )
- {
- if(!is_user_connected(e))
- continue;
- tempid = e
- team = cs_get_user_team(tempid)
- if(tempid != id && team != CS_TEAM_SPECTATOR && team != CS_TEAM_UNASSIGNED)// && !users_in_same_team(id,tempid))
- {
- get_user_name(tempid, szName, charsmax(szName));
- formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(tempid));
- if(his_offline[tempid])
- {
- formatex(nameu,charsmax(nameu), "%s \w[\dOffline Duel\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- if(isBlocked[tempid][id])
- {
- formatex(nameu,charsmax(nameu), "%s \w[\rBlocked\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else if(his_offline[tempid])
- {
- formatex(nameu,charsmax(nameu), "%s \w[\dOffline Rush\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else if(!is_user_alive(tempid))
- {
- formatex(nameu,charsmax(nameu), "\d%s [DEAD]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else
- {
- if(is_in_rush[tempid] == 2)
- {
- formatex(nameu,charsmax(nameu), "%s \w[\rInRush\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else if(is_in_duel[tempid] == 2)
- {
- formatex(nameu,charsmax(nameu), "%s \w[\rInDuel\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else if(is_in_rush[tempid] == 1)
- {
- formatex(nameu,charsmax(nameu), "%s \w[\yPending\w]", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- else
- {
- formatex(nameu,charsmax(nameu), "%s", szName);
- menu_additem(menu, nameu, szUserId, 0);
- }
- }
- }
- }
- menu_display(id, menu, 0 );
- return PLUGIN_HANDLED
- }
- public Duel_handler( id, menu, item )
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- new szData[32], szName[64];
- new _access, item_callback;
- menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
- if(equali(szData,"rf_c"))
- {
- menu_destroy( menu );
- duel_players_lists(id)
- return PLUGIN_CONTINUE
- }
- new userid = str_to_num( szData );
- //spam_hud(id)
- new enem = find_player("k", userid); // flag "k" : find player from userid
- if (is_user_connected(enem))
- {
- if(!is_user_alive(enem))
- {
- client_print_color(id,"%sYou can't challenge dead players.",CHAT_TAG)
- }
- else if(his_offline[enem])
- {
- client_print_color(id,"%sYou can't challenge offline players.",CHAT_TAG)
- }
- if(isBlocked[enem][id])
- {
- client_print_color(id,"%sThis user blocked you!",CHAT_TAG)
- }
- else if(is_in_rush[enem] == 2)
- {
- client_print_color(id,"%sYou can't challenge Rush players.",CHAT_TAG)
- }
- else
- {
- if(!is_in_duel[enem])
- {
- //spam_hud(enem)
- is_in_duel[enem] = 1
- is_in_duel[id] = 1
- his_asker[id] = enem
- his_asker[enem] = id
- ask_player(enem)
- client_print_color(0,"%s^4%s^1 has challenged ^4%s^1 for a ^3duel^1!",CHAT_TAG,his_name[id],his_name[enem])
- set_task(10.0,"taken_long",id)
- }
- else
- {
- client_print_color(id,"%s^4%s^1 seems ^3to be busy ^1with ^4another duel^1..",CHAT_TAG,his_name[enem])
- }
- }
- }
- menu_destroy( menu );
- return PLUGIN_CONTINUE;
- }
- public Rush_handler( id, menu, item )
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- new szData[32], szName[64];
- new _access, item_callback;
- menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
- if(equali(szData,"rf_c"))
- {
- menu_destroy( menu );
- rush_players_list(id)
- return PLUGIN_CONTINUE
- }
- new userid = str_to_num( szData );
- //spam_hud(id)
- new enem = find_player("k", userid); // flag "k" : find player from userid
- if (is_user_connected(enem))
- {
- if(his_offline[enem])
- {
- client_print_color(id,"%sYou can't challenge offline players.",RUSH_TAG)
- }
- else if(his_offline[enem])
- {
- client_print_color(id,"%sYou can't challenge offline players.",RUSH_TAG)
- }
- if(isBlocked[enem][id])
- {
- client_print_color(id,"%sThis user blocked you!",CHAT_TAG)
- }
- else if(is_in_duel[enem] == 2)
- {
- client_print_color(id,"%sYou can't challenge Duel players.",RUSH_TAG)
- }
- else
- {
- if(!is_in_rush[enem])
- {
- //spam_hud(enem)
- is_in_rush[enem] = 1
- is_in_rush[id] = 1
- the_asker[id] = enem
- the_asker[enem] = id
- ask_rush_player(enem)
- client_print_color(0,"%s^4%s^1 has ^3challenged^1 ^4%s^1 for a ^3duel^1!",RUSH_TAG,his_name[id],his_name[enem])
- set_task(10.0,"taken_rush_long",id)
- }
- else
- {
- client_print_color(id,"%s^4%s^1 seems to be busy with another duel..",RUSH_TAG,his_name[enem])
- }
- }
- }
- menu_destroy( menu );
- return PLUGIN_CONTINUE;
- }
- public taken_long(id)
- {
- if(is_in_duel[id] == 1)
- {
- client_print_color(id,"%s^4%s ^1has taken ^3too long to respond ^1to ^4%s^1's challenge.",CHAT_TAG,his_name[his_asker[id]],his_name[id])
- user_can_spawn[id] = 1
- user_can_spawn[his_asker[id]] = 1
- reset_values(his_asker[id])
- reset_values(id)
- show_menu(his_asker[id], 0, "^n", 1)
- }
- }
- public taken_rush_long(id)
- {
- if(is_in_rush[id] == 1)
- {
- client_print_color(id,"%s^4%s ^1has taken ^3too long to respond ^1to ^4%s^1's challenge.",RUSH_TAG,his_name[the_asker[id]],his_name[id])
- reset_player_values(the_asker[id])
- reset_player_values(id)
- show_menu(the_asker[id], 0, "^n", 1)
- }
- }
- stock available_duelers(asker)
- {
- new num;
- num = 0 // just incase...
- for(new id;id < MAXPLAYERS;id++)
- {
- if(is_user_alive(id))
- {
- if(/*!is_in_duel[id] && */id != asker && !is_user_bot(id))
- {
- num++
- }
- }
- }
- return num
- }
- stock available_rush_duelers(asker)
- {
- new num;
- num = 0 // just incase...
- for(new id;id < MAX_RUSH_PLAYERS;id++)
- {
- if(is_user_alive(id))
- {
- if(/*!is_in_rush[id] && */id != asker && !is_user_bot(id))
- {
- num++
- }
- }
- }
- return num
- }
- public ask_player(id)
- {
- if(!is_user_alive(id))
- {
- return PLUGIN_HANDLED
- }
- new asker_name[32],menu_title[64];
- get_user_name(his_asker[id],asker_name,charsmax(asker_name))
- formatex(menu_title,charsmax(menu_title),"\rAccept Duel \y%s\r %s ?",asker_name ,PartTypes(All_Configs[his_asker[id]][Types_On]))
- new menu
- menu = menu_create( menu_title, "Ask_handler" );
- menu_additem(menu, "Yes!", "user_said_yes", 0);
- menu_additem(menu, "No!","user_said_no", 0);
- menu_display(id, menu, 0 );
- return PLUGIN_HANDLED
- }
- public ask_rush_player(id)
- {
- if(!is_user_alive(id))
- {
- return PLUGIN_HANDLED
- }
- new asker_name[32],menu_title[64];
- get_user_name(the_asker[id],asker_name,charsmax(asker_name))
- formatex(menu_title,charsmax(menu_title),"\rAccept Rush \y%s\r %s ?",asker_name ,PartTypes(All_Configs[the_asker[id]][Types_On]))
- new menu
- menu = menu_create( menu_title, "Ask_rush_handler" );
- menu_additem(menu, "Sure!", "user_said_yes", 0);
- menu_additem(menu, "Nope!","user_said_no", 0);
- menu_display(id, menu, 0 );
- return PLUGIN_HANDLED
- }
- public Ask_handler( id, menu, item )
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- new szData[32], szName[64];
- new _access, item_callback;
- menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
- if(!is_user_alive(id))
- {
- client_print_color(id,"%sDuel challenge ^3canceled^1, ^4You're ^1dead..",CHAT_TAG)
- client_print_color(his_asker[id],"%sDuel challenge ^3canceled^1,^4 %s ^1is dead..",CHAT_TAG,his_name[his_asker[his_asker[id]]])
- reset_values(his_asker[id])
- reset_values(id)
- }
- else if(equali(szData,"user_said_yes"))
- {
- if(get_next_arena() == -1)
- {
- client_print_color(his_asker[id],"%sMaximum arenas reached.",CHAT_TAG)
- reset_values(his_asker[id])
- reset_values(id)
- }
- else if(is_in_duel[his_asker[id]] == 1)
- {
- manage_battle(id)
- check_teams(id,his_challenger[id])
- begin_the_battle(id,his_challenger[id])
- } else
- {
- client_print_color(id,"%s%s either canceled the duel or chosen someone else to duel.",CHAT_TAG,his_name[his_asker[id]])
- reset_values(his_asker[id])
- reset_values(id)
- }
- }
- else if(equali(szData,"user_said_no"))
- {
- if(is_user_connected(his_asker[id]))
- {
- //client_print_color(0,"%s^4%s ^1rejected ^4%s^1's challenge.",CHAT_TAG,his_name[id],his_name[his_asker[id]])
- reset_values(his_asker[id])
- reset_values(id)
- }
- }
- menu_destroy( menu );
- return PLUGIN_CONTINUE;
- }
- public Ask_rush_handler( id, menu, item )
- {
- if ( item == MENU_EXIT )
- {
- menu_destroy( menu );
- return PLUGIN_HANDLED;
- }
- new szData[32], szName[64];
- new _access, item_callback;
- menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
- if(equali(szData,"user_said_yes"))
- {
- if(get_next_rush_arena() == -1)
- {
- client_print_color(the_asker[id],"%sMaximum arenas reached.",RUSH_TAG)
- reset_player_values(the_asker[id])
- reset_player_values(id)
- }
- else if(is_in_rush[the_asker[id]] == 1)
- {
- manage_rush_battle(id)
- check_rush_teams(id,the_challenger[id])
- begin_the_rush_battle(id,the_challenger[id])
- } else
- {
- client_print_color(id,"%s%s either canceled the duel or chosen someone else to duel.",RUSH_TAG,his_name[the_asker[id]])
- reset_player_values(the_asker[id])
- reset_player_values(id)
- }
- }
- else if(equali(szData,"user_said_no"))
- {
- if(is_user_connected(the_asker[id]))
- {
- //client_print_color(0,"%s^4%s^3 rejected ^4%s^3's challenge.",RUSH_TAG,his_name[id],his_name[the_asker[id]])
- reset_player_values(the_asker[id])
- reset_player_values(id)
- }
- }
- menu_destroy( menu );
- return PLUGIN_CONTINUE;
- }
- public Player_Killed(victim, attacker, shouldgib)
- {
- if(!is_user_connected(victim))
- return
- if(is_in_duel[victim] != 2)
- return
- if(is_user_connected(his_challenger[victim]) && !is_user_connected(attacker))
- {
- if(!check_teams(victim,attacker))
- return
- }
- if(!is_user_connected(attacker))
- return
- if(attacker == victim)
- return
- if(is_in_duel[attacker] != 2 || is_in_duel[victim] != 2)
- return
- if(his_challenger[victim] == attacker || his_challenger[attacker] == victim )
- {
- his_wins[attacker]++
- rounds[arena_number[attacker]]++
- static ret;
- ExecuteForward(killed_forward, ret, attacker,victim)
- if(Head_shot[attacker][victim])
- {
- his_HS[attacker]++
- client_cmd(0,"spk ^"%s^"",DUEL_SOUNDS[5])
- Head_shot[attacker][victim] = false
- }
- if(rounds[arena_number[attacker]] >= MAX_ROUNDS || his_wins[attacker] >= MAX_KILLS)
- {
- if(!get_non_duelers_alive())
- {
- ExecuteHamB(Ham_CS_RoundRespawn, victim)
- Check_Results(attacker,victim)
- return
- }
- else
- {
- ExecuteHamB(Ham_CS_RoundRespawn, victim)
- Check_Results(attacker,victim)
- }
- }
- else
- {
- wait_for_enemy_loop(attacker)
- }
- Set_Entity_Invisible(victim, 1)
- set_task(0.1,"delay_respawn",victim)
- return
- }
- return
- }
- public Player_Rush_Killed(victim, attacker)
- {
- if(!is_user_connected(victim))
- return //HAM_IGNORED;
- if(is_user_connected(the_challenger[victim]) && !is_user_connected(attacker))
- {
- if(!check_rush_teams(victim,attacker))
- return //HAM_IGNORED
- }
- if(!is_user_connected(attacker))
- return //HAM_IGNORED
- if(attacker == victim)
- return //HAM_IGNORED
- if(is_in_rush[attacker] != 2 || is_in_rush[victim] != 2)
- return //HAM_IGNORED
- if(the_challenger[victim] == attacker || the_challenger[attacker] == victim )
- {
- the_wins[attacker]++
- rush_rounds[rush_arena_number[attacker]]++
- static Float:FOrigin3[3]
- pev(victim, pev_origin, FOrigin3)
- engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, FOrigin3, 0)
- write_byte(TE_IMPLOSION)
- engfunc(EngFunc_WriteCoord, FOrigin3[0])
- engfunc(EngFunc_WriteCoord, FOrigin3[1])
- engfunc(EngFunc_WriteCoord, FOrigin3[2])
- write_byte(200)
- write_byte(100)
- write_byte(5)
- message_end()
- if(Headshot[attacker][victim])
- {
- THE_HS[attacker]++
- Headshot[attacker][victim] = false
- }
- user_silentkill(victim)
- if(rush_rounds[rush_arena_number[attacker]] >= MAX_USER_RUSH_ROUNDS || the_wins[attacker] >= MAX_USER_KILLS)
- {
- if(!get_non_rushers_alive())
- {
- ExecuteHamB(Ham_CS_RoundRespawn, victim)
- Check_Rush_Results(attacker,victim)
- return //HAM_SUPERCEDE
- }
- else
- {
- ExecuteHamB(Ham_CS_RoundRespawn, victim)
- Check_Rush_Results(attacker,victim)
- }
- }
- else
- {
- rush_wait_for_enemy_loop(attacker)
- //client_print_color(attacker,"%s^4Rounds^1:^3%d^4/^3%d^1 | ^4You^1:^3%d^4/^3%d^1 | ^4%s^1:^3%d^4/^3%d^1.",RUSH_TAG,rush_rounds[rush_arena_number[attacker]],MAX_USER_RUSH_ROUNDS,the_wins[attacker],MAX_USER_KILLS,his_name[victim],the_wins[victim],MAX_USER_KILLS)
- //client_print_color(victim,"%s^4Rounds^1:^3%d^4/^3%d^1 | ^4You^1:^3%d^4/^3%d^1 | ^4%s^1:^3%d^4/^3%d^1.",RUSH_TAG,rush_rounds[rush_arena_number[attacker]],MAX_USER_RUSH_ROUNDS,the_wins[victim],MAX_USER_KILLS,his_name[attacker],the_wins[attacker],MAX_USER_KILLS)
- }
- Set_Entity_Invisible(victim, 1)
- set_task(0.1,"delay_rush_respawn",victim)
- return //HAM_SUPERCEDE
- }
- return //HAM_IGNORED
- }
- public delay_respawn(id)
- {
- if(is_user_connected(id))
- {
- if(!is_user_alive(id))
- {
- if(is_in_duel[id] == 2)
- {
- user_can_spawn[id] = 1
- ExecuteHamB(Ham_CS_RoundRespawn, id)
- user_can_spawn[id] = 0
- }else{
- user_can_spawn[id] = 1
- ExecuteHamB(Ham_CS_RoundRespawn, id)
- }
- }
- Set_Entity_Invisible(id, 0)
- }
- return PLUGIN_CONTINUE
- }
- public delay_rush_respawn(id)
- {
- if(is_user_connected(id))
- {
- if(!is_user_alive(id))
- {
- ExecuteHamB(Ham_CS_RoundRespawn, id)
- }
- Set_Entity_Invisible(id, 0)
- }
- return PLUGIN_CONTINUE
- }
- public Check_Results(id,enemy)
- {
- reset_teams(id)
- reset_teams(enemy)
- new id_name[64],enemy_name[64];
- get_user_name(id,id_name,charsmax(id_name))
- get_user_name(enemy,enemy_name,charsmax(enemy_name))
- new mapname[32]
- get_mapname(mapname,31)
- if(his_wins[id] > his_wins[enemy])
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s ^1won against ^4%s ^1with score ^3[%d/%d]",arena_names[arena_number[id]],id_name,enemy_name,his_wins[id],his_wins[enemy])
- reward_winner(id)
- reward_loser(enemy)
- }
- else if(his_wins[enemy] > his_wins[id])
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s ^1won against ^4%s ^1with score ^3[%d/%d]",arena_names[arena_number[id]],enemy_name,id_name,his_wins[enemy],his_wins[id])
- reward_winner(enemy)
- reward_loser(id)
- }
- else
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s ^1and ^4%s ^1ended in a ^3draw match.",arena_names[arena_number[id]],id_name,enemy_name)
- if(SOUNDS_ENABLED)
- {
- client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[2])
- client_cmd(enemy,"spk ^"%s^"",DUEL_SOUNDS[2])
- }
- if(his_wins[id] == his_wins[enemy])
- {
- user_kill(id,1)
- user_kill(enemy,1)
- }
- }
- //client_print_color(0, DontChange,"%s^3Headshots: ^4%s^1:^3%d ^4%s^1:^3%d^1.",CHAT_TAG,id_name,his_HS[id],enemy_name,his_HS[enemy])
- if(arena_number[id] == arena_number[enemy])
- remove_the_arena(arena_number[id] +ARENA_CODE)
- back_to_the_spawn(id)
- back_to_the_spawn(enemy)
- reset_values(enemy)
- reset_values(id)
- }
- public Check_Rush_Results(id,enemy)
- {
- reset_rush_teams(id)
- reset_rush_teams(enemy)
- new id_name[64],enemy_name[64];
- get_user_name(id,id_name,charsmax(id_name))
- get_user_name(enemy,enemy_name,charsmax(enemy_name))
- if(the_wins[id] > the_wins[enemy])
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s ^1won against ^4%s ^1with score ^3[%d/%d]",rush_arena_names[rush_arena_number[id]],id_name,enemy_name,the_wins[id],the_wins[enemy])
- reward_rush_winner(id)
- reward_rush_loser(enemy)
- }
- else if(the_wins[enemy] > the_wins[id])
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s ^1won against ^4%s ^1with score ^3[%d/%d]",rush_arena_names[rush_arena_number[id]],enemy_name,id_name,the_wins[enemy],the_wins[id])
- reward_rush_winner(enemy)
- reward_rush_loser(id)
- }
- else
- {
- client_print_color(0,"^3[^4Arena: %s^3] ^4%s ^1with ^3%d scores (HS:%d) ^1and ^4%s ^1with ^3%d scores (HS:%d) ^1ended in a ^4draw match.",rush_arena_names[rush_arena_number[id]],id_name,the_wins[id],THE_HS[id],enemy_name,the_wins[enemy],THE_HS[enemy])
- if(SOUNDS_RUSH_ENABLED)
- {
- client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[2])
- client_cmd(enemy,"spk ^"%s^"",RUSH_SOUNDS[2])
- }
- if(the_wins[id] == the_wins[enemy])
- {
- user_kill(id,1)
- user_kill(enemy,1)
- }
- }
- //client_print_color(0,"%s^3Headshots: ^4%s^1:^3%d ^4%s^1:^3%d^1.",RUSH_TAG,id_name,THE_HS[id],enemy_name,THE_HS[enemy])
- if(rush_arena_number[id] == rush_arena_number[enemy])
- remove_the_rush_arena(rush_arena_number[id] +RUSH_ARENA_CODE)
- back_to_the_rush_spawn(id)
- back_to_the_rush_spawn(enemy)
- reset_player_values(enemy)
- reset_player_values(id)
- }
- public back_to_the_spawn(id)
- {
- if(is_user_alive(id))
- {
- entity_set_origin(id,his_original_spawn[id])
- Set_Entity_Invisible(id, 0)
- set_user_health(id,map_default_hp)
- }
- set_user_armor(id,0)
- set_user_godmode(id, 0)
- }
- public back_to_the_rush_spawn(id)
- {
- if(is_user_alive(id))
- {
- entity_set_origin(id,his_original_player_spawn[id])
- Set_Entity_Invisible(id, 0)
- set_user_health(id,the_default_hp)
- }
- set_user_armor(id,0)
- set_user_godmode(id, 0)
- }
- public manage_battle(id)
- {
- is_in_duel[id] = 2
- his_challenger[id] = his_asker[id]
- his_challenger[his_challenger[id]] = id
- is_in_duel[his_challenger[id]] = 2
- his_asker[id] = 0
- his_wins[id] = 0
- user_can_spawn[id] = 0
- his_wins[his_challenger[id]] = 0
- new aren_code = get_next_arena()
- arena_number[id] = aren_code
- arena_number[his_challenger[id]] = aren_code
- rounds[aren_code] = 0
- new CsTeams:teamid,CsTeams:teamenemy;
- teamid = cs_get_user_team(id)
- teamenemy = cs_get_user_team(his_challenger[id])
- if(teamid == CS_TEAM_T)
- {
- his_previous_team[id] = 2
- }
- else if(teamid == CS_TEAM_CT)
- {
- his_previous_team[id] = 1
- }
- else his_previous_team[id] = 0
- if(teamenemy == CS_TEAM_T)
- {
- his_previous_team[his_challenger[id]] = 2
- }
- else if(teamenemy == CS_TEAM_CT)
- {
- his_previous_team[his_challenger[id]] = 1
- }
- else his_previous_team[his_challenger[id]] = 0
- start_build(his_challenger[id])
- if(SOUNDS_ENABLED)
- {
- client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[4])
- client_cmd(his_challenger[id],"spk ^"%s^"",DUEL_SOUNDS[4])
- }
- battle_timer(id)
- battle_timer(his_challenger[id])
- strip_user_weapons(his_challenger[id])
- give_item(his_challenger[id],"weapon_knife")
- //client_print_color(0,"%s^4%s^1 accepted ^4%s^1's challenge!",CHAT_TAG,his_name[id],his_name[his_challenger[id]])
- }
- public manage_rush_battle(id)
- {
- is_in_rush[id] = 2
- the_challenger[id] = the_asker[id]
- the_challenger[the_challenger[id]] = id
- is_in_rush[the_challenger[id]] = 2
- the_asker[id] = 0
- the_wins[id] = 0
- the_wins[the_challenger[id]] = 0
- new aren_code = get_next_rush_arena()
- rush_arena_number[id] = aren_code
- rush_arena_number[the_challenger[id]] = aren_code
- rush_rounds[aren_code] = 0
- new CsTeams:teamid,CsTeams:teamenemy;
- teamid = cs_get_user_team(id)
- teamenemy = cs_get_user_team(the_challenger[id])
- if(teamid == CS_TEAM_T)
- {
- his_previous_user_team[id] = 2
- }
- else if(teamid == CS_TEAM_CT)
- {
- his_previous_user_team[id] = 1
- }
- else his_previous_user_team[id] = 0
- if(teamenemy == CS_TEAM_T)
- {
- his_previous_user_team[the_challenger[id]] = 2
- }
- else if(teamenemy == CS_TEAM_CT)
- {
- his_previous_user_team[the_challenger[id]] = 1
- }
- else his_previous_user_team[the_challenger[id]] = 0
- start_rush_build(the_challenger[id])
- if(SOUNDS_RUSH_ENABLED)
- {
- client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[4])
- client_cmd(the_challenger[id],"spk ^"%s^"",RUSH_SOUNDS[4])
- }
- battle_rush_timer(id)
- battle_rush_timer(the_challenger[id])
- //hud_displayer(id)
- //hud_displayer(the_challenger[id])
- //client_print_color(0,"%s^4%s^3 accepted ^4%s^3's challenge!",RUSH_TAG,his_name[id],his_name[the_challenger[id]])
- }
- public begin_the_battle(id,enemy)
- {
- start_new_round(id,enemy)
- }
- public begin_the_rush_battle(id,enemy)
- {
- start_new_rush_round(id,enemy)
- }
- public start_new_round(id,enemy)
- {
- his_timer[id] = 0
- his_timer[enemy] = 0
- is_frozen[id] = 1
- is_frozen[enemy] = 1
- his_countdown[id] = MAX_COUNTDOWN
- his_countdown[enemy] = MAX_COUNTDOWN
- countdown(id)
- countdown(enemy)
- strip_user_weapons(his_challenger[id])
- give_item(his_challenger[id],"weapon_knife")
- strip_user_weapons(his_challenger[enemy])
- give_item(his_challenger[enemy],"weapon_knife")
- }
- public start_new_rush_round(id,enemy)
- {
- the_timer[id] = 0
- the_timer[enemy] = 0
- is_user_frozen[id] = 1
- is_user_frozen[enemy] = 1
- his_rush_countdown[id] = MAX_USER_COUNTDOWN
- his_rush_countdown[enemy] = MAX_USER_COUNTDOWN
- rushcountdown(id)
- rushcountdown(enemy)
- }
- public countdown(id)
- {
- if(is_user_connected(id))
- {
- his_countdown[id]--
- if(0 >= his_countdown[id])
- {
- is_frozen[id] = 0
- unfreeze_player(id)
- if(SOUNDS_ENABLED)
- client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[6])
- client_print(id,print_center,"Fight!")
- return PLUGIN_HANDLED
- }
- else
- {
- freeze_player(id)
- if(SOUNDS_ENABLED)
- client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[5])
- client_print(id,print_center,"%d",his_countdown[id])
- if(!is_frozen[id]) // we prevent it from spamming
- is_frozen[id] = 1
- }
- set_task(1.0,"countdown",id)
- }
- return PLUGIN_CONTINUE
- }
- public rushcountdown(id)
- {
- if(is_user_connected(id))
- {
- his_rush_countdown[id]--
- if(0 >= his_rush_countdown[id])
- {
- is_user_frozen[id] = 0
- unfreeze_player(id)
- if(SOUNDS_RUSH_ENABLED)
- client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[6])
- client_print(id,print_center,"Fight!")
- return PLUGIN_HANDLED
- }
- else
- {
- freeze_player(id)
- if(SOUNDS_RUSH_ENABLED)
- client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[5])
- client_print(id,print_center,"%d",his_rush_countdown[id])
- if(!is_user_frozen[id]) // we prevent it from spamming
- is_user_frozen[id] = 1
- }
- set_task(1.0,"rushcountdown",id)
- }
- return PLUGIN_CONTINUE
- }
- public reset_teams(id)
- {
- if(his_previous_team[id] == 1)
- {
- cs_set_user_team(id,CS_TEAM_CT)
- }
- else if(his_previous_team[id] == 2)
- {
- cs_set_user_team(id,CS_TEAM_T)
- }
- return PLUGIN_CONTINUE
- }
- public reset_rush_teams(id)
- {
- if(his_previous_user_team[id] == 1)
- {
- cs_set_user_team(id,CS_TEAM_CT)
- }
- else if(his_previous_user_team[id] == 2)
- {
- cs_set_user_team(id,CS_TEAM_T)
- }
- return PLUGIN_CONTINUE
- }
- public check_teams(id,enemy)
- {
- if(!is_user_connected(id) || !is_user_connected(enemy))
- return PLUGIN_CONTINUE;
- new CsTeams:teamid,CsTeams:teamenemy;
- teamid = cs_get_user_team(id)
- teamenemy = cs_get_user_team(enemy)
- if(!users_in_same_team(id,enemy) && !is_in_false_team(id) && !is_in_false_team(enemy))
- return PLUGIN_HANDLED
- if(teamid == CS_TEAM_CT && teamenemy == CS_TEAM_CT )
- {
- cs_set_user_team(id,CS_TEAM_T)
- } else if(teamid == CS_TEAM_T && teamenemy == CS_TEAM_T)
- {
- cs_set_user_team(id,CS_TEAM_CT)
- }
- else
- {
- Check_Results(id,enemy)
- return PLUGIN_CONTINUE
- }
- return PLUGIN_HANDLED
- }
- public check_rush_teams(id,enemy)
- {
- new CsTeams:teamid,CsTeams:teamenemy;
- teamid = cs_get_user_team(id)
- teamenemy = cs_get_user_team(enemy)
- if(!users_in_same_team(id,enemy) && !is_in_false_team(id) && !is_in_false_team(enemy))
- return PLUGIN_HANDLED
- if(teamid == CS_TEAM_CT && teamenemy == CS_TEAM_CT )
- {
- cs_set_user_team(id,CS_TEAM_T)
- } else if(teamid == CS_TEAM_T && teamenemy == CS_TEAM_T)
- {
- cs_set_user_team(id,CS_TEAM_CT)
- }
- else
- {
- Check_Rush_Results(id,enemy)
- return PLUGIN_CONTINUE
- }
- return PLUGIN_HANDLED
- }
- stock is_in_false_team(id)
- {
- if(cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- stock users_in_same_team(id,enemy)
- {
- if(cs_get_user_team(id) == cs_get_user_team(enemy))
- return PLUGIN_HANDLED
- return PLUGIN_CONTINUE
- }
- stock get_next_arena()
- {
- next_empty_arena = 0
- for(new id;id < MAXPLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(arena_number[id] == next_empty_arena)
- {
- next_empty_arena++
- if(next_empty_arena > total_arenas)
- return -1
- }
- }
- }
- if(next_empty_arena > total_arenas)
- {
- return -1
- }
- return next_empty_arena
- }
- stock get_next_rush_arena()
- {
- next_empty_rush_arena = 0
- for(new id;id < MAX_RUSH_PLAYERS;id++)
- {
- if(is_user_connected(id))
- {
- if(rush_arena_number[id] == next_empty_rush_arena)
- {
- next_empty_rush_arena++
- if(next_empty_rush_arena > total_rush_arenas)
- return -1
- }
- }
- }
- if(next_empty_rush_arena > total_rush_arenas)
- {
- return -1
- }
- return next_empty_rush_arena
- }
- stock reset_values(id)
- {
- his_HS[id] = 0
- rounds[arena_number[id]] = 0
- is_in_duel[id] = 0
- his_challenger[id] = 0
- his_asker[id] = 0
- arena_number[id] = 0
- his_wins[id] = 0
- got_spawn[id] = 0
- his_timer[id] = 0
- his_type[id] = 0
- user_can_spawn[id] = 1
- Duel_Arena_Spawner[id] = false
- Rush_Arena_Spawner[id] = false
- }
- stock reset_player_values(id)
- {
- THE_HS[id] = 0
- rush_rounds[rush_arena_number[id]] = 0
- is_in_rush[id] = 0
- the_challenger[id] = 0
- the_asker[id] = 0
- rush_arena_number[id] = 0
- the_wins[id] = 0
- got_player_spawn[id] = 0
- the_timer[id] = 0
- his_type[id] = 0
- Prevent_Noobs[id] = 0
- }
- public freeze_player(id)
- {
- set_user_maxspeed(id,1.0)
- }
- public unfreeze_player(id)
- {
- set_user_maxspeed(id,250.0)
- }
- public wait_for_enemy_loop(id)
- {
- if(is_user_connected(id))
- {
- if(is_in_duel[id] == 2)
- {
- if(is_user_connected(his_challenger[id]))
- {
- if(is_in_duel[his_challenger[id]] == 2)
- {
- if(is_user_alive(his_challenger[id]))
- {
- begin_the_battle(id,his_challenger[id])
- return PLUGIN_HANDLED
- }
- set_task(0.1,"wait_for_enemy_loop",id)
- }
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- public rush_wait_for_enemy_loop(id)
- {
- if(is_user_connected(id))
- {
- if(is_in_rush[id] == 2)
- {
- if(is_user_connected(the_challenger[id]))
- {
- if(is_in_rush[the_challenger[id]] == 2)
- {
- if(is_user_alive(the_challenger[id]))
- {
- begin_the_battle(id,the_challenger[id])
- return PLUGIN_HANDLED
- }
- set_task(0.1,"wait_for_enemy_loop",id)
- }
- }
- }
- }
- return PLUGIN_CONTINUE
- }
- stock Set_Entity_Invisible(ent, Invisible = 1)
- {
- if(!pev_valid(ent))
- return
- set_pev(ent, pev_effects, Invisible == 0 ? pev(ent, pev_effects) & ~EF_NODRAW : pev(ent, pev_effects) | EF_NODRAW)
- }
- stock client_print_color(const id, const input[], any:...)
- {
- new count = 1, players[32];
- static msg[191];
- vformat(msg, 190, input, 3);
- replace_all(msg, 190, "!g", "^x04"); // Green Color
- replace_all(msg, 190, "!y", "^x01"); // Default Color
- replace_all(msg, 190, "!t", "^x03"); // Team Color
- 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();
- }
- }
- }
- }
- public GameDesc( ) {
- static gamename[32];
- get_pcvar_string( cvar_gamename, gamename, 31 );
- forward_return( FMV_STRING, gamename );
- return FMRES_SUPERCEDE;
- }
- public fw_PlayerPreThink( id )
- {
- static btn
- if(is_in_duel[id] == 2 || is_in_rush[id] == 2)
- {
- if(his_type[id] == 1)
- {
- btn = pev(id, pev_button)
- if(btn & IN_ATTACK)
- {
- set_pev(id,pev_button,(btn & ~IN_ATTACK) | IN_ATTACK2)
- }
- }
- else if(his_type[id] == 2)
- {
- btn = pev(id, pev_button)
- if(btn & IN_ATTACK2)
- {
- set_pev(id,pev_button,(btn & ~IN_ATTACK2) | IN_ATTACK)
- }
- }
- else if(his_type[id] == 0)
- {
- // nothing
- }
- }
- return FMRES_IGNORED
- }
- public BlockMenu( id )
- {
- new pl[32], num
- get_players(pl, num,"ch")
- static menuid, menu[128], buffer[2]
- menuid = menu_create("Block Players Menu", "BlockMenuHandler")
- buffer[1] = 0
- for(new i = 0; i < num; i++)
- {
- if(id == pl[i]) continue
- formatex(menu, charsmax(menu), "%s %s", GetName(pl[i]), isBlocked[id][pl[i]]? "\r[BLOCKED]":"")
- buffer[0] = pl[i]
- menu_additem(menuid, menu, buffer)
- }
- menu_display(id, menuid, 0)
- return PLUGIN_HANDLED
- }
- public BlockMenuHandler( id, menuid, item ){
- if(!is_user_connected(id) || item == MENU_EXIT){
- menu_destroy(menuid)
- return PLUGIN_HANDLED
- }
- new dummy, buffer[2], playerid
- menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy )
- playerid = buffer[0]
- isBlocked[id][playerid] = !isBlocked[id][playerid]
- client_print_color(id, "%s Player '%s' %sblocked from sending you requests", CHAT_TAG, GetName(playerid), isBlocked[id][playerid]? "":"un")
- BlockMenu( id )
- return PLUGIN_HANDLED
- }
- public GetName( id )
- {
- new name[32]
- get_user_name(id, name, charsmax(name))
- return name
- }
- public CmdReset( )
- {
- fvault_clear( g_szVaultName );
- server_print( "[Knife Duel] Rank have been reset !" );
- log_amx( "[Knife Duel] Rank have been reset !" );
- return PLUGIN_HANDLED;
- }
- public CmdRank( iPlayer )
- {
- new Array:aRankData;
- new iTotal = GetPlayerRanks( aRankData );
- new iRank;
- new eRankData[ RankData ];
- if( iTotal )
- {
- new szPlayerSteamID[ 35 ];
- get_user_authid( iPlayer, szPlayerSteamID, charsmax( szPlayerSteamID ) );
- for( new i = 0; i < iTotal; i++ )
- {
- ArrayGetArray( aRankData, i, eRankData );
- if( equal( szPlayerSteamID, eRankData[ Rank_SteamID ] ) )
- {
- iRank = i + 1;
- break;
- }
- }
- }
- if( iRank )
- {
- client_print( iPlayer, print_chat, "[Knife Duel] You are ranked %i of %i with %i kill%s!", iRank, iTotal, eRankData[ Rank_Kills ], ( eRankData[ Rank_Kills ] == 1 ) ? "" : "s" );
- }
- else
- {
- client_print( iPlayer, print_chat, "[Knife Duel] You are not ranked because you have not killed anyone!" );
- }
- ArrayDestroy( aRankData );
- }
- public CmdTop( iPlayer )
- {
- new Array:aRankData;
- new iTotal = max( 0, min( GetPlayerRanks( aRankData ), get_pcvar_num( pCvar_Top ) ) );
- if( iTotal )
- {
- static szMOTD[ 2500 ], iDefaultLen;
- if( !iDefaultLen )
- {
- iDefaultLen = add( szMOTD, charsmax( szMOTD ),
- "<html><style>\
- body{background:#040404;font-family:Verdana, Arial, Sans-Serif;font-size:7pt;}\
- .t{color:#808080;text-align:left; }\
- #h{background: #222 url('http://limmudny.org/wp-content/uploads/2014/09/PageTitleBackground2-900x100.jpg') repeat-x;color:#000;font-weight:bold;}\
- #p{color:#D41313;}\
- #n{color:#fff;}\
- </style><body>\
- <table cellspacing=0 width=100% class=t>")
- add(szMOTD, charsmax(szMOTD),
- "<tr><td id=h width=7%>Nr:</td>\
- <td id=h>Nick</td>\
- <td id=h>Kills</td></tr>")
- iDefaultLen = strlen(szMOTD)
- }
- new iLen = iDefaultLen;
- new eRankData[ RankData ];
- new szFixedName[ 128 ];
- for( new i = 0; i < iTotal; i++ )
- {
- ArrayGetArray( aRankData, i, eRankData );
- copy( szFixedName, charsmax( szFixedName ), eRankData[ Rank_Name ] );
- MakeNameMOTDSafe( szFixedName, 31 );
- iLen += formatex( szMOTD[ iLen ], charsmax( szMOTD ) - iLen, "<tr><td>%i</td><td>%s</td><td>%i</td></tr>", ( i + 1 ), szFixedName, eRankData[ Rank_Kills ] );
- }
- copy( szMOTD[ iLen ], charsmax( szMOTD ) - iLen, "</tbody></table></body>" );
- show_motd( iPlayer, szMOTD, "Knife Duel Top" );
- }
- else
- {
- client_print( iPlayer, print_chat, "* No players have been put on the top!" );
- }
- ArrayDestroy( aRankData );
- }
- public fw_PlayerKilled(iVictim, iKiller)
- {
- if (iVictim == iKiller || !is_user_alive(iKiller))
- return
- new szName[ 32 ], szSteamID[ 35 ];
- get_user_authid( iKiller, szSteamID, charsmax( szSteamID ) );
- new szKills[ 48 ], iKills;
- if( fvault_get_data( g_szVaultName, szSteamID, szKills, charsmax( szKills ) ) )
- {
- strbreak( szKills, szKills, charsmax( szKills ), szName, charsmax( szName ) );
- iKills = str_to_num( szKills );
- }
- if(is_in_duel[iKiller] == 2 || is_in_rush[iKiller] == 2)
- {
- iKills++;
- get_user_name( iKiller, szName ,charsmax( szName ) );
- formatex( szKills, charsmax( szKills ), "%i %s", iKills, szName );
- fvault_set_data( g_szVaultName, szSteamID, szKills );
- }
- }
- GetPlayerRanks( &Array:aRankData )
- {
- aRankData = ArrayCreate( RankData );
- new iTotal;
- new eRankData[ RankData ];
- new szFileName[ 128 ];
- _FormatVaultName( g_szVaultName, szFileName, charsmax( szFileName ) );
- new iFile = fopen( szFileName, "rt" );
- if( !iFile )
- {
- return iTotal;
- }
- new szFileData[ 128 ];
- new szKills[ 48 ];
- while( !feof( iFile ) )
- {
- fgets( iFile, szFileData, charsmax( szFileData ) );
- trim( szFileData );
- if( !szFileData[ 0 ] )
- {
- continue;
- }
- parse( szFileData, eRankData[ Rank_SteamID ], charsmax( eRankData[ Rank_SteamID ] ), szKills, charsmax( szKills ) );
- strbreak( szKills, szKills, charsmax( szKills ), eRankData[ Rank_Name ], charsmax( eRankData[ Rank_Name ] ) );
- eRankData[ Rank_Kills ] = str_to_num( szKills );
- ArrayPushArray( aRankData, eRankData );
- iTotal++;
- }
- fclose( iFile );
- ArraySort( aRankData, "SortData" );
- return iTotal;
- }
- public SortData( Array:aData, iIndex1, iIndex2, const iSortData[ ], iSortDataSize )
- {
- new eData1[ RankData ], eData2[ RankData ];
- ArrayGetArray( aData, iIndex1, eData1 );
- ArrayGetArray( aData, iIndex2, eData2 );
- return clamp( ( eData2[ Rank_Kills ] - eData1[ Rank_Kills ] ), -1, 1 );
- }
- stock MakeNameMOTDSafe( szName[ 128 ], iMaxChars )
- {
- szName[ 32 ] = 0;
- replace_all( szName, 127, "&", "&" );
- replace_all( szName, 127, "<", "<" );
- replace_all( szName, 127, ">", ">" );
- replace_all( szName, 127, "^"", """ );
- if( iMaxChars > 128 ) return;
- new iLast;
- for( new i = 0; i < 128 && szName[ i ]; )
- {
- if( szName[ i ] == '&' )
- {
- if( equal( szName[ i ], "&", 5 ) )
- {
- i += 4;
- }
- else if( equal( szName[ i ], """, 6 ) )
- {
- i += 5;
- }
- else if( equal( szName[ i ], "<", 4 ) || equal( szName[ i ], ">", 4 ) )
- {
- i += 3;
- }
- }
- if( ++i > iMaxChars )
- {
- break;
- }
- iLast = i;
- }
- szName[ iLast ] = 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement