Advertisement
raizo21

Knife Duels & Rush

Nov 7th, 2019
678
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pawn 113.69 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <amxmisc>
  3. #include <cstrike>
  4. #include <hamsandwich>
  5. #include <fakemeta>
  6. #include <fakemeta_util>
  7. #include <fun>
  8. #include <engine>
  9. #include <xs>
  10. #include <csx>
  11. #include <fun>
  12. #include <fvault>
  13.  
  14. #pragma tabsize 0
  15. #pragma compress 1
  16.  
  17. new MAXPLAYERS
  18.  
  19. new his_type[33]
  20. new bool:isBlocked[ 33 ][ 33 ]
  21.  
  22. #define CHAT_TAG "^3[^4KnifeDuels^3]^1 " // add a space right after if you want one between the tag and the messages
  23.  
  24.  
  25. #define ARENA_ENT_NAME "entity_arena" // this is the arena's entity name
  26.  
  27.  
  28. // here you can set the maximum number of arenas that can be used ingame
  29. #define MAX_ARENAS 4
  30.  
  31. new const arena_names[][] = {
  32.     "",
  33.     "A",    // 1st arena
  34.     "B",    // 2nd arena
  35.     "C",     // 3rd arena
  36.     "D"     // 4th arena
  37. }
  38.  
  39. enum
  40. {
  41. SCOREATTRIB_ARG_PLAYERID = 1,
  42. SCOREATTRIB_ARG_FLAGS
  43. }
  44.  
  45. enum ( <<= 1 )
  46. {
  47. SCOREATTRIB_FLAG_NONE = 0,
  48. SCOREATTRIB_FLAG_DEAD = 1,
  49. SCOREATTRIB_FLAG_BOMB,
  50. SCOREATTRIB_FLAG_VIP
  51. }
  52.  
  53. // some arena codes...
  54. #define ARENA_CODE 305924
  55. #define FAKE_CODE 6969696969
  56. #define CENTER_CODE 9696969696
  57. #define EXTRA_CODE 911911911
  58.  
  59. // task code for advert
  60. #define TASK_AD 34585029
  61. #define TASK_DUEL 34585029
  62. #define TASK_GIVEUP 34585029
  63. #define TASK_OFFLINE 34585029
  64.  
  65. // some movement defines
  66. #define MOVE_UP 0
  67. #define MOVE_DOWN 1
  68. #define MOVE_RIGHT 2
  69. #define MOVE_LEFT 3
  70. #define MOVE_FRONT 4
  71. #define MOVE_BACK 5
  72.  
  73. // Arena ground size
  74. #define ARENA_MINS Float:{-150.0,-62.0,-1.5}
  75. #define ARENA_MAXS Float:{10.0,62.0,1.5}
  76.  
  77. // arena coords offcourse, this is used to build the arena.
  78. new const Float:ARENA_COORDS[][2] = {
  79. {0.0,0.0},
  80. {100.0,0.0},
  81. {0.0,100.0},
  82. {100.0,100.0},
  83. {-100.0,0.0},
  84. {0.0,-100.0},
  85. {-100.0,-100.0},
  86. {-100.0,100.0},
  87. {100.0,-100.0},
  88. {200.0,0.0},
  89. {200.0,100.0},
  90. {200.0,-100.0}
  91. }
  92.  
  93. enum {
  94. BLUE_SIDE = 0,
  95. RED_SIDE = 1,
  96. LEFT_SIDE = 2,
  97. RIGHT_SIDE = 3,
  98. TOP_SIDE = 4
  99. }
  100.  
  101. new const ARENA_FILE[] = "%s/duel_arena/%s.cfg"
  102. new user_can_spawn[33];
  103. // if you want to disable a sound, rename it with "common/null.wav"
  104. new const DUEL_SOUNDS[][] = {
  105. "ambience/goal_1.wav",       // 0 round win
  106. "x/nih_die2.wav",       // 1 round lose
  107. "ambience/des_wind1.wav",   // 2 round draw
  108. "buttons/bell1.wav",         // 3 round start
  109. "buttons/blip1.wav" ,    // 4 accepted duel
  110. "weapons/headshot2.wav",  // 5 Countdown
  111. "events/tutor_msg.wav"   // 6 "Go!"
  112. }
  113.  
  114. new const ARENA_MODELS[][] = {
  115. "models/Duel/Duel_Arena.mdl", // Arena's ground
  116. "models/Duel/Duel_Arena.mdl" // Arena's walls
  117. }
  118.  
  119. new const MAP_FIX[][] = {
  120. "35hp_2"
  121. }
  122.  
  123. new Float:MAP_FIX_Z_COORD[] = {
  124. -864.253723
  125. }
  126.  
  127. new const g_szKnifeSound[] = "weapons/knife_hitwall1.wav";
  128.  
  129. new Float:g_fHit[33];
  130. new iHitCount[33]
  131.  
  132.  
  133. new cvar_count = 0
  134.  
  135. new Head_shot[33][33]
  136. new fakes;
  137. 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];
  138. new rounds[MAX_ARENAS+1],Float:arena_coord[MAX_ARENAS+1][3]; // using +1 just incase...
  139. new Float:his_spawn[33][3],got_spawn[33],Float:his_angle[33][3],Float:his_original_spawn[33][3];
  140. new next_empty_arena,total_arenas;
  141. new map_name[32]
  142. new cvar_z_fix,cvar_sounds,cvar_rounds,cvar_kills,cvar_cooldown,cvar_time
  143. new Float:max_size[3],Float:min_size[3];
  144. new selected = 1,Float:move_size[33],his_timer[33],his_offline[33],his_HS[33];
  145. new map_default_hp;
  146. new map_id = -1;
  147. new his_previous_team[33];
  148. // using these for less cpu usage.
  149. new IS_BUGGED_MAP = 0,MAP_FIX_ENABLED,SOUNDS_ENABLED,MAX_ROUNDS,MAX_KILLS,MAX_COUNTDOWN,MAX_TIME;
  150.  
  151.  
  152. new bool:gBackStabing[33];
  153.  
  154. const OFFSET_WEAPONOWNER = 41
  155. const OFFSET_LINUX_WEAPONS = 4
  156.  
  157. #define P_NAME "Knife Duels"
  158. #define P_VERS "1.0"
  159. #define P_AUTH "raizo"
  160. #define P_REQ "- Global Knife Arena -"
  161. new killed_forward;
  162. new cvar_gamename;
  163. /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  164. #define ROUND_START_TASK 3215468
  165.  
  166.  
  167. #define RUSH_TAG "^3[^4Knife Rush^3]^1 "
  168.  
  169. #define RUSH_ENT_NAME "rush_arena"
  170.  
  171. #define MAX_RUSH_ARENAS 8
  172.  
  173.  
  174. new const rush_arena_names[][] = {
  175. "",
  176. "A",    
  177. "B",    
  178. "C",   
  179. "D",
  180. "E",    
  181. "F",    
  182. "G",   
  183. "H"
  184. }
  185.  
  186. #define RUSH_ARENA_CODE 305924
  187. #define RUSH_FAKE_CODE 6969696969
  188. #define RUSH_CENTER_CODE 9696969696
  189. #define RUSH_EXTRA_CODE 911911911
  190.  
  191. #define MOVE_ARENA_UP 0
  192. #define MOVE_ARENA_DOWN 1
  193. #define MOVE_ARENA_RIGHT 2
  194. #define MOVE_ARENA_LEFT 3
  195. #define MOVE_ARENA_FRONT 4
  196. #define MOVE_ARENA_BACK 5
  197.  
  198. #define RUSH_ARENA_MINS Float:{-350.0, -10.0, 0.0}
  199. #define RUSH_ARENA_MAXS Float:{370.0, 10.0, 10.0}
  200.  
  201. new const Float:RUSH_ARENA_COORDS[][2] =
  202. {
  203. {0.0,0.0}
  204. }
  205.  
  206. new const RUSH_ARENA_FILE[] = "%s/rush_arena/%s.cfg"
  207.  
  208. // if you want to disable a sound, rename it with "common/null.wav"
  209. new const RUSH_SOUNDS[][] = {
  210. "ambience/goal_1.wav",       // 0 round win
  211. "x/nih_die2.wav",       // 1 round lose
  212. "ambience/des_wind1.wav",   // 2 round draw
  213. "buttons/bell1.wav",         // 3 round start
  214. "buttons/blip1.wav" ,    // 4 accepted duel
  215. "common/null.wav"// 5 Countdown
  216. "common/null.wav"   // 6 "Go!"
  217. }
  218.  
  219. new const RUSH_MODELS[][] = {
  220. "models/Duel/Rush_Arena.mdl", // Arena's ground
  221. "models/Duel/Rush_Arena.mdl" // Arena's walls
  222. }
  223.  
  224. new const MAP_RUSH_FIX[][] = {
  225. "1hp"
  226. }
  227.  
  228. new Float:MAP_RUSH_FIX_Z_COORD[] = {
  229. -864.253723
  230. }
  231.  
  232. new Headshot[33][33];
  233. new fakearenas, Prevent_Noobs[32];
  234. 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]
  235. new rush_rounds[MAX_RUSH_ARENAS+1],Float:rush_arena_coord[MAX_RUSH_ARENAS+1][3];
  236. new Float:his_player_spawn[33][3],got_player_spawn[33],Float:his_player_angle[33][3],Float:his_original_player_spawn[33][3];
  237. new next_empty_rush_arena,total_rush_arenas;
  238. new MAX_RUSH_PLAYERS,the_maPLUGIN_NAME[48]
  239. new cvar_zone_fix,cvar_user_sounds,cvar_user_rounds,cvar_user_kills,cvar_user_cooldown,cvar_user_time
  240. new Float:max_arena_size[3],Float:min_arena_size[3];
  241. new selected_arenas = 1,Float:move_arena_size[33],the_timer[33],THE_HS[33];
  242. new the_default_hp;
  243. new the_map_id = -1;
  244. new his_previous_user_team[33];
  245. // using these for less cpu usage.
  246. 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;
  247. new Float:fVelocity[3], cvar_user_run;
  248. new bool:his_rush_toucher[33];
  249.  
  250.  
  251. //////////////////////////////////////////////////////////
  252.  
  253. enum _:RankData
  254. {
  255. Rank_Kills,
  256. Rank_Name[ 32 ],
  257. Rank_SteamID[ 35 ]
  258. };
  259.  
  260. new const g_szVaultName[ ] = "Knife_Duels_Rank";
  261.  
  262. new pCvar_Top;
  263. ///////////////////////////////////////////////////////////
  264.  
  265. public plugin_init()
  266. {
  267.  
  268. register_plugin(P_NAME, P_VERS, P_AUTH)
  269. register_clcmd("say /origin","print_coords")
  270. register_clcmd("say /arena","editor_menu")
  271. register_clcmd("say /rarena","editor_rush_menu")
  272. register_clcmd("say /duel", "First_Menu");
  273. register_clcmd("say /kdc", "First_Menu");
  274. register_clcmd("say /block", "BlockMenu");
  275. register_clcmd("say /dup", "give_up_player");
  276. register_clcmd("say /rup", "give_up_rush_player");
  277.  
  278. cvar_z_fix          = register_cvar("duel_map_fix","1")
  279. cvar_sounds         = register_cvar("duel_sounds","1")
  280. cvar_rounds         = register_cvar("duel_rounds","20")
  281. cvar_kills          = register_cvar("duel_kills","10")
  282. cvar_cooldown       = register_cvar("duel_cooldown","1")
  283. cvar_time           = register_cvar("duel_max_nokill_time","120")
  284. cvar_count          = register_cvar("duel_knifecount", "5");
  285. cvar_gamename       = register_cvar( "duel_gamename", "Global Knife Arena" );
  286.  
  287. cvar_zone_fix       = register_cvar("rush_z_MAP_RUSH_FIX","1")
  288. cvar_user_sounds    = register_cvar("rush_sounds","1")
  289. cvar_user_rounds    =register_cvar("rush_rounds","20")
  290. cvar_user_kills     =register_cvar("rush_kills","10")
  291. cvar_user_cooldown  = register_cvar("rush_cooldown","1")
  292. cvar_user_time      = register_cvar("rush_max_nokill_time","30")
  293. cvar_user_run        = register_cvar("rush_non_stop","0")
  294.  
  295. //register_forward(FM_SetModel, "fw_SetModel")
  296. //RegisterHam(Ham_CS_RoundRespawn, "player", "Player_Respawn_pre", 0)
  297. RegisterHam(Ham_Spawn,"player","Player_spawn_post",1)
  298. RegisterHam(Ham_Killed, "player", "Player_Killed")
  299. RegisterHam(Ham_TakeDamage, "player", "Player_Take_Damage", 0)
  300. RegisterHam(Ham_TraceAttack, "player", "Ham_TraceAttack_player", 1)
  301. register_forward(FM_CmdStart, "Cmd_start" );
  302. register_forward(FM_EmitSound, "fwd_EmitSound", 1);
  303. register_forward(FM_GetGameDescription, "GameDesc" );
  304. register_forward(FM_PlayerPreThink, "fw_PlayerPreThink")
  305. register_forward(FM_PlayerPreThink,"FW_Prethink")
  306. register_event("HLTV", "round_start_event", "a", "1=0", "2=0")
  307. register_event("HLTV", "round_start_rush_event", "a", "1=0", "2=0")
  308.  
  309. RegisterHam(Ham_Killed, "player", "Player_Rush_Killed")
  310. RegisterHam(Ham_TakeDamage, "player", "Player_Take_Damage_Rush", 0)
  311. register_forward( FM_CmdStart , "Cmd_start" );
  312. register_forward(FM_CmdStart,"Rush_Non_Stop");
  313.  
  314. MAX_RUSH_PLAYERS = get_maxplayers();
  315. RegisterHam(Ham_Spawn,"player","Player_spawn_rush_post",1)
  316.  
  317.  
  318. RegisterHam(Ham_TraceAttack, "player", "Ham_TraceAttack_rushplayer", 1)
  319. register_touch(RUSH_ENT_NAME, "player", "forward_arena_touch");
  320.  
  321. //register_touch(ARENA_ENT_NAME, "player", "forward_touch");
  322. register_forward(FM_CmdStart,"NonStop");
  323.  
  324. get_mapname(map_name,charsmax(map_name))
  325. new size = sizeof(MAP_FIX)
  326. for(new i; i <size;i++)
  327. {
  328. if(equal(map_name,MAP_FIX[i]))
  329. {
  330.     map_id = i
  331.     IS_BUGGED_MAP = 1
  332. }
  333. }
  334.  
  335. MAXPLAYERS = get_maxplayers();
  336. if(containi(map_name,"35hp") != -1)
  337. map_default_hp = 35
  338. else if(containi(map_name,"1hp") != -1)
  339.     map_default_hp = 1
  340.     else map_default_hp = 35
  341.     load_arena_coords(-1)
  342.    
  343.    
  344.     get_mapname(the_maPLUGIN_NAME,charsmax(the_maPLUGIN_NAME))
  345.     new sizex = sizeof(MAP_RUSH_FIX)
  346.     for(new i; i <sizex;i++)
  347.     {
  348.         if(equal(the_maPLUGIN_NAME,MAP_RUSH_FIX[i]))
  349.         {
  350.             the_map_id = i
  351.             IS_BUGGED_RUSH_MAP = 1
  352.         }
  353.     }
  354.     if(containi(the_maPLUGIN_NAME,"35hp") != -1)
  355.         the_default_hp = 35
  356.     else if(containi(the_maPLUGIN_NAME,"1hp") != -1)
  357.         the_default_hp = 1
  358.     else the_default_hp = 100
  359.     load_RUSH_ARENA_COORDS(-1)
  360.    
  361.    
  362.     new cfgdir[32], urlfile[64], cfgdirx[32], urlfilex[64]
  363.     get_configsdir(cfgdir, charsmax(cfgdir))
  364.     formatex(urlfile, charsmax(urlfile), "%s/duel_arena", cfgdir)
  365.     if(!dir_exists(urlfile))
  366.     {
  367.         mkdir(urlfile)
  368.         server_print("%sCreated new folder: %s",CHAT_TAG,urlfile)
  369.     }
  370.     get_configsdir(cfgdirx, charsmax(cfgdirx))
  371.     formatex(urlfilex, charsmax(urlfilex), "%s/rush_arena", cfgdirx)
  372.     if(!dir_exists(urlfilex))
  373.     {
  374.         mkdir(urlfilex)
  375.         server_print("%sCreated new folder: %s",RUSH_TAG,urlfilex)
  376.     }
  377.    
  378.    
  379.     killed_forward = CreateMultiForward("duel_player_killed", ET_IGNORE, FP_CELL,FP_CELL);
  380.     set_task(120.0,"Advertise",TASK_AD)
  381.     register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib" );
  382.    
  383.     update_cvars();
  384.    
  385.     ////////////////////////////////////////////////////////////////////    
  386.    
  387.     register_srvcmd( "reset_duel_rank", "CmdReset" );
  388.    
  389.     register_clcmd( "say /drank", "CmdRank" );
  390.     register_clcmd( "say /dtop", "CmdTop" );
  391.    
  392.     RegisterHam(Ham_Killed, "player", "fw_PlayerKilled", 1);
  393.    
  394.     pCvar_Top = register_cvar( "amx_duels_top", "10" );
  395.     /////////////////////////////////////////////////////////////////////    
  396. }
  397.  
  398.  
  399. public FW_Prethink(id)
  400. {
  401.    
  402.     if (pev(id,pev_button) & IN_RELOAD && pev(id,pev_button) & IN_USE)
  403.         First_Menu(id)
  404.    
  405.     if (pev(id,pev_button) & IN_ATTACK && pev(id,pev_button) & IN_ATTACK2)
  406.         First_Menu(id)
  407. }
  408.  
  409.  
  410. public fwd_EmitSound(id, channel, const sound[])
  411. {
  412.     if(!is_user_alive(id))
  413.         return FMRES_IGNORED;
  414.    
  415.     if(!equal(sound, g_szKnifeSound))
  416.         return FMRES_IGNORED;
  417.    
  418.     static Float:fGmTime;
  419.     fGmTime = get_gametime();
  420.    
  421.     if((fGmTime - g_fHit[id]) >= 1.0)
  422.     {
  423.         iHitCount[id] = 0;
  424.         g_fHit[id] = fGmTime;
  425.     }
  426.     ++iHitCount[id];
  427.     g_fHit[id] = fGmTime;
  428.    
  429.     if((iHitCount[id] >= get_pcvar_num(cvar_count)))
  430.     {
  431.         First_Menu(id)     
  432.         iHitCount[id] = 0;
  433.     }
  434.     return FMRES_IGNORED;
  435. }
  436.  
  437.  
  438. #define MAX_WAYS 32
  439.  
  440. enum Duel_Rush
  441. {
  442. Duel_Arena = 1,
  443. Rush_Arena
  444. }
  445.  
  446. enum Duel_Types
  447. {
  448. Type_Slash = 1,
  449. Type_Stab,
  450. Type_Both
  451. }
  452.  
  453. enum Duel_Configs
  454. {
  455. Duel_Rush:Arenas_On,
  456. Duel_Types:Types_On
  457. }
  458.  
  459. new All_Configs[MAX_WAYS+1][Duel_Configs]
  460. new szTmp[192];
  461.  
  462. new bool:Duel_Arena_Spawner[33] = false, bool:Rush_Arena_Spawner[33] = false;
  463.  
  464. public bot(id)
  465. {
  466. if(is_user_alive(id))
  467. {
  468. Duel_Arena_Spawner[id] = false
  469. Rush_Arena_Spawner[id] = false
  470.  
  471. Choose_Types_Arenas(id)
  472. Choose_Battle_Types(id)
  473. }
  474. }
  475.  
  476. public First_Menu(id)
  477. {
  478. new menu = menu_create("\y[\r Knife Duels \y ]\w By raizo","First_Menu_Handle")
  479.  
  480. formatex(szTmp,charsmax(szTmp),"Choose Arena \r%s",PartArenas(All_Configs[id][Arenas_On]));
  481. menu_additem(menu,szTmp,"1")
  482.  
  483. formatex(szTmp,charsmax(szTmp),"Choose Types \r%s",PartTypes(All_Configs[id][Types_On]));
  484. menu_additem(menu,szTmp,"2")
  485.  
  486. formatex(szTmp,charsmax(szTmp),"Choose players");
  487. menu_additem(menu,szTmp,"3")
  488.  
  489. formatex(szTmp,charsmax(szTmp),"Appear in list %s",his_offline[id] ?"\yOff":"\rOn");
  490. menu_additem(menu,szTmp,"4")
  491.  
  492. formatex(szTmp,charsmax(szTmp),"Block Player");
  493. menu_additem(menu,szTmp,"5")
  494.  
  495.  
  496. menu_display(id,menu)
  497.  
  498. return PLUGIN_HANDLED;
  499. }
  500.  
  501.  
  502. public First_Menu_Handle(id,menu,item)
  503. {
  504. if(item == MENU_EXIT)
  505. {
  506. menu_destroy(menu);
  507.  
  508. return PLUGIN_HANDLED;
  509. }
  510.  
  511. new data[3], iName[64]
  512. new access, callback;
  513. menu_item_getinfo(menu, item, access, data,2, iName, 63, callback);
  514. new key = str_to_num(data)
  515.  
  516. switch(key)
  517. {
  518. case 1:
  519. {
  520. All_Configs[id][Arenas_On] = ( ++All_Configs[id][Arenas_On] > (Duel_Rush:2) ) ? (Duel_Rush:1) :All_Configs[id][Arenas_On]
  521. }
  522. case 2:
  523. {
  524. All_Configs[id][Types_On] = ( ++All_Configs[id][Types_On] > (Duel_Types:3) ) ? (Duel_Types:1) :All_Configs[id][Types_On]
  525. }
  526. case 3:
  527. {
  528. if(Duel_Arena_Spawner[id])
  529. {
  530.     duel_players_lists(id)
  531. }
  532. if(Rush_Arena_Spawner[id])
  533. {
  534.     rush_players_list(id)
  535. }
  536. else
  537. {
  538.     //nothing
  539. }
  540. return PLUGIN_HANDLED;
  541. }
  542. case 4:
  543. {
  544. toggle_offline(id)
  545. }
  546. case 5:
  547. {
  548. BlockMenu(id)
  549. return PLUGIN_HANDLED;
  550. }
  551.  
  552. }
  553.  
  554. menu_destroy(menu);
  555.  
  556. First_Menu(id)
  557. bot(id)
  558. return PLUGIN_HANDLED;
  559. }
  560.  
  561. PartArenas(Duel_Rush:part)
  562. {
  563. new szResult[64]
  564. switch(part)
  565. {
  566. case Duel_Arena:    copy(szResult, charsmax(szResult), "Duel [ Platform ]");
  567. case Rush_Arena:    copy(szResult, charsmax(szResult), "Rush [ Bridge ]");
  568. default:             copy(szResult, charsmax(szResult), "");
  569. }
  570. return szResult;
  571. }
  572.  
  573. PartTypes(Duel_Types:part)
  574. {
  575. new szResult[64]
  576. switch(part)
  577. {
  578. case Type_Slash:    copy(szResult, charsmax(szResult), "Stab [ click 2 ]");
  579. case Type_Stab:     copy(szResult, charsmax(szResult), "Slash [ click 1 ]");
  580.     case Type_Both:     copy(szResult, charsmax(szResult), "Both [ click 1 & 2 ]");
  581.         default:             copy(szResult, charsmax(szResult), "");
  582.     }
  583.     return szResult;
  584. }
  585.  
  586. Choose_Types_Arenas(id)
  587. {
  588. switch(All_Configs[id][Arenas_On])
  589. {
  590.     case Duel_Arena:
  591.     {
  592.         Duel_Arena_Spawner[id] = true
  593.     }
  594.     case Rush_Arena:
  595.     {
  596.         Rush_Arena_Spawner[id] = true
  597.     }
  598. }
  599. return 0;
  600. }
  601.  
  602. Choose_Battle_Types(id)
  603. {
  604. switch(All_Configs[id][Types_On])
  605. {
  606. case Type_Slash:
  607. {
  608.     his_type[id] = 1
  609. }
  610. case Type_Stab:
  611. {
  612.     his_type[id] = 2
  613. }
  614. case Type_Both:
  615. {
  616.     his_type[id] = 0
  617. }
  618. }
  619. return 0;
  620. }
  621.  
  622.  
  623.  
  624. /*public fw_SetModel(entity, model[])
  625. {
  626. if(!is_valid_ent(entity))
  627. return FMRES_IGNORED
  628.  
  629. static szClassName[33]
  630. entity_get_string(entity, EV_SZ_classname, szClassName, charsmax(szClassName))
  631.  
  632. if(!equal(szClassName, "weaponbox"))
  633. return FMRES_IGNORED
  634.  
  635. if(equal(model, "models/w_c4.mdl"))
  636. {
  637.     remove_entity(entity)
  638. }
  639. return FMRES_IGNORED
  640. }*/
  641.  
  642. public MessageScoreAttrib( iMsgId, iDest, iReceiver )
  643. {
  644. new id= get_msg_arg_int( SCOREATTRIB_ARG_PLAYERID );
  645. if(!is_user_connected(id))
  646.     return;
  647.     if(!is_user_alive(id))
  648.         return;
  649.     set_msg_arg_int( SCOREATTRIB_ARG_FLAGS, ARG_BYTE, SCOREATTRIB_FLAG_NONE);
  650. }
  651.  
  652. /*public CurrentWeapon(id)
  653. {
  654. if(read_data(2) == CSW_C4)
  655. {
  656.     if(is_user_alive(id))
  657.     {
  658.         strip_user_weapons(id)
  659.         give_item(id,"weapon_knife")
  660.        
  661.     }
  662. }
  663. }
  664.  
  665. stock get_weapon_owner(ent)
  666. {
  667. return get_pdata_cbase(ent, OFFSET_WEAPONOWNER, OFFSET_LINUX_WEAPONS)
  668. }
  669.  
  670. public Player_Respawn_pre(id)
  671. {
  672. if(is_user_connected(id))
  673. {
  674.     if(!user_can_spawn[id])
  675.     {
  676.         return HAM_SUPERCEDE
  677.     }
  678. }
  679. return HAM_IGNORED
  680. }*/
  681.  
  682.  
  683. public Rush_Non_Stop(id)
  684. {
  685. if(is_in_rush[id] == 2 && get_pcvar_num(cvar_user_run) )
  686. {
  687.     if(get_user_team(id) == 1)
  688.     {
  689.         fVelocity[0] = 250.0;
  690.         fVelocity[1] = 0.0;
  691.         fVelocity[2] = 0.0;
  692.        
  693.         set_pev( id, pev_velocity, fVelocity )
  694.     }
  695.     if(get_user_team(id) == 2)
  696.     {
  697.         fVelocity[0] = -250.0;
  698.         fVelocity[1] = 0.0;
  699.         fVelocity[2] = 0.0;
  700.        
  701.         set_pev( id, pev_velocity, fVelocity )
  702.     }
  703. }
  704. }
  705.  
  706.  
  707. public plugin_natives()
  708. {
  709. register_library("knife_duels")
  710. register_native("is_user_in_duel","_is_user_in_duel")
  711. register_native("is_user_in_offline","_is_user_in_offline")
  712. register_native("is_user_dueling_user","_is_user_dueling_user")
  713. }
  714.  
  715. public get_non_duelers_alive()
  716. {
  717. new count = 0
  718. for(new id; id < MAXPLAYERS;id++)
  719. {
  720.     if(is_user_connected(id))
  721.     {
  722.         if(is_user_alive(id) && !is_in_duel[id])
  723.         {
  724.             count++
  725.         }
  726.     }
  727. }
  728. return count
  729. }
  730.  
  731. public respawn_everyone(taskid)
  732. {
  733. for(new id;id < MAXPLAYERS;id++)
  734. {
  735.     if(is_user_connected(id))
  736.     {
  737.         if(is_in_duel[id] !=2 && !is_user_alive(id))
  738.         {
  739.             if(cs_get_user_team(id) == CS_TEAM_CT || cs_get_user_team(id) == CS_TEAM_T)
  740.             {
  741.                 ExecuteHam(Ham_CS_RoundRespawn, id);
  742.             }
  743.         }
  744.     }
  745. }
  746. }
  747.  
  748. public get_non_duelers_alive_CT()
  749. {
  750. new count = 0
  751. for(new id; id < MAXPLAYERS;id++)
  752. {
  753.     if(is_user_connected(id))
  754.     {
  755.         if(is_user_alive(id) && !is_in_duel[id] && cs_get_user_team(id) == CS_TEAM_CT)
  756.         {
  757.             count++
  758.         }
  759.     }
  760. }
  761. return count
  762. }
  763.  
  764. public get_non_duelers_alive_T()
  765. {
  766. new count = 0
  767. for(new id; id < MAXPLAYERS;id++)
  768. {
  769.     if(is_user_connected(id))
  770.     {
  771.         if(is_user_alive(id) && !is_in_duel[id] && cs_get_user_team(id) == CS_TEAM_T)
  772.         {
  773.             count++
  774.         }
  775.     }
  776. }
  777. return count
  778. }
  779.  
  780. public get_non_rushers_alive()
  781. {
  782. new count = 0
  783. for(new id; id < MAX_RUSH_PLAYERS;id++)
  784. {
  785.     if(is_user_connected(id))
  786.     {
  787.         if(is_user_alive(id) && !is_in_rush[id])
  788.         {
  789.             count++
  790.         }
  791.     }
  792. }
  793. return count
  794. }
  795.  
  796. public _is_user_in_duel(plugin, iParams)
  797. {
  798. new id = get_param(1)
  799. if(!is_user_connected(id))
  800.     return PLUGIN_CONTINUE
  801.     if(is_in_duel[id] == 2)
  802.         return PLUGIN_HANDLED
  803.     return PLUGIN_CONTINUE
  804. }
  805.  
  806. public _is_user_in_offline(plugin, iParams)
  807. {
  808.     new id = get_param(1)
  809.     if(!is_user_connected(id))
  810.         return PLUGIN_CONTINUE
  811.     if(his_offline[id])
  812.         return PLUGIN_HANDLED
  813.     return PLUGIN_CONTINUE
  814. }
  815.  
  816. public _is_user_dueling_user(plugin, iParams)
  817. {
  818.     new id = get_param(1)
  819.     new enemy = get_param(2)
  820.     if(!is_user_connected(id))
  821.         return PLUGIN_CONTINUE
  822.     if(!is_user_connected(enemy))
  823.         return PLUGIN_CONTINUE
  824.     if(is_in_duel[id] != 2 || is_in_duel[enemy] != 2)
  825.         return PLUGIN_CONTINUE
  826.     if(id == his_challenger[enemy] && enemy == his_challenger[id])
  827.         return PLUGIN_HANDLED
  828.     return PLUGIN_CONTINUE
  829. }
  830.  
  831. public forward_touch(ent, id)
  832. {
  833.     if(!pev_valid(id))
  834.         return;
  835.     if(!pev_valid(ent))
  836.         return;
  837.     if(is_user_alive(id) && get_user_noclip(id))
  838.         return;
  839.    
  840.     static class[32]
  841.     pev(ent,pev_classname,class,charsmax(class));
  842.     if(equal(class,ARENA_ENT_NAME))
  843.     {
  844.        
  845.         if(is_in_duel[id] && !gBackStabing[id])
  846.         {
  847.             gBackStabing[id] = true;
  848.         }
  849.         if(is_user_alive(id) && !gBackStabing[id])
  850.         {
  851.             gBackStabing[id] = false;
  852.             First_Menu(id)
  853.             back_to_the_spawn(id)
  854.         }
  855.     }
  856. }
  857.  
  858.  
  859. public forward_arena_touch(ent, id)
  860. {
  861.     if(!pev_valid(id))
  862.         return;
  863.     if(!pev_valid(ent))
  864.         return;
  865.     if(is_user_alive(id) && get_user_noclip(id))
  866.         return;
  867.    
  868.     static class[32]
  869.     pev(ent,pev_classname,class,charsmax(class));
  870.     if(equal(class,RUSH_ENT_NAME))
  871.     {
  872.        
  873.         if(is_in_rush[id] && !his_rush_toucher[id])
  874.         {
  875.             his_rush_toucher[id] = true;
  876.         }
  877.         if(is_user_alive(id) && !his_rush_toucher[id])
  878.         {
  879.             his_rush_toucher[id] = false;
  880.             back_to_the_rush_spawn(id)
  881.         }
  882.     }
  883.     return;
  884. }
  885.  
  886.  
  887. public Ham_TraceAttack_player(victim, attacker, Float:Damage, Float:Direction[3], ptr, Damagebits)
  888. {
  889.     if(is_user_connected(attacker) && is_user_connected(victim))
  890.     {
  891.         Head_shot[attacker][victim] = bool:( get_tr2(ptr, TR_iHitgroup) == 1 )
  892.     }
  893. }
  894.  
  895. public Ham_TraceAttack_rushplayer(victim, attacker, Float:Damage, Float:Direction[3], ptr, Damagebits)
  896. {
  897.     if(is_user_connected(attacker) && is_user_connected(victim))
  898.     {
  899.         Headshot[attacker][victim] = bool:( get_tr2(ptr, TR_iHitgroup) == 1 )
  900.     }
  901. }
  902.  
  903. public editor_menu(id)
  904. {
  905.     if(!is_user_connected(id))
  906.         return PLUGIN_HANDLED
  907.     new flags = get_user_flags(id)
  908.     if(!(flags & ADMIN_RCON))
  909.     {
  910.         client_print(id,print_chat,"You have no access to this command")
  911.         return PLUGIN_HANDLED
  912.     }
  913.     new menu
  914.     menu = menu_create( "\rArena spawner:", "Arenaspawner_handler" );
  915.    
  916.     new nameu[32];
  917.    
  918.     formatex(nameu,charsmax(nameu), "Add");
  919.     menu_additem(menu, nameu, "", 0);
  920.     formatex(nameu,charsmax(nameu), "Remove");
  921.     menu_additem(menu, nameu, "", 0);
  922.     formatex(nameu,charsmax(nameu), "Remove all");
  923.     menu_additem(menu, nameu, "", 0);
  924.     formatex(nameu,charsmax(nameu), "Select");
  925.     menu_additem(menu, nameu, "", 0);
  926.     formatex(nameu,charsmax(nameu), "Select all");
  927.     menu_additem(menu, nameu, "", 0);
  928.     formatex(nameu,charsmax(nameu), "Move");
  929.     menu_additem(menu, nameu, "", 0);
  930.     formatex(nameu,charsmax(nameu), "Save");
  931.     menu_additem(menu, nameu, "", 0);
  932.     formatex(nameu,charsmax(nameu), "Load");
  933.     menu_additem(menu, nameu, "", 0);
  934.     menu_display(id, menu, 0 );
  935.     return PLUGIN_HANDLED
  936. }
  937.  
  938. public editor_rush_menu(id)
  939. {
  940.     if(!is_user_connected(id))
  941.         return PLUGIN_HANDLED
  942.     new flags = get_user_flags(id)
  943.     if(!(flags & ADMIN_RCON))
  944.     {
  945.         client_print(id,print_chat,"You have no access to this command")
  946.         return PLUGIN_HANDLED
  947.     }
  948.     new menu
  949.     menu = menu_create( "\rArena spawner:", "Arenaspawner_handler_menu" );
  950.    
  951.     new nameu[32];
  952.    
  953.     formatex(nameu,charsmax(nameu), "Add");
  954.     menu_additem(menu, nameu, "", 0);
  955.     formatex(nameu,charsmax(nameu), "Remove");
  956.     menu_additem(menu, nameu, "", 0);
  957.     formatex(nameu,charsmax(nameu), "Remove all");
  958.     menu_additem(menu, nameu, "", 0);
  959.     formatex(nameu,charsmax(nameu), "Select");
  960.     menu_additem(menu, nameu, "", 0);
  961.     formatex(nameu,charsmax(nameu), "Select all");
  962.     menu_additem(menu, nameu, "", 0);
  963.     formatex(nameu,charsmax(nameu), "Move");
  964.     menu_additem(menu, nameu, "", 0);
  965.     formatex(nameu,charsmax(nameu), "Save");
  966.     menu_additem(menu, nameu, "", 0);
  967.     formatex(nameu,charsmax(nameu), "Load");
  968.     menu_additem(menu, nameu, "", 0);
  969.     menu_display(id, menu, 0 );
  970.     return PLUGIN_HANDLED
  971. }
  972.  
  973. public Arenaspawner_handler( id, menu, item )
  974. {
  975.     if ( item == MENU_EXIT )
  976.     {
  977.         menu_destroy( menu );
  978.         remove_the_fake_arena()
  979.         return PLUGIN_HANDLED;
  980.     }
  981.    
  982.     new szData[6], szName[64];
  983.     new _access, item_callback;
  984.     menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  985.     new arenas_found;
  986.     arenas_found = fakes_count()
  987.     if(equali(szName,"Add"))
  988.     {
  989.         if(next_fake_arena() != -1)
  990.         {
  991.             start_fake_build(id,-1)
  992.             if(fakes_count())
  993.             {
  994.                 if(selected > MAX_ARENAS || selected == -1)
  995.                 {
  996.                     selected = 1
  997.                     select_the_fake_arena(EXTRA_CODE+selected)
  998.                 }
  999.             }
  1000.         }
  1001.         else client_print_color(id,"%s ^3Maximum arenas reached.^1",CHAT_TAG)
  1002.     }
  1003.     else if(equali(szName,"Remove"))
  1004.     {
  1005.         if(fakes_count())
  1006.         {
  1007.             if(selected > MAX_ARENAS || selected == -1)
  1008.                 selected = 1
  1009.             delete_the_fake_arena(EXTRA_CODE+selected)
  1010.             if(fakes_count())
  1011.                 next_selection()
  1012.         } else client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
  1013.     }
  1014.     else if(equali(szName,"Remove all"))
  1015.     {
  1016.         //remove_menu(id)
  1017.         remove_the_fake_arena()
  1018.         client_print_color(id,"%s ^3All arenas removed.",CHAT_TAG)
  1019.     }
  1020.     else if(equali(szName,"Select"))
  1021.     {
  1022.         if(fakes_count())
  1023.         {
  1024.             next_selection()
  1025.         } else client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
  1026.     }
  1027.     else if(equali(szName,"Select all"))
  1028.     {
  1029.         if(fakes_count())
  1030.         {
  1031.             selected = -1
  1032.             select_the_fake_arena(EXTRA_CODE+selected)
  1033.         } else client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
  1034.     }
  1035.     else if(equali(szName,"Move"))
  1036.     {
  1037.         if(fakes_count())
  1038.         {
  1039.             if(selected > MAX_ARENAS)
  1040.                 selected = 1
  1041.             select_the_fake_arena(EXTRA_CODE+selected)
  1042.             menu_destroy( menu );
  1043.             move_menu(id,EXTRA_CODE+selected)
  1044.             return PLUGIN_CONTINUE;
  1045.         }
  1046.         else client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
  1047.     }
  1048.     else if(equali(szName,"Load"))
  1049.     {
  1050.         remove_the_fake_arena()
  1051.         load_arena_coords(id)
  1052.         //client_print_color(id, DontChange,"%s ^3Arena coords loaded.",CHAT_TAG)
  1053.         set_task(0.1,"delay_build",id)
  1054.     }
  1055.     else if(equali(szName,"Save"))
  1056.     {
  1057.         if(fakes_count())
  1058.         {
  1059.             save_arena_coords(id)
  1060.             remove_the_fake_arena()
  1061.             load_arena_coords(id)
  1062.         }
  1063.         else
  1064.         {
  1065.             client_print_color(id,"%s ^3No arenas found.",CHAT_TAG)
  1066.         }
  1067.     }
  1068.     if(!arenas_found && fakes_count())
  1069.     {
  1070.         next_selection()
  1071.     }
  1072.     menu_destroy( menu );
  1073.     editor_menu(id)
  1074.     return PLUGIN_CONTINUE;
  1075. }
  1076.  
  1077. public Arenaspawner_handler_menu( id, menu, item )
  1078. {
  1079.     if ( item == MENU_EXIT )
  1080.     {
  1081.         menu_destroy( menu );
  1082.         remove_the_rush_fake_arena()
  1083.         return PLUGIN_HANDLED;
  1084.     }
  1085.    
  1086.     new szData[6], szName[64];
  1087.     new _access, item_callback;
  1088.     menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  1089.     new arenas_found;
  1090.     arenas_found = fake_rush_arenas_count()
  1091.     if(equali(szName,"Add"))
  1092.     {
  1093.         if(next_fake_rush_arena() != -1)
  1094.         {
  1095.             start_fake_rush_build(id,-1)
  1096.             if(fake_rush_arenas_count())
  1097.             {
  1098.                 if(selected_arenas > MAX_RUSH_ARENAS || selected_arenas == -1)
  1099.                 {
  1100.                     selected_arenas = 1
  1101.                     select_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
  1102.                 }
  1103.             }
  1104.         } else client_print_color(id,"%s ^3Maximum arenas reached.^1",RUSH_TAG)
  1105.     }
  1106.     else if(equali(szName,"Remove"))
  1107.     {
  1108.         if(fake_rush_arenas_count())
  1109.         {
  1110.             if(selected_arenas > MAX_RUSH_ARENAS || selected_arenas == -1)
  1111.                 selected_arenas = 1
  1112.             delete_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
  1113.             if(fake_rush_arenas_count())
  1114.                 next_rush_arena_selection()
  1115.         } else client_print_color(id, "%s ^3No arenas found.",RUSH_TAG)
  1116.     }
  1117.     else if(equali(szName,"Remove all"))
  1118.     {
  1119.         //remove_rush_menu(id)
  1120.         remove_the_rush_fake_arena()
  1121.         client_print_color(id,"%s ^3All arenas removed.",RUSH_TAG)
  1122.     }
  1123.     else if(equali(szName,"Select"))
  1124.     {
  1125.         if(fake_rush_arenas_count())
  1126.         {
  1127.             next_rush_arena_selection()
  1128.         } else client_print_color(id,"%s ^3No arenas found.",RUSH_TAG)
  1129.     }
  1130.     else if(equali(szName,"Select all"))
  1131.     {
  1132.         if(fake_rush_arenas_count())
  1133.         {
  1134.             selected_arenas = -1
  1135.             select_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
  1136.         } else client_print_color(id,"%s ^3No arenas found.",RUSH_TAG)
  1137.     }
  1138.     else if(equali(szName,"Move"))
  1139.     {
  1140.         if(fake_rush_arenas_count())
  1141.         {
  1142.             if(selected_arenas > MAX_RUSH_ARENAS)
  1143.                 selected_arenas = 1
  1144.             select_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
  1145.             menu_destroy( menu );
  1146.             move_rush_menu(id,RUSH_EXTRA_CODE+selected_arenas)
  1147.             return PLUGIN_CONTINUE;
  1148.         }
  1149.         else client_print_color(id,"%s ^3No arenas found.",RUSH_TAG)
  1150.     }
  1151.     else if(equali(szName,"Load"))
  1152.     {
  1153.         remove_the_rush_fake_arena()
  1154.         load_RUSH_ARENA_COORDS(id)
  1155.         //client_print_color(id,"%s ^3Arena coords loaded.",RUSH_TAG)
  1156.         set_task(0.1,"delay_build_rush",id)
  1157.     }
  1158.     else if(equali(szName,"Save"))
  1159.     {
  1160.         if(fake_rush_arenas_count())
  1161.         {
  1162.             save_RUSH_ARENA_COORDS(id)
  1163.             remove_the_rush_fake_arena()
  1164.             load_RUSH_ARENA_COORDS(id)
  1165.         }
  1166.         else
  1167.         {
  1168.             client_print_color(id,"%s ^3No arenas found.",RUSH_TAG)
  1169.         }
  1170.     }
  1171.     if(!arenas_found && fake_rush_arenas_count())
  1172.     {
  1173.         next_rush_arena_selection()
  1174.     }
  1175.     menu_destroy( menu );
  1176.     editor_rush_menu(id)
  1177.     return PLUGIN_CONTINUE;
  1178. }
  1179.  
  1180. stock next_selection()
  1181. {
  1182.     if(selected == -1)
  1183.     {
  1184.         selected = 1
  1185.     }
  1186.     new size = MAX_ARENAS*3
  1187.     for(new slct=0;slct < size;slct++)
  1188.     {
  1189.         selected++
  1190.         if(selected > MAX_ARENAS)
  1191.             selected = 1
  1192.         if(fake_arena_exists(selected))
  1193.         {
  1194.             select_the_fake_arena(EXTRA_CODE+selected)
  1195.             return;
  1196.         }
  1197.     }
  1198. }
  1199.  
  1200. stock next_rush_arena_selection()
  1201. {
  1202.     if(selected_arenas == -1)
  1203.     {
  1204.         selected_arenas = 1
  1205.     }
  1206.     new size = MAX_RUSH_ARENAS*3
  1207.     for(new slct=0;slct < size;slct++)
  1208.     {
  1209.         selected_arenas++
  1210.         if(selected_arenas > MAX_RUSH_ARENAS)
  1211.             selected_arenas = 1
  1212.         if(fake_rush_arena_exists(selected_arenas))
  1213.         {
  1214.             select_the_fake_rush_arena(RUSH_EXTRA_CODE+selected_arenas)
  1215.             return;
  1216.         }
  1217.     }
  1218. }
  1219.  
  1220. public fake_arena_exists(code)
  1221. {
  1222.     new arenas_ent = -1
  1223.     new code_ent
  1224.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  1225.     {
  1226.         if(entity_get_int(arenas_ent,EV_INT_iuser2) == CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
  1227.         {
  1228.             code_ent = entity_get_int(arenas_ent,EV_INT_iuser3)-EXTRA_CODE
  1229.             if(code_ent == code)
  1230.             {
  1231.                 return PLUGIN_HANDLED
  1232.             }
  1233.         }
  1234.     }
  1235.     return PLUGIN_CONTINUE
  1236. }
  1237.  
  1238. public fake_rush_arena_exists(code)
  1239. {
  1240.     new arenas_ent = -1
  1241.     new code_ent
  1242.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  1243.     {
  1244.         if(entity_get_int(arenas_ent,EV_INT_iuser2) == RUSH_CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
  1245.         {
  1246.             code_ent = entity_get_int(arenas_ent,EV_INT_iuser3)-RUSH_EXTRA_CODE
  1247.             if(code_ent == code)
  1248.             {
  1249.                 return PLUGIN_HANDLED
  1250.             }
  1251.         }
  1252.     }
  1253.     return PLUGIN_CONTINUE
  1254. }
  1255.  
  1256. public fakes_count()
  1257. {
  1258.     new arenas_ent = -1
  1259.     new found = 0
  1260.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  1261.     {
  1262.         if(entity_get_int(arenas_ent,EV_INT_iuser2) == CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
  1263.         {
  1264.             found++
  1265.         }
  1266.     }
  1267.     return found
  1268. }
  1269.  
  1270. public fake_rush_arenas_count()
  1271. {
  1272.     new arenas_ent = -1
  1273.     new found = 0
  1274.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  1275.     {
  1276.         if(entity_get_int(arenas_ent,EV_INT_iuser2) == RUSH_CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
  1277.         {
  1278.             found++
  1279.         }
  1280.     }
  1281.     return found
  1282. }
  1283.  
  1284. public arenas_count()
  1285. {
  1286.     new found = 0
  1287.     for(new id;id < MAXPLAYERS;id++)
  1288.     {
  1289.         if(is_user_connected(id))
  1290.         {
  1291.             if(is_in_duel[id] == 2)
  1292.                 found++
  1293.         }
  1294.     }
  1295.     return found/2
  1296. }
  1297.  
  1298. public arenas_count_rush()
  1299. {
  1300.     new found = 0
  1301.     for(new id;id < MAX_RUSH_PLAYERS;id++)
  1302.     {
  1303.         if(is_user_connected(id))
  1304.         {
  1305.             if(is_in_rush[id] == 2)
  1306.                 found++
  1307.         }
  1308.     }
  1309.     return found/2
  1310. }
  1311.  
  1312. public delay_build(id)
  1313. {
  1314.     for(new i=1;i < total_arenas+1;i++)
  1315.     {
  1316.         start_fake_build(id,i)
  1317.     }
  1318.     if(fakes_count())
  1319.     {
  1320.         next_selection()
  1321.     }
  1322. }
  1323.  
  1324.  
  1325. public delay_build_rush(id)
  1326. {
  1327.     for(new i=1;i < total_rush_arenas+1;i++)
  1328.     {
  1329.         start_fake_rush_build(id,i)
  1330.     }
  1331.     if(fake_rush_arenas_count())
  1332.     {
  1333.         next_rush_arena_selection()
  1334.     }
  1335. }
  1336.  
  1337. public move_menu(id,code)
  1338. {
  1339.     new menu
  1340.     menu = menu_create( "\rMove arena:", "move_handler" );
  1341.    
  1342.     new nameu[32];
  1343.     new code_t[32];
  1344.     num_to_str(code,code_t,charsmax(code_t))
  1345.     formatex(nameu,charsmax(nameu), "Move up");
  1346.     menu_additem(menu, nameu, code_t, 0);
  1347.    
  1348.     formatex(nameu,charsmax(nameu), "Move down");
  1349.     menu_additem(menu, nameu, code_t, 0);
  1350.    
  1351.     formatex(nameu,charsmax(nameu), "Move front");
  1352.     menu_additem(menu, nameu, code_t, 0);
  1353.    
  1354.     formatex(nameu,charsmax(nameu), "Move back");
  1355.     menu_additem(menu, nameu, code_t, 0);
  1356.    
  1357.     formatex(nameu,charsmax(nameu), "Move right");
  1358.     menu_additem(menu, nameu, code_t, 0);
  1359.    
  1360.     formatex(nameu,charsmax(nameu), "Move left");
  1361.     menu_additem(menu, nameu, code_t, 0);
  1362.    
  1363.     formatex(nameu,charsmax(nameu), "Remove the arena");
  1364.     menu_additem(menu, nameu, code_t, 0);
  1365.    
  1366.     formatex(nameu,charsmax(nameu), "Move size: %.2f",move_size[id]);
  1367.     menu_additem(menu, nameu, code_t, 0);
  1368.     menu_display(id, menu, 0 );
  1369.     return PLUGIN_HANDLED
  1370. }
  1371.  
  1372. public move_rush_menu(id,code)
  1373. {
  1374.     new menu
  1375.     menu = menu_create( "\rMove arena:", "move_rush_handler" );
  1376.    
  1377.     new nameu[32];
  1378.     new code_t[32];
  1379.     num_to_str(code,code_t,charsmax(code_t))
  1380.     formatex(nameu,charsmax(nameu), "Move up");
  1381.     menu_additem(menu, nameu, code_t, 0);
  1382.    
  1383.     formatex(nameu,charsmax(nameu), "Move down");
  1384.     menu_additem(menu, nameu, code_t, 0);
  1385.    
  1386.     formatex(nameu,charsmax(nameu), "Move front");
  1387.     menu_additem(menu, nameu, code_t, 0);
  1388.    
  1389.     formatex(nameu,charsmax(nameu), "Move back");
  1390.     menu_additem(menu, nameu, code_t, 0);
  1391.    
  1392.     formatex(nameu,charsmax(nameu), "Move right");
  1393.     menu_additem(menu, nameu, code_t, 0);
  1394.    
  1395.     formatex(nameu,charsmax(nameu), "Move left");
  1396.     menu_additem(menu, nameu, code_t, 0);
  1397.    
  1398.     formatex(nameu,charsmax(nameu), "Remove the arena");
  1399.     menu_additem(menu, nameu, code_t, 0);
  1400.    
  1401.     formatex(nameu,charsmax(nameu), "Move size: %.2f",move_arena_size[id]);
  1402.     menu_additem(menu, nameu, code_t, 0);
  1403.     menu_display(id, menu, 0 );
  1404.     return PLUGIN_HANDLED
  1405. }
  1406.  
  1407. public move_handler( id, menu, item )
  1408. {
  1409.     if ( item == MENU_EXIT )
  1410.     {
  1411.         menu_destroy( menu );
  1412.         set_task(0.1,"editor_menu",id)
  1413.         return PLUGIN_HANDLED;
  1414.     }
  1415.    
  1416.     new szData[32], szName[64];
  1417.     new _access, item_callback;
  1418.     menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  1419.     new code = str_to_num(szData)
  1420.     if(equali(szName,"remove the arena"))
  1421.     {
  1422.         delete_the_fake_arena(code)
  1423.         menu_destroy( menu );
  1424.         editor_menu(id)
  1425.         unselect_the_fake_arena(0)
  1426.         return PLUGIN_CONTINUE;
  1427.     }
  1428.     else if(containi(szName,"move size:") != -1)
  1429.     {
  1430.         move_size[id]+= 10.0
  1431.         if(move_size[id] > 100.0)
  1432.         {
  1433.             move_size[id] = 10.0
  1434.         }
  1435.     }
  1436.     else if(equali(szName,"move up"))
  1437.     {
  1438.         move_the_fake_arena(id,code,MOVE_UP)
  1439.     }
  1440.     else if(equali(szName,"move down"))
  1441.     {
  1442.         move_the_fake_arena(id,code,MOVE_DOWN)
  1443.     }
  1444.     else if(equali(szName,"move right"))
  1445.     {
  1446.         move_the_fake_arena(id,code,MOVE_RIGHT)
  1447.     }
  1448.     else if(equali(szName,"move left"))
  1449.     {
  1450.         move_the_fake_arena(id,code,MOVE_LEFT)
  1451.     }
  1452.     else if(equali(szName,"move front"))
  1453.     {
  1454.         move_the_fake_arena(id,code,MOVE_FRONT)
  1455.     }
  1456.     else if(equali(szName,"move back"))
  1457.     {
  1458.         move_the_fake_arena(id,code,MOVE_BACK)
  1459.     }
  1460.     menu_destroy( menu );
  1461.     move_menu(id,code)
  1462.    
  1463.     return PLUGIN_CONTINUE;
  1464. }
  1465.  
  1466. public move_rush_handler( id, menu, item )
  1467. {
  1468.     if ( item == MENU_EXIT )
  1469.     {
  1470.         menu_destroy( menu );
  1471.         set_task(0.1,"editor_rush_menu",id)
  1472.         return PLUGIN_HANDLED;
  1473.     }
  1474.    
  1475.     new szData[32], szName[64];
  1476.     new _access, item_callback;
  1477.     menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  1478.     new code = str_to_num(szData)
  1479.     if(equali(szName,"remove the arena"))
  1480.     {
  1481.         delete_the_fake_rush_arena(code)
  1482.         menu_destroy( menu );
  1483.         editor_rush_menu(id)
  1484.         unselect_the_fake_rush_arena(0)
  1485.         return PLUGIN_CONTINUE;
  1486.     }
  1487.     else if(containi(szName,"move size:") != -1)
  1488.     {
  1489.         move_arena_size[id]+= 10.0
  1490.         if(move_arena_size[id] > 100.0)
  1491.         {
  1492.             move_arena_size[id] = 10.0
  1493.         }
  1494.     }
  1495.     else if(equali(szName,"move up"))
  1496.     {
  1497.         move_the_rush_fake_arena(id,code,MOVE_ARENA_UP)
  1498.     }
  1499.     else if(equali(szName,"move down"))
  1500.     {
  1501.         move_the_rush_fake_arena(id,code,MOVE_ARENA_DOWN)
  1502.     }
  1503.     else if(equali(szName,"move right"))
  1504.     {
  1505.         move_the_rush_fake_arena(id,code,MOVE_ARENA_RIGHT)
  1506.     }
  1507.     else if(equali(szName,"move left"))
  1508.     {
  1509.         move_the_rush_fake_arena(id,code,MOVE_ARENA_LEFT)
  1510.     }
  1511.     else if(equali(szName,"move front"))
  1512.     {
  1513.         move_the_rush_fake_arena(id,code,MOVE_ARENA_FRONT)
  1514.     }
  1515.     else if(equali(szName,"move back"))
  1516.     {
  1517.         move_the_rush_fake_arena(id,code,MOVE_ARENA_BACK)
  1518.     }
  1519.     menu_destroy( menu );
  1520.     move_rush_menu(id,code)
  1521.    
  1522.     return PLUGIN_CONTINUE;
  1523. }
  1524.  
  1525. public save_arena_coords(id)
  1526. {
  1527.     new found;
  1528.     new cfgdir[32], mapname[32], urlfile[64]
  1529.     get_configsdir(cfgdir, charsmax(cfgdir))
  1530.     get_mapname(mapname, charsmax(mapname))
  1531.     formatex(urlfile, charsmax(urlfile), ARENA_FILE, cfgdir, mapname)
  1532.    
  1533.     if (file_exists(urlfile))
  1534.         delete_file(urlfile)
  1535.    
  1536.     new lineset[128]
  1537.     new Float:origin[3]
  1538.     new arenas_ent=-1;
  1539.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  1540.     {
  1541.         if(entity_get_int(arenas_ent,EV_INT_iuser2) == CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
  1542.         {
  1543.             found++
  1544.             pev(arenas_ent,pev_origin,origin);
  1545.             format(lineset, charsmax(lineset), "%.f %.f %.f", origin[0], origin[1], origin[2])
  1546.             write_file(urlfile, lineset,found)
  1547.            
  1548.         }
  1549.     }
  1550.     if(!found)
  1551.         client_print_color(id, "%s Couldn't save:^3No arenas found.",CHAT_TAG)
  1552.     else client_print_color(id,"%s %d ^3Arena coords saved.",CHAT_TAG,found)
  1553. }
  1554.  
  1555.  
  1556. public save_RUSH_ARENA_COORDS(id)
  1557. {
  1558.     new found;
  1559.     new cfgdir[32], mapname[32], urlfile[64]
  1560.     get_configsdir(cfgdir, charsmax(cfgdir))
  1561.     get_mapname(mapname, charsmax(mapname))
  1562.     formatex(urlfile, charsmax(urlfile), RUSH_ARENA_FILE, cfgdir, mapname)
  1563.    
  1564.     if (file_exists(urlfile))
  1565.         delete_file(urlfile)
  1566.    
  1567.     new lineset[128]
  1568.     new Float:origin[3]
  1569.     new arenas_ent=-1;
  1570.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  1571.     {
  1572.         if(entity_get_int(arenas_ent,EV_INT_iuser2) == RUSH_CENTER_CODE && entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
  1573.         {
  1574.             found++
  1575.             pev(arenas_ent,pev_origin,origin);
  1576.             format(lineset, charsmax(lineset), "%.f %.f %.f", origin[0], origin[1], origin[2])
  1577.             write_file(urlfile, lineset,found)
  1578.            
  1579.         }
  1580.     }
  1581.     if(!found)
  1582.         client_print_color(id,"%s Couldn't save:^3No arenas found.",RUSH_TAG)
  1583.     else client_print_color(id,"%s %d ^3Arena coords saved.",RUSH_TAG,found)
  1584. }
  1585.  
  1586. public print_coords(id)
  1587. {
  1588.     new Float:coord[3]
  1589.     pev(id,pev_origin,coord);
  1590.     client_print_color(id,"origin: ^3%.f %.f %.f",coord[0],coord[1],coord[2])
  1591.     return PLUGIN_HANDLED
  1592. }
  1593.  
  1594. public start_fake_build(id,zecode)
  1595. {
  1596.     if(!is_user_connected(id))
  1597.         return PLUGIN_HANDLED
  1598.     new ext_code
  1599.     if(zecode == -1)
  1600.     {
  1601.         ext_code = next_fake_arena()
  1602.         if(ext_code == -1)
  1603.             return PLUGIN_HANDLED
  1604.     }
  1605.     else ext_code = zecode
  1606.     ext_code+=EXTRA_CODE
  1607.     static Float:origin[3];
  1608.     if(zecode == -1)
  1609.         get_user_hitpoint(id,origin)
  1610.     else
  1611.     {
  1612.         origin[0]=arena_coord[zecode][0]
  1613.         origin[1]=arena_coord[zecode][1]
  1614.         origin[2]=arena_coord[zecode][2]
  1615.     }
  1616.    
  1617.     /*origin[0] = 1002.911376
  1618.     origin[1] = -1561.421997
  1619.     origin[2] = 0.0*/
  1620.     new Float:fake_origin[3]
  1621.     static size
  1622.     size = sizeof(ARENA_COORDS)
  1623.     new ent_code = FAKE_CODE
  1624.     fakes++
  1625.     for(new coords;coords < size; coords++)
  1626.     {
  1627.         fake_origin[0] = origin[0]
  1628.         fake_origin[1] = origin[1]
  1629.         if(bugged_map())
  1630.             fake_origin[2]= MAP_FIX_Z_COORD[map_id]
  1631.         else fake_origin[2] = origin[2]
  1632.         //fake_origin[2]=-712.876892
  1633.        
  1634.         fake_origin[0]+=ARENA_COORDS[coords][0]*1.7
  1635.         fake_origin[1]+=ARENA_COORDS[coords][1]*1.53
  1636.        
  1637.         new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
  1638.        
  1639.         set_pev(ent,pev_classname,ARENA_ENT_NAME);
  1640.         engfunc(EngFunc_SetModel,ent,ARENA_MODELS[0]);
  1641.         entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
  1642.         engfunc(EngFunc_SetSize,ent,ARENA_MINS,ARENA_MAXS);
  1643.         entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
  1644.         entity_set_int(ent,EV_INT_iuser1,ent_code)
  1645.         entity_set_int(ent,EV_INT_iuser3,ext_code)
  1646.         engfunc(EngFunc_SetOrigin,ent,fake_origin);
  1647.         stuck_check(fake_origin,120.0)
  1648.         static Float:rvec[3];
  1649.         pev(ent,pev_v_angle,rvec);
  1650.        
  1651.         rvec[0]=90.0;
  1652.         set_pev(ent,pev_angles,rvec);
  1653.        
  1654.         if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == 100.0)
  1655.         {
  1656.             fake_origin[0] += max_size[0]
  1657.             fake_origin[1] += max_size[1]
  1658.             //create_wall(LEFT_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
  1659.         }
  1660.         if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == -100.0)
  1661.         {
  1662.             fake_origin[0] += max_size[2]
  1663.             fake_origin[1] += min_size[0]
  1664.             //create_wall(RIGHT_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
  1665.         }
  1666.         if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == 0.0)
  1667.         {
  1668.             create_wall(TOP_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
  1669.             entity_set_int(ent,EV_INT_iuser2,CENTER_CODE)
  1670.         }
  1671.         else if(ARENA_COORDS[coords][0] == 200.0 && ARENA_COORDS[coords][1] == 0.0)
  1672.         {
  1673.             fake_origin[0] += min_size[1]
  1674.            
  1675.             //create_wall(BLUE_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
  1676.         }
  1677.         else if(ARENA_COORDS[coords][0] == -100.0 && ARENA_COORDS[coords][1] == 0.0)
  1678.         {
  1679.             fake_origin[0] += min_size[2]
  1680.             //create_wall(RED_SIDE,255,SOLID_BBOX,ent_code,0,ext_code,fake_origin)
  1681.         }
  1682.         set_rendering(ent,kRenderFxGlowShell,0,50,0,kRenderNormal,10)
  1683.     }
  1684.     select_the_fake_arena(ext_code)
  1685.     return PLUGIN_HANDLED;
  1686. }
  1687.  
  1688. public start_fake_rush_build(id,zecode)
  1689. {
  1690.     if(!is_user_connected(id))
  1691.         return PLUGIN_HANDLED
  1692.     new ext_code
  1693.     if(zecode == -1)
  1694.     {
  1695.         ext_code = next_fake_rush_arena()
  1696.         if(ext_code == -1)
  1697.             return PLUGIN_HANDLED
  1698.     }
  1699.     else ext_code = zecode
  1700.     ext_code+=RUSH_EXTRA_CODE
  1701.     static Float:origin[3];
  1702.     if(zecode == -1)
  1703.         get_user_hitpoint_rush(id,origin)
  1704.     else
  1705.     {
  1706.         origin[0]=rush_arena_coord[zecode][0]
  1707.         origin[1]=rush_arena_coord[zecode][1]
  1708.         origin[2]=rush_arena_coord[zecode][2]
  1709.     }
  1710.    
  1711.     /*origin[0] = 1002.911376
  1712.     origin[1] = -1561.421997
  1713.     origin[2] = 0.0*/
  1714.     new Float:fake_origin[3]
  1715.     static size
  1716.     size = sizeof(RUSH_ARENA_COORDS)
  1717.     new ent_code = RUSH_FAKE_CODE
  1718.     fakearenas++
  1719.     for(new coords;coords < size; coords++)
  1720.     {
  1721.         fake_origin[0] = origin[0]
  1722.         fake_origin[1] = origin[1]
  1723.         if(bugged_rush_map())
  1724.             fake_origin[2]= MAP_RUSH_FIX_Z_COORD[the_map_id]
  1725.         else fake_origin[2] = origin[2]
  1726.         //fake_origin[2]=-712.876892
  1727.        
  1728.         fake_origin[0]+=RUSH_ARENA_COORDS[coords][0]*1.7
  1729.         fake_origin[1]+=RUSH_ARENA_COORDS[coords][1]*1.53
  1730.        
  1731.         new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
  1732.        
  1733.         set_pev(ent,pev_classname,RUSH_ENT_NAME);
  1734.         engfunc(EngFunc_SetModel,ent,RUSH_MODELS[0]);
  1735.         entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
  1736.         engfunc(EngFunc_SetSize,ent,RUSH_ARENA_MINS,RUSH_ARENA_MAXS);
  1737.         entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
  1738.         entity_set_int(ent,EV_INT_iuser1,ent_code)
  1739.         entity_set_int(ent,EV_INT_iuser3,ext_code)
  1740.         engfunc(EngFunc_SetOrigin,ent,fake_origin);
  1741.         stuck_rush_check(fake_origin,120.0)
  1742.         static Float:rvec[3];
  1743.         pev(ent,pev_v_angle,rvec);
  1744.        
  1745.         rvec[0]=0.0;
  1746.         set_pev(ent,pev_angles,rvec);
  1747.        
  1748.         if(RUSH_ARENA_COORDS[coords][0] == 0.0 && RUSH_ARENA_COORDS[coords][1] == 100.0)
  1749.         {
  1750.             fake_origin[0] += max_arena_size[0]
  1751.             fake_origin[1] += max_arena_size[1]
  1752.         }
  1753.         if(RUSH_ARENA_COORDS[coords][0] == 0.0 && RUSH_ARENA_COORDS[coords][1] == -100.0)
  1754.         {
  1755.             fake_origin[0] += max_arena_size[2]
  1756.             fake_origin[1] += min_arena_size[0]
  1757.         }
  1758.         if(RUSH_ARENA_COORDS[coords][0] == 0.0 && RUSH_ARENA_COORDS[coords][1] == 0.0)
  1759.         {
  1760.             entity_set_int(ent,EV_INT_iuser2,RUSH_CENTER_CODE)
  1761.         }
  1762.         else if(RUSH_ARENA_COORDS[coords][0] == 200.0 && RUSH_ARENA_COORDS[coords][1] == 0.0)
  1763.         {
  1764.             fake_origin[0] += min_arena_size[1]
  1765.         }
  1766.         else if(RUSH_ARENA_COORDS[coords][0] == -100.0 && RUSH_ARENA_COORDS[coords][1] == 0.0)
  1767.         {
  1768.             fake_origin[0] += min_arena_size[2]
  1769.         }
  1770.         set_rendering(ent,kRenderFxGlowShell,0,50,0,kRenderNormal,10)
  1771.     }
  1772.     select_the_fake_rush_arena(ext_code)
  1773.     return PLUGIN_HANDLED;
  1774. }
  1775.  
  1776. public move_the_fake_arena(id,code,moveto)
  1777. {
  1778.     new num;
  1779.     num = code-EXTRA_CODE
  1780.     new arenas_ent=-1;
  1781.     new Float:origin[3];
  1782.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  1783.     {
  1784.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
  1785.         {
  1786.             if(entity_get_int(arenas_ent,EV_INT_iuser3) == code || num == -1)
  1787.             {
  1788.                 pev(arenas_ent,pev_origin,origin);
  1789.                 switch(moveto)
  1790.                 {
  1791.                     case MOVE_UP:
  1792.                     {
  1793.                         origin[2]+=move_size[id]
  1794.                     }
  1795.                     case MOVE_DOWN:
  1796.                     {
  1797.                         origin[2]-=move_size[id]
  1798.                     }
  1799.                     case MOVE_RIGHT:
  1800.                     {
  1801.                         origin[1]+=move_size[id]
  1802.                     }
  1803.                     case MOVE_LEFT:
  1804.                     {
  1805.                         origin[1]-=move_size[id]
  1806.                     }
  1807.                     case MOVE_FRONT:
  1808.                     {
  1809.                         origin[0]+=move_size[id]
  1810.                     }
  1811.                     case MOVE_BACK:
  1812.                     {
  1813.                         origin[0]-=move_size[id]
  1814.                     }
  1815.                 }
  1816.                 engfunc(EngFunc_SetOrigin,arenas_ent,origin);
  1817.                 stuck_check(origin,360.0)
  1818.             }
  1819.         }
  1820.     }
  1821.    
  1822. }
  1823.  
  1824. public move_the_rush_fake_arena(id,code,moveto)
  1825. {
  1826.     new num;
  1827.     num = code-RUSH_EXTRA_CODE
  1828.     new arenas_ent=-1;
  1829.     new Float:origin[3];
  1830.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  1831.     {
  1832.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
  1833.         {
  1834.             if(entity_get_int(arenas_ent,EV_INT_iuser3) == code || num == -1)
  1835.             {
  1836.                 pev(arenas_ent,pev_origin,origin);
  1837.                 switch(moveto)
  1838.                 {
  1839.                     case MOVE_ARENA_UP:
  1840.                     {
  1841.                         origin[2]+=move_arena_size[id]
  1842.                     }
  1843.                     case MOVE_ARENA_DOWN:
  1844.                     {
  1845.                         origin[2]-=move_arena_size[id]
  1846.                     }
  1847.                     case MOVE_ARENA_RIGHT:
  1848.                     {
  1849.                         origin[1]+=move_arena_size[id]
  1850.                     }
  1851.                     case MOVE_ARENA_LEFT:
  1852.                     {
  1853.                         origin[1]-=move_arena_size[id]
  1854.                     }
  1855.                     case MOVE_ARENA_FRONT:
  1856.                     {
  1857.                         origin[0]+=move_arena_size[id]
  1858.                     }
  1859.                     case MOVE_ARENA_BACK:
  1860.                     {
  1861.                         origin[0]-=move_arena_size[id]
  1862.                     }
  1863.                 }
  1864.                 engfunc(EngFunc_SetOrigin,arenas_ent,origin);
  1865.                 stuck_rush_check(origin,360.0)
  1866.             }
  1867.         }
  1868.     }
  1869.    
  1870. }
  1871.  
  1872. public select_the_fake_arena(code)
  1873. {
  1874.     new num;
  1875.     num = code-EXTRA_CODE
  1876.     new arenas_ent=-1;
  1877.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  1878.     {
  1879.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
  1880.         {
  1881.             if(num == -1)
  1882.                 set_rendering(arenas_ent,kRenderFxGlowShell,250,0,0,kRenderNormal,10)
  1883.             else if(entity_get_int(arenas_ent,EV_INT_iuser3) == code)
  1884.                 set_rendering(arenas_ent,kRenderFxGlowShell,250,0,0,kRenderNormal,10)
  1885.         }
  1886.     }
  1887.     unselect_the_fake_arena(code)
  1888.    
  1889. }
  1890.  
  1891. public select_the_fake_rush_arena(code)
  1892. {
  1893.     new num;
  1894.     num = code-RUSH_EXTRA_CODE
  1895.     new arenas_ent=-1;
  1896.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  1897.     {
  1898.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
  1899.         {
  1900.             if(num == -1)
  1901.                 set_rendering(arenas_ent,kRenderFxGlowShell,250,0,0,kRenderNormal,10)
  1902.             else if(entity_get_int(arenas_ent,EV_INT_iuser3) == code)
  1903.                 set_rendering(arenas_ent,kRenderFxGlowShell,250,0,0,kRenderNormal,10)
  1904.         }
  1905.     }
  1906.     unselect_the_fake_rush_arena(code)
  1907.    
  1908. }
  1909.  
  1910. public unselect_the_fake_arena(code)
  1911. {
  1912.     new num;
  1913.     num = code-EXTRA_CODE
  1914.     if(num == -1)
  1915.         return;
  1916.     new arenas_ent=-1;
  1917.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  1918.     {
  1919.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE && entity_get_int(arenas_ent,EV_INT_iuser3) != code)
  1920.             set_rendering(arenas_ent,kRenderFxGlowShell,50,50,50,kRenderTransAdd,120)
  1921.     }
  1922.    
  1923. }
  1924.  
  1925. public unselect_the_fake_rush_arena(code)
  1926. {
  1927.     new num;
  1928.     num = code-RUSH_EXTRA_CODE
  1929.     if(num == -1)
  1930.         return;
  1931.     new arenas_ent=-1;
  1932.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  1933.     {
  1934.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE && entity_get_int(arenas_ent,EV_INT_iuser3) != code)
  1935.             set_rendering(arenas_ent,kRenderFxGlowShell,50,50,50,kRenderTransAdd,120)
  1936.     }
  1937.    
  1938. }
  1939.  
  1940. public delete_the_fake_arena(code)
  1941. {
  1942.     new arenas_ent=-1;
  1943.     new found = 0
  1944.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  1945.     {
  1946.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE && entity_get_int(arenas_ent,EV_INT_iuser3) == code)
  1947.         {
  1948.             engfunc(EngFunc_RemoveEntity,arenas_ent)
  1949.             found++
  1950.         }
  1951.     }
  1952.     if(found)
  1953.     {
  1954.         fakes--
  1955.     }
  1956.    
  1957. }
  1958.  
  1959. public delete_the_fake_rush_arena(code)
  1960. {
  1961.     new arenas_ent=-1;
  1962.     new found = 0
  1963.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  1964.     {
  1965.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE && entity_get_int(arenas_ent,EV_INT_iuser3) == code)
  1966.         {
  1967.             engfunc(EngFunc_RemoveEntity,arenas_ent)
  1968.             found++
  1969.         }
  1970.     }
  1971.     if(found)
  1972.     {
  1973.         fakearenas--
  1974.     }
  1975.    
  1976. }
  1977.  
  1978. public load_arena_coords(id)
  1979. {
  1980.     // Check for spawns points of the current map
  1981.     new cfgdir[32], mapname[32], filepath[100], linedata[64]
  1982.     get_configsdir(cfgdir, charsmax(cfgdir))
  1983.     get_mapname(mapname, charsmax(mapname))
  1984.     formatex(filepath, charsmax(filepath), ARENA_FILE, cfgdir, mapname)
  1985.     new arena = 0
  1986.     total_arenas = 0
  1987.     // Load spawns points
  1988.     if (file_exists(filepath))
  1989.     {
  1990.         new file = fopen(filepath,"rt"), row[4][6]
  1991.        
  1992.         while (file && !feof(file))
  1993.         {
  1994.             fgets(file, linedata, charsmax(linedata))
  1995.            
  1996.             // invalid spawn
  1997.             if(!linedata[0] || str_count(linedata,' ') < 2) continue;
  1998.            
  1999.             arena++
  2000.             if (arena > MAX_ARENAS)
  2001.             {
  2002.                 break
  2003.             }
  2004.            
  2005.             // get spawn point data
  2006.             parse(linedata,row[0],5,row[1],5,row[2],5)
  2007.            
  2008.             // origin
  2009.             arena_coord[arena][0] = floatstr(row[0])
  2010.             arena_coord[arena][1] = floatstr(row[1])
  2011.             if(bugged_map())
  2012.                 arena_coord[arena][2] = MAP_FIX_Z_COORD[map_id]
  2013.             else arena_coord[arena][2] = floatstr(row[2])
  2014.            
  2015.             total_arenas = arena
  2016.         }
  2017.         if (file) fclose(file)
  2018.     }
  2019.     if(id != -1)
  2020.     {
  2021.         if(!total_arenas)
  2022.         {
  2023.             client_print_color(id,"%sCouldn't load: ^3No arenas found.",CHAT_TAG)
  2024.         }
  2025.         else
  2026.         {
  2027.             client_print_color(id,"%s%d ^3arena%s loaded.",CHAT_TAG,total_arenas, (total_arenas > 1 ? "s" : ""))
  2028.         }
  2029.     }
  2030. }
  2031.  
  2032. public load_RUSH_ARENA_COORDS(id)
  2033. {
  2034.     // Check for spawns points of the current map
  2035.     new cfgdir[32], mapname[32], filepath[100], linedata[64]
  2036.     get_configsdir(cfgdir, charsmax(cfgdir))
  2037.     get_mapname(mapname, charsmax(mapname))
  2038.     formatex(filepath, charsmax(filepath), RUSH_ARENA_FILE, cfgdir, mapname)
  2039.     new arena = 0
  2040.     total_rush_arenas = 0
  2041.     // Load spawns points
  2042.     if (file_exists(filepath))
  2043.     {
  2044.         new file = fopen(filepath,"rt"), row[4][6]
  2045.        
  2046.         while (file && !feof(file))
  2047.         {
  2048.             fgets(file, linedata, charsmax(linedata))
  2049.            
  2050.             // invalid spawn
  2051.             if(!linedata[0] || str_count(linedata,' ') < 2) continue;
  2052.            
  2053.             arena++
  2054.             if (arena > MAX_RUSH_ARENAS)
  2055.             {
  2056.                 break
  2057.             }
  2058.            
  2059.             // get spawn point data
  2060.             parse(linedata,row[0],5,row[1],5,row[2],5)
  2061.            
  2062.             // origin
  2063.             rush_arena_coord[arena][0] = floatstr(row[0])
  2064.             rush_arena_coord[arena][1] = floatstr(row[1])
  2065.             if(bugged_rush_map())
  2066.                 rush_arena_coord[arena][2] = MAP_RUSH_FIX_Z_COORD[the_map_id]
  2067.             else rush_arena_coord[arena][2] = floatstr(row[2])
  2068.            
  2069.             total_rush_arenas = arena
  2070.         }
  2071.         if (file) fclose(file)
  2072.     }
  2073.     if(id != -1)
  2074.     {
  2075.         if(!total_rush_arenas)
  2076.         {
  2077.             client_print_color(id,"%sCouldn't load: ^3No arenas found.",RUSH_TAG)
  2078.         }
  2079.         else
  2080.         {
  2081.             client_print_color(id,"%s%d ^3arena%s loaded.",RUSH_TAG,total_rush_arenas, (total_rush_arenas > 1 ? "s" : ""))
  2082.         }
  2083.     }
  2084. }
  2085.  
  2086. stock bugged_map()
  2087. {
  2088.     if(!MAP_FIX_ENABLED)
  2089.         return PLUGIN_CONTINUE
  2090.     if(IS_BUGGED_MAP)
  2091.         return PLUGIN_HANDLED
  2092.     return PLUGIN_CONTINUE
  2093. }
  2094.  
  2095.  
  2096. stock bugged_rush_map()
  2097. {
  2098.     if(!MAP_RUSH_FIX_ENABLED)
  2099.         return PLUGIN_CONTINUE
  2100.     if(IS_BUGGED_RUSH_MAP)
  2101.         return PLUGIN_HANDLED
  2102.     return PLUGIN_CONTINUE
  2103. }
  2104.  
  2105. stock str_count(const str[], searchchar)
  2106. {
  2107.     new count, i, len = strlen(str)
  2108.    
  2109.     for (i = 0; i <= len; i++)
  2110.     {
  2111.         if(str[i] == searchchar)
  2112.             count++
  2113.     }
  2114.    
  2115.     return count;
  2116. }
  2117.  
  2118. public Player_spawn_post(id)
  2119. {
  2120.     Set_Entity_Invisible(id, 0)
  2121.     if(is_user_alive(id))
  2122.     {
  2123.         if(is_in_duel[id] != 2)
  2124.         {
  2125.             set_task(1.0,"get_spawn_origin",id)
  2126.             return;
  2127.         }
  2128.         if(is_in_duel[id] == 2)
  2129.             spawn_back(id)
  2130.     }
  2131. }
  2132.  
  2133. public Player_spawn_rush_post(id)
  2134. {
  2135.     Set_Entity_Invisible(id, 0)
  2136.     if(is_user_alive(id))
  2137.     {
  2138.         if(is_in_rush[id] != 2)
  2139.         {
  2140.             set_task(1.0,"get_spawn_rush_origin",id)
  2141.             return;
  2142.         }
  2143.         if(is_in_rush[id] == 2)
  2144.             spawn_rush_back(id)
  2145.     }
  2146. }
  2147.  
  2148. public spawn_back(id)
  2149. {
  2150.     entity_set_origin(id,his_spawn[id])
  2151.     set_user_health(id,map_default_hp)
  2152.     set_user_armor(id,0)
  2153.     set_user_godmode(id, 0)
  2154.     if(is_user_connected(his_challenger[id]))
  2155.     {
  2156.         check_teams(id,his_challenger[id])
  2157.         entity_set_origin(his_challenger[id],his_spawn[his_challenger[id]])
  2158.         set_user_health(his_challenger[id],map_default_hp)
  2159.         set_user_armor(his_challenger[id],0)
  2160.         entity_set_vector(id, EV_VEC_angles, his_angle[id])
  2161.         entity_set_int(id, EV_INT_fixangle, 1)
  2162.         entity_set_vector(his_challenger[id], EV_VEC_angles, his_angle[his_challenger[id]])
  2163.         entity_set_int(his_challenger[id], EV_INT_fixangle, 1)
  2164.        
  2165.         if(his_type[id] == 1)
  2166.         {
  2167.             his_type[his_challenger[id]] = 1   
  2168.         }
  2169.         else if(his_type[id] == 2)
  2170.         {
  2171.             his_type[his_challenger[id]] = 2   
  2172.         }
  2173.         else if(his_type[id] == 0)
  2174.         {
  2175.             his_type[his_challenger[id]] = 0   
  2176.         }
  2177.        
  2178.     }
  2179. }
  2180.  
  2181. public spawn_rush_back(id)
  2182. {
  2183.     entity_set_origin(id,his_player_spawn[id])
  2184.     set_user_health(id,the_default_hp)
  2185.     set_user_armor(id,0)
  2186.     set_user_godmode(id, 0)
  2187.     if(is_user_connected(the_challenger[id]))
  2188.     {
  2189.         check_rush_teams(id,the_challenger[id])
  2190.         entity_set_origin(the_challenger[id],his_player_spawn[the_challenger[id]])
  2191.         set_user_health(the_challenger[id],the_default_hp)
  2192.         set_user_armor(the_challenger[id],0)
  2193.         entity_set_vector(id, EV_VEC_angles, his_player_angle[id])
  2194.         entity_set_int(id, EV_INT_fixangle, 1)
  2195.         entity_set_vector(the_challenger[id], EV_VEC_angles, his_player_angle[the_challenger[id]])
  2196.         entity_set_int(the_challenger[id], EV_INT_fixangle, 1)
  2197.        
  2198.         if(his_type[id] == 1)
  2199.         {
  2200.             his_type[the_challenger[id]] = 1   
  2201.         }
  2202.         else if(his_type[id] == 2)
  2203.         {
  2204.             his_type[the_challenger[id]] = 2   
  2205.         }
  2206.         else if(his_type[id] == 0)
  2207.         {
  2208.             his_type[the_challenger[id]] = 0   
  2209.         }
  2210.     }
  2211. }
  2212.  
  2213. public update_cvars()
  2214. {
  2215.     MAP_FIX_ENABLED = get_pcvar_num(cvar_z_fix)
  2216.     SOUNDS_ENABLED = get_pcvar_num(cvar_sounds)
  2217.     MAX_ROUNDS = get_pcvar_num(cvar_rounds)
  2218.     MAX_KILLS = get_pcvar_num(cvar_kills)
  2219.     MAX_COUNTDOWN = get_pcvar_num(cvar_cooldown)
  2220.     MAX_TIME = get_pcvar_num(cvar_time)
  2221.    
  2222.     MAP_RUSH_FIX_ENABLED = get_pcvar_num(cvar_zone_fix)
  2223.     SOUNDS_RUSH_ENABLED = get_pcvar_num(cvar_user_sounds)
  2224.     MAX_USER_RUSH_ROUNDS = get_pcvar_num(cvar_user_rounds)
  2225.     MAX_USER_KILLS = get_pcvar_num(cvar_user_kills)
  2226.     MAX_USER_COUNTDOWN = get_pcvar_num(cvar_user_cooldown)
  2227.     MAX_USER_TIME = get_pcvar_num(cvar_user_time)
  2228. }
  2229.  
  2230. stock remove_allarenas()
  2231. {
  2232.     new arenas_ent=-1;
  2233.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  2234.     {
  2235.         engfunc(EngFunc_RemoveEntity,arenas_ent)
  2236.     }
  2237.     fakes = 0
  2238. }
  2239.  
  2240. stock remove_all_rush_arenas()
  2241. {
  2242.     new arenas_ent=-1;
  2243.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  2244.     {
  2245.         engfunc(EngFunc_RemoveEntity,arenas_ent)
  2246.     }
  2247.     fakearenas = 0
  2248. }
  2249.  
  2250. public get_all_arena_coords(id)
  2251. {
  2252.     new Float:origin[3]
  2253.     new arenas_ent=-1;
  2254.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  2255.     {
  2256.         if(entity_get_int(arenas_ent,EV_INT_iuser2) == CENTER_CODE)
  2257.         {
  2258.             pev(arenas_ent,pev_origin,origin);
  2259.             client_print(id,print_console,"%.f %.f %.f",origin[0],origin[1],origin[2])
  2260.         }
  2261.     }
  2262.     client_print_color(id, "%s ^4Coords printed in console.",CHAT_TAG)
  2263. }
  2264.  
  2265. public get_all_RUSH_ARENA_COORDS(id)
  2266. {
  2267.     new Float:origin[3]
  2268.     new arenas_ent=-1;
  2269.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  2270.     {
  2271.         if(entity_get_int(arenas_ent,EV_INT_iuser2) == RUSH_CENTER_CODE)
  2272.         {
  2273.             pev(arenas_ent,pev_origin,origin);
  2274.             client_print(id,print_console,"%.f %.f %.f",origin[0],origin[1],origin[2])
  2275.         }
  2276.     }
  2277.     client_print_color(id, "%s ^4Coords printed in console.",RUSH_TAG)
  2278. }
  2279.  
  2280. public remove_the_fake_arena()
  2281. {
  2282.     new arenas_ent=-1;
  2283.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  2284.     {
  2285.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == FAKE_CODE)
  2286.             engfunc(EngFunc_RemoveEntity,arenas_ent)
  2287.     }
  2288.     fakes = 0
  2289. }
  2290.  
  2291. public remove_the_rush_fake_arena()
  2292. {
  2293.     new arenas_ent=-1;
  2294.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  2295.     {
  2296.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == RUSH_FAKE_CODE)
  2297.             engfunc(EngFunc_RemoveEntity,arenas_ent)
  2298.     }
  2299.     fakearenas = 0
  2300. }
  2301.  
  2302. public next_fake_arena()
  2303. {
  2304.     if(fakes_count() >= MAX_ARENAS)
  2305.         return -1
  2306.     for(new i=1;i < MAX_ARENAS+1;i++)
  2307.     {
  2308.         if(!fake_arena_exists(i))
  2309.         {
  2310.             return i
  2311.         }
  2312.     }
  2313.     return -1
  2314.     /*new num = fakes
  2315.     num++
  2316.     return num*/
  2317. }
  2318.  
  2319. public next_fake_rush_arena()
  2320. {
  2321.     if(fake_rush_arenas_count() >= MAX_RUSH_ARENAS)
  2322.         return -1
  2323.     for(new i=1;i < MAX_RUSH_ARENAS+1;i++)
  2324.     {
  2325.         if(!fake_rush_arena_exists(i))
  2326.         {
  2327.             return i
  2328.         }
  2329.     }
  2330.     return -1
  2331.     /*new num = fakearenas
  2332.     num++
  2333.     return num*/
  2334. }
  2335.  
  2336. public remove_the_arena(code)
  2337. {
  2338.     new arenas_ent=-1;
  2339.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",ARENA_ENT_NAME)))
  2340.     {
  2341.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == code)
  2342.             engfunc(EngFunc_RemoveEntity,arenas_ent)
  2343.     }
  2344. }
  2345.  
  2346. public remove_the_rush_arena(code)
  2347. {
  2348.     new arenas_ent=-1;
  2349.     while((arenas_ent=engfunc(EngFunc_FindEntityByString,arenas_ent,"classname",RUSH_ENT_NAME)))
  2350.     {
  2351.         if(entity_get_int(arenas_ent,EV_INT_iuser1) == code)
  2352.             engfunc(EngFunc_RemoveEntity,arenas_ent)
  2353.     }
  2354. }
  2355.  
  2356. public start_build(id)
  2357. {
  2358.     if(!is_user_connected(id))
  2359.         return PLUGIN_HANDLED
  2360.     if(is_in_duel[id] != 2)
  2361.         return PLUGIN_HANDLED
  2362.     if(!his_challenger[id])
  2363.         return PLUGIN_HANDLED
  2364.     if(!total_arenas)
  2365.     {
  2366.         return PLUGIN_HANDLED
  2367.     }
  2368.     static Float:origin[3];
  2369.     //get_user_hitpoint(id,origin)
  2370.     /*origin[0] = 1002.911376
  2371.     origin[1] = -1561.421997
  2372.     origin[2] = 0.0*/
  2373.     origin[0] = arena_coord[arena_number[id]][0]
  2374.     origin[1] = arena_coord[arena_number[id]][1]
  2375.     origin[2] = arena_coord[arena_number[id]][2]
  2376.     new Float:fake_origin[3]
  2377.     static size
  2378.     size = sizeof(ARENA_COORDS)
  2379.     new ent_code = arena_number[id]+ARENA_CODE
  2380.     for(new coords;coords < size; coords++)
  2381.     {
  2382.         fake_origin[0] = origin[0]
  2383.         fake_origin[1] = origin[1]
  2384.         fake_origin[2] = origin[2]
  2385.         //fake_origin[2]=-712.876892
  2386.         //fake_origin[2]=-864.253723
  2387.         fake_origin[0]+=ARENA_COORDS[coords][0]*1.7
  2388.         fake_origin[1]+=ARENA_COORDS[coords][1]*1.53
  2389.        
  2390.         new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
  2391.        
  2392.         set_pev(ent,pev_classname,ARENA_ENT_NAME);
  2393.         engfunc(EngFunc_SetModel,ent,ARENA_MODELS[0]);
  2394.         entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
  2395.         engfunc(EngFunc_SetSize,ent,ARENA_MINS,ARENA_MAXS);
  2396.         entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
  2397.         entity_set_int(ent,EV_INT_iuser1,ent_code)
  2398.         engfunc(EngFunc_SetOrigin,ent,fake_origin);
  2399.         static Float:rvec[3];
  2400.         pev(ent,pev_v_angle,rvec);
  2401.        
  2402.         rvec[0]=90.0;
  2403.         set_pev(ent,pev_angles,rvec);
  2404.        
  2405.         if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == 100.0)
  2406.         {
  2407.             create_wall(LEFT_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
  2408.         }
  2409.         if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == -100.0)
  2410.         {
  2411.             create_wall(RIGHT_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
  2412.         }
  2413.         if(ARENA_COORDS[coords][0] == 0.0 && ARENA_COORDS[coords][1] == 0.0)
  2414.         {
  2415.             create_wall(TOP_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
  2416.             entity_set_int(ent,EV_INT_iuser2,CENTER_CODE)
  2417.         }
  2418.         else if(ARENA_COORDS[coords][0] == 200.0 && ARENA_COORDS[coords][1] == 0.0)
  2419.         {
  2420.             create_wall(BLUE_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
  2421.             if(cs_get_user_team(id) == CS_TEAM_CT)
  2422.             {
  2423.                 set_spawn_positions(id,BLUE_SIDE,fake_origin,rvec)
  2424.             }                                                                              
  2425.             else
  2426.             {
  2427.                 if(his_challenger[id])
  2428.                 {
  2429.                     set_spawn_positions(his_challenger[id],BLUE_SIDE,fake_origin,rvec)
  2430.                 }
  2431.             }
  2432.             //set_rendering(ent,kRenderFxGlowShell,0,0,200,kRenderNormal,10)
  2433.         }
  2434.         else if(ARENA_COORDS[coords][0] == -100.0 && ARENA_COORDS[coords][1] == 0.0)
  2435.         {
  2436.             create_wall(RED_SIDE,0,SOLID_BBOX,ent_code,0,0,fake_origin)
  2437.             if(cs_get_user_team(id) == CS_TEAM_T)
  2438.             {
  2439.                 set_spawn_positions(id,RED_SIDE,fake_origin,rvec)
  2440.             }                                                                              
  2441.             else
  2442.             {
  2443.                 if(his_challenger[id])
  2444.                 {
  2445.                     set_spawn_positions(his_challenger[id],RED_SIDE,fake_origin,rvec)
  2446.                 }
  2447.             }
  2448.             //set_rendering(ent,kRenderFxGlowShell,200,0,0,kRenderNormal,10)
  2449.         }
  2450.         spawn_back(id)
  2451.     }
  2452.    
  2453.     return PLUGIN_HANDLED;
  2454. }
  2455.  
  2456. public start_rush_build(id)
  2457. {
  2458.     if(!is_user_connected(id))
  2459.         return PLUGIN_HANDLED
  2460.     if(is_in_rush[id] != 2)
  2461.         return PLUGIN_HANDLED
  2462.     if(!the_challenger[id])
  2463.         return PLUGIN_HANDLED
  2464.     if(!total_rush_arenas)
  2465.     {
  2466.         return PLUGIN_HANDLED
  2467.     }
  2468.     static Float:origin[3];
  2469.     //get_user_hitpoint_rush(id,origin)
  2470.     /*origin[0] = 1002.911376
  2471.     origin[1] = -1561.421997
  2472.     origin[2] = 0.0*/
  2473.     origin[0] = rush_arena_coord[rush_arena_number[id]][0]
  2474.     origin[1] = rush_arena_coord[rush_arena_number[id]][1]
  2475.     origin[2] = rush_arena_coord[rush_arena_number[id]][2]
  2476.     new Float:fake_origin[3]
  2477.     static size
  2478.     size = sizeof(RUSH_ARENA_COORDS)
  2479.     new ent_code = rush_arena_number[id]+RUSH_ARENA_CODE
  2480.     for(new coords;coords < size; coords++)
  2481.     {
  2482.         fake_origin[0] = origin[0]
  2483.         fake_origin[1] = origin[1]
  2484.         fake_origin[2] = origin[2]
  2485.         //fake_origin[2]=-712.876892
  2486.         //fake_origin[2]=-864.253723
  2487.         fake_origin[0]+=RUSH_ARENA_COORDS[coords][0]*1.7
  2488.         fake_origin[1]+=RUSH_ARENA_COORDS[coords][1]*1.53
  2489.        
  2490.         new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
  2491.        
  2492.         set_pev(ent,pev_classname,RUSH_ENT_NAME);
  2493.         engfunc(EngFunc_SetModel,ent,RUSH_MODELS[0]);
  2494.         entity_set_int(ent, EV_INT_solid, SOLID_BBOX);
  2495.         engfunc(EngFunc_SetSize,ent,RUSH_ARENA_MINS,RUSH_ARENA_MAXS);
  2496.         entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
  2497.         entity_set_int(ent,EV_INT_iuser1,ent_code)
  2498.         engfunc(EngFunc_SetOrigin,ent,fake_origin);
  2499.         static Float:rvec[3];
  2500.         pev(ent,pev_v_angle,rvec);
  2501.        
  2502.         rvec[0]=0.0;
  2503.         set_pev(ent,pev_angles,rvec);
  2504.        
  2505.         cs_set_user_team(id,CS_TEAM_T)
  2506.         cs_set_user_team(the_challenger[id],CS_TEAM_CT)
  2507.        
  2508.         set_spawn_positions_rush(id,fake_origin)
  2509.         set_spawn_positions_rush(the_challenger[id],fake_origin)
  2510.        
  2511.         spawn_rush_back(id)
  2512.     }
  2513.    
  2514.     return PLUGIN_HANDLED;
  2515. }
  2516.  
  2517. public set_spawn_positions(id,side,Float:origin[3],Float:angle[3])
  2518. {
  2519.     if(side == BLUE_SIDE)
  2520.         his_spawn[id][0] = origin[0]-20.0
  2521.     else his_spawn[id][0] = origin[0]-120.0
  2522.     his_spawn[id][1] = origin[1]
  2523.     his_spawn[id][2] = origin[2]+50.0
  2524.     entity_get_vector(id, EV_VEC_angles,his_angle[id])
  2525.     switch(side)
  2526.     {
  2527.         case RED_SIDE:
  2528.         {
  2529.             his_angle[id][1] = 0.0
  2530.             his_angle[id][0] = 0.0
  2531.            
  2532.         }
  2533.         case BLUE_SIDE:
  2534.         {
  2535.             his_angle[id][1] = 180.0
  2536.             his_angle[id][0] = 0.0
  2537.         }
  2538.     }
  2539.     got_spawn[id] = 1
  2540. }
  2541.  
  2542. public set_spawn_positions_rush(id,Float:origin[3])
  2543. {
  2544.     if(get_user_team(id) == 1)
  2545.     {
  2546.         his_player_spawn[id][0] = origin[0]-320
  2547.         his_player_spawn[id][1] = origin[1]
  2548.         his_player_spawn[id][2] = origin[2]+50
  2549.        
  2550.         his_player_angle[id][1] = 0.0
  2551.         his_player_angle[id][0] = 0.0
  2552.        
  2553.     }
  2554.     if(get_user_team(id) == 2)
  2555.     {
  2556.         his_player_spawn[id][0] = origin[0]+320
  2557.         his_player_spawn[id][1] = origin[1]
  2558.         his_player_spawn[id][2] = origin[2]+50
  2559.        
  2560.         his_player_angle[id][1] = 180.0
  2561.         his_player_angle[id][0] = 0.0
  2562.     }
  2563.     entity_set_origin(id,his_player_spawn[id])
  2564.    
  2565. }
  2566.  
  2567. public client_PostThink(id)
  2568. {
  2569.     if(is_in_rush[id] == 2)
  2570.     {
  2571.         new flags = entity_get_int(id, EV_INT_flags);
  2572.        
  2573.         new Float:origin[3], Float:dest[3];
  2574.         entity_get_vector(id, EV_VEC_origin, origin);
  2575.        
  2576.        
  2577.         dest[0] = origin[0];
  2578.         dest[1] = origin[1];
  2579.         dest[2] = origin[2] - 70.0;
  2580.         new ptr = create_tr2();
  2581.         engfunc(EngFunc_TraceHull, origin, dest, 0, flags & FL_DUCKING ? HULL_HEAD : HULL_HUMAN, id, ptr);
  2582.         new Float:flFraction;
  2583.         get_tr2(ptr, TR_flFraction, flFraction);
  2584.        
  2585.         if( flFraction >= 1.0)
  2586.         {
  2587.             Prevent_Noobs[id] ++
  2588.            
  2589.             if(Prevent_Noobs[id] == 10 )
  2590.             {
  2591.                 Prevent_Noobs[id] = 0;
  2592.                 end_his_rush(id)
  2593.             }
  2594.            
  2595.             ExecuteHamB(Ham_CS_RoundRespawn, id)
  2596.            
  2597.             free_tr2(ptr);
  2598.             return;
  2599.         }
  2600.        
  2601.         get_tr2(ptr, TR_vecPlaneNormal, dest);
  2602.         free_tr2(ptr);
  2603.     }
  2604. }
  2605.  
  2606. public stuck_check(Float:origin[3],Float:radius)
  2607. {
  2608.     new player=-1;
  2609.     while((player = find_ent_in_sphere(player,origin,radius)) != 0)
  2610.     {
  2611.         if(is_user_alive(player))
  2612.         {
  2613.             if(is_player_stuck(player) && is_in_duel[player] != 2)
  2614.             {
  2615.                 back_to_the_spawn(player)
  2616.             }
  2617.         }
  2618.     }
  2619. }
  2620.  
  2621. public stuck_rush_check(Float:origin[3],Float:radius)
  2622. {
  2623.     new player=-1;
  2624.     while((player = find_ent_in_sphere(player,origin,radius)) != 0)
  2625.     {
  2626.         if(is_user_alive(player))
  2627.         {
  2628.             if(is_player_stuck_rush(player) && is_in_rush[player] != 2)
  2629.             {
  2630.                 back_to_the_rush_spawn(player)
  2631.             }
  2632.         }
  2633.     }
  2634. }
  2635.  
  2636. stock is_player_stuck(id)
  2637. {
  2638.     static Float:originF[3]
  2639.     pev(id, pev_origin, originF)
  2640.    
  2641.     engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
  2642.    
  2643.     if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
  2644.         return true;
  2645.    
  2646.     return false;
  2647. }
  2648.  
  2649.  
  2650. stock is_player_stuck_rush(id)
  2651. {
  2652.     static Float:originF[3]
  2653.     pev(id, pev_origin, originF)
  2654.    
  2655.     engfunc(EngFunc_TraceHull, originF, originF, 0, (pev(id, pev_flags) & FL_DUCKING) ? HULL_HEAD : HULL_HUMAN, id, 0)
  2656.    
  2657.     if (get_tr2(0, TR_StartSolid) || get_tr2(0, TR_AllSolid) || !get_tr2(0, TR_InOpen))
  2658.         return true;
  2659.    
  2660.     return false;
  2661. }
  2662.  
  2663. public create_wall(type,alpha,solidity,code,code1,code2,Float:origin[3])
  2664. {
  2665.     new Float:wall_maxsize[3];
  2666.     new Float:wall_minsize[3];
  2667.     new Float:rvec[3];
  2668.     new ent=engfunc(EngFunc_CreateNamedEntity,engfunc(EngFunc_AllocString,"func_wall"));
  2669.     pev(ent,pev_v_angle,rvec);
  2670.     switch(type)
  2671.     {
  2672.         case BLUE_SIDE:
  2673.         {
  2674.             wall_maxsize[0] = 2.0
  2675.             wall_minsize[0] = 0.0
  2676.             wall_maxsize[1] = 230.0
  2677.             wall_minsize[1] = -230.0
  2678.             wall_maxsize[2] = 150.0
  2679.             wall_minsize[2] = -1.0
  2680.             rvec[1]=180.0
  2681.         }
  2682.         case RED_SIDE:
  2683.         {
  2684.             wall_maxsize[0] = -150.0
  2685.             wall_minsize[0] = -152.0
  2686.             wall_maxsize[1] = 230.0
  2687.             wall_minsize[1] = -230.0
  2688.             wall_maxsize[2] = 150.0
  2689.             wall_minsize[2] = -1.0
  2690.             rvec[1]=180.0
  2691.         }
  2692.         case LEFT_SIDE:
  2693.         {
  2694.             wall_maxsize[0] = 360.0
  2695.             wall_minsize[0] = -300.0
  2696.             wall_maxsize[1] = 65.0
  2697.             wall_minsize[1] = 63.0
  2698.             wall_maxsize[2] = 150.0
  2699.             wall_minsize[2] = -1.0
  2700.             rvec[1]=90.0
  2701.         }
  2702.         case RIGHT_SIDE:
  2703.         {
  2704.             wall_maxsize[0] = 360.0
  2705.             wall_minsize[0] = -300.0
  2706.             wall_maxsize[1] = -63.0
  2707.             wall_minsize[1] = -65.0
  2708.             wall_maxsize[2] = 150.0
  2709.             rvec[1]=90.0
  2710.         }
  2711.         case TOP_SIDE:
  2712.         {
  2713.             wall_maxsize[0] = 360.0
  2714.             wall_minsize[0] = -300.0
  2715.             wall_maxsize[1] = 230.0
  2716.             wall_minsize[1] = -230.0
  2717.             wall_maxsize[2] = 150.0
  2718.             wall_minsize[2] = 148.0
  2719.             rvec[0]=90.0          
  2720.         }
  2721.     }
  2722.     set_pev(ent,pev_angles,rvec);
  2723.    
  2724.     set_pev(ent,pev_classname,ARENA_ENT_NAME);
  2725.     engfunc(EngFunc_SetModel,ent,ARENA_MODELS[0]);
  2726.     set_pev(ent, pev_effects, EF_NODRAW)
  2727.     entity_set_int(ent, EV_INT_solid, solidity);
  2728.     engfunc(EngFunc_SetSize,ent,wall_minsize,wall_maxsize);
  2729.     entity_set_int(ent, EV_INT_movetype, MOVETYPE_NONE);
  2730.     entity_set_int(ent,EV_INT_iuser1,code)
  2731.     entity_set_int(ent,EV_INT_iuser2,code1)
  2732.     entity_set_int(ent,EV_INT_iuser3,code2)
  2733.     engfunc(EngFunc_SetOrigin,ent,origin);
  2734.     //set_rendering(ent,kRenderFxGlowShell,0,0,0,kRenderTransAlpha,alpha)
  2735.     //set_rendering(ent, kRenderFxGlowShell, 255, 100, 0, kRenderTransColor, 1);
  2736. }
  2737.  
  2738. public get_spawn_origin(id)
  2739. {
  2740.     pev(id,pev_origin,his_original_spawn[id]);
  2741. }
  2742.  
  2743.  
  2744. public get_spawn_rush_origin(id)
  2745. {
  2746.     pev(id,pev_origin,his_original_player_spawn[id]);
  2747. }
  2748.  
  2749. stock get_user_hitpoint(id,Float:hOrigin[3])  {
  2750.     if(!is_user_alive(id))
  2751.         return 0;
  2752.    
  2753.     new Float:fOrigin[3],Float:fvAngle[3],Float:fvOffset[3],Float:fvOrigin[3],Float:feOrigin[3];
  2754.     new Float:fTemp[3];
  2755.    
  2756.     pev(id,pev_origin,fOrigin);
  2757.     pev(id,pev_v_angle,fvAngle);
  2758.     pev(id,pev_view_ofs,fvOffset);
  2759.    
  2760.     xs_vec_add(fOrigin,fvOffset,fvOrigin);
  2761.    
  2762.     engfunc(EngFunc_AngleVectors,fvAngle,feOrigin,fTemp,fTemp);
  2763.    
  2764.     xs_vec_mul_scalar(feOrigin,9999.9,feOrigin);
  2765.     xs_vec_add(fvOrigin,feOrigin,feOrigin);
  2766.    
  2767.     engfunc(EngFunc_TraceLine,fvOrigin,feOrigin,0,id);
  2768.     global_get(glb_trace_endpos,hOrigin);
  2769.    
  2770.     return 1;
  2771. }
  2772.  
  2773. stock get_user_hitpoint_rush(id,Float:hOrigin[3])  {
  2774.     if(!is_user_alive(id))
  2775.         return 0;
  2776.    
  2777.     new Float:fOrigin[3],Float:fvAngle[3],Float:fvOffset[3],Float:fvOrigin[3],Float:feOrigin[3];
  2778.     new Float:fTemp[3];
  2779.    
  2780.     pev(id,pev_origin,fOrigin);
  2781.     pev(id,pev_v_angle,fvAngle);
  2782.     pev(id,pev_view_ofs,fvOffset);
  2783.    
  2784.     xs_vec_add(fOrigin,fvOffset,fvOrigin);
  2785.    
  2786.     engfunc(EngFunc_AngleVectors,fvAngle,feOrigin,fTemp,fTemp);
  2787.    
  2788.     xs_vec_mul_scalar(feOrigin,9999.9,feOrigin);
  2789.     xs_vec_add(fvOrigin,feOrigin,feOrigin);
  2790.    
  2791.     engfunc(EngFunc_TraceLine,fvOrigin,feOrigin,0,id);
  2792.     global_get(glb_trace_endpos,hOrigin);
  2793.    
  2794.     return 1;
  2795. }
  2796.  
  2797. public plugin_precache()
  2798. {
  2799.     new size;
  2800.     size = sizeof(ARENA_MODELS)
  2801.     for(new i; i< size; i++)
  2802.     {
  2803.         engfunc(EngFunc_PrecacheModel,ARENA_MODELS[i]);
  2804.         engfunc(EngFunc_PrecacheModel,RUSH_MODELS[i]);
  2805.     }
  2806. }
  2807.  
  2808.  
  2809. public round_start_event()
  2810. {
  2811.     update_cvars();
  2812.     // using a variable to store player's names instead of regenerating it all the time...
  2813.     for(new id;id < MAXPLAYERS;id++)
  2814.     {
  2815.         if(is_user_connected(id))
  2816.         {
  2817.             get_user_name(id,his_name[id],charsmax(his_name))
  2818.         }
  2819.     }
  2820. }
  2821.  
  2822. public round_start_rush_event()
  2823. {
  2824.     update_cvars()
  2825.     // using a variable to store player's names instead of regenerating it all the time...
  2826.     for(new id;id < MAX_RUSH_PLAYERS;id++)
  2827.     {
  2828.         if(is_user_connected(id))
  2829.         {
  2830.             get_user_name(id,his_name[id],charsmax(his_name))
  2831.         }
  2832.     }
  2833. }
  2834.  
  2835. public Advertise(task)
  2836. {
  2837.     client_print_color(0,"^3[^4Global Knife^3] ^1Type ^3/duel ^1/drank ^3/dtop ^1to open ^4Duel Menu (rank & top)")
  2838.    
  2839.     set_task(120.0,"Advertise",TASK_AD)
  2840. }
  2841.  
  2842.  
  2843. public Cmd_start(id,hndle)
  2844. {
  2845.     if(!is_user_alive(id))
  2846.         return FMRES_IGNORED
  2847.     if(!is_frozen[id])
  2848.         return FMRES_IGNORED
  2849.     new Buttons = get_uc(hndle,UC_Buttons)
  2850.     if(Buttons & IN_ATTACK)
  2851.     {
  2852.         Buttons &= ~IN_ATTACK
  2853.         set_uc( hndle , UC_Buttons , Buttons )
  2854.         return FMRES_SUPERCEDE
  2855.     }
  2856.     if(Buttons & IN_ATTACK2)
  2857.     {
  2858.         Buttons &= ~IN_ATTACK2
  2859.         set_uc( hndle , UC_Buttons , Buttons )
  2860.         return FMRES_SUPERCEDE
  2861.     }
  2862.     return FMRES_IGNORED
  2863. }
  2864.  
  2865. public Player_Take_Damage(victim, inflictor, attacker, Float:damage, damage_bits)
  2866. {    
  2867.     if(is_user_connected(attacker)) // we make sure the attacker is a player
  2868.     {
  2869.         if(is_in_duel[victim] == 2 || is_in_duel[attacker] == 2)
  2870.         {
  2871.             if(his_challenger[victim] != attacker || his_challenger[attacker] != victim)
  2872.             {
  2873.                 // we protect the contenders from getting killed by other people or them killing others?
  2874.                 return HAM_SUPERCEDE
  2875.             }
  2876.         }
  2877.     }
  2878.     return HAM_IGNORED
  2879. }
  2880.  
  2881. public Player_Take_Damage_Rush(victim, inflictor, attacker, Float:damage, damage_bits)
  2882. {    
  2883.     if(is_user_connected(attacker)) // we make sure the attacker is a player
  2884.     {
  2885.         if(is_in_rush[victim] == 2 || is_in_rush[attacker] == 2)
  2886.         {
  2887.             if(the_challenger[victim] != attacker || the_challenger[attacker] != victim)
  2888.             {
  2889.                 // we protect the contenders from getting killed by other people or them killing others?
  2890.                 return HAM_SUPERCEDE
  2891.             }
  2892.         }
  2893.     }
  2894.     return HAM_IGNORED
  2895. }
  2896.  
  2897. public client_putinserver(id)
  2898. {
  2899.     get_user_name(id,his_name[id],charsmax(his_name))
  2900.     reset_values(id)
  2901.     move_size[id] = 10.0
  2902.     his_offline[id] = 0
  2903.     his_type[id] = 0
  2904.     his_previous_team[id] = 0
  2905.    
  2906.     reset_player_values(id)
  2907.     move_arena_size[id] = 10.0
  2908.     his_previous_user_team[id] = 0
  2909.    
  2910.    
  2911.     return PLUGIN_CONTINUE
  2912. }
  2913.  
  2914. public client_disconnect(id)
  2915. {
  2916.     end_his_duel(id)
  2917.     end_his_rush(id)
  2918.    
  2919.     Duel_Arena_Spawner[id] = false
  2920.     Rush_Arena_Spawner[id] = false
  2921. }
  2922.  
  2923. public end_his_duel(id)
  2924. {
  2925.     if(his_challenger[id])
  2926.     {
  2927.         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])
  2928.         user_can_spawn[his_challenger[id]] = 1
  2929.         user_can_spawn[id] = 1
  2930.         if(arena_number[id] == arena_number[his_challenger[id]])
  2931.             remove_the_arena(arena_number[id] +ARENA_CODE)
  2932.         back_to_the_spawn(id)
  2933.         back_to_the_spawn(his_challenger[id])
  2934.         reset_values(his_challenger[id])
  2935.     }
  2936.     reset_values(id)
  2937. }
  2938.  
  2939. public end_his_rush(id)
  2940. {
  2941.     if(the_challenger[id])
  2942.     {
  2943.         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])
  2944.        
  2945.         if(rush_arena_number[id] == rush_arena_number[the_challenger[id]])
  2946.             remove_the_rush_arena(rush_arena_number[id] +RUSH_ARENA_CODE)
  2947.         back_to_the_rush_spawn(id)
  2948.         back_to_the_rush_spawn(the_challenger[id])
  2949.         reset_player_values(the_challenger[id])
  2950.     }
  2951.     reset_player_values(id)
  2952. }
  2953.  
  2954. public times_up_duel(id)
  2955. {
  2956.     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])
  2957.    
  2958.     if(his_challenger[id])
  2959.     {
  2960.         if(arena_number[id] == arena_number[his_challenger[id]])
  2961.             remove_the_arena(arena_number[id] +ARENA_CODE)
  2962.         user_kill(id,1)
  2963.         user_kill(his_challenger[id],1)
  2964.         //back_to_the_spawn(id)
  2965.         //back_to_the_spawn(his_challenger[id])
  2966.         reset_values(his_challenger[id])
  2967.     }
  2968.     reset_values(id)
  2969. }
  2970.  
  2971. public times_up_rush(id)
  2972. {
  2973.     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])
  2974.    
  2975.     if(the_challenger[id])
  2976.     {
  2977.         if(rush_arena_number[id] == rush_arena_number[the_challenger[id]])
  2978.             remove_the_rush_arena(rush_arena_number[id] +RUSH_ARENA_CODE)
  2979.         user_kill(id,1)
  2980.         user_kill(the_challenger[id],1)
  2981.         back_to_the_rush_spawn(id)
  2982.         back_to_the_rush_spawn(the_challenger[id])
  2983.         reset_player_values(the_challenger[id])
  2984.     }
  2985.     reset_player_values(id)
  2986. }
  2987.  
  2988. public battle_timer(id)
  2989. {
  2990.     if(is_user_connected(id))
  2991.     {
  2992.         if(is_in_duel[id] == 2)
  2993.         {
  2994.             his_timer[id]++
  2995.             if(his_timer[id] > MAX_TIME)
  2996.             {
  2997.                 times_up_duel(id)
  2998.             }
  2999.             set_task(1.0,"battle_timer",id)
  3000.         }
  3001.     }
  3002. }
  3003.  
  3004. public battle_rush_timer(id)
  3005. {
  3006.     if(is_user_connected(id))
  3007.     {
  3008.         if(is_in_rush[id] == 2)
  3009.         {
  3010.             the_timer[id]++
  3011.             if(the_timer[id] > MAX_USER_TIME)
  3012.             {
  3013.                 times_up_rush(id)
  3014.             }
  3015.             set_task(1.0,"battle_rush_timer",id)
  3016.         }
  3017.     }
  3018. }
  3019.  
  3020. public toggle_offline(id)
  3021. {
  3022.     switch(his_offline[id])
  3023.     {
  3024.         case 0:
  3025.         {
  3026.             his_offline[id] = 1
  3027.             client_print_color(id,"%s^4%s^1 disconnected from the duel list.",CHAT_TAG,his_name[id])
  3028.         }
  3029.         default:
  3030.     {
  3031.         his_offline[id] = 0
  3032.         client_print_color(id,"%s^4%s^1 connected to the duel list.",CHAT_TAG,his_name[id])
  3033.     }
  3034. }
  3035. }
  3036.  
  3037. public give_up_player(id)
  3038. {
  3039. if(is_user_connected(his_challenger[id]))
  3040. {
  3041.     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]])
  3042.     if(arena_number[id] == arena_number[his_challenger[id]])
  3043.         remove_the_arena(arena_number[id] +ARENA_CODE)
  3044.         back_to_the_spawn(id)
  3045.         back_to_the_spawn(his_challenger[id])
  3046.         reset_values(his_challenger[id])
  3047.     }
  3048.     reset_values(id)
  3049. }
  3050.  
  3051. public give_up_rush_player(id)
  3052. {
  3053.     if(is_user_connected(the_challenger[id]))
  3054.     {
  3055.         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]])
  3056.         if(rush_arena_number[id] == rush_arena_number[the_challenger[id]])
  3057.             remove_the_rush_arena(rush_arena_number[id] +RUSH_ARENA_CODE)
  3058.         back_to_the_rush_spawn(id)
  3059.         back_to_the_rush_spawn(the_challenger[id])
  3060.         reset_player_values(the_challenger[id])
  3061.     }
  3062.     reset_player_values(id)
  3063. }
  3064.  
  3065.  
  3066. public reward_winner(id)
  3067. {
  3068.     if(is_user_connected(id))
  3069.     {
  3070.         give_item(id, "weapon_hegrenade")
  3071.         gBackStabing[id] = false;
  3072.        
  3073.         client_print_color(id,"%s^4Congratulations!!!^1, You have ^3won this battle^1!",CHAT_TAG)
  3074.         if(SOUNDS_ENABLED)
  3075.             client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[0])
  3076.         /*if(cs_get_user_money(id)+15000 <= 16000)
  3077.     {
  3078.         cs_set_user_money(id,cs_get_user_money(id)+15000,1)
  3079.     } else cs_set_user_money(id,16000,1)*/
  3080. }
  3081. }
  3082.  
  3083. public reward_rush_winner(id)
  3084. {
  3085. if(is_user_connected(id))
  3086. {
  3087.     // here you can reward the winner with something
  3088.     client_print_color(id,"%s^4Congratulations!!!^1, You have ^3won this battle^1!",RUSH_TAG)
  3089.     if(SOUNDS_RUSH_ENABLED)
  3090.         client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[0])
  3091.         if(cs_get_user_money(id)+15000 <= 16000)
  3092.         {
  3093.             cs_set_user_money(id,cs_get_user_money(id)+15000,1)
  3094.             //client_print_color(id,"%s^4You've earned ^3$15000^4!",RUSH_TAG)
  3095.         } else cs_set_user_money(id,16000,1)
  3096.     }
  3097. }
  3098.  
  3099.  
  3100. public reward_loser(id)
  3101. {
  3102.     if(is_user_connected(id))
  3103.     {
  3104.         back_to_the_spawn(id)
  3105.         gBackStabing[id] = false;
  3106.         client_print_color(id,"%sYou've ^3lost this battle^1!",CHAT_TAG)
  3107.         if(SOUNDS_ENABLED)
  3108.             client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[1])
  3109.     }
  3110. }
  3111.  
  3112. public reward_rush_loser(id)
  3113. {
  3114.     if(is_user_connected(id))
  3115.     {
  3116.         // here you can reward the winner with something
  3117.         back_to_the_spawn(id)
  3118.         client_print_color(id,"%sYou've ^3lost this battle^1!",RUSH_TAG)
  3119.         if(SOUNDS_RUSH_ENABLED)
  3120.             client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[1])
  3121.         if(cs_get_user_money(id)-15000 >= 0)
  3122.         {
  3123.             cs_set_user_money(id,cs_get_user_money(id)-15000,1)
  3124.             //client_print_color(id,"%s^4You've lost ^3$15000^4!",RUSH_TAG)
  3125.         } else cs_set_user_money(id,0,1)
  3126.     }
  3127. }
  3128.  
  3129. public duel_players_lists(id)
  3130. {
  3131.     if(!is_user_alive(id))
  3132.     {
  3133.         client_print_color(id,"%sYou can't challenge anyone when you're ^3dead1.",CHAT_TAG)
  3134.         return PLUGIN_HANDLED
  3135.     }
  3136.     if(his_offline[id])
  3137.     {
  3138.         client_print_color(id,"%sYou can't challenge people when you're ^3offline^1.",CHAT_TAG)
  3139.         return PLUGIN_HANDLED
  3140.     }
  3141.     if(is_user_connected(his_challenger[id]))
  3142.     {
  3143.         client_print_color(id,"%s^4%s ^1is still ^4fighting against you^1.",CHAT_TAG,his_name[his_challenger[id]])
  3144.         return PLUGIN_HANDLED
  3145.     }
  3146.     if(is_user_connected(his_asker[id]))
  3147.     {
  3148.         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]])
  3149.         return PLUGIN_HANDLED
  3150.     }
  3151.     if(!available_duelers(id))
  3152.     {
  3153.         client_print_color(id,"%sThere's ^4nobody^1 you can challenge.",CHAT_TAG)
  3154.         return PLUGIN_HANDLED
  3155.     }
  3156.     if(is_in_rush[id] == 2)
  3157.     {
  3158.         return PLUGIN_HANDLED
  3159.     }
  3160.     if(get_next_arena() == -1)
  3161.     {
  3162.         client_print_color(id,"%s^4Maximum arenas reached.",CHAT_TAG)
  3163.         return PLUGIN_HANDLED
  3164.     }
  3165.     new menu,menuformat[64];
  3166.     formatex(menuformat,charsmax(menuformat),"\w[\rGlobal Knife\w] \yKnifeDuels ^n\dArenas Free: %d/%d \w",arenas_count(),total_arenas)
  3167.     menu = menu_create( menuformat, "Duel_handler" );
  3168.    
  3169.     new tempid;
  3170.    
  3171.     new szName[32], szUserId[32],nameu[92],CsTeams:team;
  3172.     formatex(nameu,charsmax(nameu), "\yRefresh");
  3173.     menu_additem(menu, nameu,"rf_c", 0);
  3174.     menu_addblank(menu,0)
  3175.    
  3176.     //get_players( players, pnum, "c" );
  3177.     for ( new e; e<MAXPLAYERS; e++ )
  3178.     {
  3179.         if(!is_user_connected(e))
  3180.             continue;
  3181.         tempid = e
  3182.         team = cs_get_user_team(tempid)
  3183.        
  3184.         if(tempid != id && team != CS_TEAM_SPECTATOR && team != CS_TEAM_UNASSIGNED)//  && !users_in_same_team(id,tempid))
  3185.     {
  3186.         get_user_name(tempid, szName, charsmax(szName));
  3187.         formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(tempid));
  3188.         if(his_offline[tempid])
  3189.         {
  3190.             formatex(nameu,charsmax(nameu), "%s \w[\dOffline\w]", szName);
  3191.             menu_additem(menu, nameu, szUserId, 0);
  3192.         }
  3193.         if(isBlocked[tempid][id])
  3194.         {
  3195.             formatex(nameu,charsmax(nameu), "%s \w[\rBlocked\w]", szName);
  3196.             menu_additem(menu, nameu, szUserId, 0);
  3197.         }
  3198.         else if(!is_user_alive(tempid))
  3199.         {
  3200.             formatex(nameu,charsmax(nameu), "\d%s [DEAD]", szName);
  3201.             menu_additem(menu, nameu, szUserId, 0);
  3202.         }
  3203.         else
  3204.         {
  3205.             if(is_in_duel[tempid] == 2)
  3206.             {
  3207.                 formatex(nameu,charsmax(nameu), "%s \w[\rIn Duel\w]", szName);
  3208.                 menu_additem(menu, nameu, szUserId, 0);
  3209.             }
  3210.             else if(is_in_rush[tempid] == 2)
  3211.             {
  3212.                 formatex(nameu,charsmax(nameu), "%s \w[\rIn Rush\w]", szName);
  3213.                 menu_additem(menu, nameu, szUserId, 0);
  3214.             }
  3215.             else if(is_in_duel[tempid] == 1)
  3216.             {
  3217.                 formatex(nameu,charsmax(nameu), "%s \w[\yPending\w]", szName);
  3218.                 menu_additem(menu, nameu, szUserId, 0);
  3219.             }
  3220.             else
  3221.             {
  3222.                 formatex(nameu,charsmax(nameu), "%s", szName);
  3223.                 menu_additem(menu, nameu, szUserId, 0);
  3224.             }
  3225.         }
  3226.     }
  3227. }
  3228.  
  3229. menu_display(id, menu, 0 );
  3230. return PLUGIN_HANDLED
  3231. }
  3232.  
  3233. public rush_players_list(id)
  3234. {
  3235. if(!is_user_alive(id))
  3236. {
  3237.     client_print_color(id,"%sYou can't challenge anyone when you're ^3dead1.",RUSH_TAG)
  3238.     return PLUGIN_HANDLED
  3239. }
  3240. if(his_offline[id])
  3241. {
  3242.     client_print_color(id,"%sYou can't challenge people when you're ^3offline^1.",RUSH_TAG)
  3243.     return PLUGIN_HANDLED
  3244. }
  3245. if(his_offline[id])
  3246. {
  3247.     client_print_color(id,"%sYou can't challenge people when you're ^3offline^1.",RUSH_TAG)
  3248.     return PLUGIN_HANDLED
  3249. }
  3250. if(is_user_connected(the_challenger[id]))
  3251. {
  3252.     client_print_color(id,"%s^4%s ^1is still ^4fighting against you^1.",RUSH_TAG,his_name[the_challenger[id]])
  3253.     return PLUGIN_HANDLED
  3254. }
  3255. if(is_user_connected(the_asker[id]))
  3256. {
  3257.     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]])
  3258.     return PLUGIN_HANDLED
  3259. }
  3260. if(!available_rush_duelers(id))
  3261. {
  3262.     client_print_color(id,"%sThere's ^4nobody^1 you can challenge.",RUSH_TAG)
  3263.     return PLUGIN_HANDLED
  3264. }
  3265. if(get_next_rush_arena() == -1)
  3266. {
  3267.     client_print_color(id,"%s^4Maximum arenas reached.",RUSH_TAG)
  3268.     return PLUGIN_HANDLED
  3269. }
  3270. if(is_in_duel[id] == 2)
  3271. {
  3272.     client_print_color(id,"%sThis player ^4already^1 played in Duel",RUSH_TAG)
  3273.     return PLUGIN_HANDLED
  3274. }
  3275. new menu,menuformat[64];
  3276. formatex(menuformat,charsmax(menuformat),"\w[\rGlobal Knife\w] \yKnifeRush ^n\dArenas Free: %d/%d \w",arenas_count_rush(),total_rush_arenas)
  3277. menu = menu_create( menuformat, "Rush_handler" );
  3278.  
  3279. new tempid;
  3280.  
  3281. new szName[32], szUserId[32],nameu[92],CsTeams:team;
  3282. formatex(nameu,charsmax(nameu), "\yRefresh");
  3283. menu_additem(menu, nameu,"rf_c", 0);
  3284. menu_addblank(menu,0)
  3285. //get_players( players, pnum, "c" );
  3286. for ( new e; e<MAX_RUSH_PLAYERS; e++ )
  3287. {
  3288.     if(!is_user_connected(e))
  3289.         continue;
  3290.         tempid = e
  3291.         team = cs_get_user_team(tempid)
  3292.        
  3293.         if(tempid != id && team != CS_TEAM_SPECTATOR && team != CS_TEAM_UNASSIGNED)//  && !users_in_same_team(id,tempid))
  3294.     {
  3295.         get_user_name(tempid, szName, charsmax(szName));
  3296.         formatex(szUserId, charsmax(szUserId), "%d", get_user_userid(tempid));
  3297.         if(his_offline[tempid])
  3298.         {
  3299.             formatex(nameu,charsmax(nameu), "%s \w[\dOffline Duel\w]", szName);
  3300.             menu_additem(menu, nameu, szUserId, 0);
  3301.         }
  3302.         if(isBlocked[tempid][id])
  3303.         {
  3304.             formatex(nameu,charsmax(nameu), "%s \w[\rBlocked\w]", szName);
  3305.             menu_additem(menu, nameu, szUserId, 0);
  3306.         }
  3307.         else if(his_offline[tempid])
  3308.         {    
  3309.             formatex(nameu,charsmax(nameu), "%s \w[\dOffline Rush\w]", szName);
  3310.             menu_additem(menu, nameu, szUserId, 0);
  3311.         }
  3312.         else if(!is_user_alive(tempid))
  3313.         {
  3314.             formatex(nameu,charsmax(nameu), "\d%s [DEAD]", szName);
  3315.             menu_additem(menu, nameu, szUserId, 0);
  3316.         }
  3317.         else
  3318.         {
  3319.             if(is_in_rush[tempid] == 2)
  3320.             {
  3321.                 formatex(nameu,charsmax(nameu), "%s \w[\rInRush\w]", szName);
  3322.                 menu_additem(menu, nameu, szUserId, 0);
  3323.             }
  3324.             else if(is_in_duel[tempid] == 2)
  3325.             {
  3326.                 formatex(nameu,charsmax(nameu), "%s \w[\rInDuel\w]", szName);
  3327.                 menu_additem(menu, nameu, szUserId, 0);
  3328.             }
  3329.             else if(is_in_rush[tempid] == 1)
  3330.             {
  3331.                 formatex(nameu,charsmax(nameu), "%s \w[\yPending\w]", szName);
  3332.                 menu_additem(menu, nameu, szUserId, 0);
  3333.             }
  3334.             else
  3335.             {
  3336.                 formatex(nameu,charsmax(nameu), "%s", szName);
  3337.                 menu_additem(menu, nameu, szUserId, 0);
  3338.             }
  3339.         }
  3340.     }
  3341. }
  3342.  
  3343. menu_display(id, menu, 0 );
  3344. return PLUGIN_HANDLED
  3345. }
  3346.  
  3347. public Duel_handler( id, menu, item )
  3348. {
  3349. if ( item == MENU_EXIT )
  3350. {
  3351.     menu_destroy( menu );
  3352.     return PLUGIN_HANDLED;
  3353. }
  3354.  
  3355. new szData[32], szName[64];
  3356. new _access, item_callback;
  3357. menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  3358. if(equali(szData,"rf_c"))
  3359. {
  3360.     menu_destroy( menu );
  3361.     duel_players_lists(id)
  3362.     return PLUGIN_CONTINUE
  3363. }
  3364. new userid = str_to_num( szData );
  3365. //spam_hud(id)
  3366. new enem = find_player("k", userid); // flag "k" : find player from userid
  3367. if (is_user_connected(enem))
  3368. {
  3369.     if(!is_user_alive(enem))
  3370.     {
  3371.         client_print_color(id,"%sYou can't challenge dead players.",CHAT_TAG)
  3372.     }
  3373.     else if(his_offline[enem])
  3374.     {
  3375.         client_print_color(id,"%sYou can't challenge offline players.",CHAT_TAG)
  3376.     }
  3377.     if(isBlocked[enem][id])
  3378.     {
  3379.         client_print_color(id,"%sThis user blocked you!",CHAT_TAG)
  3380.     }
  3381.     else if(is_in_rush[enem] == 2)
  3382.     {
  3383.         client_print_color(id,"%sYou can't challenge Rush players.",CHAT_TAG)
  3384.     }
  3385.     else
  3386.     {
  3387.         if(!is_in_duel[enem])
  3388.         {
  3389.             //spam_hud(enem)
  3390.             is_in_duel[enem] = 1
  3391.             is_in_duel[id] = 1
  3392.             his_asker[id] = enem
  3393.             his_asker[enem] = id
  3394.             ask_player(enem)
  3395.             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])
  3396.            
  3397.             set_task(10.0,"taken_long",id)
  3398.         }
  3399.         else
  3400.         {
  3401.             client_print_color(id,"%s^4%s^1 seems ^3to be busy ^1with ^4another duel^1..",CHAT_TAG,his_name[enem])
  3402.         }
  3403.     }
  3404. }
  3405. menu_destroy( menu );
  3406. return PLUGIN_CONTINUE;
  3407. }
  3408.  
  3409. public Rush_handler( id, menu, item )
  3410. {
  3411. if ( item == MENU_EXIT )
  3412. {
  3413.     menu_destroy( menu );
  3414.     return PLUGIN_HANDLED;
  3415. }
  3416.  
  3417. new szData[32], szName[64];
  3418. new _access, item_callback;
  3419. menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  3420. if(equali(szData,"rf_c"))
  3421. {
  3422.     menu_destroy( menu );
  3423.     rush_players_list(id)
  3424.     return PLUGIN_CONTINUE
  3425. }
  3426. new userid = str_to_num( szData );
  3427. //spam_hud(id)
  3428. new enem = find_player("k", userid); // flag "k" : find player from userid
  3429. if (is_user_connected(enem))
  3430. {
  3431.     if(his_offline[enem])
  3432.     {
  3433.         client_print_color(id,"%sYou can't challenge offline players.",RUSH_TAG)
  3434.     }
  3435.     else if(his_offline[enem])
  3436.     {
  3437.         client_print_color(id,"%sYou can't challenge offline players.",RUSH_TAG)
  3438.     }
  3439.     if(isBlocked[enem][id])
  3440.     {
  3441.         client_print_color(id,"%sThis user blocked you!",CHAT_TAG)
  3442.     }
  3443.     else if(is_in_duel[enem] == 2)
  3444.     {
  3445.         client_print_color(id,"%sYou can't challenge Duel players.",RUSH_TAG)
  3446.     }
  3447.     else
  3448.     {
  3449.         if(!is_in_rush[enem])
  3450.         {
  3451.             //spam_hud(enem)
  3452.             is_in_rush[enem] = 1
  3453.             is_in_rush[id] = 1
  3454.             the_asker[id] = enem
  3455.             the_asker[enem] = id
  3456.             ask_rush_player(enem)
  3457.             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])
  3458.            
  3459.             set_task(10.0,"taken_rush_long",id)
  3460.         }
  3461.         else
  3462.         {
  3463.             client_print_color(id,"%s^4%s^1 seems to be busy with another duel..",RUSH_TAG,his_name[enem])
  3464.         }
  3465.     }
  3466. }
  3467. menu_destroy( menu );
  3468. return PLUGIN_CONTINUE;
  3469. }
  3470.  
  3471. public taken_long(id)
  3472. {
  3473. if(is_in_duel[id] == 1)
  3474. {
  3475.     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])
  3476.     user_can_spawn[id] = 1
  3477.     user_can_spawn[his_asker[id]] = 1
  3478.     reset_values(his_asker[id])
  3479.     reset_values(id)
  3480.     show_menu(his_asker[id], 0, "^n", 1)
  3481. }
  3482. }
  3483.  
  3484.  
  3485. public taken_rush_long(id)
  3486. {
  3487. if(is_in_rush[id] == 1)
  3488. {
  3489.     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])
  3490.     reset_player_values(the_asker[id])
  3491.     reset_player_values(id)
  3492.     show_menu(the_asker[id], 0, "^n", 1)
  3493. }
  3494. }
  3495.  
  3496.  
  3497. stock available_duelers(asker)
  3498. {
  3499. new num;
  3500. num = 0 // just incase...
  3501. for(new id;id < MAXPLAYERS;id++)
  3502. {
  3503.     if(is_user_alive(id))
  3504.     {
  3505.         if(/*!is_in_duel[id] && */id != asker && !is_user_bot(id))
  3506.         {
  3507.             num++
  3508.         }
  3509.     }
  3510. }
  3511. return num
  3512. }
  3513.  
  3514. stock available_rush_duelers(asker)
  3515. {
  3516. new num;
  3517. num = 0 // just incase...
  3518. for(new id;id < MAX_RUSH_PLAYERS;id++)
  3519. {
  3520.     if(is_user_alive(id))
  3521.     {
  3522.         if(/*!is_in_rush[id] && */id != asker && !is_user_bot(id))
  3523.         {
  3524.             num++
  3525.         }
  3526.     }
  3527. }
  3528. return num
  3529. }
  3530.  
  3531. public ask_player(id)
  3532. {
  3533. if(!is_user_alive(id))
  3534. {
  3535.     return PLUGIN_HANDLED
  3536. }
  3537. new asker_name[32],menu_title[64];
  3538. get_user_name(his_asker[id],asker_name,charsmax(asker_name))
  3539. formatex(menu_title,charsmax(menu_title),"\rAccept Duel \y%s\r %s ?",asker_name ,PartTypes(All_Configs[his_asker[id]][Types_On]))
  3540. new menu
  3541. menu = menu_create( menu_title, "Ask_handler" );
  3542.  
  3543. menu_additem(menu, "Yes!", "user_said_yes", 0);
  3544. menu_additem(menu, "No!","user_said_no", 0);
  3545.  
  3546. menu_display(id, menu, 0 );
  3547. return PLUGIN_HANDLED
  3548. }
  3549.  
  3550. public ask_rush_player(id)
  3551. {
  3552. if(!is_user_alive(id))
  3553. {
  3554.     return PLUGIN_HANDLED
  3555. }
  3556. new asker_name[32],menu_title[64];
  3557. get_user_name(the_asker[id],asker_name,charsmax(asker_name))
  3558. formatex(menu_title,charsmax(menu_title),"\rAccept Rush \y%s\r %s ?",asker_name ,PartTypes(All_Configs[the_asker[id]][Types_On]))
  3559. new menu
  3560. menu = menu_create( menu_title, "Ask_rush_handler" );
  3561.  
  3562. menu_additem(menu, "Sure!", "user_said_yes", 0);
  3563. menu_additem(menu, "Nope!","user_said_no", 0);
  3564.  
  3565. menu_display(id, menu, 0 );
  3566. return PLUGIN_HANDLED
  3567. }
  3568.  
  3569. public Ask_handler( id, menu, item )
  3570. {
  3571. if ( item == MENU_EXIT )
  3572. {
  3573.     menu_destroy( menu );
  3574.     return PLUGIN_HANDLED;
  3575. }
  3576.  
  3577. new szData[32], szName[64];
  3578. new _access, item_callback;
  3579. menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  3580.  
  3581. if(!is_user_alive(id))
  3582. {
  3583.     client_print_color(id,"%sDuel challenge ^3canceled^1, ^4You're ^1dead..",CHAT_TAG)
  3584.     client_print_color(his_asker[id],"%sDuel challenge ^3canceled^1,^4 %s ^1is dead..",CHAT_TAG,his_name[his_asker[his_asker[id]]])
  3585.     reset_values(his_asker[id])
  3586.     reset_values(id)
  3587. }
  3588. else if(equali(szData,"user_said_yes"))
  3589. {
  3590.     if(get_next_arena() == -1)
  3591.     {
  3592.         client_print_color(his_asker[id],"%sMaximum arenas reached.",CHAT_TAG)
  3593.         reset_values(his_asker[id])
  3594.         reset_values(id)
  3595.     }
  3596.     else if(is_in_duel[his_asker[id]] == 1)
  3597.     {
  3598.         manage_battle(id)
  3599.         check_teams(id,his_challenger[id])
  3600.         begin_the_battle(id,his_challenger[id])
  3601.     } else
  3602. {
  3603.     client_print_color(id,"%s%s either canceled the duel or chosen someone else to duel.",CHAT_TAG,his_name[his_asker[id]])
  3604.     reset_values(his_asker[id])
  3605.     reset_values(id)
  3606. }
  3607. }
  3608. else if(equali(szData,"user_said_no"))
  3609. {
  3610. if(is_user_connected(his_asker[id]))
  3611. {
  3612.     //client_print_color(0,"%s^4%s ^1rejected ^4%s^1's challenge.",CHAT_TAG,his_name[id],his_name[his_asker[id]])
  3613.     reset_values(his_asker[id])
  3614.     reset_values(id)
  3615. }
  3616.  
  3617. }
  3618. menu_destroy( menu );
  3619. return PLUGIN_CONTINUE;
  3620. }
  3621.  
  3622. public Ask_rush_handler( id, menu, item )
  3623. {
  3624. if ( item == MENU_EXIT )
  3625. {
  3626. menu_destroy( menu );
  3627. return PLUGIN_HANDLED;
  3628. }
  3629.  
  3630. new szData[32], szName[64];
  3631. new _access, item_callback;
  3632. menu_item_getinfo( menu, item, _access, szData,charsmax( szData ), szName,charsmax( szName ), item_callback );
  3633.  
  3634. if(equali(szData,"user_said_yes"))
  3635. {
  3636. if(get_next_rush_arena() == -1)
  3637. {
  3638.     client_print_color(the_asker[id],"%sMaximum arenas reached.",RUSH_TAG)
  3639.     reset_player_values(the_asker[id])
  3640.     reset_player_values(id)
  3641. }
  3642. else if(is_in_rush[the_asker[id]] == 1)
  3643. {
  3644.     manage_rush_battle(id)
  3645.     check_rush_teams(id,the_challenger[id])
  3646.     begin_the_rush_battle(id,the_challenger[id])
  3647. } else
  3648. {
  3649. client_print_color(id,"%s%s either canceled the duel or chosen someone else to duel.",RUSH_TAG,his_name[the_asker[id]])
  3650. reset_player_values(the_asker[id])
  3651. reset_player_values(id)
  3652. }
  3653. }
  3654. else if(equali(szData,"user_said_no"))
  3655. {
  3656. if(is_user_connected(the_asker[id]))
  3657. {
  3658. //client_print_color(0,"%s^4%s^3 rejected ^4%s^3's challenge.",RUSH_TAG,his_name[id],his_name[the_asker[id]])
  3659. reset_player_values(the_asker[id])
  3660. reset_player_values(id)
  3661. }
  3662.  
  3663. }
  3664. menu_destroy( menu );
  3665. return PLUGIN_CONTINUE;
  3666. }
  3667.  
  3668. public Player_Killed(victim, attacker, shouldgib)
  3669. {
  3670. if(!is_user_connected(victim))
  3671. return
  3672.  
  3673. if(is_in_duel[victim] != 2)
  3674. return
  3675.  
  3676. if(is_user_connected(his_challenger[victim]) && !is_user_connected(attacker))
  3677. {
  3678.     if(!check_teams(victim,attacker))
  3679.         return
  3680.     }
  3681.     if(!is_user_connected(attacker))
  3682.         return
  3683.    
  3684.     if(attacker == victim)
  3685.         return
  3686.    
  3687.     if(is_in_duel[attacker] != 2 || is_in_duel[victim] != 2)
  3688.         return
  3689.    
  3690.     if(his_challenger[victim] == attacker || his_challenger[attacker] == victim )
  3691.     {
  3692.         his_wins[attacker]++
  3693.        
  3694.         rounds[arena_number[attacker]]++
  3695.         static ret;
  3696.         ExecuteForward(killed_forward, ret, attacker,victim)
  3697.        
  3698.         if(Head_shot[attacker][victim])
  3699.         {
  3700.             his_HS[attacker]++
  3701.             client_cmd(0,"spk ^"%s^"",DUEL_SOUNDS[5])
  3702.             Head_shot[attacker][victim] = false
  3703.         }
  3704.         if(rounds[arena_number[attacker]] >= MAX_ROUNDS || his_wins[attacker] >= MAX_KILLS)
  3705.         {
  3706.             if(!get_non_duelers_alive())
  3707.             {
  3708.                 ExecuteHamB(Ham_CS_RoundRespawn, victim)
  3709.                 Check_Results(attacker,victim)
  3710.                 return
  3711.             }
  3712.             else
  3713.             {
  3714.                 ExecuteHamB(Ham_CS_RoundRespawn, victim)
  3715.                 Check_Results(attacker,victim)
  3716.             }
  3717.         }
  3718.         else
  3719.         {
  3720.             wait_for_enemy_loop(attacker)
  3721.         }
  3722.         Set_Entity_Invisible(victim, 1)
  3723.         set_task(0.1,"delay_respawn",victim)
  3724.         return
  3725.     }
  3726.     return
  3727. }
  3728.  
  3729.  
  3730. public Player_Rush_Killed(victim, attacker)
  3731. {
  3732.     if(!is_user_connected(victim))
  3733.         return //HAM_IGNORED;
  3734.     if(is_user_connected(the_challenger[victim]) && !is_user_connected(attacker))
  3735.     {
  3736.         if(!check_rush_teams(victim,attacker))
  3737.             return //HAM_IGNORED
  3738.     }
  3739.     if(!is_user_connected(attacker))
  3740.         return //HAM_IGNORED
  3741.    
  3742.     if(attacker == victim)
  3743.         return //HAM_IGNORED
  3744.    
  3745.     if(is_in_rush[attacker] != 2 || is_in_rush[victim] != 2)
  3746.         return //HAM_IGNORED
  3747.    
  3748.     if(the_challenger[victim] == attacker || the_challenger[attacker] == victim )
  3749.     {
  3750.         the_wins[attacker]++
  3751.         rush_rounds[rush_arena_number[attacker]]++
  3752.        
  3753.         static Float:FOrigin3[3]
  3754.         pev(victim, pev_origin, FOrigin3)
  3755.        
  3756.         engfunc(EngFunc_MessageBegin, MSG_PVS, SVC_TEMPENTITY, FOrigin3, 0)
  3757.         write_byte(TE_IMPLOSION)
  3758.         engfunc(EngFunc_WriteCoord, FOrigin3[0])
  3759.         engfunc(EngFunc_WriteCoord, FOrigin3[1])
  3760.         engfunc(EngFunc_WriteCoord, FOrigin3[2])
  3761.         write_byte(200)
  3762.         write_byte(100)
  3763.         write_byte(5)  
  3764.         message_end()
  3765.        
  3766.         if(Headshot[attacker][victim])
  3767.         {
  3768.             THE_HS[attacker]++
  3769.             Headshot[attacker][victim] = false
  3770.         }
  3771.         user_silentkill(victim)
  3772.         if(rush_rounds[rush_arena_number[attacker]] >= MAX_USER_RUSH_ROUNDS || the_wins[attacker] >= MAX_USER_KILLS)
  3773.         {
  3774.             if(!get_non_rushers_alive())
  3775.             {
  3776.                 ExecuteHamB(Ham_CS_RoundRespawn, victim)
  3777.                 Check_Rush_Results(attacker,victim)
  3778.                 return //HAM_SUPERCEDE
  3779.             }
  3780.             else
  3781.             {
  3782.                 ExecuteHamB(Ham_CS_RoundRespawn, victim)
  3783.                 Check_Rush_Results(attacker,victim)
  3784.             }
  3785.         }
  3786.         else
  3787.         {
  3788.             rush_wait_for_enemy_loop(attacker)
  3789.             //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)
  3790.             //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)
  3791.         }
  3792.         Set_Entity_Invisible(victim, 1)
  3793.         set_task(0.1,"delay_rush_respawn",victim)
  3794.         return //HAM_SUPERCEDE
  3795.     }
  3796.     return //HAM_IGNORED
  3797. }
  3798.  
  3799. public delay_respawn(id)
  3800. {
  3801.     if(is_user_connected(id))
  3802.     {
  3803.         if(!is_user_alive(id))
  3804.         {
  3805.             if(is_in_duel[id] == 2)
  3806.             {
  3807.                 user_can_spawn[id] = 1
  3808.                 ExecuteHamB(Ham_CS_RoundRespawn, id)
  3809.                 user_can_spawn[id] = 0
  3810.                 }else{
  3811.                 user_can_spawn[id] = 1
  3812.                 ExecuteHamB(Ham_CS_RoundRespawn, id)
  3813.             }
  3814.         }
  3815.         Set_Entity_Invisible(id, 0)
  3816.     }
  3817.     return PLUGIN_CONTINUE
  3818. }
  3819.  
  3820. public delay_rush_respawn(id)
  3821. {
  3822.     if(is_user_connected(id))
  3823.     {
  3824.         if(!is_user_alive(id))
  3825.         {
  3826.             ExecuteHamB(Ham_CS_RoundRespawn, id)
  3827.         }
  3828.         Set_Entity_Invisible(id, 0)
  3829.     }
  3830.     return PLUGIN_CONTINUE
  3831. }
  3832.  
  3833. public Check_Results(id,enemy)
  3834. {
  3835.     reset_teams(id)
  3836.     reset_teams(enemy)
  3837.     new id_name[64],enemy_name[64];
  3838.     get_user_name(id,id_name,charsmax(id_name))
  3839.     get_user_name(enemy,enemy_name,charsmax(enemy_name))
  3840.     new mapname[32]
  3841.     get_mapname(mapname,31)
  3842.    
  3843.     if(his_wins[id] > his_wins[enemy])
  3844.     {
  3845.         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])
  3846.        
  3847.         reward_winner(id)
  3848.         reward_loser(enemy)
  3849.     }
  3850.     else if(his_wins[enemy] > his_wins[id])
  3851.     {
  3852.         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])
  3853.         reward_winner(enemy)
  3854.         reward_loser(id)
  3855.     }
  3856.     else
  3857.     {
  3858.         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)
  3859.         if(SOUNDS_ENABLED)
  3860.         {
  3861.             client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[2])
  3862.             client_cmd(enemy,"spk ^"%s^"",DUEL_SOUNDS[2])
  3863.         }
  3864.         if(his_wins[id] == his_wins[enemy])
  3865.         {
  3866.             user_kill(id,1)
  3867.             user_kill(enemy,1)
  3868.         }
  3869.     }
  3870.     //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])
  3871.     if(arena_number[id] == arena_number[enemy])
  3872.         remove_the_arena(arena_number[id] +ARENA_CODE)
  3873.     back_to_the_spawn(id)
  3874.     back_to_the_spawn(enemy)
  3875.     reset_values(enemy)
  3876.     reset_values(id)
  3877.    
  3878. }
  3879.  
  3880. public Check_Rush_Results(id,enemy)
  3881. {
  3882.     reset_rush_teams(id)
  3883.     reset_rush_teams(enemy)
  3884.     new id_name[64],enemy_name[64];
  3885.     get_user_name(id,id_name,charsmax(id_name))
  3886.     get_user_name(enemy,enemy_name,charsmax(enemy_name))
  3887.     if(the_wins[id] > the_wins[enemy])
  3888.     {
  3889.         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])
  3890.         reward_rush_winner(id)
  3891.         reward_rush_loser(enemy)
  3892.     }
  3893.     else if(the_wins[enemy] > the_wins[id])
  3894.     {
  3895.         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])
  3896.         reward_rush_winner(enemy)
  3897.         reward_rush_loser(id)
  3898.     }
  3899.     else
  3900.     {
  3901.         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])
  3902.         if(SOUNDS_RUSH_ENABLED)
  3903.         {
  3904.             client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[2])
  3905.             client_cmd(enemy,"spk ^"%s^"",RUSH_SOUNDS[2])
  3906.         }
  3907.         if(the_wins[id] == the_wins[enemy])
  3908.         {
  3909.             user_kill(id,1)
  3910.             user_kill(enemy,1)
  3911.         }
  3912.     }
  3913.     //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])
  3914.     if(rush_arena_number[id] == rush_arena_number[enemy])
  3915.         remove_the_rush_arena(rush_arena_number[id] +RUSH_ARENA_CODE)
  3916.     back_to_the_rush_spawn(id)
  3917.     back_to_the_rush_spawn(enemy)
  3918.     reset_player_values(enemy)
  3919.     reset_player_values(id)
  3920.    
  3921. }
  3922.  
  3923. public back_to_the_spawn(id)
  3924. {
  3925.     if(is_user_alive(id))
  3926.     {
  3927.         entity_set_origin(id,his_original_spawn[id])
  3928.         Set_Entity_Invisible(id, 0)
  3929.         set_user_health(id,map_default_hp)
  3930.     }
  3931.     set_user_armor(id,0)
  3932.     set_user_godmode(id, 0)
  3933. }
  3934.  
  3935. public back_to_the_rush_spawn(id)
  3936. {
  3937.     if(is_user_alive(id))
  3938.     {
  3939.         entity_set_origin(id,his_original_player_spawn[id])
  3940.         Set_Entity_Invisible(id, 0)
  3941.         set_user_health(id,the_default_hp)
  3942.     }
  3943.     set_user_armor(id,0)
  3944.     set_user_godmode(id, 0)
  3945. }
  3946.  
  3947.  
  3948.  
  3949. public manage_battle(id)
  3950. {
  3951.     is_in_duel[id] = 2
  3952.     his_challenger[id] = his_asker[id]
  3953.     his_challenger[his_challenger[id]] = id
  3954.     is_in_duel[his_challenger[id]] = 2
  3955.     his_asker[id] = 0
  3956.     his_wins[id] = 0
  3957.     user_can_spawn[id] = 0
  3958.     his_wins[his_challenger[id]] = 0
  3959.     new aren_code = get_next_arena()
  3960.     arena_number[id] = aren_code
  3961.     arena_number[his_challenger[id]] = aren_code
  3962.     rounds[aren_code] = 0
  3963.     new CsTeams:teamid,CsTeams:teamenemy;
  3964.     teamid = cs_get_user_team(id)
  3965.     teamenemy = cs_get_user_team(his_challenger[id])
  3966.     if(teamid == CS_TEAM_T)
  3967.     {
  3968.         his_previous_team[id] = 2
  3969.     }
  3970.     else if(teamid == CS_TEAM_CT)
  3971.     {
  3972.         his_previous_team[id] = 1
  3973.     }
  3974.     else his_previous_team[id] = 0
  3975.    
  3976.     if(teamenemy == CS_TEAM_T)
  3977.     {
  3978.         his_previous_team[his_challenger[id]] = 2
  3979.     }
  3980.     else if(teamenemy == CS_TEAM_CT)
  3981.     {
  3982.         his_previous_team[his_challenger[id]] = 1
  3983.     }
  3984.     else his_previous_team[his_challenger[id]] = 0
  3985.     start_build(his_challenger[id])
  3986.     if(SOUNDS_ENABLED)
  3987.     {
  3988.         client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[4])
  3989.         client_cmd(his_challenger[id],"spk ^"%s^"",DUEL_SOUNDS[4])
  3990.     }
  3991.     battle_timer(id)
  3992.     battle_timer(his_challenger[id])
  3993.    
  3994.     strip_user_weapons(his_challenger[id])
  3995.     give_item(his_challenger[id],"weapon_knife")
  3996.     //client_print_color(0,"%s^4%s^1 accepted ^4%s^1's challenge!",CHAT_TAG,his_name[id],his_name[his_challenger[id]])
  3997. }
  3998.  
  3999.  
  4000. public manage_rush_battle(id)
  4001. {
  4002.     is_in_rush[id] = 2
  4003.     the_challenger[id] = the_asker[id]
  4004.     the_challenger[the_challenger[id]] = id
  4005.     is_in_rush[the_challenger[id]] = 2
  4006.     the_asker[id] = 0
  4007.     the_wins[id] = 0
  4008.     the_wins[the_challenger[id]] = 0
  4009.     new aren_code = get_next_rush_arena()
  4010.     rush_arena_number[id] = aren_code
  4011.     rush_arena_number[the_challenger[id]] = aren_code
  4012.     rush_rounds[aren_code] = 0
  4013.     new CsTeams:teamid,CsTeams:teamenemy;
  4014.     teamid = cs_get_user_team(id)
  4015.     teamenemy = cs_get_user_team(the_challenger[id])
  4016.     if(teamid == CS_TEAM_T)
  4017.     {
  4018.         his_previous_user_team[id] = 2
  4019.     }
  4020.     else if(teamid == CS_TEAM_CT)
  4021.     {
  4022.         his_previous_user_team[id] = 1
  4023.     }
  4024.     else his_previous_user_team[id] = 0
  4025.    
  4026.     if(teamenemy == CS_TEAM_T)
  4027.     {
  4028.         his_previous_user_team[the_challenger[id]] = 2
  4029.     }
  4030.     else if(teamenemy == CS_TEAM_CT)
  4031.     {
  4032.         his_previous_user_team[the_challenger[id]] = 1
  4033.     }
  4034.     else his_previous_user_team[the_challenger[id]] = 0
  4035.     start_rush_build(the_challenger[id])
  4036.     if(SOUNDS_RUSH_ENABLED)
  4037.     {
  4038.         client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[4])
  4039.         client_cmd(the_challenger[id],"spk ^"%s^"",RUSH_SOUNDS[4])
  4040.     }
  4041.     battle_rush_timer(id)
  4042.     battle_rush_timer(the_challenger[id])
  4043.     //hud_displayer(id)
  4044.     //hud_displayer(the_challenger[id])
  4045.     //client_print_color(0,"%s^4%s^3 accepted ^4%s^3's challenge!",RUSH_TAG,his_name[id],his_name[the_challenger[id]])
  4046. }
  4047.  
  4048.  
  4049. public begin_the_battle(id,enemy)
  4050. {
  4051.     start_new_round(id,enemy)
  4052. }
  4053.  
  4054. public begin_the_rush_battle(id,enemy)
  4055. {
  4056.     start_new_rush_round(id,enemy)
  4057. }
  4058.  
  4059. public start_new_round(id,enemy)
  4060. {
  4061.     his_timer[id] = 0
  4062.     his_timer[enemy] = 0
  4063.     is_frozen[id] = 1
  4064.     is_frozen[enemy] = 1
  4065.     his_countdown[id] = MAX_COUNTDOWN
  4066.     his_countdown[enemy] = MAX_COUNTDOWN
  4067.     countdown(id)
  4068.     countdown(enemy)
  4069.     strip_user_weapons(his_challenger[id])
  4070.     give_item(his_challenger[id],"weapon_knife")
  4071.     strip_user_weapons(his_challenger[enemy])
  4072.     give_item(his_challenger[enemy],"weapon_knife")
  4073. }
  4074.  
  4075. public start_new_rush_round(id,enemy)
  4076. {
  4077.     the_timer[id] = 0
  4078.     the_timer[enemy] = 0
  4079.     is_user_frozen[id] = 1
  4080.     is_user_frozen[enemy] = 1
  4081.     his_rush_countdown[id] = MAX_USER_COUNTDOWN
  4082.     his_rush_countdown[enemy] = MAX_USER_COUNTDOWN
  4083.     rushcountdown(id)
  4084.     rushcountdown(enemy)
  4085. }
  4086.  
  4087. public countdown(id)
  4088. {
  4089.     if(is_user_connected(id))
  4090.     {
  4091.         his_countdown[id]--
  4092.         if(0 >= his_countdown[id])
  4093.         {
  4094.             is_frozen[id] = 0
  4095.             unfreeze_player(id)
  4096.             if(SOUNDS_ENABLED)
  4097.                 client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[6])
  4098.             client_print(id,print_center,"Fight!")
  4099.             return PLUGIN_HANDLED
  4100.         }
  4101.         else
  4102.         {
  4103.             freeze_player(id)
  4104.             if(SOUNDS_ENABLED)
  4105.                 client_cmd(id,"spk ^"%s^"",DUEL_SOUNDS[5])
  4106.             client_print(id,print_center,"%d",his_countdown[id])
  4107.             if(!is_frozen[id]) // we prevent it from spamming
  4108.                 is_frozen[id] = 1
  4109.         }
  4110.         set_task(1.0,"countdown",id)
  4111.     }
  4112.     return PLUGIN_CONTINUE
  4113. }
  4114.  
  4115. public rushcountdown(id)
  4116. {
  4117.     if(is_user_connected(id))
  4118.     {
  4119.         his_rush_countdown[id]--
  4120.         if(0 >= his_rush_countdown[id])
  4121.         {
  4122.             is_user_frozen[id] = 0
  4123.             unfreeze_player(id)
  4124.             if(SOUNDS_RUSH_ENABLED)
  4125.                 client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[6])
  4126.             client_print(id,print_center,"Fight!")
  4127.             return PLUGIN_HANDLED
  4128.         }
  4129.         else
  4130.         {
  4131.             freeze_player(id)
  4132.             if(SOUNDS_RUSH_ENABLED)
  4133.                 client_cmd(id,"spk ^"%s^"",RUSH_SOUNDS[5])
  4134.             client_print(id,print_center,"%d",his_rush_countdown[id])
  4135.             if(!is_user_frozen[id]) // we prevent it from spamming
  4136.                 is_user_frozen[id] = 1
  4137.         }
  4138.         set_task(1.0,"rushcountdown",id)
  4139.     }
  4140.     return PLUGIN_CONTINUE
  4141. }
  4142.  
  4143. public reset_teams(id)
  4144. {
  4145.     if(his_previous_team[id] == 1)
  4146.     {
  4147.         cs_set_user_team(id,CS_TEAM_CT)
  4148.     }
  4149.     else if(his_previous_team[id] == 2)
  4150.     {
  4151.         cs_set_user_team(id,CS_TEAM_T)
  4152.     }
  4153.     return PLUGIN_CONTINUE
  4154. }
  4155.  
  4156. public reset_rush_teams(id)
  4157. {
  4158.     if(his_previous_user_team[id] == 1)
  4159.     {
  4160.         cs_set_user_team(id,CS_TEAM_CT)
  4161.     }
  4162.     else if(his_previous_user_team[id] == 2)
  4163.     {
  4164.         cs_set_user_team(id,CS_TEAM_T)
  4165.     }
  4166.     return PLUGIN_CONTINUE
  4167. }
  4168.  
  4169. public check_teams(id,enemy)
  4170. {
  4171.     if(!is_user_connected(id) || !is_user_connected(enemy))
  4172.         return PLUGIN_CONTINUE;
  4173.     new CsTeams:teamid,CsTeams:teamenemy;
  4174.     teamid = cs_get_user_team(id)
  4175.     teamenemy = cs_get_user_team(enemy)
  4176.     if(!users_in_same_team(id,enemy) && !is_in_false_team(id) && !is_in_false_team(enemy))
  4177.         return PLUGIN_HANDLED
  4178.     if(teamid == CS_TEAM_CT && teamenemy == CS_TEAM_CT )
  4179.     {
  4180.         cs_set_user_team(id,CS_TEAM_T)
  4181.     } else if(teamid == CS_TEAM_T && teamenemy == CS_TEAM_T)
  4182. {
  4183.     cs_set_user_team(id,CS_TEAM_CT)
  4184. }
  4185. else
  4186. {
  4187.     Check_Results(id,enemy)
  4188.     return PLUGIN_CONTINUE
  4189. }
  4190. return PLUGIN_HANDLED
  4191. }
  4192.  
  4193. public check_rush_teams(id,enemy)
  4194. {
  4195. new CsTeams:teamid,CsTeams:teamenemy;
  4196. teamid = cs_get_user_team(id)
  4197. teamenemy = cs_get_user_team(enemy)
  4198. if(!users_in_same_team(id,enemy) && !is_in_false_team(id) && !is_in_false_team(enemy))
  4199.     return PLUGIN_HANDLED
  4200.     if(teamid == CS_TEAM_CT && teamenemy == CS_TEAM_CT )
  4201.     {
  4202.         cs_set_user_team(id,CS_TEAM_T)
  4203.     } else if(teamid == CS_TEAM_T && teamenemy == CS_TEAM_T)
  4204. {
  4205.     cs_set_user_team(id,CS_TEAM_CT)
  4206. }
  4207. else
  4208. {
  4209.     Check_Rush_Results(id,enemy)
  4210.     return PLUGIN_CONTINUE
  4211. }
  4212. return PLUGIN_HANDLED
  4213. }
  4214.  
  4215. stock is_in_false_team(id)
  4216. {
  4217. if(cs_get_user_team(id) == CS_TEAM_SPECTATOR || cs_get_user_team(id) == CS_TEAM_UNASSIGNED)
  4218.     return PLUGIN_HANDLED
  4219.     return PLUGIN_CONTINUE
  4220. }
  4221. stock users_in_same_team(id,enemy)
  4222. {
  4223.     if(cs_get_user_team(id) == cs_get_user_team(enemy))
  4224.         return PLUGIN_HANDLED
  4225.     return PLUGIN_CONTINUE
  4226. }
  4227.  
  4228.  
  4229. stock get_next_arena()
  4230. {
  4231.     next_empty_arena = 0
  4232.     for(new id;id < MAXPLAYERS;id++)
  4233.     {
  4234.         if(is_user_connected(id))
  4235.         {
  4236.             if(arena_number[id] == next_empty_arena)
  4237.             {
  4238.                 next_empty_arena++
  4239.                 if(next_empty_arena > total_arenas)
  4240.                     return -1
  4241.             }
  4242.         }
  4243.     }
  4244.     if(next_empty_arena > total_arenas)
  4245.     {
  4246.         return -1
  4247.     }
  4248.     return next_empty_arena
  4249. }
  4250.  
  4251.  
  4252. stock get_next_rush_arena()
  4253. {
  4254.     next_empty_rush_arena = 0
  4255.     for(new id;id < MAX_RUSH_PLAYERS;id++)
  4256.     {
  4257.         if(is_user_connected(id))
  4258.         {
  4259.             if(rush_arena_number[id] == next_empty_rush_arena)
  4260.             {
  4261.                 next_empty_rush_arena++
  4262.                 if(next_empty_rush_arena > total_rush_arenas)
  4263.                     return -1
  4264.             }
  4265.         }
  4266.     }
  4267.     if(next_empty_rush_arena > total_rush_arenas)
  4268.     {
  4269.         return -1
  4270.     }
  4271.     return next_empty_rush_arena
  4272. }
  4273.  
  4274. stock reset_values(id)
  4275. {
  4276.     his_HS[id] = 0
  4277.     rounds[arena_number[id]] = 0
  4278.     is_in_duel[id] = 0
  4279.     his_challenger[id] = 0
  4280.     his_asker[id] = 0
  4281.     arena_number[id] = 0
  4282.     his_wins[id] = 0
  4283.     got_spawn[id] = 0
  4284.     his_timer[id] = 0
  4285.     his_type[id] = 0
  4286.     user_can_spawn[id] = 1
  4287.     Duel_Arena_Spawner[id] = false
  4288.     Rush_Arena_Spawner[id] = false
  4289. }
  4290.  
  4291. stock reset_player_values(id)
  4292. {
  4293.     THE_HS[id] = 0
  4294.     rush_rounds[rush_arena_number[id]] = 0
  4295.     is_in_rush[id] = 0
  4296.     the_challenger[id] = 0
  4297.     the_asker[id] = 0
  4298.     rush_arena_number[id] = 0
  4299.     the_wins[id] = 0
  4300.     got_player_spawn[id] = 0
  4301.     the_timer[id] = 0
  4302.     his_type[id] = 0
  4303.     Prevent_Noobs[id] = 0
  4304. }
  4305.  
  4306. public freeze_player(id)
  4307. {
  4308.     set_user_maxspeed(id,1.0)
  4309. }
  4310.  
  4311. public unfreeze_player(id)
  4312. {
  4313.     set_user_maxspeed(id,250.0)
  4314. }
  4315.  
  4316.  
  4317.  
  4318. public wait_for_enemy_loop(id)
  4319. {
  4320.     if(is_user_connected(id))
  4321.     {
  4322.         if(is_in_duel[id] == 2)
  4323.         {
  4324.             if(is_user_connected(his_challenger[id]))
  4325.             {
  4326.                 if(is_in_duel[his_challenger[id]] == 2)
  4327.                 {
  4328.                     if(is_user_alive(his_challenger[id]))
  4329.                     {
  4330.                         begin_the_battle(id,his_challenger[id])
  4331.                         return PLUGIN_HANDLED
  4332.                     }
  4333.                     set_task(0.1,"wait_for_enemy_loop",id)
  4334.                 }
  4335.             }
  4336.         }
  4337.     }
  4338.     return PLUGIN_CONTINUE
  4339. }
  4340.  
  4341. public rush_wait_for_enemy_loop(id)
  4342. {
  4343.     if(is_user_connected(id))
  4344.     {
  4345.         if(is_in_rush[id] == 2)
  4346.         {
  4347.             if(is_user_connected(the_challenger[id]))
  4348.             {
  4349.                 if(is_in_rush[the_challenger[id]] == 2)
  4350.                 {
  4351.                     if(is_user_alive(the_challenger[id]))
  4352.                     {
  4353.                         begin_the_battle(id,the_challenger[id])
  4354.                         return PLUGIN_HANDLED
  4355.                     }
  4356.                     set_task(0.1,"wait_for_enemy_loop",id)
  4357.                 }
  4358.             }
  4359.         }
  4360.     }
  4361.     return PLUGIN_CONTINUE
  4362. }
  4363.  
  4364.  
  4365. stock Set_Entity_Invisible(ent, Invisible = 1)
  4366. {
  4367.     if(!pev_valid(ent))
  4368.         return
  4369.     set_pev(ent, pev_effects, Invisible == 0 ? pev(ent, pev_effects) & ~EF_NODRAW : pev(ent, pev_effects) | EF_NODRAW)
  4370. }
  4371.  
  4372. stock client_print_color(const id, const input[], any:...)  
  4373. {  
  4374.     new count = 1, players[32];  
  4375.     static msg[191];  
  4376.     vformat(msg, 190, input, 3);
  4377.     replace_all(msg, 190, "!g", "^x04"); // Green Color  
  4378.     replace_all(msg, 190, "!y", "^x01"); // Default Color  
  4379.     replace_all(msg, 190, "!t", "^x03"); // Team Color  
  4380.     if (id) players[0] = id; else get_players(players, count, "ch");  
  4381. {  
  4382.     for (new i = 0; i < count; i++)  
  4383.     {  
  4384.         if (is_user_connected(players[i]))  
  4385.         {  
  4386.             message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, players[i]);  
  4387.             write_byte(players[i]);  
  4388.             write_string(msg);  
  4389.             message_end();  
  4390.            
  4391.         }  
  4392.     }  
  4393. }  
  4394. }
  4395.  
  4396. public GameDesc( ) {
  4397. static gamename[32];
  4398. get_pcvar_string( cvar_gamename, gamename, 31 );
  4399. forward_return( FMV_STRING, gamename );
  4400. return FMRES_SUPERCEDE;
  4401. }
  4402.  
  4403.  
  4404. public fw_PlayerPreThink( id )
  4405. {
  4406. static btn
  4407.  
  4408. if(is_in_duel[id] == 2 || is_in_rush[id] == 2)
  4409. {
  4410.     if(his_type[id] == 1)
  4411.     {
  4412.         btn = pev(id, pev_button)
  4413.        
  4414.         if(btn & IN_ATTACK)
  4415.         {
  4416.             set_pev(id,pev_button,(btn & ~IN_ATTACK) | IN_ATTACK2)
  4417.         }
  4418.     }
  4419.     else if(his_type[id] == 2)
  4420.     {
  4421.         btn = pev(id, pev_button)
  4422.        
  4423.         if(btn & IN_ATTACK2)
  4424.         {
  4425.             set_pev(id,pev_button,(btn & ~IN_ATTACK2) | IN_ATTACK)
  4426.         }
  4427.     }
  4428.     else if(his_type[id] == 0)
  4429.     {
  4430.         // nothing
  4431.     }
  4432. }
  4433. return FMRES_IGNORED
  4434. }
  4435.  
  4436. public BlockMenu( id )
  4437. {
  4438. new pl[32], num
  4439. get_players(pl, num,"ch")
  4440. static menuid, menu[128], buffer[2]
  4441.  
  4442. menuid = menu_create("Block Players Menu", "BlockMenuHandler")
  4443. buffer[1] = 0
  4444.  
  4445. for(new i = 0; i < num; i++)
  4446. {
  4447.     if(id == pl[i]) continue
  4448.     formatex(menu, charsmax(menu), "%s %s", GetName(pl[i]), isBlocked[id][pl[i]]? "\r[BLOCKED]":"")
  4449.     buffer[0] = pl[i]
  4450.     menu_additem(menuid, menu, buffer)
  4451. }
  4452. menu_display(id, menuid, 0)
  4453. return PLUGIN_HANDLED
  4454. }
  4455. public BlockMenuHandler( id, menuid, item ){
  4456. if(!is_user_connected(id) || item == MENU_EXIT){
  4457.     menu_destroy(menuid)
  4458.     return PLUGIN_HANDLED
  4459. }
  4460. new dummy, buffer[2], playerid
  4461. menu_item_getinfo(menuid, item, dummy, buffer, charsmax(buffer), _, _, dummy )
  4462. playerid = buffer[0]
  4463. isBlocked[id][playerid] = !isBlocked[id][playerid]
  4464. client_print_color(id, "%s Player '%s' %sblocked from sending you requests", CHAT_TAG, GetName(playerid), isBlocked[id][playerid]? "":"un")
  4465. BlockMenu( id )
  4466. return PLUGIN_HANDLED
  4467. }
  4468.  
  4469. public GetName( id )
  4470. {
  4471. new name[32]
  4472.  
  4473. get_user_name(id, name, charsmax(name))
  4474. return name
  4475. }
  4476.  
  4477.  
  4478. public CmdReset( )
  4479. {
  4480. fvault_clear( g_szVaultName );
  4481.  
  4482. server_print( "[Knife Duel] Rank have been reset !" );
  4483.  
  4484. log_amx( "[Knife Duel] Rank have been reset !" );
  4485.  
  4486. return PLUGIN_HANDLED;
  4487. }
  4488.  
  4489. public CmdRank( iPlayer )
  4490. {
  4491. new Array:aRankData;
  4492. new iTotal = GetPlayerRanks( aRankData );
  4493.  
  4494. new iRank;
  4495. new eRankData[ RankData ];
  4496.  
  4497. if( iTotal )
  4498. {
  4499.     new szPlayerSteamID[ 35 ];
  4500.     get_user_authid( iPlayer, szPlayerSteamID, charsmax( szPlayerSteamID ) );
  4501.    
  4502.     for( new i = 0; i < iTotal; i++ )
  4503.     {
  4504.         ArrayGetArray( aRankData, i, eRankData );
  4505.        
  4506.         if( equal( szPlayerSteamID, eRankData[ Rank_SteamID ] ) )
  4507.         {
  4508.             iRank = i + 1;
  4509.             break;
  4510.         }
  4511.     }
  4512. }
  4513.  
  4514. if( iRank )
  4515. {
  4516.     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" );
  4517. }
  4518. else
  4519. {
  4520.     client_print( iPlayer, print_chat, "[Knife Duel] You are not ranked because you have not killed anyone!" );
  4521. }
  4522.  
  4523. ArrayDestroy( aRankData );
  4524. }
  4525.  
  4526. public CmdTop( iPlayer )
  4527. {
  4528. new Array:aRankData;
  4529. new iTotal = max( 0, min( GetPlayerRanks( aRankData ), get_pcvar_num( pCvar_Top ) ) );
  4530.  
  4531. if( iTotal )
  4532. {
  4533.     static szMOTD[ 2500 ], iDefaultLen;
  4534.     if( !iDefaultLen )
  4535.     {
  4536.         iDefaultLen = add( szMOTD, charsmax( szMOTD ),
  4537.         "<html><style>\
  4538.         body{background:#040404;font-family:Verdana, Arial, Sans-Serif;font-size:7pt;}\
  4539.         .t{color:#808080;text-align:left; }\
  4540.         #h{background: #222 url('http://limmudny.org/wp-content/uploads/2014/09/PageTitleBackground2-900x100.jpg') repeat-x;color:#000;font-weight:bold;}\
  4541.             #p{color:#D41313;}\
  4542.             #n{color:#fff;}\
  4543.             </style><body>\
  4544.             <table cellspacing=0 width=100% class=t>")
  4545.            
  4546.             add(szMOTD, charsmax(szMOTD),
  4547.             "<tr><td id=h width=7%>Nr:</td>\
  4548.             <td id=h>Nick</td>\
  4549.             <td id=h>Kills</td></tr>")
  4550.            
  4551.             iDefaultLen = strlen(szMOTD)
  4552.         }
  4553.        
  4554.         new iLen = iDefaultLen;
  4555.        
  4556.         new eRankData[ RankData ];
  4557.        
  4558.         new szFixedName[ 128 ];
  4559.        
  4560.         for( new i = 0; i < iTotal; i++ )
  4561.         {
  4562.             ArrayGetArray( aRankData, i, eRankData );
  4563.            
  4564.             copy( szFixedName, charsmax( szFixedName ), eRankData[ Rank_Name ] );
  4565.            
  4566.             MakeNameMOTDSafe( szFixedName, 31 );
  4567.            
  4568.             iLen += formatex( szMOTD[ iLen ], charsmax( szMOTD ) - iLen, "<tr><td>%i</td><td>%s</td><td>%i</td></tr>", ( i + 1 ), szFixedName, eRankData[ Rank_Kills ] );
  4569.         }
  4570.        
  4571.         copy( szMOTD[ iLen ], charsmax( szMOTD ) - iLen, "</tbody></table></body>" );
  4572.        
  4573.         show_motd( iPlayer, szMOTD, "Knife Duel Top" );
  4574.     }
  4575.     else
  4576.     {
  4577.         client_print( iPlayer, print_chat, "* No players have been put on the top!" );
  4578.     }
  4579.    
  4580.     ArrayDestroy( aRankData );
  4581. }
  4582.  
  4583.  
  4584. public fw_PlayerKilled(iVictim, iKiller)  
  4585. {
  4586.     if (iVictim == iKiller || !is_user_alive(iKiller))
  4587.         return
  4588.        
  4589.         new szName[ 32 ], szSteamID[ 35 ];
  4590.         get_user_authid( iKiller, szSteamID, charsmax( szSteamID ) );
  4591.        
  4592.         new szKills[ 48 ], iKills;
  4593.        
  4594.         if( fvault_get_data( g_szVaultName, szSteamID, szKills, charsmax( szKills ) ) )
  4595.         {
  4596.             strbreak( szKills, szKills, charsmax( szKills ), szName, charsmax( szName ) );
  4597.            
  4598.             iKills = str_to_num( szKills );
  4599.         }
  4600.         if(is_in_duel[iKiller] == 2 || is_in_rush[iKiller] == 2)
  4601.         {
  4602.             iKills++;
  4603.            
  4604.             get_user_name( iKiller, szName ,charsmax( szName ) );
  4605.            
  4606.             formatex( szKills, charsmax( szKills ), "%i %s", iKills, szName );
  4607.            
  4608.             fvault_set_data( g_szVaultName, szSteamID, szKills );
  4609.         }
  4610.        
  4611.     }
  4612.    
  4613.     GetPlayerRanks( &Array:aRankData )
  4614. {
  4615.     aRankData = ArrayCreate( RankData );
  4616.     new iTotal;
  4617.    
  4618.     new eRankData[ RankData ];
  4619.    
  4620.     new szFileName[ 128 ];
  4621.     _FormatVaultName( g_szVaultName, szFileName, charsmax( szFileName ) );
  4622.    
  4623.     new iFile = fopen( szFileName, "rt" );
  4624.    
  4625.     if( !iFile )
  4626.     {
  4627.         return iTotal;
  4628.     }
  4629.    
  4630.     new szFileData[ 128 ];
  4631.     new szKills[ 48 ];
  4632.    
  4633.     while( !feof( iFile ) )
  4634.     {
  4635.         fgets( iFile, szFileData, charsmax( szFileData ) );
  4636.         trim( szFileData );
  4637.        
  4638.         if( !szFileData[ 0 ] )
  4639.         {
  4640.             continue;
  4641.         }
  4642.        
  4643.         parse( szFileData, eRankData[ Rank_SteamID ], charsmax( eRankData[ Rank_SteamID ] ), szKills, charsmax( szKills ) );
  4644.         strbreak( szKills, szKills, charsmax( szKills ), eRankData[ Rank_Name ], charsmax( eRankData[ Rank_Name ] ) );
  4645.         eRankData[ Rank_Kills ] = str_to_num( szKills );
  4646.        
  4647.         ArrayPushArray( aRankData, eRankData );
  4648.        
  4649.         iTotal++;
  4650.     }
  4651.    
  4652.     fclose( iFile );
  4653.    
  4654.     ArraySort( aRankData, "SortData" );
  4655.    
  4656.     return iTotal;
  4657. }
  4658.  
  4659. public SortData( Array:aData, iIndex1, iIndex2, const iSortData[ ], iSortDataSize )
  4660. {
  4661.     new eData1[ RankData ], eData2[ RankData ];
  4662.     ArrayGetArray( aData, iIndex1, eData1 );
  4663.     ArrayGetArray( aData, iIndex2, eData2 );
  4664.    
  4665.     return clamp( ( eData2[ Rank_Kills ] - eData1[ Rank_Kills ] ), -1, 1 );
  4666. }
  4667.  
  4668. stock MakeNameMOTDSafe( szName[ 128 ], iMaxChars )
  4669. {
  4670.     szName[ 32 ] = 0;
  4671.    
  4672.     replace_all( szName, 127, "&", "&amp;" );
  4673.     replace_all( szName, 127, "<", "&lt;" );
  4674.     replace_all( szName, 127, ">", "&gt;" );
  4675.     replace_all( szName, 127, "^"", "&quot;" );
  4676.    
  4677.     if( iMaxChars > 128 ) return;
  4678.    
  4679.     new iLast;
  4680.     for( new i = 0; i < 128 && szName[ i ]; )
  4681.     {
  4682.         if( szName[ i ] == '&' )
  4683.         {
  4684.             if( equal( szName[ i ], "&amp;", 5 ) )
  4685.             {
  4686.                 i += 4;
  4687.             }
  4688.             else if( equal( szName[ i ], "&quot;", 6 ) )
  4689.             {
  4690.                 i += 5;
  4691.             }
  4692.             else if( equal( szName[ i ], "&lt;", 4 ) || equal( szName[ i ], "&gt;", 4 ) )
  4693.             {
  4694.                 i += 3;
  4695.             }
  4696.         }
  4697.        
  4698.         if( ++i > iMaxChars )
  4699.         {
  4700.             break;
  4701.         }
  4702.        
  4703.         iLast = i;
  4704.     }
  4705.    
  4706.     szName[ iLast ] = 0;
  4707. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement