Advertisement
Guest User

Untitled

a guest
Mar 27th, 2012
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 60.47 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <cstrike>
  3. #include <fun>
  4. #include <colorchat>
  5. #include <fakemeta>
  6. #include <geoip>
  7. #include <hamsandwich>
  8. #include <sqlx>
  9.  
  10. #define KZ_LEVEL ADMIN_KICK
  11. #define MAX_ENTITYS 900+15*32
  12.  
  13. #define SCOREATTRIB_NONE 0
  14. #define SCOREATTRIB_DEAD ( 1 << 0 )
  15. #define SCOREATTRIB_BOMB ( 1 << 1 )
  16. #define SCOREATTRIB_VIP ( 1 << 2 )
  17.  
  18. #if cellbits == 32
  19. #define OFFSET_BUYZONE 235
  20. #else
  21. #define OFFSET_BUYZONE 268
  22. #endif
  23.  
  24. new g_iPlayers[32], g_iNum, g_iPlayer
  25. new const g_szAliveFlags[] = "a"
  26. #define RefreshPlayersList() get_players(g_iPlayers, g_iNum, g_szAliveFlags)
  27.  
  28. new const FL_ONGROUND2 = ( FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR | FL_FLOAT )
  29. new const KZ_DIR[] = "addons/amxmodx/configs/kz"
  30. new const KZ_STARTFILE[] = "start.ini"
  31. new const KZ_STARTFILE_TEMP[] = "temp_start.ini"
  32.  
  33. new Handle:g_SqlTuple
  34. new Handle:SqlConnection
  35. new g_Error[512]
  36. new kz_sql_host
  37. new kz_sql_user
  38. new kz_sql_pass
  39. new kz_sql_db
  40. new kz_sql_name
  41. new kz_sql_file
  42.  
  43. new Float:Checkpoints[33][2][3]
  44. new Float:timer_time[33]
  45. new Float:g_pausetime[33]
  46. new Float:antihookcheat[33]
  47. new Float:SpecLoc[33][3]
  48. new Float:PauseOrigin[33][3]
  49. new Float:SavedStart[33][3]
  50. new hookorigin[33][3]
  51. new Float:DefaultStartPos[3]
  52.  
  53. new bool:g_bCpAlternate[33]
  54. new bool:timer_started[33]
  55. new bool:IsPaused[33]
  56. new bool:firstspawn[33]
  57. new bool:canusehook[33]
  58. new bool:ishooked[33]
  59. new bool:NightVisionUse[33]
  60. new bool:HealsOnMap
  61. new bool:gViewInvisible[33]
  62. new bool:gMarkedInvisible[33] = { true, ...};
  63. new bool:gWaterInvisible[33]
  64. new bool:gWaterEntity[MAX_ENTITYS]
  65. new bool:gWaterFound
  66. new bool:DefaultStart
  67. new bool:AutoStart[33]
  68.  
  69. new Trie:g_tStarts
  70. new Trie:g_tStops;
  71.  
  72. new checknumbers[33]
  73. new gochecknumbers[33]
  74. new g_WeaponUsed[33]
  75. new ShowTime[33]
  76.  
  77. new kz_checkpoints
  78. new kz_cheatdetect
  79. new kz_spawn_mainmenu
  80. new kz_show_timer
  81. new kz_chatorhud
  82. new kz_hud_color
  83. new hud_message
  84. new kz_other_weapons
  85. new kz_maxspeedmsg
  86. new kz_drop_weapons
  87. new kz_remove_drops
  88. new kz_strip_other_weapons
  89. new kz_pick_weapons
  90. new kz_reload_weapons
  91. new kz_use_radio
  92. new kz_hook_prize
  93. new kz_hook_sound
  94. new kz_hook_speed
  95. new kz_pause
  96. new kz_nvg
  97. new kz_nvg_colors
  98. new kz_vip
  99. new kz_respawn_ct
  100. new kz_semiclip
  101. new kz_spec_saves
  102. new kz_save_autostart
  103. new MaxPlayers
  104. new Sbeam = 0
  105.  
  106. new const other_weapons[8] =
  107. {
  108. CSW_SCOUT, CSW_P90, CSW_FAMAS, CSW_SG552,
  109. CSW_M4A1, CSW_M249, CSW_AK47, CSW_AWP
  110. }
  111.  
  112. new const other_weapons_name[8][] =
  113. {
  114. "weapon_scout", "weapon_p90", "weapon_famas", "weapon_sg552",
  115. "weapon_m4a1", "weapon_m249", "weapon_ak47", "weapon_awp"
  116. }
  117.  
  118. new const g_weaponsnames[][] =
  119. {
  120. "", // NULL
  121. "p228", "shield", "scout", "hegrenade", "xm1014", "c4",
  122. "mac10", "aug", "smokegrenade", "elite", "fiveseven",
  123. "ump45", "sg550", "galil", "famas", "usp", "glock18",
  124. "awp", "mp5navy", "m249", "m3", "m4a1", "tmp", "g3sg1",
  125. "flashbang", "deagle", "sg552", "ak47", "knife", "p90"
  126. }
  127.  
  128. enum
  129. {
  130. TOP_NULL,
  131. PRO_TOP,
  132. NUB_TOP,
  133. LAST_PRO10,
  134. PRO_RECORDS,
  135. PLAYERS_RANKING,
  136. MAPS_STATISTIC
  137. }
  138.  
  139. // =================================================================================================
  140.  
  141. public plugin_init()
  142. {
  143. register_plugin("ProKreedz","2.0y","nucLeaR")
  144.  
  145. kz_checkpoints = register_cvar("kz_checkpoints","1")
  146. kz_cheatdetect = register_cvar("kz_cheatdetect","1")
  147. kz_spawn_mainmenu = register_cvar("kz_spawn_mainmenu", "1")
  148. kz_show_timer = register_cvar("kz_show_timer", "2")
  149. kz_chatorhud = register_cvar("kz_chatorhud", "2")
  150. kz_hud_color = register_cvar("kz_hud_color", "12 122 221")
  151. kz_other_weapons = register_cvar("kz_other_weapons","1")
  152. kz_drop_weapons = register_cvar("kz_drop_weapons", "0")
  153. kz_remove_drops = register_cvar("kz_remove_drops", "1")
  154. kz_strip_other_weapons = register_cvar("kz_strip_other_weapons", "1")
  155. kz_pick_weapons = register_cvar("kz_pick_weapons", "0")
  156. kz_reload_weapons = register_cvar("kz_reload_weapons", "0")
  157. kz_maxspeedmsg = register_cvar("kz_maxspeedmsg","1")
  158. kz_hook_prize = register_cvar("kz_hook_prize","1")
  159. kz_hook_sound = register_cvar("kz_hook_sound","1")
  160. kz_hook_speed = register_cvar("kz_hook_speed", "300.0")
  161. kz_use_radio = register_cvar("kz_use_radio", "0")
  162. kz_pause = register_cvar("kz_pause", "1")
  163. kz_nvg = register_cvar("kz_nvg","1")
  164. kz_nvg_colors = register_cvar("kz_nvg_colors","5 0 255")
  165. kz_vip = register_cvar("kz_vip","1")
  166. kz_respawn_ct = register_cvar("kz_respawn_ct", "1")
  167. kz_semiclip = register_cvar("kz_semiclip", "1")
  168. kz_spec_saves = register_cvar("kz_spec_saves", "1")
  169. kz_save_autostart = register_cvar("kz_save_autostart", "1")
  170.  
  171. kz_sql_host = register_cvar("kz_sql_host", "127.0.0.1")
  172. kz_sql_user = register_cvar("kz_sql_user", "trickjumps")
  173. kz_sql_pass = register_cvar("kz_sql_pass", "", FCVAR_PROTECTED)
  174. kz_sql_db = register_cvar("kz_sql_db", "trickjumps")
  175. kz_sql_name = register_cvar("kz_sql_server", "TJ")
  176. kz_sql_file = register_cvar("kz_sql_file", "kz.evil.lv/top")
  177.  
  178. register_clcmd("say .kreedz","kz_menu")
  179. register_clcmd("say /kreedz","kz_menu")
  180. register_clcmd("say .menu","kz_menu")
  181. register_clcmd("say /menu","kz_menu")
  182.  
  183. register_clcmd("say /timer", "ShowTimer_Menu" )
  184. register_clcmd( "say_team /timer", "ShowTimer_Menu" );
  185. register_clcmd("say /showtimer", "ShowTimer_Menu")
  186.  
  187. register_clcmd("cp","CheckPoint")
  188. register_clcmd("/cp","CheckPoint")
  189. register_clcmd(".cp","CheckPoint")
  190. register_clcmd("say /cp","CheckPoint")
  191. register_clcmd("say /checkpoint","CheckPoint")
  192.  
  193. register_clcmd("tp","GoCheck")
  194. register_clcmd("/tp","GoCheck")
  195. register_clcmd(".tp","GoCheck")
  196. register_clcmd("say /tp", "GoCheck")
  197. register_clcmd("say /teleport", "GoCheck")
  198.  
  199. register_clcmd("gc","GoCheck")
  200. register_clcmd("/gc","GoCheck")
  201. register_clcmd(".gc","GoCheck")
  202. register_clcmd("say /gc", "GoCheck")
  203. register_clcmd("say /gocheck", "GoCheck")
  204.  
  205. register_clcmd("stuck","Stuck")
  206. register_clcmd("/stuck","Stuck")
  207. register_clcmd(".stuck", "Stuck")
  208. register_clcmd("say .stuck","Stuck")
  209. register_clcmd("say /stuck","Stuck")
  210.  
  211. register_clcmd("say .reset","reset_checkpoints")
  212. register_clcmd("say /reset","reset_checkpoints")
  213.  
  214. register_clcmd("say .noclip","noclip")
  215. register_clcmd("say /noclip","noclip")
  216. register_clcmd("say /nc","noclip")
  217. register_clcmd("say /godmode","GodMode")
  218. register_clcmd("say /god","GodMode")
  219. register_clcmd("say .god","GodMode")
  220.  
  221. register_clcmd("say /spec","ct")
  222. register_clcmd("say /ct","ct")
  223. register_clcmd("say /pause", "Pause")
  224.  
  225. register_clcmd("say /invis", "InvisMenu")
  226. register_clcmd("say /winvis", "cmdWaterInvisible")
  227. register_clcmd("say /pinvis", "cmdInvisible")
  228.  
  229. register_concmd("kz_hook","give_hook", KZ_LEVEL, "<name|#userid|steamid|@ALL> <on/off>")
  230. register_concmd("nightvision","ToggleNVG")
  231.  
  232. register_clcmd("say .top15","top15menu")
  233. register_clcmd("say /top15","top15menu")
  234. register_clcmd("say .top10","top15menu")
  235. register_clcmd("say /top10","top15menu")
  236. register_clcmd("say .noob10","NoobTop_show")
  237. register_clcmd("say /noob10","NoobTop_show")
  238. register_clcmd("say .noob15","NoobTop_show")
  239. register_clcmd("say /noob15","NoobTop_show")
  240. register_clcmd("say .nub10","NoobTop_show")
  241. register_clcmd("say /nub10","NoobTop_show")
  242. register_clcmd("say .nub15","NoobTop_show")
  243. register_clcmd("say /nub15","NoobTop_show")
  244. register_clcmd("say .pro10","ProTop_show")
  245. register_clcmd("say /pro10","ProTop_show")
  246. register_clcmd("say .pro15","ProTop_show")
  247. register_clcmd("say /pro15","ProTop_show")
  248. register_clcmd("say /prorecords", "ProRecs_show")
  249. register_clcmd("say /prorecs", "ProRecs_show")
  250. register_clcmd("say .prorecords", "ProRecs_show")
  251. register_clcmd("say /prorecs", "ProRecs_show")
  252.  
  253. register_clcmd("say /weapons","weapons")
  254. register_clcmd("say /scout", "cmdScout")
  255. register_clcmd("say /usp", "cmdUsp")
  256. register_clcmd("say /knife", "cmdUsp")
  257.  
  258. register_clcmd("say /start", "goStart");
  259. register_clcmd("/start", "goStart");
  260. register_clcmd("say /respawn", "goStart");
  261. register_clcmd("/respawn", "goStart");
  262. register_clcmd("say /setstart", "setStart", KZ_LEVEL, "")
  263.  
  264. register_clcmd("+hook","hook_on",KZ_LEVEL)
  265. register_clcmd("-hook","hook_off",KZ_LEVEL)
  266.  
  267. register_event("ResetHUD","resethud","be")
  268. register_event("CurWeapon","curweapon","be")
  269. register_event( "StatusValue", "EventStatusValue", "b", "1>0", "2>0" );
  270.  
  271. register_forward(FM_StartFrame, "fw_StartFrame")
  272. register_forward(FM_AddToFullPack, "FM_client_AddToFullPack_Post", 1)
  273.  
  274. RegisterHam( Ham_Player_PreThink, "player", "Ham_CBasePlayer_PreThink_Post", 1)
  275. RegisterHam( Ham_Use, "func_button", "fwdUse", 0)
  276. RegisterHam( Ham_Killed, "player", "Ham_CBasePlayer_Killed_Post", 1)
  277. RegisterHam( Ham_Spawn, "weaponbox", "FwdSpawnWeaponbox", 1 )
  278. RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawn", 1 )
  279. RegisterHam( Ham_Touch, "weaponbox", "GroundWeapon_Touch")
  280.  
  281. register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib" )
  282. register_message( get_user_msgid( "StatusIcon" ), "msgStatusIcon" );
  283.  
  284. hud_message = CreateHudSyncObj()
  285. MaxPlayers = get_maxplayers()
  286. set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
  287. set_task(0.5,"timer_task",2000,"",0,"ab")
  288. set_task(0.2, "plugin_sql")
  289.  
  290. if( !dir_exists(KZ_DIR) )
  291. mkdir(KZ_DIR)
  292.  
  293. new kreedz_cfg[128]
  294. formatex(kreedz_cfg,128,"%s/kreedz.cfg",KZ_DIR)
  295.  
  296. if( file_exists( kreedz_cfg ) )
  297. {
  298. server_exec()
  299. server_cmd("exec %s",kreedz_cfg)
  300. }
  301.  
  302. g_tStarts = TrieCreate( )
  303. g_tStops = TrieCreate( )
  304.  
  305. new const szStarts[ ][ ] =
  306. {
  307. "counter_start", "clockstartbutton", "firsttimerelay", "but_start", "counter_start_button",
  308. "multi_start", "timer_startbutton", "start_timer_emi", "gogogo"
  309. }
  310.  
  311. new const szStops[ ][ ] =
  312. {
  313. "counter_off", "clockstopbutton", "clockstop", "but_stop", "counter_stop_button",
  314. "multi_stop", "stop_counter", "m_counter_end_emi"
  315. }
  316.  
  317. for( new i = 0; i < sizeof szStarts; i++ )
  318. TrieSetCell( g_tStarts, szStarts[ i ], 1 )
  319.  
  320. for( new i = 0; i < sizeof szStops; i++ )
  321. TrieSetCell( g_tStops, szStops[ i ], 1 )
  322. }
  323.  
  324. public plugin_sql()
  325. {
  326. new host[64], user[64], pass[64], db[64]
  327.  
  328. get_pcvar_string(kz_sql_host, host, 63)
  329. get_pcvar_string(kz_sql_user, user, 63)
  330. get_pcvar_string(kz_sql_pass, pass, 63)
  331. get_pcvar_string(kz_sql_db, db, 63)
  332.  
  333. g_SqlTuple = SQL_MakeDbTuple(host, user, pass, db)
  334.  
  335. new ErrorCode
  336. SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
  337.  
  338. if(!SqlConnection)
  339. {
  340. server_print("[XJ] TOP15 SQL: Could not connect to SQL database.!")
  341. log_amx("[XJ] TOP15 SQL: Could not connect to SQL database.")
  342. return pause("a")
  343. }
  344.  
  345. new createinto[1001]
  346. formatex(createinto, 1000, "CREATE TABLE IF NOT EXISTS `kz_pro15` (`mapname` varchar(64) NOT NULL, `authid` varchar(64) NOT NULL, `country` varchar(6) NOT NULL, `name` varchar(64) NOT NULL, `time` decimal(65,2) NOT NULL, `date` datetime NOT NULL, `weapon` varchar(64) NOT NULL, `server` varchar(64) NOT NULL)")
  347. SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
  348. formatex(createinto, 1000, "CREATE TABLE IF NOT EXISTS `kz_nub15` (`mapname` varchar(64) NOT NULL, `authid` varchar(64) NOT NULL, `country` varchar(6) NOT NULL, `name` varchar(64) NOT NULL, `time`decimal(65,2) NOT NULL, `date` datetime NOT NULL, `weapon` varchar(64) NOT NULL, `server` varchar(64) NOT NULL, `checkpoints` real NOT NULL, `gocheck` real NOT NULL)")
  349. SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
  350.  
  351. return PLUGIN_CONTINUE
  352. }
  353.  
  354. public QueryHandle(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  355. {
  356. if( iFailState != TQUERY_SUCCESS )
  357. {
  358. log_amx("[XJ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
  359. ColorChat(0, GREEN, "[XJ]^x01: Warring the SQL Tops can not be saved.")
  360. }
  361.  
  362. server_print("[XJ] Server Sending Info to SQL Server")
  363.  
  364. return PLUGIN_CONTINUE
  365. }
  366.  
  367. public plugin_end( )
  368. {
  369. TrieDestroy( g_tStarts )
  370. TrieDestroy( g_tStops )
  371. }
  372.  
  373. public plugin_precache()
  374. {
  375. RegisterHam( Ham_Spawn, "func_door", "FwdHamDoorSpawn", 1 )
  376. precache_sound("weapons/xbow_hit2.wav")
  377. Sbeam = precache_model("sprites/laserbeam.spr")
  378. }
  379.  
  380. public plugin_cfg()
  381. {
  382. new startcheck[100], data[256], mapname[64], map[64], x[13], y[13], z[13];
  383. get_mapname( mapname, 63)
  384. formatex(startcheck, 99, "%s/%s", KZ_DIR, KZ_STARTFILE)
  385. new f = fopen(startcheck, "rt" )
  386. while( !feof( f ) )
  387. {
  388. fgets( f, data, sizeof data - 1 )
  389. parse( data, map, 63, x, 12, y, 12, z, 12)
  390.  
  391. if( equali( map, mapname ) )
  392. {
  393. DefaultStartPos[0] = str_to_float(x)
  394. DefaultStartPos[1] = str_to_float(y)
  395. DefaultStartPos[2] = str_to_float(z)
  396.  
  397. DefaultStart = true
  398. break;
  399. }
  400. }
  401. fclose(f)
  402.  
  403. new ent = -1;
  404. while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_water") ) != 0 )
  405. {
  406. if( !gWaterFound )
  407. {
  408. gWaterFound = true;
  409. }
  410.  
  411. gWaterEntity[ent] = true;
  412. }
  413.  
  414. ent = -1;
  415. while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_illusionary") ) != 0 )
  416. {
  417. if( pev( ent, pev_skin ) == CONTENTS_WATER )
  418. {
  419. if( !gWaterFound )
  420. {
  421. gWaterFound = true;
  422. }
  423.  
  424. gWaterEntity[ent] = true;
  425. }
  426. }
  427.  
  428. ent = -1;
  429. while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_conveyor") ) != 0 )
  430. {
  431. if( pev( ent, pev_spawnflags ) == 3 )
  432. {
  433. if( !gWaterFound )
  434. {
  435. gWaterFound = true;
  436. }
  437.  
  438. gWaterEntity[ent] = true;
  439. }
  440. }
  441. }
  442. // =================================================================================================
  443. // Global Functions
  444. // =================================================================================================
  445.  
  446. public Pause(id)
  447. {
  448. if (get_pcvar_num(kz_pause) == 0)
  449. {
  450. kz_hud_message(id, "Pause is disabled")
  451. return PLUGIN_HANDLED
  452. }
  453.  
  454. if(! timer_started[id])
  455. {
  456. kz_hud_message(id, "Timer is not started")
  457. return PLUGIN_HANDLED
  458. }
  459.  
  460. if(! is_user_alive(id) )
  461. {
  462. kz_hud_message(id, "You must be alive to use this command")
  463. return PLUGIN_HANDLED
  464. }
  465.  
  466.  
  467. if( ( pev( id, pev_flags ) & FL_ONGROUND2 ) )
  468. {
  469. if(!IsPaused[id])
  470. {
  471. g_pausetime[id] = get_gametime() - timer_time[id]
  472. timer_time[id] = 0.0
  473. IsPaused[id] = true
  474. kz_hud_message(id, "Your timer has been paused")
  475. set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
  476. pev(id, pev_origin, PauseOrigin[id])
  477. }
  478. else
  479. {
  480. timer_time[id] = get_gametime() - g_pausetime[id] + timer_time[id]
  481. IsPaused[id] = false
  482. kz_hud_message(id, "Your timer has been unpaused")
  483. set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
  484. }
  485. }
  486. else
  487. kz_hud_message(id, "You must be on ground to get paused")
  488.  
  489. return PLUGIN_HANDLED
  490. }
  491.  
  492. public timer_task()
  493. {
  494. for(new i=1;i<=MaxPlayers;i++)
  495. {
  496. if ( get_pcvar_num(kz_show_timer) > 0 )
  497. {
  498. if (is_user_alive(i))
  499. {
  500. if( is_user_connected(i) && timer_started[i])
  501. {
  502. new Float:kreedztime = get_gametime() - (IsPaused[i] ? get_gametime() - g_pausetime[i] : timer_time[i])
  503.  
  504. if( ShowTime[i] == 1 )
  505. {
  506. new colors[12], r[4], g[4], b[4];
  507. new imin = floatround(kreedztime / 60.0,floatround_floor)
  508. new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
  509. get_pcvar_string(kz_hud_color, colors, 11)
  510. parse(colors, r, 3, g, 3, b, 4)
  511.  
  512. set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), 0.40, 0.10, 0, 0.0, 1.0, 0.0, 0.0, 1)
  513. show_hudmessage(i, "Time: %02d:%02d | CPs: %d | TPs: %d ",imin, isec,checknumbers[i], gochecknumbers[i])
  514. }
  515. else
  516. if( ShowTime[i] == 2 )
  517. {
  518. kz_showtime_roundtime(i, floatround(kreedztime))
  519. }
  520. }
  521. }
  522. else
  523. {
  524. new specmode = pev(i, pev_iuser1)
  525. if(specmode == 2 || specmode == 4)
  526. {
  527. new target = pev(i, pev_iuser2)
  528. if(target != i)
  529. if(is_user_alive(target) && timer_started[target])
  530. {
  531. new name[32], colors[12], r[4], g[4], b[4];
  532. get_user_name (target, name, 31)
  533.  
  534. new Float:kreedztime = get_gametime() - (IsPaused[target] ? get_gametime() - g_pausetime[target] : timer_time[target])
  535. new imin = floatround(kreedztime / 60.0,floatround_floor)
  536. new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
  537.  
  538. get_pcvar_string(kz_hud_color, colors, 11)
  539. parse(colors, r, 3, g, 3, b, 4)
  540.  
  541. set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), -1.0, 0.46, 0, 0.0, 1.0, 0.0, 0.0, 1)
  542. show_hudmessage(i, "Time: %02d:%02d | CPs: %d | TPs: %d %s ",imin, isec, checknumbers[target], gochecknumbers[target], IsPaused[target] ? "| *Paused*" : "")
  543. }
  544. }
  545. }
  546. }
  547. }
  548. }
  549.  
  550. // ============================ Block Commands ================================
  551.  
  552. public client_command(id)
  553. {
  554. static szCmd[13]
  555. read_argv(0, szCmd, 12)
  556.  
  557. static const commands_block[][] =
  558. {
  559. "radio1", "radio2", "radio3",
  560. "coverme", "takepoint", "holdpos",
  561. "regroup", "followme", "takingfire",
  562. "go", "fallback", "sticktog",
  563. "getinpos", "stormfront", "report",
  564. "roger", "enemyspot", "needbackup",
  565. "sectorclear", "inposition", "reportingin",
  566. "getout", "negative", "enemydown",
  567. "chooseteam", "jointeam 1"
  568. }
  569.  
  570. static const drop_weapons[][] =
  571. {
  572. "drop"
  573. }
  574.  
  575. if (get_pcvar_num(kz_use_radio) == 0)
  576. for ( new i = 0 ; i < sizeof( commands_block ) ; i++ )
  577. {
  578. if(equal(szCmd, commands_block[i]))
  579. return PLUGIN_HANDLED;
  580. }
  581. else
  582. return PLUGIN_CONTINUE
  583.  
  584. if (get_pcvar_num(kz_drop_weapons) == 0)
  585. for ( new i = 0 ; i < sizeof( drop_weapons ) ; i++ )
  586. {
  587. if(equal(szCmd, drop_weapons[i]))
  588. return PLUGIN_HANDLED
  589. }
  590. else
  591. return PLUGIN_CONTINUE
  592.  
  593. return PLUGIN_CONTINUE
  594. }
  595.  
  596. public msgStatusIcon( const iMsgId, const iMsgDest, const iPlayer )
  597. {
  598. static szMsg[ 8 ];
  599. get_msg_arg_string( 2, szMsg, 7 );
  600.  
  601. if( equal( szMsg, "buyzone" ) )
  602. {
  603. set_pdata_int( iPlayer, OFFSET_BUYZONE, get_pdata_int( iPlayer, OFFSET_BUYZONE ) & ~( 1<<0 ) )
  604. return PLUGIN_HANDLED
  605. }
  606. return PLUGIN_CONTINUE
  607. }
  608.  
  609. public CmdRespawn(id)
  610. {
  611. if ( get_user_team(id) == 3 )
  612. return PLUGIN_HANDLED
  613. else
  614. ExecuteHamB(Ham_CS_RoundRespawn, id)
  615.  
  616. return PLUGIN_HANDLED
  617. }
  618.  
  619. public ct(id)
  620. {
  621. new CsTeams:team = cs_get_user_team(id)
  622. if (team == CS_TEAM_CT)
  623. {
  624. if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) && timer_started[id] )
  625. return PLUGIN_HANDLED
  626.  
  627. if (get_pcvar_num(kz_spec_saves) == 1)
  628. {
  629. pev(id, pev_origin, SpecLoc[id])
  630.  
  631. if ( timer_started[id] )
  632. {
  633. if ( IsPaused[id] )
  634. Pause(id)
  635.  
  636. g_pausetime[id] = get_gametime() - timer_time[id]
  637. timer_time[id] = 0.0
  638. ColorChat(id, GREEN, "[XJ]^x01 Your timer has been paused.")
  639. }
  640. }
  641.  
  642. if(gViewInvisible[id])
  643. gViewInvisible[id] = false
  644.  
  645. cs_set_user_team(id,CS_TEAM_SPECTATOR)
  646. set_pev(id, pev_solid, SOLID_NOT)
  647. set_pev(id, pev_movetype, MOVETYPE_FLY)
  648. set_pev(id, pev_effects, EF_NODRAW)
  649. set_pev(id, pev_deadflag, DEAD_DEAD)
  650. }
  651. else
  652. {
  653. cs_set_user_team(id,CS_TEAM_CT)
  654. set_pev(id, pev_effects, 0)
  655. set_pev(id, pev_movetype, MOVETYPE_WALK)
  656. set_pev(id, pev_deadflag, DEAD_NO)
  657. set_pev(id, pev_takedamage, DAMAGE_AIM)
  658. CmdRespawn(id)
  659. give_item(id,"weapon_knife")
  660. give_item(id,"weapon_usp")
  661. give_item(id,"weapon_usp")
  662. give_item(id,"weapon_usp")
  663.  
  664. if (get_pcvar_num(kz_spec_saves) == 1)
  665. {
  666. set_pev(id, pev_origin, SpecLoc[id])
  667. if ( timer_started [id] )
  668. timer_time[id] = get_gametime() - g_pausetime[id] + timer_time[id]
  669. }
  670. }
  671. return PLUGIN_HANDLED
  672. }
  673.  
  674.  
  675. //=================== Weapons ==============
  676.  
  677. public curweapon(id)
  678. {
  679. new WeaponNum = read_data(2)
  680. new WeaponActive = read_data(1)
  681.  
  682. if ((WeaponNum != g_WeaponUsed[id]) && WeaponActive) // if weapon has changed and its the active weapon continue
  683. {
  684. g_WeaponUsed[id] = WeaponNum
  685.  
  686. if(get_pcvar_num(kz_maxspeedmsg) == 1)
  687. {
  688. new clip, ammo, speed
  689. switch(get_user_weapon(id,clip,ammo))
  690. {
  691. case CSW_SCOUT: speed = 260
  692. case CSW_C4, CSW_P228, CSW_MAC10, CSW_MP5NAVY, CSW_USP, CSW_TMP, CSW_FLASHBANG, CSW_DEAGLE, CSW_GLOCK18, CSW_SMOKEGRENADE, CSW_ELITE, CSW_FIVESEVEN, CSW_UMP45, CSW_HEGRENADE, CSW_KNIFE: speed = 250
  693. case CSW_P90: speed = 245
  694. case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS: speed = 240
  695. case CSW_SG552: speed = 235
  696. case CSW_M3, CSW_M4A1: speed= 230
  697. case CSW_AK47: speed = 221
  698. case CSW_M249: speed = 220
  699. case CSW_G3SG1, CSW_SG550, CSW_AWP: speed = 210
  700. }
  701. kz_hud_message(id,"This weapons maxspeed is %d",speed)
  702. }
  703. }
  704.  
  705. return PLUGIN_HANDLED
  706. }
  707.  
  708. public weapons(id)
  709. {
  710. if (!timer_started[id])
  711. {
  712. if(get_pcvar_num(kz_other_weapons) == 1)
  713. {
  714. if(is_user_alive(id))
  715. {
  716. for(new i = 0; i < 8; i++)
  717. if( !user_has_weapon(id, other_weapons[i]) )
  718. {
  719. new item;
  720. item = give_item(id, other_weapons_name[i] );
  721. cs_set_weapon_ammo(item, 0);
  722. }
  723.  
  724. if( !user_has_weapon(id, CSW_USP) )
  725. cmdUsp(id)
  726. }
  727. else
  728. switch (get_pcvar_num(kz_chatorhud))
  729. {
  730. case 1: ColorChat(id, GREEN, "[XJ]^x01 You must be alive to use this function.")
  731. case 2: kz_hud_message(id, "You must be alive to use this function")
  732. }
  733. }
  734. else
  735. switch (get_pcvar_num(kz_chatorhud))
  736. {
  737. case 1: ColorChat(id, GREEN, "[XJ]^x01 Different weapons are disabled.")
  738. case 2: kz_hud_message(id, "Different weapons are disabled")
  739. }
  740. }
  741. else
  742. switch (get_pcvar_num(kz_chatorhud))
  743. {
  744. case 1: ColorChat(id, GREEN, "[XJ]^x01 You can not get different weapons during a run, type /reset.")
  745. case 2: kz_hud_message(id, "You can not get different weapons during a run, type /reset")
  746. }
  747. return PLUGIN_HANDLED
  748. }
  749.  
  750.  
  751. // ========================= Scout =======================
  752.  
  753. public cmdScout(id)
  754. {
  755.  
  756. if (timer_started[id])
  757. {
  758. strip_user_weapons(id)
  759. if( !user_has_weapon(id, CSW_SCOUT))
  760. give_item(id,"weapon_scout")
  761. }
  762.  
  763. return PLUGIN_HANDLED
  764. }
  765.  
  766. public cmdUsp(id)
  767. {
  768. if (timer_started[id] && (user_has_weapon(id, CSW_SCOUT)))
  769. {
  770. ColorChat(id, GREEN, "[XJ]^x01 You need to reset your timer to get usp & knife.")
  771. return PLUGIN_CONTINUE
  772. }
  773. else
  774. {
  775. give_item(id,"weapon_usp")
  776. give_item(id,"weapon_knife")
  777. }
  778.  
  779. return PLUGIN_HANDLED
  780. }
  781.  
  782. // ========================== Start location =================
  783.  
  784. public goStart(id)
  785. {
  786. if( !is_user_alive( id ) )
  787. {
  788. switch (get_pcvar_num(kz_chatorhud))
  789. {
  790. case 1: ColorChat(id, GREEN, "[XJ]^x01 You must be alive to use this command.")
  791. case 2: kz_hud_message(id, "You must be alive to use this command")
  792. }
  793.  
  794. return PLUGIN_HANDLED
  795. }
  796.  
  797. if (IsPaused[id])
  798. {
  799. switch (get_pcvar_num(kz_chatorhud))
  800. {
  801. case 1: ColorChat(id, GREEN, "[XJ]^x01 You can't teleport in pause.")
  802. case 2: kz_hud_message(id, "You can't teleport in pause")
  803. }
  804. return PLUGIN_HANDLED
  805. }
  806.  
  807. if(get_pcvar_num(kz_save_autostart) == 1 && AutoStart [id] )
  808. {
  809. set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
  810. set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
  811. set_pev(id, pev_origin, SavedStart [id] )
  812.  
  813. switch (get_pcvar_num(kz_chatorhud))
  814. {
  815. case 1: ColorChat(id, GREEN, "[XJ]^x01 You have been teleported to the start button.")
  816. case 2: kz_hud_message(id, "You have been teleported to the start button")
  817. }
  818. }
  819. else if ( DefaultStart )
  820. {
  821. set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
  822. set_pev(id, pev_origin, DefaultStartPos)
  823.  
  824. switch (get_pcvar_num(kz_chatorhud))
  825. {
  826. case 1: ColorChat(id, GREEN, "[XJ]^x01 You have been teleported to the start button.")
  827. case 2: kz_hud_message(id, "You have been teleported to the start button")
  828. }
  829. }
  830. else
  831. {
  832. switch (get_pcvar_num(kz_chatorhud))
  833. {
  834. case 1: ColorChat(id, GREEN, "[XJ]^x01 No start position set for this map.")
  835. case 2: kz_hud_message(id, "No start position set for this map")
  836. }
  837.  
  838. CmdRespawn(id)
  839. }
  840.  
  841. return PLUGIN_HANDLED
  842. }
  843.  
  844. public setStart(id)
  845. {
  846. if (! (get_user_flags( id ) & KZ_LEVEL ))
  847. {
  848. switch (get_pcvar_num(kz_chatorhud))
  849. {
  850. case 1: ColorChat(id, GREEN, "[XJ]^x01 You have no acces to that command.")
  851. case 2 : kz_hud_message(id, "You have no acces to that command")
  852. }
  853. return PLUGIN_HANDLED
  854. }
  855.  
  856. new Float:origin[3], mapname[64]
  857. get_mapname(mapname, 63)
  858. pev(id, pev_origin, origin)
  859. kz_set_start(mapname, origin)
  860. AutoStart[id] = false;
  861. ColorChat(id, GREEN, "[XJ]^x01 Start position set for this map.")
  862.  
  863. return PLUGIN_HANDLED
  864. }
  865.  
  866. // ========= Respawn CT if dies ========
  867.  
  868. public Ham_CBasePlayer_Killed_Post(id)
  869. {
  870. if(get_pcvar_num(kz_respawn_ct) == 1)
  871. {
  872. if( get_pdata_int(id, 114) == 2 )
  873. {
  874. set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
  875. cs_set_user_deaths(id, 0)
  876. set_user_frags(id, 0)
  877. }
  878. }
  879. }
  880.  
  881.  
  882. // ============================= NightVision ================================================
  883.  
  884. public ToggleNVG(id)
  885. {
  886.  
  887. if( get_pcvar_num(kz_nvg) == 0 || !is_user_alive(id))
  888. return PLUGIN_CONTINUE;
  889.  
  890. if ( NightVisionUse[id] )
  891. StopNVG(id)
  892. else
  893. StartNVG(id)
  894.  
  895. return PLUGIN_HANDLED;
  896. }
  897.  
  898. public StartNVG(id)
  899. {
  900. emit_sound(id,CHAN_ITEM,"items/nvg_on.wav",1.0,ATTN_NORM,0,PITCH_NORM)
  901. set_task(0.1,"RunNVG",id+111111,_,_,"b")
  902. NightVisionUse[id] = true;
  903.  
  904. return PLUGIN_HANDLED
  905. }
  906.  
  907. public StopNVG(id)
  908. {
  909. emit_sound(id,CHAN_ITEM,"items/nvg_off.wav",1.0,ATTN_NORM,0,PITCH_NORM)
  910. remove_task(id+111111)
  911. NightVisionUse[id] = false;
  912.  
  913. return PLUGIN_HANDLED
  914. }
  915.  
  916.  
  917. public RunNVG(taskid)
  918. {
  919. new id = taskid - 111111
  920.  
  921. if (!is_user_alive(id)) return
  922.  
  923. new origin[3]
  924. get_user_origin(id,origin,3)
  925.  
  926. new color[17];
  927. get_pcvar_string(kz_nvg_colors,color,16);
  928.  
  929. new iRed[5], iGreen[7], iBlue[5]
  930. parse(color,iRed,4,iGreen ,6,iBlue,4)
  931.  
  932. message_begin(MSG_ONE_UNRELIABLE, SVC_TEMPENTITY, _, id)
  933. write_byte(TE_DLIGHT)
  934. write_coord(origin[0])
  935. write_coord(origin[1])
  936. write_coord(origin[2])
  937. write_byte(80)
  938. write_byte(str_to_num(iRed))
  939. write_byte(str_to_num(iGreen))
  940. write_byte(str_to_num(iBlue))
  941. write_byte(2)
  942. write_byte(0)
  943. message_end()
  944. }
  945.  
  946. // ============================ Hook ==============================================================
  947.  
  948. public give_hook(id)
  949. {
  950. if (!( get_user_flags( id ) & KZ_LEVEL ))
  951. return PLUGIN_HANDLED
  952.  
  953. new szarg1[32], szarg2[8], bool:mode
  954. read_argv(1,szarg1,32)
  955. read_argv(2,szarg2,32)
  956. if(equal(szarg2,"on"))
  957. mode = true
  958.  
  959. if(equal(szarg1,"@ALL"))
  960. {
  961. for(new i=1;i<=MaxPlayers;i++)
  962. {
  963. if(is_user_connected(i) && is_user_alive(i))
  964. {
  965. canusehook[i] = mode
  966. if(mode)
  967. {
  968. ColorChat(i, GREEN, "[XJ]^x01 Hook has been enabled, bind any key '+hook' to use it.")
  969. }
  970. }
  971. }
  972. }
  973. else
  974. {
  975. new pid = find_player("bl",szarg1);
  976. if(pid > 0)
  977. {
  978. canusehook[pid] = mode
  979. if(mode)
  980. {
  981. ColorChat(pid, GREEN, "[XJ]^x01 Hook has been enabled, bind any key '+hook' to use it.")
  982. }
  983. }
  984. }
  985.  
  986. return PLUGIN_HANDLED
  987. }
  988.  
  989. // =================================================================================================
  990.  
  991. public hook_on(id)
  992. {
  993. if( !canusehook[id] && !( get_user_flags( id ) & KZ_LEVEL ) || !is_user_alive(id) )
  994. return PLUGIN_HANDLED
  995.  
  996. if (IsPaused[id])
  997. {
  998. kz_hud_message(id, "You can't use hook while paused")
  999. return PLUGIN_HANDLED
  1000. }
  1001.  
  1002. detect_cheat(id,"Hook")
  1003. get_user_origin(id,hookorigin[id],3)
  1004. ishooked[id] = true
  1005. antihookcheat[id] = get_gametime()
  1006.  
  1007. if (get_pcvar_num(kz_hook_sound) == 1)
  1008. emit_sound(id,CHAN_STATIC,"weapons/xbow_hit2.wav",1.0,ATTN_NORM,0,PITCH_NORM)
  1009.  
  1010. set_task(0.1,"hook_task",id,"",0,"ab")
  1011. hook_task(id)
  1012.  
  1013. return PLUGIN_HANDLED
  1014. }
  1015.  
  1016. // =================================================================================================
  1017.  
  1018. public hook_off(id)
  1019. {
  1020. remove_hook(id)
  1021.  
  1022. return PLUGIN_HANDLED
  1023. }
  1024.  
  1025. // =================================================================================================
  1026.  
  1027. public hook_task(id)
  1028. {
  1029. if(!is_user_connected(id) || !is_user_alive(id))
  1030. remove_hook(id)
  1031.  
  1032. remove_beam(id)
  1033. draw_hook(id)
  1034.  
  1035. new origin[3], Float:velocity[3]
  1036. get_user_origin(id,origin)
  1037. new distance = get_distance(hookorigin[id],origin)
  1038. velocity[0] = (hookorigin[id][0] - origin[0]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
  1039. velocity[1] = (hookorigin[id][1] - origin[1]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
  1040. velocity[2] = (hookorigin[id][2] - origin[2]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
  1041.  
  1042. set_pev(id,pev_velocity,velocity)
  1043. }
  1044.  
  1045. // =================================================================================================
  1046.  
  1047. public draw_hook(id)
  1048. {
  1049. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1050. write_byte(1) // TE_BEAMENTPOINT
  1051. write_short(id) // entid
  1052. write_coord(hookorigin[id][0]) // origin
  1053. write_coord(hookorigin[id][1]) // origin
  1054. write_coord(hookorigin[id][2]) // origin
  1055. write_short(Sbeam) // sprite index
  1056. write_byte(0) // start frame
  1057. write_byte(0) // framerate
  1058. write_byte(random_num(1,100)) // life
  1059. write_byte(random_num(1,20)) // width
  1060. write_byte(random_num(1,0)) // noise
  1061. write_byte(random_num(1,255)) // r
  1062. write_byte(random_num(1,255)) // g
  1063. write_byte(random_num(1,255)) // b
  1064. write_byte(random_num(1,500)) // brightness
  1065. write_byte(random_num(1,200)) // speed
  1066. message_end()
  1067. }
  1068.  
  1069. public remove_hook(id)
  1070. {
  1071. if(task_exists(id))
  1072. remove_task(id)
  1073. remove_beam(id)
  1074. ishooked[id] = false
  1075. }
  1076.  
  1077. public remove_beam(id)
  1078. {
  1079. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1080. write_byte(99) // TE_KILLBEAM
  1081. write_short(id)
  1082. message_end()
  1083. }
  1084.  
  1085. //============================ VIP In ScoreBoard =================================================
  1086.  
  1087. public MessageScoreAttrib( iMsgID, iDest, iReceiver )
  1088. {
  1089. if( get_pcvar_num(kz_vip) )
  1090. {
  1091. new iPlayer = get_msg_arg_int( 1 )
  1092. if( is_user_connected( iPlayer ) && ( get_user_flags( iPlayer ) & KZ_LEVEL ) )
  1093. {
  1094. set_msg_arg_int( 2, ARG_BYTE, is_user_alive( iPlayer ) ? SCOREATTRIB_VIP : SCOREATTRIB_DEAD );
  1095. }
  1096. }
  1097. }
  1098.  
  1099. public EventStatusValue( const id )
  1100. {
  1101.  
  1102. new szMessage[ 34 ], Target, aux
  1103. get_user_aiming(id, Target, aux)
  1104. formatex( szMessage, 33, "1 %s: %%p2", get_user_flags( Target ) & KZ_LEVEL ? "VIP" : "Player" )
  1105.  
  1106. message_begin( MSG_ONE_UNRELIABLE, get_user_msgid( "StatusText" ) , _, id )
  1107. write_byte( 0 )
  1108. write_string( szMessage )
  1109. message_end( )
  1110. }
  1111.  
  1112. public detect_cheat(id,reason[])
  1113. {
  1114. if(timer_started[id] && get_pcvar_num(kz_cheatdetect) == 1)
  1115. {
  1116. timer_started[id] = false
  1117. switch (get_pcvar_num(kz_chatorhud))
  1118. {
  1119. case 1: ColorChat(id, GREEN, "[XJ]^x01 %s detected. Timer reseted.",reason)
  1120. case 2: kz_hud_message(id, "%s detected. Timer reseted.",reason)
  1121. }
  1122. }
  1123. }
  1124.  
  1125.  
  1126. // =================================================================================================
  1127. // Cmds
  1128. // =================================================================================================
  1129.  
  1130. public CheckPoint(id)
  1131. {
  1132. if(get_pcvar_num(kz_checkpoints) == 1)
  1133. {
  1134.  
  1135. if( !is_user_alive( id ) )
  1136. {
  1137. switch (get_pcvar_num(kz_chatorhud))
  1138. {
  1139. case 1: ColorChat(id, GREEN, "[XJ]^x01 You must be alive to use this command.")
  1140. case 2: kz_hud_message(id, "You must be alive to use this command")
  1141. }
  1142. return PLUGIN_HANDLED
  1143. }
  1144.  
  1145. if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) )
  1146. {
  1147. switch (get_pcvar_num(kz_chatorhud))
  1148. {
  1149. case 1: ColorChat(id, GREEN, "[XJ]^x01 You can't make a checkpoint in the air.")
  1150. case 2: kz_hud_message(id, "You can't make a checkpoint in the air")
  1151. }
  1152. return PLUGIN_HANDLED
  1153. }
  1154.  
  1155. if( IsPaused[id] )
  1156. {
  1157. switch (get_pcvar_num(kz_chatorhud))
  1158. {
  1159. case 1: ColorChat(id, GREEN, "[XJ]^x01 You can't make a checkpoint in pause.")
  1160. case 2: kz_hud_message(id, "You can't make a checkpoint in pause")
  1161. }
  1162. return PLUGIN_HANDLED
  1163. }
  1164.  
  1165. pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id] ? 1 : 0])
  1166. g_bCpAlternate[id] = !g_bCpAlternate[id]
  1167. checknumbers[id]++
  1168.  
  1169. switch (get_pcvar_num(kz_chatorhud))
  1170. {
  1171. case 1: ColorChat(id, GREEN, "[XJ]^x01 Checkpoint #%d created",checknumbers[id])
  1172. case 2: kz_hud_message(id, "Checkpoint #%d",checknumbers[id])
  1173. }
  1174. }
  1175. else
  1176. {
  1177. switch (get_pcvar_num(kz_chatorhud))
  1178. {
  1179. case 1: ColorChat(id, GREEN, "[XJ]^x01 Checkpoints are off.")
  1180. case 2: kz_hud_message(id, "Checkpoints are off")
  1181. }
  1182. }
  1183. return PLUGIN_HANDLED
  1184. }
  1185.  
  1186. public GoCheck(id)
  1187. {
  1188. if( !is_user_alive( id ) )
  1189. {
  1190. switch (get_pcvar_num(kz_chatorhud))
  1191. {
  1192. case 1: ColorChat(id, GREEN, "[XJ]^x01 You must be alive to use this command.")
  1193. case 2: kz_hud_message(id, "You must be alive to use this command")
  1194. }
  1195. return PLUGIN_HANDLED
  1196. }
  1197.  
  1198. if( checknumbers[id] == 0 )
  1199. {
  1200. switch (get_pcvar_num(kz_chatorhud))
  1201. {
  1202. case 1: ColorChat(id, GREEN, "[XJ]^x01 You don't have enough Checkpoints.")
  1203. case 2: kz_hud_message(id, "You don't have enough Checkpoints")
  1204. }
  1205. return PLUGIN_HANDLED
  1206. }
  1207.  
  1208. if( IsPaused[id] )
  1209. {
  1210. switch (get_pcvar_num(kz_chatorhud))
  1211. {
  1212. case 1: ColorChat(id, GREEN, "[XJ]^x01 You can't teleport in pause.")
  1213. case 2: kz_hud_message(id, "You can't teleport in pause")
  1214. }
  1215. return PLUGIN_HANDLED
  1216. }
  1217.  
  1218. set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} )
  1219. set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
  1220. set_pev( id, pev_fuser2, 0.0 )
  1221. engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 18.0 } )
  1222. set_pev(id, pev_origin, Checkpoints[ id ][ !g_bCpAlternate[id] ] )
  1223.  
  1224. gochecknumbers[id]++
  1225. switch (get_pcvar_num(kz_chatorhud))
  1226. {
  1227. case 1: ColorChat(id, GREEN, "[XJ]^x01 GoCheck #%d",gochecknumbers[id])
  1228. case 2: kz_hud_message(id, "GoCheck #%d",gochecknumbers[id])
  1229. }
  1230. return PLUGIN_HANDLED
  1231. }
  1232.  
  1233. public Stuck(id)
  1234. {
  1235. if( !is_user_alive( id ) )
  1236. {
  1237. switch (get_pcvar_num(kz_chatorhud))
  1238. {
  1239. case 1: ColorChat(id, GREEN, "[XJ]^x01 You must be alive to use this command.")
  1240. case 2: kz_hud_message(id, "You must be alive to use this command")
  1241. }
  1242. return PLUGIN_HANDLED
  1243. }
  1244.  
  1245. if( checknumbers[id] < 2 )
  1246. {
  1247. switch (get_pcvar_num(kz_chatorhud))
  1248. {
  1249. case 1: ColorChat(id, GREEN, "[XJ]^x01 You don't have enough Checkpoints.")
  1250. case 2: kz_hud_message(id, "You don't have enough Checkpoints")
  1251. }
  1252. return PLUGIN_HANDLED
  1253. }
  1254.  
  1255. set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} )
  1256. set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
  1257. set_pev( id, pev_fuser2, 0.0 )
  1258. engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 18.0 } )
  1259. set_pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id]] )
  1260.  
  1261. g_bCpAlternate[id] = !g_bCpAlternate[id];
  1262.  
  1263. gochecknumbers[id]++
  1264. switch (get_pcvar_num(kz_chatorhud))
  1265. {
  1266. case 1: ColorChat(id, GREEN, "[XJ]^x01 GoCheck #%d",gochecknumbers[id])
  1267. case 2: kz_hud_message(id, "GoCheck #%d",gochecknumbers[id])
  1268. }
  1269.  
  1270. return PLUGIN_HANDLED
  1271. }
  1272.  
  1273. // =================================================================================================
  1274.  
  1275. public reset_checkpoints(id)
  1276. {
  1277. checknumbers[id] = 0
  1278. gochecknumbers[id] = 0
  1279. timer_started[id] = false
  1280. timer_time[id] = 0.0
  1281. if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2 )
  1282. kz_showtime_roundtime(id, 0)
  1283.  
  1284. return PLUGIN_HANDLED
  1285. }
  1286.  
  1287. //===== Invis =======
  1288.  
  1289. public cmdInvisible(id)
  1290. {
  1291. if(!gViewInvisible[id])
  1292. {
  1293. gViewInvisible[id] = true
  1294. switch (get_pcvar_num(kz_chatorhud))
  1295. {
  1296. case 1: ColorChat(id, GREEN, "[XJ]^x01 Players are now^x03 invisible^x01")
  1297. case 2: kz_hud_message(id, "Players are now invisible")
  1298. }
  1299. }
  1300. else
  1301. {
  1302. gViewInvisible[id] = false
  1303. switch (get_pcvar_num(kz_chatorhud))
  1304. {
  1305. case 1: ColorChat(id, GREEN, "[XJ]^x01 Players are now^x03 visible^x01")
  1306. case 2: kz_hud_message(id, "Players are now visible")
  1307. }
  1308. }
  1309.  
  1310. return PLUGIN_HANDLED
  1311. }
  1312.  
  1313. public cmdWaterInvisible(id)
  1314. {
  1315. if( gWaterFound )
  1316. {
  1317. if(!gWaterInvisible[id])
  1318. {
  1319. gWaterInvisible[id] = true
  1320. switch (get_pcvar_num(kz_chatorhud))
  1321. {
  1322. case 1: ColorChat(id, GREEN, "[XJ]^x01 Water is now^x03 invisible^x01")
  1323. case 2: kz_hud_message(id, "Water is now invisible")
  1324. }
  1325. }
  1326. else
  1327. {
  1328. gWaterInvisible[id] = false
  1329. switch (get_pcvar_num(kz_chatorhud))
  1330. {
  1331. case 1: ColorChat(id, GREEN, "[XJ]^x01 Water is now^x03 visible^x01")
  1332. case 2: kz_hud_message(id, "Water is now visible")
  1333. }
  1334. }
  1335. }
  1336. else
  1337. {
  1338. switch (get_pcvar_num(kz_chatorhud))
  1339. {
  1340. case 1: ColorChat(id, GREEN, "[XJ]^x01 There is no water on the map.")
  1341. case 2 : kz_hud_message(id, "There is not water on the map")
  1342. }
  1343. }
  1344.  
  1345. return PLUGIN_HANDLED
  1346. }
  1347.  
  1348. // ================== Semiclip/Invis ======================
  1349.  
  1350. public FM_client_AddToFullPack_Post(es, e, ent, host, hostflags, player, pSet)
  1351. {
  1352. if( player )
  1353. {
  1354. if (get_pcvar_num(kz_semiclip) == 1)
  1355. {
  1356. if ( host != ent && get_orig_retval() && is_user_alive(host) )
  1357. {
  1358. set_es(es, ES_Solid, SOLID_NOT)
  1359. set_es(es, ES_RenderMode, kRenderTransAlpha)
  1360. set_es(es, ES_RenderAmt, 85)
  1361. }
  1362. }
  1363. if(gMarkedInvisible[ent] && gViewInvisible[host])
  1364. {
  1365. set_es(es, ES_RenderMode, kRenderTransTexture)
  1366. set_es(es, ES_RenderAmt, 0)
  1367. set_es(es, ES_Origin, { 999999999.0, 999999999.0, 999999999.0 } )
  1368. }
  1369. }
  1370. else if( gWaterInvisible[host] && gWaterEntity[ent] )
  1371. {
  1372. set_es(es, ES_Effects, get_es( es, ES_Effects ) | EF_NODRAW )
  1373. }
  1374.  
  1375. return FMRES_IGNORED
  1376. }
  1377.  
  1378. public Ham_CBasePlayer_PreThink_Post(id)
  1379. {
  1380. if( !is_user_alive(id) )
  1381. {
  1382. return
  1383. }
  1384.  
  1385. RefreshPlayersList()
  1386.  
  1387. if (get_pcvar_num(kz_semiclip) == 1)
  1388. {
  1389. for(new i = 0; i<g_iNum; i++)
  1390. {
  1391. g_iPlayer = g_iPlayers[i]
  1392. if( id != g_iPlayer )
  1393. {
  1394. set_pev(g_iPlayer, pev_solid, SOLID_NOT)
  1395. }
  1396. }
  1397. }
  1398. }
  1399.  
  1400. public client_PostThink(id)
  1401. {
  1402. if( !is_user_alive(id) )
  1403. return
  1404.  
  1405. RefreshPlayersList()
  1406.  
  1407. if (get_pcvar_num(kz_semiclip) == 1)
  1408. for(new i = 0; i<g_iNum; i++)
  1409. {
  1410. g_iPlayer = g_iPlayers[i]
  1411. if( g_iPlayer != id )
  1412. set_pev(g_iPlayer, pev_solid, SOLID_SLIDEBOX)
  1413. }
  1414. }
  1415.  
  1416. // =================================================================================================
  1417.  
  1418. public noclip(id)
  1419. {
  1420. set_user_noclip(id, get_user_noclip(id) == 1 ? 0 : 1)
  1421. if(get_user_noclip(id) == 1)
  1422. detect_cheat(id,"Noclip")
  1423. ColorChat(id, GREEN, "[XJ]^x01 Noclip ^x03%s^x01", get_user_noclip(id) ? "ON" : "OFF")
  1424.  
  1425. return PLUGIN_HANDLED
  1426. }
  1427.  
  1428. public GodMode(id)
  1429. {
  1430. set_user_godmode(id, get_user_godmode(id) == 1 ? 0 : 1)
  1431. if(get_user_godmode(id) == 1)
  1432. detect_cheat(id,"God Mode")
  1433. ColorChat(id, GREEN, "[XJ]^x01 God Mode ^x03%s^x01", get_user_godmode(id) ? "ON" : "OFF")
  1434.  
  1435. return PLUGIN_HANDLED
  1436. }
  1437.  
  1438.  
  1439. // =================================================================================================
  1440.  
  1441.  
  1442. stock kz_set_start(const map[], Float:origin[3])
  1443. {
  1444. new realfile[128], tempfile[128], formatorigin[50]
  1445. formatex(realfile, 127, "%s/%s", KZ_DIR, KZ_STARTFILE)
  1446. formatex(tempfile, 127, "%s/%s", KZ_DIR, KZ_STARTFILE_TEMP)
  1447. formatex(formatorigin, 49, "%f %f %f", origin[0], origin[1], origin[2])
  1448.  
  1449. DefaultStartPos = origin
  1450. DefaultStart = true
  1451.  
  1452. new file = fopen(tempfile, "wt")
  1453. new vault = fopen(realfile, "rt")
  1454.  
  1455. new data[128], key[64]
  1456. new bool:replaced = false
  1457.  
  1458. while( !feof(vault) )
  1459. {
  1460. fgets(vault, data, 127)
  1461. parse(data, key, 63)
  1462.  
  1463. if( equal(key, map) && !replaced )
  1464. {
  1465. fprintf(file, "%s %s^n", map, formatorigin)
  1466.  
  1467. replaced = true
  1468. }
  1469. else
  1470. {
  1471. fputs(file, data)
  1472. }
  1473. }
  1474.  
  1475. if( !replaced )
  1476. {
  1477. fprintf(file, "%s %s^n", map, formatorigin)
  1478. }
  1479.  
  1480. fclose(file)
  1481. fclose(vault)
  1482.  
  1483. delete_file(realfile)
  1484. while( !rename_file(tempfile, realfile, 1) ) {}
  1485. }
  1486.  
  1487. stock kz_showtime_roundtime(id, time)
  1488. {
  1489. if( is_user_connected(id) )
  1490. {
  1491. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid( "RoundTime" ), _, id);
  1492. write_short(time + 1);
  1493. message_end();
  1494. }
  1495. }
  1496.  
  1497. stock kz_hud_message(id, const message[], {Float,Sql,Result,_}:...)
  1498. {
  1499. static msg[192], colors[12], r[4], g[4], b[4];
  1500. vformat(msg, 191, message, 3);
  1501.  
  1502. get_pcvar_string(kz_hud_color, colors, 11)
  1503. parse(colors, r, 3, g, 3, b, 4)
  1504.  
  1505. set_hudmessage(str_to_num(r), str_to_num(g), str_to_num(b), -1.0, 0.90, 0, 0.0, 2.0, 0.0, 1.0, -1);
  1506. ShowSyncHudMsg(id, hud_message, msg);
  1507. }
  1508.  
  1509. stock GetNewRank(id, type)
  1510. {
  1511. new createinto[1001], mapname[64]
  1512. get_mapname(mapname, 63)
  1513.  
  1514. new cData[2]
  1515. cData[0] = id
  1516. cData[1] = type
  1517.  
  1518. formatex(createinto, 1000, "SELECT authid FROM `%s` WHERE mapname='%s' ORDER BY time LIMIT 15", type == PRO_TOP ? "kz_pro15" : "kz_nub15", mapname)
  1519. SQL_ThreadQuery(g_SqlTuple, "GetNewRank_QueryHandler", createinto, cData, 2)
  1520. }
  1521.  
  1522. stock kz_update_plrname(id)
  1523. {
  1524. new createinto[1001], authid[32], name[32]
  1525. get_user_authid(id, authid, 31)
  1526. get_user_name(id, name, 31)
  1527.  
  1528. if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
  1529. return 0;
  1530. else
  1531. {
  1532. formatex(createinto, 1000, "UPDATE `kz_pro15` SET name='%s' WHERE authid='%s'", name, authid)
  1533. SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
  1534. formatex(createinto, 1000, "UPDATE `kz_nub15` SET name='%s' WHERE authid='%s'", name, authid)
  1535. SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
  1536. }
  1537. return 1
  1538. }
  1539.  
  1540. public FwdSpawnWeaponbox( iEntity )
  1541. {
  1542. if(get_pcvar_num(kz_remove_drops) == 1)
  1543. {
  1544. set_pev( iEntity, pev_flags, FL_KILLME )
  1545. dllfunc( DLLFunc_Think, iEntity )
  1546. }
  1547.  
  1548. return HAM_IGNORED
  1549. }
  1550.  
  1551. public FwdHamDoorSpawn( iEntity )
  1552. {
  1553. static const szNull[ ] = "common/null.wav";
  1554.  
  1555. new Float:flDamage;
  1556. pev( iEntity, pev_dmg, flDamage );
  1557.  
  1558. if( flDamage < -999.0 ) {
  1559. set_pev( iEntity, pev_noise1, szNull );
  1560. set_pev( iEntity, pev_noise2, szNull );
  1561. set_pev( iEntity, pev_noise3, szNull );
  1562.  
  1563. if( !HealsOnMap )
  1564. HealsOnMap = true
  1565. }
  1566. }
  1567.  
  1568. public FwdHamPlayerSpawn( id )
  1569. {
  1570. if( !is_user_alive( id ) )
  1571. return;
  1572.  
  1573. if( HealsOnMap )
  1574. set_pev( id, pev_health, 50175.0 )
  1575.  
  1576. if( IsPaused[id] )
  1577. {
  1578. set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
  1579. set_pev(id, pev_origin, PauseOrigin[id])
  1580. }
  1581. }
  1582.  
  1583. public GroundWeapon_Touch(iWeapon, id)
  1584. {
  1585. if( is_user_alive(id) && timer_started[id] && get_pcvar_num(kz_pick_weapons) == 0 )
  1586. return HAM_SUPERCEDE
  1587.  
  1588. return HAM_IGNORED
  1589. }
  1590.  
  1591. // =================================================================================================
  1592. // Events / Forwards
  1593. // =================================================================================================
  1594.  
  1595. public resethud(id)
  1596. {
  1597. if( !user_has_weapon(id,CSW_KNIFE) )
  1598. give_item( id,"weapon_knife" )
  1599.  
  1600. if(firstspawn[id])
  1601. {
  1602. ColorChat(id, GREEN, "[XJ]^x01 Welcome to ^x03 kz.leet.ro ^x01")
  1603. ColorChat(id, GREEN, "[XJ]^x01 Visit ^x03www.KZ-Romania.com ^x01. Plugin created by ^x03nucLeaR ^x01.")
  1604. if(get_pcvar_num(kz_checkpoints) == 0)
  1605. ColorChat(id, GREEN, "[XJ]^x01 Checkpoints are off.")
  1606.  
  1607. if(get_pcvar_num(kz_spawn_mainmenu) == 1)
  1608. kz_menu (id)
  1609.  
  1610. kz_update_plrname(id)
  1611. }
  1612. firstspawn[id] = false
  1613.  
  1614. return HAM_IGNORED
  1615. }
  1616.  
  1617. //=================================================================================================
  1618.  
  1619. public client_disconnect(id)
  1620. {
  1621. checknumbers[id] = 0
  1622. gochecknumbers[id] = 0
  1623. antihookcheat[id] = 0.0
  1624. timer_started[id] = false
  1625. ShowTime[id] = get_pcvar_num(kz_show_timer)
  1626. firstspawn[id] = true
  1627. NightVisionUse[id] = false
  1628. IsPaused[id] = false
  1629. remove_hook(id)
  1630. }
  1631.  
  1632. public client_putinserver(id)
  1633. {
  1634. checknumbers[id] = 0
  1635. gochecknumbers[id] = 0
  1636. antihookcheat[id] = 0.0
  1637. timer_started[id] = false
  1638. ShowTime[id] = get_pcvar_num(kz_show_timer)
  1639. firstspawn[id] = true
  1640. NightVisionUse[id] = false
  1641. IsPaused[id] = false
  1642. remove_hook(id)
  1643. }
  1644.  
  1645. // =================================================================================================
  1646. // Menu
  1647. // =================================================================================================
  1648.  
  1649. public kz_menu(id)
  1650. {
  1651. new menu = menu_create("\yProKreedz Menu\w", "MenuHandler")
  1652. menu_setprop(menu, MPROP_PERPAGE, 0)
  1653.  
  1654. new msgcheck[64], msggocheck[64], msgpause[64]
  1655. formatex(msgcheck, 63, "Checkpoint - \y#%i", checknumbers[id])
  1656. formatex(msggocheck, 63, "Gocheck - \y#%i", gochecknumbers[id])
  1657. formatex(msgpause, 63, "Pause - %s^n", IsPaused[id] ? "\yON" : "\rOFF" )
  1658.  
  1659. menu_additem( menu, msgcheck, "1" )
  1660. menu_additem( menu, msggocheck, "2" )
  1661. menu_additem( menu, "Top 15^n", "3")
  1662. menu_additem( menu, "Start", "4")
  1663. menu_additem( menu, "Timer Menu", "5" )
  1664. menu_additem( menu, msgpause, "6" )
  1665. menu_additem( menu, "Invisible Menu", "7" )
  1666. menu_additem( menu, "Spectator/CT", "8" )
  1667. menu_additem( menu, "Reset Time^n", "9")
  1668. menu_additem( menu, "Exit", "*" )
  1669.  
  1670. menu_display(id, menu, 0)
  1671. return PLUGIN_HANDLED
  1672. }
  1673.  
  1674. public MenuHandler(id , menu, item)
  1675. {
  1676. if( item == MENU_EXIT ) {
  1677. menu_destroy(menu)
  1678. return PLUGIN_HANDLED
  1679. }
  1680.  
  1681. new data[6], name[32]
  1682. new access, callback
  1683.  
  1684. menu_item_getinfo(menu, item, access, data, 5, _, _, callback)
  1685.  
  1686. new key = str_to_num(data)
  1687. get_user_name(id, name, 31)
  1688.  
  1689. switch(key) {
  1690. case 1:{
  1691. CheckPoint(id)
  1692. kz_menu(id)
  1693. }
  1694. case 2:{
  1695. GoCheck(id)
  1696. kz_menu(id)
  1697. }
  1698. case 3:{
  1699. top15menu(id)
  1700. }
  1701. case 4:{
  1702. goStart(id)
  1703. kz_menu(id)
  1704. }
  1705. case 5:{
  1706. ShowTimer_Menu(id)
  1707. }
  1708. case 6:{
  1709. Pause(id)
  1710. kz_menu(id)
  1711. }
  1712. case 7:{
  1713. InvisMenu(id)
  1714. }
  1715. case 8:{
  1716. ct(id)
  1717.  
  1718. }
  1719. case 9:{
  1720. reset_checkpoints(id)
  1721. kz_menu(id)
  1722. }
  1723. case '*':{
  1724. }
  1725. }
  1726.  
  1727. return PLUGIN_HANDLED
  1728. }
  1729. public InvisMenu(id)
  1730. {
  1731. new menu = menu_create("\yInvis Menu\w", "InvisMenuHandler")
  1732. new msginvis[64], msgwaterinvis[64]
  1733.  
  1734. formatex(msginvis, 63, "Players - %s", gViewInvisible[id] ? "\yON" : "\rOFF" )
  1735. formatex(msgwaterinvis, 63, "Water - %s^n^n", gWaterInvisible[id] ? "\yON" : "\rOFF" )
  1736.  
  1737. menu_additem( menu, msginvis, "1" )
  1738. menu_additem( menu, msgwaterinvis, "2" )
  1739.  
  1740. menu_display(id, menu, 0)
  1741. return PLUGIN_HANDLED
  1742. }
  1743.  
  1744. public InvisMenuHandler (id, menu, item)
  1745. {
  1746. if( item == MENU_EXIT )
  1747. {
  1748. menu_destroy(menu)
  1749. return PLUGIN_HANDLED
  1750. }
  1751.  
  1752. new data[6]
  1753. new access, callback
  1754.  
  1755. menu_item_getinfo(menu, item, access, data, 5, _, _, callback)
  1756.  
  1757. new key = str_to_num(data)
  1758.  
  1759. switch(key)
  1760. {
  1761.  
  1762. case 1:
  1763. {
  1764. cmdInvisible(id)
  1765. InvisMenu(id)
  1766. }
  1767. case 2:
  1768. {
  1769. cmdWaterInvisible(id)
  1770. InvisMenu(id)
  1771. }
  1772. case 9:
  1773. {
  1774. show_menu(id,0,"")
  1775. }
  1776. }
  1777. return PLUGIN_HANDLED
  1778. }
  1779.  
  1780. public ShowTimer_Menu(id)
  1781. {
  1782. if (get_pcvar_num(kz_show_timer) == 0 )
  1783. {
  1784. kz_hud_message(id, "Timer show is disabled by CVar")
  1785. return PLUGIN_HANDLED
  1786. }
  1787. else
  1788. {
  1789. new menu = menu_create("\yTimer Menu\w", "TimerHandler")
  1790.  
  1791. new roundtimer[64], hudtimer[64], notimer[64];
  1792.  
  1793. formatex(roundtimer, 63, "Round Timer %s", ShowTime[id] == 2 ? "\y x" : "" )
  1794. formatex(hudtimer, 63, "HUD Timer %s", ShowTime[id] == 1 ? "\y x" : "" )
  1795. formatex(notimer, 63, "No Timer %s^n", ShowTime[id] == 0 ? "\y x" : "" )
  1796.  
  1797. menu_additem( menu, roundtimer, "1" )
  1798. menu_additem( menu, hudtimer, "2" )
  1799. menu_additem( menu, notimer, "3" )
  1800. menu_additem( menu, "Main Menu", "4" )
  1801.  
  1802. menu_display(id, menu, 0)
  1803. return PLUGIN_HANDLED
  1804. }
  1805.  
  1806. return PLUGIN_HANDLED
  1807. }
  1808.  
  1809. public TimerHandler (id, menu, item)
  1810. {
  1811. if( item == MENU_EXIT )
  1812. {
  1813. menu_destroy(menu)
  1814. return PLUGIN_HANDLED
  1815. }
  1816.  
  1817. new data[6]
  1818. new access, callback
  1819.  
  1820. menu_item_getinfo(menu, item, access, data, 5, _, _, callback)
  1821.  
  1822. new key = str_to_num(data)
  1823.  
  1824. switch(key)
  1825. {
  1826.  
  1827. case 1:
  1828. {
  1829. ShowTime[id]= 2
  1830. ShowTimer_Menu(id)
  1831. }
  1832. case 2:
  1833. {
  1834. ShowTime[id]= 1
  1835. ShowTimer_Menu(id)
  1836. if (timer_started[id])
  1837. kz_showtime_roundtime(id, 0)
  1838. }
  1839. case 3:
  1840. {
  1841. ShowTime[id]= 0
  1842. ShowTimer_Menu(id)
  1843. if (timer_started[id])
  1844. kz_showtime_roundtime(id, 0)
  1845. }
  1846. case 4:
  1847. {
  1848. kz_menu(id)
  1849. }
  1850. case 9:
  1851. {
  1852. show_menu(id,0,"")
  1853. }
  1854. }
  1855. return PLUGIN_HANDLED
  1856. }
  1857.  
  1858. public top15menu(id)
  1859. {
  1860. new menu = menu_create("\r[ProKreedz] \yTop15 \w", "menufunc")
  1861. menu_additem(menu, "Pro 15", "1")
  1862. menu_additem(menu, "Noob 15", "2")
  1863. menu_additem(menu, "Pro Records","3")
  1864. menu_additem(menu, "Players Rankings^n","4")
  1865. menu_additem(menu, "Last 10 Pro Entries", "5")
  1866. menu_additem(menu, "Maps Statistic","6")
  1867.  
  1868.  
  1869. menu_display(id, menu, 0)
  1870. return PLUGIN_HANDLED
  1871. }
  1872.  
  1873. public menufunc(id, menu, item)
  1874. {
  1875. if(item == MENU_EXIT)
  1876. {
  1877. menu_destroy(menu)
  1878. return PLUGIN_HANDLED
  1879. }
  1880.  
  1881. new data[6], iName[64]
  1882. new iaccess, callback
  1883.  
  1884. menu_item_getinfo(menu, item, iaccess, data,5, iName, 63, callback)
  1885.  
  1886. new key = str_to_num(data);
  1887.  
  1888. switch(key)
  1889. {
  1890. case 1:
  1891. {
  1892. ProTop_show(id)
  1893. }
  1894. case 2:
  1895. {
  1896. NoobTop_show(id)
  1897. }
  1898. case 3:
  1899. {
  1900. kz_showhtml_motd(id, PRO_RECORDS, "")
  1901. }
  1902. case 4:
  1903. {
  1904. kz_showhtml_motd(id, PLAYERS_RANKING, "")
  1905. }
  1906. case 5:
  1907. {
  1908. kz_showhtml_motd(id, LAST_PRO10, "")
  1909. }
  1910. case 6:
  1911. {
  1912. kz_showhtml_motd(id, MAPS_STATISTIC, "")
  1913. }
  1914. case 9:
  1915. {
  1916. show_menu(id,0,"")
  1917. }
  1918. }
  1919.  
  1920. return PLUGIN_HANDLED;
  1921. }
  1922.  
  1923. stock kz_showhtml_motd(id, type, const map[])
  1924. {
  1925. new buffer[1001], namebuffer[64], filepath[96]
  1926. get_pcvar_string(kz_sql_file, filepath, 95)
  1927. new authid[32]
  1928. get_user_authid(id, authid, 31)
  1929.  
  1930. switch( type )
  1931. {
  1932. case PRO_TOP:
  1933. {
  1934. formatex(namebuffer, 63, "Pro 15 of %s", equal(map, "") ? "All Maps" : map)
  1935. formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/pro15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
  1936. }
  1937. case NUB_TOP:
  1938. {
  1939. formatex(namebuffer, 63, "Noob 15 of %s", equal(map, "") ? "All Maps" : map)
  1940. formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/nub15.php?map=%s^"></head><body><p>LOADING...</p></body></html>", filepath, map)
  1941. }
  1942. case PRO_RECORDS:
  1943. {
  1944. formatex(namebuffer, 63, "ProRecords and Rank")
  1945. formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/player.php?authid=%s^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
  1946. }
  1947. case PLAYERS_RANKING:
  1948. {
  1949. formatex(namebuffer, 63, "Players Ranking")
  1950. formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/players.php^"></head><body><p>LOADING...</p></body></html>", filepath, authid)
  1951. }
  1952. case LAST_PRO10:
  1953. {
  1954. formatex(namebuffer, 63, "Last 10 Pro Entries")
  1955. formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/kz_lastpro.php^"></head><body><p>LOADING...</p></body></html>", filepath)
  1956. }
  1957. case MAPS_STATISTIC:
  1958. {
  1959. formatex(namebuffer, 63, "Maps Statistic")
  1960. formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/map.php^"></head><body><p>LOADING...</p></body></html>", filepath)
  1961. }
  1962. }
  1963.  
  1964. show_motd(id, buffer, namebuffer)
  1965. }
  1966.  
  1967. // Timersystem
  1968. // =================================================================================================
  1969. public fwdUse(ent, id)
  1970. {
  1971. if( !ent || id > 32 )
  1972. {
  1973. return HAM_IGNORED;
  1974. }
  1975.  
  1976. if( !is_user_alive(id) )
  1977. {
  1978. return HAM_IGNORED;
  1979. }
  1980.  
  1981. new name[32]
  1982. get_user_name(id, name, 31)
  1983.  
  1984. new szTarget[ 32 ];
  1985. pev(ent, pev_target, szTarget, 31);
  1986.  
  1987. if( TrieKeyExists( g_tStarts, szTarget ) )
  1988. {
  1989.  
  1990. if ( get_gametime() - antihookcheat[id] < 3.0 )
  1991. {
  1992. kz_hud_message( id, "Wait 3 seconds after using hook" );
  1993. return PLUGIN_HANDLED
  1994. }
  1995.  
  1996. if ( reset_checkpoints(id) && !timer_started[id] )
  1997. {
  1998. start_climb(id)
  1999.  
  2000. if(get_pcvar_num(kz_strip_other_weapons) == 1)
  2001. for(new i = 0; i < 8; i++)
  2002. if( user_has_weapon(id, other_weapons[i]) )
  2003. {
  2004. strip_user_weapons(id)
  2005. give_item(id,"weapon_knife")
  2006. give_item(id,"weapon_usp")
  2007. set_pdata_int(id, 382, 24, 5)
  2008. }
  2009.  
  2010. if( pev(id, pev_health) < 100 )
  2011. set_pev(id, pev_health, 100.0)
  2012.  
  2013. pev(id, pev_origin, SavedStart[id])
  2014. if(get_pcvar_num(kz_save_autostart) == 1)
  2015. AutoStart[id] = true;
  2016.  
  2017. if( !DefaultStart )
  2018. {
  2019. new mapname[64]
  2020. get_mapname( mapname, 63)
  2021. kz_set_start(mapname, SavedStart[id])
  2022. ColorChat(id, GREEN, "[XJ]^x01 Start position set for this map.")
  2023. }
  2024.  
  2025. remove_hook(id)
  2026. }
  2027.  
  2028. }
  2029.  
  2030. if( TrieKeyExists( g_tStops, szTarget ) )
  2031. {
  2032. if( timer_started[id] )
  2033. {
  2034. finish_climb(id)
  2035.  
  2036. if(get_pcvar_num(kz_hook_prize) == 1 && !canusehook[id])
  2037. {
  2038. canusehook[id] = true
  2039. ColorChat(id, GREEN, "[XJ]^x01 Hook has been enabled, bind any key '+hook' to use it.")
  2040. }
  2041. }
  2042. else
  2043. kz_hud_message(id, "You must press the start button first")
  2044.  
  2045. }
  2046. return HAM_IGNORED
  2047. }
  2048.  
  2049. public start_climb(id)
  2050. {
  2051. switch (get_pcvar_num(kz_chatorhud))
  2052. {
  2053. case 1: ColorChat(id, GREEN, "[XJ]^x01 Timer started.")
  2054. case 2: kz_hud_message(id, "Timer started")
  2055. }
  2056.  
  2057. if (get_pcvar_num(kz_reload_weapons) == 1)
  2058. {
  2059. strip_user_weapons(id)
  2060. give_item(id,"weapon_knife")
  2061. give_item(id,"weapon_usp")
  2062. }
  2063.  
  2064. if (ShowTime[id] == 2)
  2065. kz_showtime_roundtime(id, 0)
  2066. set_pev(id, pev_gravity, 1.0);
  2067. set_pev(id, pev_movetype, MOVETYPE_WALK)
  2068. set_user_godmode(id, 0)
  2069. reset_checkpoints(id)
  2070. IsPaused[id] = false
  2071. timer_started[id] = true
  2072. timer_time[id] = get_gametime()
  2073. }
  2074.  
  2075.  
  2076. public finish_climb(id)
  2077. {
  2078. if (!is_user_alive (id))
  2079. {
  2080. return;
  2081. }
  2082.  
  2083. new Float: time, weapon
  2084. time = get_gametime() - timer_time[id]
  2085. show_finish_message(id, time)
  2086. timer_started[id] = false
  2087. new checkpoints=checknumbers[id]
  2088. new gocheck=gochecknumbers[id]
  2089. if (user_has_weapon(id,CSW_SCOUT) )
  2090. weapon = CSW_SCOUT
  2091. else
  2092. weapon=get_user_weapon(id)
  2093.  
  2094. new map[64], steam[32], name[32]
  2095. get_mapname(map, sizeof map - 1 )
  2096. get_user_name(id, name, 31)
  2097. get_user_authid(id, steam, 31 )
  2098. client_cmd(0, "spk buttons/bell1")
  2099. new createinto[1001]
  2100.  
  2101. new cData[192]
  2102. cData[0] = id
  2103. formatex(cData[2], charsmax(cData)-2, "^"%f^" ^"%d^" ^"%d^" ^"%d^"", time, weapon, checkpoints ,gocheck)
  2104.  
  2105.  
  2106. if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
  2107. {
  2108. if (gochecknumbers[id] == 0 && !user_has_weapon(id,CSW_SCOUT) )
  2109. {
  2110. cData[1] = PRO_TOP
  2111. formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND name='%s'", map, name)
  2112. SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
  2113. }
  2114. if (gochecknumbers[id] > 0 || user_has_weapon(id,CSW_SCOUT) )
  2115. {
  2116. cData[1] = NUB_TOP
  2117. formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND name='%s'", map, name)
  2118. SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
  2119. }
  2120. } else
  2121. {
  2122.  
  2123. if (gochecknumbers[id] == 0 && !user_has_weapon(id,CSW_SCOUT) )
  2124. {
  2125. cData[1] = PRO_TOP
  2126. formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND authid='%s'", map, steam)
  2127. SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
  2128. }
  2129. if (gochecknumbers[id] > 0 || user_has_weapon(id,CSW_SCOUT) )
  2130. {
  2131. cData[1] = NUB_TOP
  2132. formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND authid='%s'", map, steam)
  2133. SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
  2134. }
  2135. }
  2136. }
  2137.  
  2138. public show_finish_message(id, Float:kreedztime)
  2139. {
  2140. new name[32]
  2141. new imin,isec,ims, wpn = get_user_weapon( id )
  2142. get_user_name(id, name, 31)
  2143. kreedztime = get_gametime() - timer_time[id]
  2144. imin = floatround(kreedztime / 60.0, floatround_floor)
  2145. isec = floatround(kreedztime - imin * 60.0,floatround_floor)
  2146. ims = floatround( ( kreedztime - ( imin * 60.0 + isec ) ) * 100.0, floatround_floor )
  2147.  
  2148. ColorChat(0, GREEN, "[XJ]^x01^x03 %s^x01 finished in^x04 %02i:%02i.%02i ^x03(^x01 CPs: ^x04%d^x03 | ^x01 TPs: ^x04%d^x03 | ^x01 Weapon: ^x04%s^x03) ^x01 !",name,imin,isec,ims, checknumbers[id], gochecknumbers[id], g_weaponsnames[wpn])
  2149. }
  2150.  
  2151.  
  2152. public Set_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  2153. {
  2154. new id = cData[0]
  2155. new style = cData[1]
  2156. if( iFailState != TQUERY_SUCCESS )
  2157. {
  2158. log_amx("[XJ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
  2159. ColorChat(0, GREEN, "[XJ]^x01: Warring the SQL Tops can not be saved.")
  2160. }
  2161.  
  2162. server_print("[XJ] Server Geting Info of SQL Server")
  2163.  
  2164. new createinto[1001]
  2165. new x1[16], x2[4], x3[5], x4[5]
  2166. parse(cData[2], x1, 15, x2, 3, x3, 4, x4, 4)
  2167.  
  2168. new dia[64], map[64], steam[32], name[32], ip[15], country[3], checkpoints[32], gochecks[32]
  2169. new Float:newtime = str_to_float(x1)
  2170. new iMin, iSec, iMs, server[64]
  2171. get_pcvar_string(kz_sql_name, server, 63)
  2172. get_time("%Y%m%d%H%M%S", dia, sizeof dia - 1)
  2173. get_mapname(map, sizeof map - 1)
  2174. get_user_authid(id, steam, 31)
  2175. get_user_name(id, name, sizeof name - 1)
  2176. get_user_ip (id, ip, sizeof ip - 1, 1)
  2177. geoip_code2_ex( ip, country)
  2178.  
  2179. replace_all(name, 31, "\", "")
  2180. replace_all(name, 31, "`", "")
  2181. replace_all(name, 31, "'", "")
  2182.  
  2183.  
  2184. if( SQL_NumResults(hQuery) == 0 )
  2185. {
  2186. formatex(checkpoints, 31, ", '%d'", str_to_num(x3))
  2187. formatex(gochecks, 31, ", '%d'", str_to_num(x4))
  2188. formatex( createinto, sizeof createinto - 1, "INSERT INTO `%s` VALUES('%s', '%s','%s','%s','%f','%s','%s','%s'%s%s)", style == PRO_TOP ? "kz_pro15" : "kz_nub15", map, steam, country, name, newtime, dia, g_weaponsnames[str_to_num(x2)], server, style == PRO_TOP ? "" : checkpoints, style == PRO_TOP ? "" : gochecks)
  2189. SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
  2190. GetNewRank(id, style)
  2191. }
  2192. else
  2193. {
  2194. new Float:oldtime, Float:thetime
  2195. SQL_ReadResult(hQuery, 0, oldtime)
  2196.  
  2197. if(newtime < oldtime)
  2198. {
  2199. thetime = oldtime - newtime
  2200. iMin = floatround(thetime / 60.0, floatround_floor)
  2201. iSec = floatround(thetime - iMin * 60.0,floatround_floor)
  2202. iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
  2203. ColorChat(id, GREEN, "[XJ]^x01 You improved your time by^x03 %02i:%02i.%02i^x01 in ^x03%s", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
  2204. formatex(checkpoints, 31, ", checkpoints='%d'", str_to_num(x3))
  2205. formatex(gochecks, 31, ", gocheck='%d'", str_to_num(x4))
  2206. if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
  2207. formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE name='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro15" : "kz_nub15", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, name, map)
  2208. else
  2209. formatex(createinto, sizeof createinto - 1, "UPDATE `%s` SET time='%f', weapon='%s', date='%s', server='%s'%s%s WHERE authid='%s' AND mapname='%s'", style == PRO_TOP ? "kz_pro15" : "kz_nub15", newtime, g_weaponsnames[str_to_num(x2)], dia, server, style == PRO_TOP ? "" : gochecks, style == PRO_TOP ? "" : checkpoints, steam, map)
  2210.  
  2211. SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto )
  2212. GetNewRank(id, style)
  2213. }
  2214. else
  2215. {
  2216. thetime = newtime - oldtime
  2217. iMin = floatround(thetime / 60.0, floatround_floor)
  2218. iSec = floatround(thetime - iMin * 60.0,floatround_floor)
  2219. iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
  2220. ColorChat(id, GREEN, "[XJ]^x01 You failed your best time by^x03 %02i:%02i.%02i ^x01in ^x03%s", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
  2221. }
  2222. }
  2223.  
  2224. return PLUGIN_CONTINUE
  2225.  
  2226. }
  2227.  
  2228. public GetNewRank_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  2229. {
  2230. new id = cData[0]
  2231. if( iFailState != TQUERY_SUCCESS )
  2232. {
  2233. return log_amx("TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
  2234. }
  2235.  
  2236. new steam[32], authid[32], namez[32], name[32], i = 0
  2237. get_user_authid(id, steam, 31)
  2238. get_user_name(id, namez, 31)
  2239.  
  2240. while( SQL_MoreResults(hQuery) )
  2241. {
  2242. i++
  2243. if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
  2244. {
  2245. SQL_ReadResult(hQuery, 0, name, 31)
  2246. if( equal(name, namez) )
  2247. {
  2248. ColorChat(0, GREEN, "[XJ]^x03 %s^x01 is now on place ^x03%d^x01 in^x03 %s^x01", namez, i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
  2249. break;
  2250. }
  2251. }
  2252. else
  2253. {
  2254. SQL_ReadResult(hQuery, 0, authid, 31)
  2255. if( equal(authid, steam) )
  2256. {
  2257. ColorChat(0, GREEN, "[XJ]^x03 %s^x01 is now on place ^x03%d^x01 in^x03 %s^x01", namez, i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
  2258. break;
  2259. }
  2260. }
  2261. SQL_NextRow(hQuery)
  2262. }
  2263.  
  2264. return PLUGIN_CONTINUE
  2265. }
  2266.  
  2267. public ProTop_show(id)
  2268. {
  2269. new mapname[64]
  2270. get_mapname(mapname, 63)
  2271.  
  2272. kz_showhtml_motd(id, PRO_TOP, mapname)
  2273.  
  2274. return PLUGIN_HANDLED
  2275. }
  2276.  
  2277. public NoobTop_show(id)
  2278. {
  2279. new mapname[64]
  2280. get_mapname(mapname, 63)
  2281.  
  2282. kz_showhtml_motd(id, NUB_TOP, mapname)
  2283.  
  2284. return PLUGIN_HANDLED
  2285. }
  2286.  
  2287. public ProRecs_show(id)
  2288. {
  2289. new mapname[64], authid[32]
  2290. get_mapname(mapname, 63)
  2291. get_user_authid(id, authid, 31)
  2292.  
  2293. if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
  2294. {
  2295. ColorChat (id, GREEN, "[XJ]^x03 ProRecords function is available just for Steam users.")
  2296. return PLUGIN_HANDLED
  2297. }
  2298.  
  2299. kz_showhtml_motd(id, PRO_RECORDS, mapname)
  2300.  
  2301. return PLUGIN_HANDLED
  2302. }
  2303.  
  2304. // You reached the end of file
  2305. // This plugin was made by p4ddY :)
  2306. // This plugin was edited by nucLeaR
  2307. // Version 2.0y
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement