Advertisement
Guest User

Untitled

a guest
Mar 25th, 2017
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 73.93 KB | None | 0 0
  1. #include <amxmodx>
  2. #include <cstrike>
  3. #include <colorchat>
  4. #include <fun>
  5. #include <fakemeta>
  6. #include <hamsandwich>
  7.  
  8. #define USE_SQL
  9.  
  10. #if defined USE_SQL
  11. #include <sqlx>
  12. #include <geoip>
  13. #endif
  14.  
  15. #define KZ_LEVEL ADMIN_KICK
  16. #define MSG MSG_ONE_UNRELIABLE
  17. #define MAX_ENTITYS 900+15*32
  18. #define IsOnLadder(%1) (pev(%1, pev_movetype) == MOVETYPE_FLY)
  19. #define VERSION "2.31"
  20.  
  21. #define SCOREATTRIB_NONE 0
  22. #define SCOREATTRIB_DEAD ( 1 << 0 )
  23. #define SCOREATTRIB_BOMB ( 1 << 1 )
  24. #define SCOREATTRIB_VIP ( 1 << 2 )
  25.  
  26.  
  27. new g_iPlayers[32], g_iNum, g_iPlayer
  28. new const g_szAliveFlags[] = "a"
  29. #define RefreshPlayersList() get_players(g_iPlayers, g_iNum, g_szAliveFlags)
  30.  
  31. new const FL_ONGROUND2 = ( FL_ONGROUND | FL_PARTIALGROUND | FL_INWATER | FL_CONVEYOR | FL_FLOAT )
  32. new const KZ_STARTFILE[] = "start.ini"
  33. new const KZ_STARTFILE_TEMP[] = "temp_start.ini"
  34.  
  35. #if defined USE_SQL
  36. new Handle:g_SqlTuple
  37. new Handle:SqlConnection
  38. new g_Error[512]
  39. new kz_sql_host
  40. new kz_sql_user
  41. new kz_sql_pass
  42. new kz_sql_db
  43. new kz_sql_name
  44. new kz_sql_files
  45. #else
  46. new Float:Pro_Times[24]
  47. new Pro_AuthIDS[24][32]
  48. new Pro_Names[24][32]
  49. new Pro_Date[24][32]
  50. new Float:Noob_Tiempos[24]
  51. new Noob_AuthIDS[24][32]
  52. new Noob_Names[24][32]
  53. new Noob_Date[24][32]
  54. new Noob_CheckPoints[24]
  55. new Noob_GoChecks[24]
  56. new Noob_Weapon[24][32]
  57. #endif
  58.  
  59. new Float:Checkpoints[33][2][3]
  60. new Float:timer_time[33]
  61. new Float:g_pausetime[33]
  62. new Float:antihookcheat[33]
  63. new Float:SpecLoc[33][3]
  64. new Float:NoclipPos[33][3]
  65. new Float:PauseOrigin[33][3]
  66. new Float:SavedStart[33][3]
  67. new hookorigin[33][3]
  68. new Float:DefaultStartPos[3]
  69.  
  70. new Float:SavedTime[33]
  71. new SavedChecks[33]
  72. new SavedGoChecks[33]
  73. new SavedScout[33]
  74. new SavedOrigins[33][3]
  75.  
  76. new bool:g_bCpAlternate[33]
  77. new bool:timer_started[33]
  78. new bool:IsPaused[33]
  79. new bool:WasPaused[33]
  80. new bool:firstspawn[33]
  81. new bool:canusehook[33]
  82. new bool:ishooked[33]
  83. new bool:user_has_scout[33]
  84. new bool:NightVisionUse[33]
  85. new bool:HealsOnMap
  86. new bool:gViewInvisible[33]
  87. new bool:gMarkedInvisible[33] = { true, ...};
  88. new bool:gWaterInvisible[33]
  89. new bool:gWaterEntity[MAX_ENTITYS]
  90. new bool:gWaterFound
  91. new bool:DefaultStart
  92. new bool:AutoStart[33]
  93.  
  94. new Trie:g_tStarts
  95. new Trie:g_tStops;
  96.  
  97. new checknumbers[33]
  98. new gochecknumbers[33]
  99. new chatorhud[33]
  100. new ShowTime[33]
  101. new MapName[64]
  102. new Kzdir[128]
  103. new SavePosDir[128]
  104. new prefix[33]
  105. #if !defined USE_SQL
  106. new Topdir[128]
  107. #endif
  108.  
  109. new kz_checkpoints
  110. new kz_cheatdetect
  111. new kz_spawn_mainmenu
  112. new kz_show_timer
  113. new kz_chatorhud
  114. new kz_hud_color
  115. new kz_chat_prefix
  116. new hud_message
  117. new kz_other_weapons
  118. new kz_maxspeedmsg
  119. new kz_drop_weapons
  120. new kz_remove_drops
  121. new kz_pick_weapons
  122. new kz_reload_weapons
  123. new kz_use_radio
  124. new kz_hook_prize
  125. new kz_hook_sound
  126. new kz_hook_speed
  127. new kz_pause
  128. new kz_noclip_pause
  129. new kz_nvg
  130. new kz_nvg_colors
  131. new kz_vip
  132. new kz_respawn_ct
  133. new kz_save_pos
  134. new kz_save_pos_gochecks
  135. new kz_semiclip
  136. new kz_semiclip_transparency
  137. new kz_spec_saves
  138. new kz_save_autostart
  139. new kz_top15_authid
  140. new Sbeam = 0
  141.  
  142. new const other_weapons[8] =
  143. {
  144. CSW_SCOUT, CSW_P90, CSW_FAMAS, CSW_SG552,
  145. CSW_M4A1, CSW_M249, CSW_AK47, CSW_AWP
  146. }
  147.  
  148. new const other_weapons_name[8][] =
  149. {
  150. "weapon_scout", "weapon_p90", "weapon_famas", "weapon_sg552",
  151. "weapon_m4a1", "weapon_m249", "weapon_ak47", "weapon_awp"
  152. }
  153.  
  154. new const g_weaponsnames[][] =
  155. {
  156. "", // NULL
  157. "p228", "shield", "scout", "hegrenade", "xm1014", "c4",
  158. "mac10", "aug", "smokegrenade", "elite", "fiveseven",
  159. "ump45", "sg550", "galil", "famas", "usp", "glock18",
  160. "awp", "mp5navy", "m249", "m3", "m4a1", "tmp", "g3sg1",
  161. "flashbang", "deagle", "sg552", "ak47", "knife", "p90",
  162. "glock", "elites", "fn57", "mp5", "vest", "vesthelm",
  163. "flash", "hegren", "sgren", "defuser", "nvgs", "primammo",
  164. "secammo", "km45", "9x19mm", "nighthawk", "228compact",
  165. "12gauge", "autoshotgun", "mp", "c90", "cv47", "defender",
  166. "clarion", "krieg552", "bullpup", "magnum", "d3au1",
  167. "krieg550"
  168. }
  169.  
  170. new const g_block_commands[][]=
  171. {
  172. "buy", "buyammo1", "buyammo2", "buyequip",
  173. "cl_autobuy", "cl_rebuy", "cl_setautobuy", "cl_setrebuy"
  174.  
  175. }
  176.  
  177. #if defined USE_SQL
  178. enum
  179. {
  180. TOP_NULL,
  181. PRO_TOP,
  182. NUB_TOP,
  183. LAST_PRO10,
  184. PRO_RECORDS,
  185. PLAYERS_RANKING,
  186. MAPS_STATISTIC
  187. }
  188. #endif
  189.  
  190. // =================================================================================================
  191.  
  192. public plugin_init()
  193. {
  194. register_plugin("ProKreedz", VERSION, "siim944 & p4ddY")
  195.  
  196. kz_checkpoints = register_cvar("kz_checkpoints","1")
  197. kz_cheatdetect = register_cvar("kz_cheatdetect","1")
  198. kz_spawn_mainmenu = register_cvar("kz_spawn_mainmenu", "0")
  199. kz_show_timer = register_cvar("kz_show_timer", "1")
  200. kz_chatorhud = register_cvar("kz_chatorhud", "2")
  201. kz_chat_prefix = register_cvar("kz_chat_prefix", "[KZ]")
  202. kz_hud_color = register_cvar("kz_hud_color", "12 122 221")
  203. kz_other_weapons = register_cvar("kz_other_weapons","1")
  204. kz_drop_weapons = register_cvar("kz_drop_weapons", "0")
  205. kz_remove_drops = register_cvar("kz_remove_drops", "1")
  206. kz_pick_weapons = register_cvar("kz_pick_weapons", "0")
  207. kz_reload_weapons = register_cvar("kz_reload_weapons", "0")
  208. kz_maxspeedmsg = register_cvar("kz_maxspeedmsg","1")
  209. kz_hook_prize = register_cvar("kz_hook_prize","1")
  210. kz_hook_sound = register_cvar("kz_hook_sound","1")
  211. kz_hook_speed = register_cvar("kz_hook_speed", "300.0")
  212. kz_use_radio = register_cvar("kz_use_radio", "0")
  213. kz_pause = register_cvar("kz_pause", "1")
  214. kz_noclip_pause = register_cvar("kz_noclip_pause", "1")
  215. kz_nvg = register_cvar("kz_nvg","1")
  216. kz_nvg_colors = register_cvar("kz_nvg_colors","5 0 255")
  217. kz_vip = register_cvar("kz_vip","1")
  218. kz_respawn_ct = register_cvar("kz_respawn_ct", "1")
  219. kz_semiclip = register_cvar("kz_semiclip", "1")
  220. kz_semiclip_transparency = register_cvar ("kz_semiclip_transparency", "85")
  221. kz_spec_saves = register_cvar("kz_spec_saves", "1")
  222. kz_save_autostart = register_cvar("kz_save_autostart", "1")
  223. kz_top15_authid = register_cvar("kz_top15_authid", "1")
  224. kz_save_pos = register_cvar("kz_save_pos", "1")
  225. kz_save_pos_gochecks = register_cvar("kz_save_pos_gochecks", "1")
  226.  
  227. #if defined USE_SQL
  228. kz_sql_host = register_cvar("kz_sql_host", "") // Host of DB
  229. kz_sql_user = register_cvar("kz_sql_user", "") // Username of DB
  230. kz_sql_pass = register_cvar("kz_sql_pass", "", FCVAR_PROTECTED) // Password for DB user
  231. kz_sql_db = register_cvar("kz_sql_db", "") // DB Name for the top 15
  232. kz_sql_name = register_cvar("kz_sql_server", "") // Name of server
  233. kz_sql_files = register_cvar("kz_sql_files", "") // Path of the PHP files
  234. #endif
  235.  
  236. register_clcmd("/cp","CheckPoint")
  237. register_clcmd("drop", "BlockDrop")
  238. register_clcmd("/gc", "GoCheck")
  239. register_clcmd("+hook","hook_on",KZ_LEVEL)
  240. register_clcmd("-hook","hook_off",KZ_LEVEL)
  241. register_concmd("kz_hook","give_hook", KZ_LEVEL, "<name|#userid|steamid|@ALL> <on/off>")
  242. register_concmd("nightvision","ToggleNVG")
  243. register_clcmd("radio1", "BlockRadio")
  244. register_clcmd("radio2", "BlockRadio")
  245. register_clcmd("radio3", "BlockRadio")
  246.  
  247.  
  248.  
  249. kz_register_saycmd("chatorhud", "ChatHud", 0)
  250. kz_register_saycmd("invis", "InvisMenu", 0)
  251. kz_register_saycmd("pinvis", "cmdInvisible", 0)
  252. kz_register_saycmd("top10", "ProTop_show", 0)
  253. kz_register_saycmd("top15", "ProTop_show", 0)
  254. kz_register_saycmd("setstart", "setStart", KZ_LEVEL)
  255. kz_register_saycmd("showtimer", "ShowTimer_Menu", 0)
  256. kz_register_saycmd("timer", "ShowTimer_Menu", 0)
  257. kz_register_saycmd("menu", "top15menu",0)
  258.  
  259. kz_register_saycmd("winvis", "cmdWaterInvisible", 0)
  260.  
  261. #if defined USE_SQL
  262. kz_register_saycmd("prorecords", "ProRecs_show", 0)
  263. kz_register_saycmd("prorecs", "ProRecs_show", 0)
  264. #endif
  265.  
  266. register_event("CurWeapon", "curweapon", "be", "1=1")
  267. register_event( "StatusValue", "EventStatusValue", "b", "1>0", "2>0" );
  268.  
  269. register_forward(FM_AddToFullPack, "FM_client_AddToFullPack_Post", 1)
  270.  
  271. RegisterHam( Ham_Player_PreThink, "player", "Ham_CBasePlayer_PreThink_Post", 1)
  272. RegisterHam( Ham_Use, "func_button", "fwdUse", 0)
  273. RegisterHam( Ham_Killed, "player", "Ham_CBasePlayer_Killed_Post", 1)
  274. RegisterHam( Ham_Touch, "weaponbox", "FwdSpawnWeaponbox" )
  275. RegisterHam( Ham_Spawn, "player", "FwdHamPlayerSpawn", 1 )
  276. RegisterHam( Ham_Touch, "weaponbox", "GroundWeapon_Touch")
  277.  
  278. register_message( get_user_msgid( "ScoreAttrib" ), "MessageScoreAttrib" )
  279. register_dictionary("prokreedz.txt")
  280. get_pcvar_string(kz_chat_prefix, prefix, 31)
  281. get_mapname(MapName, 63)
  282. set_msg_block(get_user_msgid("ClCorpse"), BLOCK_SET)
  283. set_task(0.5,"timer_task",2000,"",0,"ab")
  284. #if defined USE_SQL
  285. set_task(0.2, "plugin_sql")
  286. #endif
  287.  
  288. new kreedz_cfg[128], ConfigDir[64]
  289. get_configsdir( ConfigDir, 64)
  290. formatex(Kzdir,128, "%s/kz", ConfigDir)
  291. if( !dir_exists(Kzdir) )
  292. mkdir(Kzdir)
  293.  
  294. #if !defined USE_SQL
  295. formatex(Topdir,128, "%s/top15", Kzdir)
  296. if( !dir_exists(Topdir) )
  297. mkdir(Topdir)
  298. #endif
  299.  
  300. formatex(SavePosDir, 128, "%s/savepos", Kzdir)
  301. if( !dir_exists(SavePosDir) )
  302. mkdir(SavePosDir)
  303.  
  304. formatex(kreedz_cfg,128,"%s/kreedz.cfg", Kzdir)
  305.  
  306. if( file_exists( kreedz_cfg ) )
  307. {
  308. server_exec()
  309. server_cmd("exec %s",kreedz_cfg)
  310. }
  311.  
  312. for(new i = 0; i < sizeof(g_block_commands) ; i++)
  313. register_clcmd(g_block_commands[i], "BlockBuy")
  314.  
  315. g_tStarts = TrieCreate( )
  316. g_tStops = TrieCreate( )
  317.  
  318. new const szStarts[ ][ ] =
  319. {
  320. "counter_start", "clockstartbutton", "firsttimerelay", "but_start", "counter_start_button",
  321. "multi_start", "timer_startbutton", "start_timer_emi", "gogogo"
  322. }
  323.  
  324. new const szStops[ ][ ] =
  325. {
  326. "counter_off", "clockstopbutton", "clockstop", "but_stop", "counter_stop_button",
  327. "multi_stop", "stop_counter", "m_counter_end_emi"
  328. }
  329.  
  330. for( new i = 0; i < sizeof szStarts; i++ )
  331. TrieSetCell( g_tStarts, szStarts[ i ], 1 )
  332.  
  333. for( new i = 0; i < sizeof szStops; i++ )
  334. TrieSetCell( g_tStops, szStops[ i ], 1 )
  335. }
  336.  
  337. #if defined USE_SQL
  338. public plugin_sql()
  339. {
  340. new host[64], user[64], pass[64], db[64]
  341.  
  342. get_pcvar_string(kz_sql_host, host, 63)
  343. get_pcvar_string(kz_sql_user, user, 63)
  344. get_pcvar_string(kz_sql_pass, pass, 63)
  345. get_pcvar_string(kz_sql_db, db, 63)
  346.  
  347. g_SqlTuple = SQL_MakeDbTuple(host, user, pass, db)
  348.  
  349. new ErrorCode
  350. SqlConnection = SQL_Connect(g_SqlTuple,ErrorCode,g_Error,511)
  351.  
  352. if(!SqlConnection)
  353. {
  354. server_print("[KZ] TOP15 SQL: Could not connect to SQL database.!")
  355. log_amx("[KZ] TOP15 SQL: Could not connect to SQL database.")
  356. return pause("a")
  357. }
  358.  
  359. new createinto[1001]
  360. 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)")
  361. SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
  362. 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)")
  363. SQL_ThreadQuery(g_SqlTuple,"QueryHandle", createinto)
  364.  
  365. return PLUGIN_CONTINUE
  366. }
  367.  
  368. public QueryHandle(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  369. {
  370. if( iFailState != TQUERY_SUCCESS )
  371. {
  372. log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
  373. ColorChat(0, GREEN, "[KZ]^x01: Warning the SQL Tops can not be saved.")
  374. }
  375.  
  376. server_print("[KZ] Server Sending Info to SQL Server")
  377.  
  378. return PLUGIN_CONTINUE
  379. }
  380. #endif
  381.  
  382. public plugin_precache()
  383. {
  384. hud_message = CreateHudSyncObj()
  385. RegisterHam( Ham_Spawn, "func_door", "FwdHamDoorSpawn", 1 )
  386. precache_sound("weapons/xbow_hit2.wav")
  387. Sbeam = precache_model("sprites/laserbeam.spr")
  388. }
  389.  
  390. public plugin_cfg()
  391. {
  392. #if !defined USE_SQL
  393. for (new i = 0 ; i < 15; ++i)
  394. {
  395. Pro_Times[i] = 999999999.00000;
  396. Noob_Tiempos[i] = 999999999.00000;
  397. }
  398.  
  399. read_pro15()
  400. read_Noob15()
  401. #endif
  402.  
  403. new startcheck[100], data[256], map[64], x[13], y[13], z[13];
  404. formatex(startcheck, 99, "%s/%s", Kzdir, KZ_STARTFILE)
  405. new f = fopen(startcheck, "rt" )
  406. while( !feof( f ) )
  407. {
  408. fgets( f, data, sizeof data - 1 )
  409. parse( data, map, 63, x, 12, y, 12, z, 12)
  410.  
  411. if( equali( map, MapName ) )
  412. {
  413. DefaultStartPos[0] = str_to_float(x)
  414. DefaultStartPos[1] = str_to_float(y)
  415. DefaultStartPos[2] = str_to_float(z)
  416.  
  417. DefaultStart = true
  418. break;
  419. }
  420. }
  421. fclose(f)
  422.  
  423. new ent = -1;
  424. while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_water") ) != 0 )
  425. {
  426. if( !gWaterFound )
  427. {
  428. gWaterFound = true;
  429. }
  430.  
  431. gWaterEntity[ent] = true;
  432. }
  433.  
  434. ent = -1;
  435. while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_illusionary") ) != 0 )
  436. {
  437. if( pev( ent, pev_skin ) == CONTENTS_WATER )
  438. {
  439. if( !gWaterFound )
  440. {
  441. gWaterFound = true;
  442. }
  443.  
  444. gWaterEntity[ent] = true;
  445. }
  446. }
  447.  
  448. ent = -1;
  449. while( ( ent = engfunc(EngFunc_FindEntityByString, ent, "classname", "func_conveyor") ) != 0 )
  450. {
  451. if( pev( ent, pev_spawnflags ) == 3 )
  452. {
  453. if( !gWaterFound )
  454. {
  455. gWaterFound = true;
  456. }
  457.  
  458. gWaterEntity[ent] = true;
  459. }
  460. }
  461. }
  462.  
  463. public client_command(id)
  464. {
  465.  
  466. new sArg[13];
  467. if( read_argv(0, sArg, 12) > 11 )
  468. {
  469. return PLUGIN_CONTINUE;
  470. }
  471.  
  472. for( new i = 0; i < sizeof(g_weaponsnames); i++ )
  473. {
  474. if( equali(g_weaponsnames[i], sArg, 0) )
  475. {
  476. return PLUGIN_HANDLED;
  477. }
  478. }
  479. return PLUGIN_CONTINUE;
  480. }
  481.  
  482. // =================================================================================================
  483. // Global Functions
  484. // =================================================================================================
  485.  
  486. public Pause(id)
  487. {
  488.  
  489. if (get_pcvar_num(kz_pause) == 0)
  490. {
  491. kz_chat(id, "%L", id, "KZ_PAUSE_DISABLED")
  492.  
  493. return PLUGIN_HANDLED
  494. }
  495.  
  496. if(! is_user_alive(id) )
  497. {
  498. kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
  499.  
  500. return PLUGIN_HANDLED
  501. }
  502.  
  503.  
  504. if(!IsPaused[id])
  505. {
  506. if(! timer_started[id])
  507. {
  508. kz_chat(id, "%L", id, "KZ_TIMER_NOT_STARTED")
  509. return PLUGIN_HANDLED
  510. }
  511.  
  512. g_pausetime[id] = get_gametime() - timer_time[id]
  513. timer_time[id] = 0.0
  514. IsPaused[id] = true
  515. kz_chat(id, "%L", id, "KZ_PAUSE_ON")
  516. set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
  517. pev(id, pev_origin, PauseOrigin[id])
  518.  
  519. }
  520. else
  521. {
  522. if(timer_started[id])
  523. {
  524. kz_chat(id, "%L", id, "KZ_PAUSE_OFF")
  525. if(get_user_noclip(id))
  526. noclip(id)
  527. timer_time[id] = get_gametime() - g_pausetime[id]
  528. }
  529. IsPaused[id] = false
  530. set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
  531. }
  532.  
  533. return PLUGIN_HANDLED
  534. }
  535.  
  536. public timer_task()
  537. {
  538. if ( get_pcvar_num(kz_show_timer) > 0 )
  539. {
  540. new Alive[32], Dead[32], alivePlayers, deadPlayers;
  541. get_players(Alive, alivePlayers, "ach")
  542. get_players(Dead, deadPlayers, "bch")
  543. for(new i=0;i<alivePlayers;i++)
  544. {
  545. if( timer_started[Alive[i]])
  546. {
  547. new Float:kreedztime = get_gametime() - (IsPaused[Alive[i]] ? get_gametime() - g_pausetime[Alive[i]] : timer_time[Alive[i]])
  548.  
  549. if( ShowTime[Alive[i]] == 1 )
  550. {
  551. new colors[12], r[4], g[4], b[4];
  552. new imin = floatround(kreedztime / 60.0,floatround_floor)
  553. new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
  554. get_pcvar_string(kz_hud_color, colors, 11)
  555. parse(colors, r, 3, g, 3, b, 4)
  556.  
  557. 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)
  558. show_hudmessage(Alive[i], "Time: %02d:%02d | CPs: %d | TPs: %d %s ",imin, isec,checknumbers[Alive[i]], gochecknumbers[Alive[i]], IsPaused[Alive[i]] ? "| *Paused*" : "")
  559. }
  560. else
  561. if( ShowTime[Alive[i]] == 2 )
  562. {
  563. kz_showtime_roundtime(Alive[i], floatround(kreedztime))
  564. }
  565. }
  566.  
  567. }
  568. for(new i=0;i<deadPlayers;i++)
  569. {
  570. new specmode = pev(Dead[i], pev_iuser1)
  571. if(specmode == 2 || specmode == 4)
  572. {
  573. new target = pev(Dead[i], pev_iuser2)
  574. if(target != Dead[i])
  575. if(is_user_alive(target) && timer_started[target])
  576. {
  577. new name[32], colors[12], r[4], g[4], b[4];
  578. get_user_name (target, name, 31)
  579.  
  580. new Float:kreedztime = get_gametime() - (IsPaused[target] ? get_gametime() - g_pausetime[target] : timer_time[target])
  581. new imin = floatround(kreedztime / 60.0,floatround_floor)
  582. new isec = floatround(kreedztime - imin * 60.0,floatround_floor)
  583.  
  584. get_pcvar_string(kz_hud_color, colors, 11)
  585. parse(colors, r, 3, g, 3, b, 4)
  586.  
  587. 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)
  588. show_hudmessage(Dead[i], "Time: %02d:%02d | CPs: %d | TPs: %d %s ",imin, isec, checknumbers[target], gochecknumbers[target], IsPaused[target] ? "| *Paused*" : "")
  589. }
  590. }
  591. }
  592. }
  593. }
  594.  
  595. // ============================ Block Commands ================================
  596.  
  597.  
  598. public BlockRadio(id)
  599. {
  600. if (get_pcvar_num(kz_use_radio) == 1)
  601. return PLUGIN_CONTINUE
  602. return PLUGIN_HANDLED
  603. }
  604.  
  605. public BlockDrop(id)
  606. {
  607. if (get_pcvar_num(kz_drop_weapons) == 1)
  608. return PLUGIN_CONTINUE
  609. return PLUGIN_HANDLED
  610. }
  611.  
  612. public BlockBuy(id)
  613. {
  614. return PLUGIN_HANDLED
  615. }
  616.  
  617. public CmdRespawn(id)
  618. {
  619. if ( get_user_team(id) == 3 )
  620. return PLUGIN_HANDLED
  621. else
  622. ExecuteHamB(Ham_CS_RoundRespawn, id)
  623.  
  624. return PLUGIN_HANDLED
  625. }
  626.  
  627. public ChatHud(id)
  628. {
  629. if(get_pcvar_num(kz_chatorhud) == 0)
  630. {
  631. ColorChat(id, GREEN, "%s^x01 %L", id, "KZ_CHECKPOINT_OFF", prefix)
  632. return PLUGIN_HANDLED
  633. }
  634. if(chatorhud[id] == -1)
  635. ++chatorhud[id];
  636.  
  637. ++chatorhud[id];
  638.  
  639. if(chatorhud[id] == 3)
  640. chatorhud[id] = 0;
  641. else
  642. kz_chat(id, "%L", id, "KZ_CHATORHUD", chatorhud[id] == 1 ? "Chat" : "HUD")
  643.  
  644. return PLUGIN_HANDLED
  645. }
  646.  
  647. public ct(id)
  648. {
  649. new CsTeams:team = cs_get_user_team(id)
  650. if (team == CS_TEAM_CT)
  651. {
  652. if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) && timer_started[id] )
  653. return PLUGIN_HANDLED
  654.  
  655. if (get_pcvar_num(kz_spec_saves) == 1)
  656. {
  657. pev(id, pev_origin, SpecLoc[id])
  658.  
  659. if ( timer_started[id] )
  660. {
  661. if ( IsPaused[id] )
  662. {
  663. Pause(id)
  664. WasPaused[id]=true
  665. }
  666.  
  667. g_pausetime[id] = get_gametime() - timer_time[id]
  668. timer_time[id] = 0.0
  669. kz_chat(id, "%L", id, "KZ_PAUSE_ON")
  670. }
  671. }
  672.  
  673. if(gViewInvisible[id])
  674. gViewInvisible[id] = false
  675.  
  676. cs_set_user_team(id,CS_TEAM_SPECTATOR)
  677. set_pev(id, pev_solid, SOLID_NOT)
  678. set_pev(id, pev_movetype, MOVETYPE_FLY)
  679. set_pev(id, pev_effects, EF_NODRAW)
  680. set_pev(id, pev_deadflag, DEAD_DEAD)
  681. }
  682. else
  683. {
  684. cs_set_user_team(id,CS_TEAM_CT)
  685. set_pev(id, pev_effects, 0)
  686. set_pev(id, pev_movetype, MOVETYPE_WALK)
  687. set_pev(id, pev_deadflag, DEAD_NO)
  688. set_pev(id, pev_takedamage, DAMAGE_AIM)
  689. CmdRespawn(id)
  690. give_item(id,"weapon_knife")
  691. give_item(id,"weapon_usp")
  692. cs_set_user_bpammo(id, CSW_USP, 36)
  693.  
  694. if (get_pcvar_num(kz_spec_saves) == 1)
  695. {
  696. set_pev(id, pev_origin, SpecLoc[id])
  697. if ( timer_started [id] )
  698. timer_time[id] = get_gametime() - g_pausetime[id] + timer_time[id]
  699. if( WasPaused[id] )
  700. {
  701. Pause(id)
  702. WasPaused[id]=false
  703. }
  704. }
  705. }
  706. return PLUGIN_HANDLED
  707. }
  708.  
  709.  
  710. //=================== Weapons ==============
  711. public curweapon(id)
  712. {
  713. /*
  714. if(get_pcvar_num(kz_maxspeedmsg) == 1 && is_user_alive(id))
  715. {
  716. new clip, ammo, speed,
  717. switch(get_user_weapon(id,clip,ammo))
  718. {
  719. case CSW_SCOUT: speed = 260
  720. 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
  721. case CSW_P90: speed = 245
  722. case CSW_XM1014, CSW_AUG, CSW_GALIL, CSW_FAMAS: speed = 240
  723. case CSW_SG552: speed = 235
  724. case CSW_M3, CSW_M4A1: speed= 230
  725. case CSW_AK47: speed = 221
  726. case CSW_M249: speed = 220
  727. case CSW_G3SG1, CSW_SG550, CSW_AWP: speed = 210
  728. }
  729. kz_hud_message(id,"%L",id, "KZ_WEAPONS_SPEED",speed)
  730. }
  731. */
  732. static last_weapon[33];
  733. static weapon_active, weapon_num
  734. weapon_active = read_data(1)
  735. weapon_num = read_data(2)
  736.  
  737. if( ( weapon_num != last_weapon[id] ) && weapon_active && get_pcvar_num(kz_maxspeedmsg) == 1)
  738. {
  739. last_weapon[id] = weapon_num;
  740.  
  741. static Float:maxspeed;
  742. pev(id, pev_maxspeed, maxspeed );
  743.  
  744. if( maxspeed < 0.0 )
  745. maxspeed = 250.0;
  746.  
  747. kz_hud_message(id,"%L",id, "KZ_WEAPONS_SPEED",floatround( maxspeed, floatround_floor ));
  748. }
  749. return PLUGIN_HANDLED
  750. }
  751.  
  752. public weapons(id)
  753. {
  754. if(!is_user_alive(id))
  755. {
  756. kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
  757. return PLUGIN_HANDLED
  758. }
  759.  
  760. if(get_pcvar_num(kz_other_weapons) == 0)
  761. {
  762. kz_chat(id, "%L", id, "KZ_OTHER_WEAPONS_ZERO")
  763. return PLUGIN_HANDLED
  764. }
  765.  
  766. if (timer_started[id])
  767. {
  768. kz_chat(id, "%L", id, "KZ_WEAPONS_IN_RUN")
  769. return PLUGIN_HANDLED
  770. }
  771.  
  772. for(new i = 0; i < 8; i++)
  773. if( !user_has_weapon(id, other_weapons[i]) )
  774. {
  775. new item;
  776. item = give_item(id, other_weapons_name[i] );
  777. cs_set_weapon_ammo(item, 0);
  778. }
  779.  
  780. if( !user_has_weapon(id, CSW_USP) )
  781. cmdUsp(id)
  782.  
  783. return PLUGIN_HANDLED
  784. }
  785.  
  786.  
  787. // ========================= Scout =======================
  788. public cmdScout(id)
  789. {
  790. if (timer_started[id])
  791. user_has_scout[id] = true
  792.  
  793. strip_user_weapons(id)
  794. give_item(id,"weapon_usp")
  795. give_item(id,"weapon_knife")
  796. if( !user_has_weapon(id, CSW_SCOUT))
  797. give_item(id,"weapon_scout")
  798.  
  799. return PLUGIN_HANDLED
  800. }
  801.  
  802. public cmdUsp(id)
  803. {
  804. give_item(id,"weapon_usp")
  805. give_item(id,"weapon_knife")
  806.  
  807. return PLUGIN_HANDLED
  808. }
  809.  
  810. // ========================== Start location =================
  811.  
  812. public goStart(id)
  813. {
  814. if( !is_user_alive( id ) )
  815. {
  816. kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
  817. return PLUGIN_HANDLED
  818. }
  819.  
  820. if (IsPaused[id])
  821. {
  822. kz_chat(id, "%L", id, "KZ_TELEPORT_PAUSE")
  823. return PLUGIN_HANDLED
  824. }
  825.  
  826. if(get_pcvar_num(kz_save_autostart) == 1 && AutoStart [id] )
  827. {
  828. set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
  829. set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
  830. set_pev(id, pev_origin, SavedStart [id] )
  831.  
  832. kz_chat(id, "%L", id, "KZ_START")
  833. }
  834. else if ( DefaultStart )
  835. {
  836. set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
  837. set_pev(id, pev_origin, DefaultStartPos)
  838.  
  839. kz_chat(id, "%L", id, "KZ_START")
  840. }
  841. else
  842. {
  843. kz_chat(id, "%L", id, "KZ_NO_START")
  844.  
  845. CmdRespawn(id)
  846. }
  847.  
  848. return PLUGIN_HANDLED
  849. }
  850.  
  851. public setStart(id)
  852. {
  853. if (! (get_user_flags( id ) & KZ_LEVEL ))
  854. {
  855. kz_chat(id, "%L", id, "KZ_NO_ACCESS")
  856. return PLUGIN_HANDLED
  857. }
  858.  
  859. new Float:origin[3]
  860. pev(id, pev_origin, origin)
  861. kz_set_start(MapName, origin)
  862. AutoStart[id] = false;
  863. ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_SET_START")
  864.  
  865. return PLUGIN_HANDLED
  866. }
  867.  
  868. // ========= Respawn CT if dies ========
  869.  
  870. public Ham_CBasePlayer_Killed_Post(id)
  871. {
  872. if(get_pcvar_num(kz_respawn_ct) == 1)
  873. {
  874. if( cs_get_user_team(id) == CS_TEAM_CT )
  875. {
  876. set_pev(id, pev_deadflag, DEAD_RESPAWNABLE)
  877. cs_set_user_deaths(id, 0)
  878. set_user_frags(id, 0)
  879. }
  880. }
  881. }
  882.  
  883.  
  884. // ============================= NightVision ================================================
  885.  
  886. public ToggleNVG(id)
  887. {
  888.  
  889. if( get_pcvar_num(kz_nvg) == 0 || !is_user_alive(id))
  890. return PLUGIN_CONTINUE;
  891.  
  892. if ( NightVisionUse[id] )
  893. StopNVG(id)
  894. else
  895. StartNVG(id)
  896.  
  897. return PLUGIN_HANDLED
  898. }
  899.  
  900. public StartNVG(id)
  901. {
  902. emit_sound(id,CHAN_ITEM,"items/nvg_on.wav",1.0,ATTN_NORM,0,PITCH_NORM)
  903. set_task(0.1,"RunNVG",id+111111,_,_,"b")
  904. NightVisionUse[id] = true;
  905.  
  906. return PLUGIN_HANDLED
  907. }
  908.  
  909. public StopNVG(id)
  910. {
  911. emit_sound(id,CHAN_ITEM,"items/nvg_off.wav",1.0,ATTN_NORM,0,PITCH_NORM)
  912. remove_task(id+111111)
  913. NightVisionUse[id] = false;
  914.  
  915. return PLUGIN_HANDLED
  916. }
  917.  
  918.  
  919. public RunNVG(taskid)
  920. {
  921. new id = taskid - 111111
  922.  
  923. if (!is_user_alive(id)) return
  924.  
  925. new origin[3]
  926. get_user_origin(id,origin,3)
  927.  
  928. new color[17];
  929. get_pcvar_string(kz_nvg_colors,color,16);
  930.  
  931. new iRed[5], iGreen[7], iBlue[5]
  932. parse(color,iRed,4,iGreen ,6,iBlue,4)
  933.  
  934. message_begin(MSG, SVC_TEMPENTITY, _, id)
  935. write_byte(TE_DLIGHT)
  936. write_coord(origin[0])
  937. write_coord(origin[1])
  938. write_coord(origin[2])
  939. write_byte(80)
  940. write_byte(str_to_num(iRed))
  941. write_byte(str_to_num(iGreen))
  942. write_byte(str_to_num(iBlue))
  943. write_byte(2)
  944. write_byte(0)
  945. message_end()
  946. }
  947.  
  948. // ============================ Hook ==============================================================
  949.  
  950. public give_hook(id)
  951. {
  952. if (!( get_user_flags( id ) & KZ_LEVEL ))
  953. return PLUGIN_HANDLED
  954.  
  955. new szarg1[32], szarg2[8], bool:mode
  956. read_argv(1,szarg1,32)
  957. read_argv(2,szarg2,32)
  958. if(equal(szarg2,"on"))
  959. mode = true
  960.  
  961. if(equal(szarg1,"@ALL"))
  962. {
  963. new Alive[32], alivePlayers
  964. get_players(Alive, alivePlayers, "ach")
  965. for(new i;i<alivePlayers;i++)
  966. {
  967. canusehook[i] = mode
  968. if(mode)
  969. ColorChat(i, GREEN, "%s^x01, %L.", prefix, i, "KZ_HOOK")
  970. }
  971. }
  972. else
  973. {
  974. new pid = find_player("bl",szarg1);
  975. if(pid > 0)
  976. {
  977. canusehook[pid] = mode
  978. if(mode)
  979. {
  980. ColorChat(pid, GREEN, "%s^x01 %L.", prefix, pid, "KZ_HOOK")
  981. }
  982. }
  983. }
  984.  
  985. return PLUGIN_HANDLED
  986. }
  987.  
  988. public hook_on(id)
  989. {
  990. if( !canusehook[id] && !( get_user_flags( id ) & KZ_LEVEL ) || !is_user_alive(id) )
  991. return PLUGIN_HANDLED
  992.  
  993. if (IsPaused[id])
  994. {
  995. kz_chat(id, "%L", id, "KZ_HOOK_PAUSE")
  996. return PLUGIN_HANDLED
  997. }
  998.  
  999. detect_cheat(id,"Hook")
  1000. get_user_origin(id,hookorigin[id],3)
  1001. ishooked[id] = true
  1002. antihookcheat[id] = get_gametime()
  1003.  
  1004. if (get_pcvar_num(kz_hook_sound) == 1)
  1005. emit_sound(id,CHAN_STATIC,"weapons/xbow_hit2.wav",1.0,ATTN_NORM,0,PITCH_NORM)
  1006.  
  1007. set_task(0.1,"hook_task",id,"",0,"ab")
  1008. hook_task(id)
  1009.  
  1010. return PLUGIN_HANDLED
  1011. }
  1012.  
  1013. public hook_off(id)
  1014. {
  1015. remove_hook(id)
  1016.  
  1017. return PLUGIN_HANDLED
  1018. }
  1019.  
  1020. public hook_task(id)
  1021. {
  1022. if(!is_user_connected(id) || !is_user_alive(id))
  1023. remove_hook(id)
  1024.  
  1025. remove_beam(id)
  1026. draw_hook(id)
  1027.  
  1028. new origin[3], Float:velocity[3]
  1029. get_user_origin(id,origin)
  1030. new distance = get_distance(hookorigin[id],origin)
  1031. velocity[0] = (hookorigin[id][0] - origin[0]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
  1032. velocity[1] = (hookorigin[id][1] - origin[1]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
  1033. velocity[2] = (hookorigin[id][2] - origin[2]) * (2.0 * get_pcvar_num(kz_hook_speed) / distance)
  1034.  
  1035. set_pev(id,pev_velocity,velocity)
  1036. }
  1037.  
  1038. public draw_hook(id)
  1039. {
  1040. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1041. write_byte(1) // TE_BEAMENTPOINT
  1042. write_short(id) // entid
  1043. write_coord(hookorigin[id][0]) // origin
  1044. write_coord(hookorigin[id][1]) // origin
  1045. write_coord(hookorigin[id][2]) // origin
  1046. write_short(Sbeam) // sprite index
  1047. write_byte(0) // start frame
  1048. write_byte(0) // framerate
  1049. write_byte(random_num(1,100)) // life
  1050. write_byte(random_num(1,20)) // width
  1051. write_byte(random_num(1,0)) // noise
  1052. write_byte(random_num(1,255)) // r
  1053. write_byte(random_num(1,255)) // g
  1054. write_byte(random_num(1,255)) // b
  1055. write_byte(random_num(1,500)) // brightness
  1056. write_byte(random_num(1,200)) // speed
  1057. message_end()
  1058. }
  1059.  
  1060. public remove_hook(id)
  1061. {
  1062. if(task_exists(id))
  1063. remove_task(id)
  1064. remove_beam(id)
  1065. ishooked[id] = false
  1066. }
  1067.  
  1068. public remove_beam(id)
  1069. {
  1070. message_begin(MSG_BROADCAST,SVC_TEMPENTITY)
  1071. write_byte(99) // TE_KILLBEAM
  1072. write_short(id)
  1073. message_end()
  1074. }
  1075.  
  1076.  
  1077. //============================ VIP In ScoreBoard =================================================
  1078.  
  1079. public MessageScoreAttrib( iMsgID, iDest, iReceiver )
  1080. {
  1081. if( get_pcvar_num(kz_vip) )
  1082. {
  1083. new iPlayer = get_msg_arg_int( 1 )
  1084. if( is_user_alive( iPlayer ) && ( get_user_flags( iPlayer ) & KZ_LEVEL ) )
  1085. {
  1086. set_msg_arg_int( 2, ARG_BYTE, SCOREATTRIB_VIP );
  1087. }
  1088. }
  1089. }
  1090.  
  1091. public EventStatusValue( const id )
  1092. {
  1093.  
  1094. new szMessage[ 34 ], Target, aux
  1095. get_user_aiming(id, Target, aux)
  1096. if (is_user_alive(Target))
  1097. {
  1098. formatex( szMessage, 33, "1 %s: %%p2", get_user_flags( Target ) & KZ_LEVEL ? "VIP" : "Player" )
  1099. message_begin( MSG, get_user_msgid( "StatusText" ) , _, id )
  1100. write_byte( 0 )
  1101. write_string( szMessage )
  1102. message_end( )
  1103. }
  1104. }
  1105.  
  1106. public detect_cheat(id,reason[])
  1107. {
  1108. if(timer_started[id] && get_pcvar_num(kz_cheatdetect) == 1)
  1109. {
  1110. timer_started[id] = false
  1111. if(IsPaused[id])
  1112. {
  1113. set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
  1114. IsPaused[id] = false
  1115. }
  1116. if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
  1117. kz_showtime_roundtime(id, 0)
  1118. ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_CHEAT_DETECT", reason)
  1119. }
  1120. }
  1121.  
  1122. // =================================================================================================
  1123. // Cmds
  1124. // =================================================================================================
  1125.  
  1126. public CheckPoint(id)
  1127. {
  1128.  
  1129. if( !is_user_alive( id ) )
  1130. {
  1131. kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
  1132. return PLUGIN_HANDLED
  1133. }
  1134.  
  1135. if(get_pcvar_num(kz_checkpoints) == 0)
  1136. {
  1137. kz_chat(id, "%L", id, "KZ_CHECKPOINT_OFF")
  1138. return PLUGIN_HANDLED
  1139. }
  1140.  
  1141. if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) && !IsOnLadder(id))
  1142. {
  1143. kz_chat(id, "%L", id, "KZ_CHECKPOINT_AIR")
  1144. return PLUGIN_HANDLED
  1145. }
  1146.  
  1147. if( IsPaused[id] )
  1148. {
  1149. kz_chat(id, "%L", id, "KZ_CHECKPOINT_PAUSE")
  1150. return PLUGIN_HANDLED
  1151. }
  1152.  
  1153. pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id] ? 1 : 0])
  1154. g_bCpAlternate[id] = !g_bCpAlternate[id]
  1155. checknumbers[id]++
  1156.  
  1157. kz_chat(id, "%L", id, "KZ_CHECKPOINT", checknumbers[id])
  1158.  
  1159. return PLUGIN_HANDLED
  1160. }
  1161.  
  1162. public GoCheck(id)
  1163. {
  1164. if( !is_user_alive( id ) )
  1165. {
  1166. kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
  1167. return PLUGIN_HANDLED
  1168. }
  1169.  
  1170. if( checknumbers[id] == 0 )
  1171. {
  1172. kz_chat(id, "%L", id, "KZ_NOT_ENOUGH_CHECKPOINTS")
  1173. return PLUGIN_HANDLED
  1174. }
  1175.  
  1176. if( IsPaused[id] )
  1177. {
  1178. kz_chat(id, "%L", id, "KZ_TELEPORT_PAUSE")
  1179. return PLUGIN_HANDLED
  1180. }
  1181.  
  1182. set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} );
  1183. set_pev( id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 } );
  1184. set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING );
  1185. set_pev( id, pev_fuser2, 0.0 );
  1186. engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 } );
  1187. set_pev(id, pev_origin, Checkpoints[ id ][ !g_bCpAlternate[id] ] )
  1188. gochecknumbers[id]++
  1189.  
  1190. kz_chat(id, "%L", id, "KZ_GOCHECK", gochecknumbers[id])
  1191.  
  1192. return PLUGIN_HANDLED
  1193. }
  1194.  
  1195. public Stuck(id)
  1196. {
  1197. if( !is_user_alive( id ) )
  1198. {
  1199. kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
  1200. return PLUGIN_HANDLED
  1201. }
  1202.  
  1203. if( checknumbers[id] < 2 )
  1204. {
  1205. kz_chat(id, "%L", id, "KZ_NOT_ENOUGH_CHECKPOINTS")
  1206. return PLUGIN_HANDLED
  1207. }
  1208.  
  1209. set_pev( id, pev_velocity, Float:{0.0, 0.0, 0.0} )
  1210. set_pev( id, pev_view_ofs, Float:{ 0.0, 0.0, 12.0 })
  1211. set_pev( id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
  1212. set_pev( id, pev_fuser2, 0.0 )
  1213. engfunc( EngFunc_SetSize, id, {-16.0, -16.0, -18.0 }, { 16.0, 16.0, 32.0 } )
  1214. set_pev(id, pev_origin, Checkpoints[id][g_bCpAlternate[id]] )
  1215. g_bCpAlternate[id] = !g_bCpAlternate[id];
  1216. gochecknumbers[id]++
  1217.  
  1218. kz_chat(id, "%L", id, "KZ_GOCHECK", gochecknumbers[id])
  1219.  
  1220. return PLUGIN_HANDLED;
  1221. }
  1222.  
  1223. // =================================================================================================
  1224.  
  1225. public reset_checkpoints(id)
  1226. {
  1227. checknumbers[id] = 0
  1228. gochecknumbers[id] = 0
  1229. timer_started[id] = false
  1230. timer_time[id] = 0.0
  1231. user_has_scout[id] = false
  1232. if(IsPaused[id])
  1233. {
  1234. set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
  1235. IsPaused[id] = false
  1236. }
  1237. if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
  1238. kz_showtime_roundtime(id, 0)
  1239.  
  1240. return PLUGIN_HANDLED
  1241. }
  1242.  
  1243. //===== Invis =======
  1244.  
  1245. public cmdInvisible(id)
  1246. {
  1247.  
  1248. gViewInvisible[id] = !gViewInvisible[id]
  1249. if(gViewInvisible[id])
  1250. kz_chat(id, "%L", id, "KZ_INVISIBLE_PLAYERS_ON")
  1251. else
  1252. kz_chat(id, "%L", id, "KZ_INVISIBLE_PLAYERS_OFF")
  1253.  
  1254. return PLUGIN_HANDLED
  1255. }
  1256.  
  1257. public cmdWaterInvisible(id)
  1258. {
  1259. if( !gWaterFound )
  1260. {
  1261. kz_chat(id, "%L", id, "KZ_INVISIBLE_NOWATER")
  1262. return PLUGIN_HANDLED
  1263. }
  1264.  
  1265. gWaterInvisible[id] = !gWaterInvisible[id]
  1266. if(gWaterInvisible[id])
  1267. kz_chat(id, "%L", id, "KZ_INVISIBLE_WATER_ON")
  1268. else
  1269. kz_chat(id, "%L", id, "KZ_INVISIBLE_WATER_OFF")
  1270.  
  1271. return PLUGIN_HANDLED
  1272. }
  1273.  
  1274. //======================Semiclip / Invis==========================
  1275.  
  1276. public FM_client_AddToFullPack_Post(es, e, ent, host, hostflags, player, pSet)
  1277. {
  1278. if( player )
  1279. {
  1280. if (get_pcvar_num(kz_semiclip) == 1)
  1281. {
  1282. if ( host != ent && get_orig_retval() && is_user_alive(host) )
  1283. {
  1284. set_es(es, ES_Solid, SOLID_NOT)
  1285. set_es(es, ES_RenderMode, kRenderTransAlpha)
  1286. set_es(es, ES_RenderAmt, get_pcvar_num(kz_semiclip_transparency))
  1287. }
  1288. }
  1289. if(gMarkedInvisible[ent] && gViewInvisible[host])
  1290. {
  1291. set_es(es, ES_RenderMode, kRenderTransTexture)
  1292. set_es(es, ES_RenderAmt, 0)
  1293. set_es(es, ES_Origin, { 999999999.0, 999999999.0, 999999999.0 } )
  1294. }
  1295. }
  1296. else if( gWaterInvisible[host] && gWaterEntity[ent] )
  1297. {
  1298. set_es(es, ES_Effects, get_es( es, ES_Effects ) | EF_NODRAW )
  1299. }
  1300.  
  1301. return FMRES_IGNORED
  1302. }
  1303.  
  1304. public Ham_CBasePlayer_PreThink_Post(id)
  1305. {
  1306. if( !is_user_alive(id) )
  1307. {
  1308. return
  1309. }
  1310.  
  1311. RefreshPlayersList()
  1312.  
  1313. if (get_pcvar_num(kz_semiclip) == 1)
  1314. {
  1315. for(new i = 0; i<g_iNum; i++)
  1316. {
  1317. g_iPlayer = g_iPlayers[i]
  1318. if( id != g_iPlayer )
  1319. {
  1320. set_pev(g_iPlayer, pev_solid, SOLID_NOT)
  1321. }
  1322. }
  1323. }
  1324. }
  1325.  
  1326. public client_PostThink(id)
  1327. {
  1328. if( !is_user_alive(id) )
  1329. return
  1330.  
  1331. RefreshPlayersList()
  1332.  
  1333. if (get_pcvar_num(kz_semiclip) == 1)
  1334. for(new i = 0; i<g_iNum; i++)
  1335. {
  1336. g_iPlayer = g_iPlayers[i]
  1337. if( g_iPlayer != id )
  1338. set_pev(g_iPlayer, pev_solid, SOLID_SLIDEBOX)
  1339. }
  1340. }
  1341.  
  1342. public noclip(id)
  1343. {
  1344. if(!is_user_alive(id))
  1345. {
  1346. kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
  1347. return PLUGIN_HANDLED
  1348. }
  1349. new noclip = !get_user_noclip(id)
  1350. set_user_noclip(id, noclip)
  1351. if(IsPaused[id] && (get_pcvar_num(kz_noclip_pause) == 1))
  1352. {
  1353. if(noclip)
  1354. {
  1355. pev(id, pev_origin, NoclipPos[id])
  1356. set_pev(id, pev_flags, pev(id, pev_flags) & ~FL_FROZEN)
  1357. }
  1358. else
  1359. {
  1360. set_pev(id, pev_origin, NoclipPos[id])
  1361. set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
  1362. }
  1363. }
  1364. else if(noclip)
  1365. detect_cheat(id,"Noclip")
  1366. kz_chat(id, "%L", id, "KZ_NOCLIP" , noclip ? "ON" : "OFF")
  1367.  
  1368. return PLUGIN_HANDLED
  1369. }
  1370.  
  1371. public GodMode(id)
  1372. {
  1373. if(!is_user_alive(id))
  1374. {
  1375. kz_chat(id, "%L", id, "KZ_NOT_ALIVE")
  1376. return PLUGIN_HANDLED
  1377. }
  1378.  
  1379. new godmode = !get_user_godmode(id)
  1380. set_user_godmode(id, godmode)
  1381. if(godmode)
  1382. detect_cheat(id,"God Mode")
  1383. kz_chat(id, "%L", id, "KZ_GODMODE" , godmode ? "ON" : "OFF")
  1384.  
  1385. return PLUGIN_HANDLED
  1386. }
  1387.  
  1388. // =================================================================================================
  1389.  
  1390. stock kz_set_start(const map[], Float:origin[3])
  1391. {
  1392. new realfile[128], tempfile[128], formatorigin[50]
  1393. formatex(realfile, 127, "%s/%s", Kzdir, KZ_STARTFILE)
  1394. formatex(tempfile, 127, "%s/%s", Kzdir, KZ_STARTFILE_TEMP)
  1395. formatex(formatorigin, 49, "%f %f %f", origin[0], origin[1], origin[2])
  1396.  
  1397. DefaultStartPos = origin
  1398. DefaultStart = true
  1399.  
  1400. new file = fopen(tempfile, "wt")
  1401. new vault = fopen(realfile, "rt")
  1402.  
  1403. new data[128], key[64]
  1404. new bool:replaced = false
  1405.  
  1406. while( !feof(vault) )
  1407. {
  1408. fgets(vault, data, 127)
  1409. parse(data, key, 63)
  1410.  
  1411. if( equal(key, map) && !replaced )
  1412. {
  1413. fprintf(file, "%s %s^n", map, formatorigin)
  1414.  
  1415. replaced = true
  1416. }
  1417. else
  1418. {
  1419. fputs(file, data)
  1420. }
  1421. }
  1422.  
  1423. if( !replaced )
  1424. {
  1425. fprintf(file, "%s %s^n", map, formatorigin)
  1426. }
  1427.  
  1428. fclose(file)
  1429. fclose(vault)
  1430.  
  1431. delete_file(realfile)
  1432. while( !rename_file(tempfile, realfile, 1) ) {}
  1433. }
  1434.  
  1435. stock kz_showtime_roundtime(id, time)
  1436. {
  1437. if( is_user_connected(id) )
  1438. {
  1439. message_begin(MSG, get_user_msgid( "RoundTime" ), _, id);
  1440. write_short(time + 1);
  1441. message_end();
  1442. }
  1443. }
  1444.  
  1445. stock kz_chat(id, const message[], {Float,Sql,Result,_}:...)
  1446. {
  1447. new cvar = get_pcvar_num(kz_chatorhud)
  1448. if(cvar == 0)
  1449. return PLUGIN_HANDLED
  1450.  
  1451. new msg[180], final[192]
  1452. if (cvar == 1 && chatorhud[id] == -1 || chatorhud[id] == 1)
  1453. {
  1454. vformat(msg, 179, message, 3)
  1455. formatex(final, 191, "%s^x01 %s", prefix, msg)
  1456. kz_remplace_colors(final, 191)
  1457. ColorChat(id, GREEN, "%s", final)
  1458. }
  1459. else if( cvar == 2 && chatorhud[id] == -1 || chatorhud[id] == 2)
  1460. {
  1461. vformat(msg, 179, message, 3)
  1462. replace_all(msg, 191, "^x01", "")
  1463. replace_all(msg, 191, "^x03", "")
  1464. replace_all(msg, 191, "^x04", "")
  1465. replace_all(msg, 191, ".", "")
  1466. kz_hud_message(id, "%s", msg)
  1467. }
  1468.  
  1469. return 1
  1470. }
  1471.  
  1472. stock kz_print_config(id, const msg[])
  1473. {
  1474. message_begin(MSG_ONE_UNRELIABLE, get_user_msgid("SayText"), _, id);
  1475. write_byte(id);
  1476. write_string(msg);
  1477. message_end();
  1478. }
  1479.  
  1480. stock kz_remplace_colors(message[], len)
  1481. {
  1482. replace_all(message, len, "!g", "^x04")
  1483. replace_all(message, len, "!t", "^x03")
  1484. replace_all(message, len, "!y", "^x01")
  1485. }
  1486.  
  1487. stock kz_hud_message(id, const message[], {Float,Sql,Result,_}:...)
  1488. {
  1489. static msg[192], colors[12], r[4], g[4], b[4];
  1490. vformat(msg, 191, message, 3);
  1491.  
  1492. get_pcvar_string(kz_hud_color, colors, 11)
  1493. parse(colors, r, 3, g, 3, b, 4)
  1494.  
  1495. 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);
  1496. ShowSyncHudMsg(id, hud_message, msg);
  1497. }
  1498.  
  1499. stock kz_register_saycmd(const saycommand[], const function[], flags)
  1500. {
  1501. new temp[64]
  1502. formatex(temp, 63, "say /%s", saycommand)
  1503. register_clcmd(temp, function, flags)
  1504. formatex(temp, 63, "say .%s", saycommand)
  1505. register_clcmd(temp, function, flags)
  1506. formatex(temp, 63, "say_team /%s", saycommand)
  1507. register_clcmd(temp, function, flags)
  1508. formatex(temp, 63, "say_team .%s", saycommand)
  1509. register_clcmd(temp, function, flags)
  1510. }
  1511.  
  1512. stock get_configsdir(name[],len)
  1513. {
  1514. return get_localinfo("amxx_configsdir",name,len);
  1515. }
  1516.  
  1517. #if defined USE_SQL
  1518. stock GetNewRank(id, type)
  1519. {
  1520. new createinto[1001]
  1521.  
  1522. new cData[2]
  1523. cData[0] = id
  1524. cData[1] = type
  1525.  
  1526. formatex(createinto, 1000, "SELECT authid FROM `%s` WHERE mapname='%s' ORDER BY time LIMIT 15", type == PRO_TOP ? "kz_pro15" : "kz_nub15", MapName)
  1527. SQL_ThreadQuery(g_SqlTuple, "GetNewRank_QueryHandler", createinto, cData, 2)
  1528. }
  1529.  
  1530. stock kz_update_plrname(id)
  1531. {
  1532. new createinto[1001], authid[32], name[32]
  1533. get_user_authid(id, authid, 31)
  1534. get_user_name(id, name, 31)
  1535.  
  1536. replace_all(name, 31, "\", "")
  1537. replace_all(name, 31, "`", "")
  1538. replace_all(name, 31, "'", "")
  1539.  
  1540. if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
  1541. return 0;
  1542. else
  1543. {
  1544. formatex(createinto, 1000, "UPDATE `kz_pro15` SET name='%s' WHERE authid='%s'", name, authid)
  1545. SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
  1546. formatex(createinto, 1000, "UPDATE `kz_nub15` SET name='%s' WHERE authid='%s'", name, authid)
  1547. SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
  1548. }
  1549. return 1
  1550. }
  1551. #endif
  1552.  
  1553. public FwdSpawnWeaponbox( iEntity )
  1554. {
  1555. if(get_pcvar_num(kz_remove_drops) == 1)
  1556. {
  1557. set_pev( iEntity, pev_flags, FL_KILLME )
  1558. dllfunc( DLLFunc_Think, iEntity )
  1559. }
  1560.  
  1561. return HAM_IGNORED
  1562. }
  1563.  
  1564. public FwdHamDoorSpawn( iEntity )
  1565. {
  1566. static const szNull[ ] = "common/null.wav";
  1567.  
  1568. new Float:flDamage;
  1569. pev( iEntity, pev_dmg, flDamage );
  1570.  
  1571. if( flDamage < -999.0 ) {
  1572. set_pev( iEntity, pev_noise1, szNull );
  1573. set_pev( iEntity, pev_noise2, szNull );
  1574. set_pev( iEntity, pev_noise3, szNull );
  1575.  
  1576. if( !HealsOnMap )
  1577. HealsOnMap = true
  1578. }
  1579. }
  1580.  
  1581. public FwdHamPlayerSpawn( id )
  1582. {
  1583.  
  1584. if( !is_user_alive( id ) )
  1585. return;
  1586.  
  1587. if(firstspawn[id])
  1588. {
  1589. ColorChat(id, GREEN, "%s^x01 Welcome to^x03 VIRUS^x01 Server ", prefix)
  1590. ColorChat(id, GREEN, "%s^x01 Feel free to visit our website ^x03Virus.ee ^x01", prefix)
  1591.  
  1592.  
  1593.  
  1594. if(Verif(id,1) && get_pcvar_num(kz_save_pos) == 1)
  1595. savepos_menu(id)
  1596. else if(get_pcvar_num(kz_spawn_mainmenu) == 1)
  1597. kz_menu (id)
  1598. }
  1599. firstspawn[id] = false
  1600.  
  1601.  
  1602. if( !user_has_weapon(id,CSW_KNIFE) )
  1603. give_item( id,"weapon_knife" )
  1604.  
  1605. if( HealsOnMap )
  1606. set_user_health(id, 50175)
  1607.  
  1608. if( IsPaused[id] )
  1609. {
  1610. set_pev(id, pev_flags, pev(id, pev_flags) | FL_FROZEN)
  1611. set_pev(id, pev_origin, PauseOrigin[id])
  1612. }
  1613.  
  1614. if(get_pcvar_num(kz_use_radio) == 0)
  1615. {
  1616. #define XO_PLAYER 5
  1617. #define m_iRadiosLeft 192
  1618. set_pdata_int(id, m_iRadiosLeft, 0, XO_PLAYER)
  1619. }
  1620. }
  1621.  
  1622. public GroundWeapon_Touch(iWeapon, id)
  1623. {
  1624. if( is_user_alive(id) && timer_started[id] && get_pcvar_num(kz_pick_weapons) == 0 )
  1625. return HAM_SUPERCEDE
  1626.  
  1627. return HAM_IGNORED
  1628. }
  1629.  
  1630.  
  1631.  
  1632. // ==================================Save positions=================================================
  1633.  
  1634. public SavePos(id)
  1635. {
  1636.  
  1637. new authid[33];
  1638. get_user_authid(id, authid, 32)
  1639. if(get_pcvar_num(kz_save_pos) == 0)
  1640. {
  1641. kz_chat(id, "%L", id, "KZ_SAVEPOS_DISABLED")
  1642. return PLUGIN_HANDLED
  1643. }
  1644.  
  1645. if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
  1646. {
  1647. ColorChat (id, GREEN, "%s^x01 %L", prefix, id, "KZ_NO_STEAM")
  1648.  
  1649. return PLUGIN_HANDLED
  1650. }
  1651.  
  1652. if( !( pev( id, pev_flags ) & FL_ONGROUND2 ) )
  1653. {
  1654. kz_chat(id, "%L", id, "KZ_NOT_ON_GROUND")
  1655.  
  1656. return PLUGIN_HANDLED
  1657. }
  1658.  
  1659. if(!timer_started[id])
  1660. {
  1661. kz_chat(id, "%L", id, "KZ_TIMER_NOT_STARTED")
  1662. return PLUGIN_HANDLED
  1663. }
  1664.  
  1665. if(Verif(id,1))
  1666. {
  1667. ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_ALREADY")
  1668. savepos_menu(id)
  1669. return PLUGIN_HANDLED
  1670. }
  1671.  
  1672. if(get_user_noclip(id))
  1673. {
  1674. ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_NOCLIP")
  1675. return PLUGIN_HANDLED
  1676. }
  1677.  
  1678. new Float:origin[3], scout
  1679. pev(id, pev_origin, origin)
  1680. new Float:Time,check,gocheck
  1681. if(IsPaused[id])
  1682. {
  1683. Time = g_pausetime[id]
  1684. Pause(id)
  1685. }
  1686. else
  1687. Time=get_gametime() - timer_time[id]
  1688. check=checknumbers[id]
  1689. gocheck=gochecknumbers[id]
  1690. ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS")
  1691. if (user_has_scout[id])
  1692. scout=1
  1693. else
  1694. scout=0
  1695. kz_savepos(id, Time, check, gocheck, origin, scout)
  1696. reset_checkpoints(id)
  1697.  
  1698. return PLUGIN_HANDLED
  1699. }
  1700.  
  1701. public GoPos(id)
  1702. {
  1703. remove_hook(id)
  1704. set_user_godmode(id, 0)
  1705. set_user_noclip(id, 0)
  1706. if(Verif(id,0))
  1707. {
  1708. set_pev(id, pev_velocity, Float:{0.0, 0.0, 0.0})
  1709. set_pev(id, pev_flags, pev(id, pev_flags) | FL_DUCKING )
  1710. set_pev(id, pev_origin, SavedOrigins[id] )
  1711. }
  1712.  
  1713. checknumbers[id]=SavedChecks[id]
  1714. gochecknumbers[id]=SavedGoChecks[id]+((get_pcvar_num(kz_save_pos_gochecks)>0) ? 1 : 0)
  1715. CheckPoint(id)
  1716. CheckPoint(id)
  1717. strip_user_weapons(id)
  1718. give_item(id,"weapon_usp")
  1719. give_item(id,"weapon_knife")
  1720. if(SavedScout[id])
  1721. {
  1722. give_item(id, "weapon_scout")
  1723. user_has_scout[id] = true
  1724. }
  1725. timer_time[id]=get_gametime()-SavedTime[id]
  1726. timer_started[id]=true
  1727. Pause(id)
  1728.  
  1729. }
  1730.  
  1731. public Verif(id, action)
  1732. {
  1733. new realfile[128], tempfile[128], authid[32], map[64]
  1734. new bool:exist = false
  1735. get_mapname(map, 63)
  1736. get_user_authid(id, authid, 31)
  1737. formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
  1738. formatex(tempfile, 127, "%s/temp.ini", SavePosDir)
  1739.  
  1740. if( !file_exists(realfile) )
  1741. return 0
  1742.  
  1743. new file = fopen(tempfile, "wt")
  1744. new vault = fopen(realfile, "rt")
  1745. new data[150], sid[32], time[25], checks[5], gochecks[5], x[25], y[25], z[25], scout[5]
  1746. while( !feof(vault) )
  1747. {
  1748. fgets(vault, data, 149)
  1749. parse(data, sid, 31, time, 24, checks, 4, gochecks, 4, x, 24, y, 24, z, 24, scout, 4)
  1750.  
  1751. if( equal(sid, authid) && !exist) // ma aflu in fisier?
  1752. {
  1753. if(action == 1)
  1754. fputs(file, data)
  1755. exist= true
  1756. SavedChecks[id] = str_to_num(checks)
  1757. SavedGoChecks[id] = str_to_num(gochecks)
  1758. SavedTime[id] = str_to_float(time)
  1759. SavedOrigins[id][0]=str_to_num(x)
  1760. SavedOrigins[id][1]=str_to_num(y)
  1761. SavedOrigins[id][2]=str_to_num(z)
  1762. SavedScout[id] = str_to_num(scout)
  1763. }
  1764. else
  1765. {
  1766. fputs(file, data)
  1767. }
  1768. }
  1769.  
  1770. fclose(file)
  1771. fclose(vault)
  1772.  
  1773. delete_file(realfile)
  1774. if(file_size(tempfile) == 0)
  1775. delete_file(tempfile)
  1776. else
  1777. while( !rename_file(tempfile, realfile, 1) ) {}
  1778.  
  1779.  
  1780. if(!exist)
  1781. return 0
  1782.  
  1783. return 1
  1784. }
  1785. public kz_savepos (id, Float:time, checkpoints, gochecks, Float:origin[3], scout)
  1786. {
  1787. new realfile[128], formatorigin[128], map[64], authid[32]
  1788. get_mapname(map, 63)
  1789. get_user_authid(id, authid, 31)
  1790. formatex(realfile, 127, "%s/%s.ini", SavePosDir, map)
  1791. formatex(formatorigin, 127, "%s %f %d %d %d %d %d %d", authid, time, checkpoints, gochecks, origin[0], origin[1], origin[2], scout)
  1792.  
  1793. new vault = fopen(realfile, "rt+")
  1794. write_file(realfile, formatorigin) // La sfarsit adaug datele mele
  1795.  
  1796. fclose(vault)
  1797.  
  1798. }
  1799.  
  1800. // =================================================================================================
  1801. // Events / Forwards
  1802. // =================================================================================================
  1803.  
  1804. //=================================================================================================
  1805.  
  1806. public client_disconnect(id)
  1807. {
  1808. checknumbers[id] = 0
  1809. gochecknumbers[id] = 0
  1810. antihookcheat[id] = 0.0
  1811. chatorhud[id] = -1
  1812. timer_started[id] = false
  1813. ShowTime[id] = get_pcvar_num(kz_show_timer)
  1814. firstspawn[id] = true
  1815. NightVisionUse[id] = false
  1816. IsPaused[id] = false
  1817. WasPaused[id] = false
  1818. user_has_scout[id] = false
  1819. remove_hook(id)
  1820. }
  1821.  
  1822. public client_putinserver(id)
  1823. {
  1824. checknumbers[id] = 0
  1825. gochecknumbers[id] = 0
  1826. antihookcheat[id] = 0.0
  1827. chatorhud[id] = -1
  1828. timer_started[id] = false
  1829. ShowTime[id] = get_pcvar_num(kz_show_timer)
  1830. firstspawn[id] = true
  1831. NightVisionUse[id] = false
  1832. IsPaused[id] = false
  1833. WasPaused[id] = false
  1834. user_has_scout[id] = false
  1835. remove_hook(id)
  1836. }
  1837.  
  1838. // =================================================================================================
  1839. // Menu
  1840. // =================================================================================================
  1841.  
  1842.  
  1843. public kz_menu(id)
  1844. {
  1845. new title[64];
  1846. formatex(title, 63, "\yProKreedz %s Menu\w", VERSION)
  1847. new menu = menu_create(title, "MenuHandler")
  1848.  
  1849. new msgcheck[64], msggocheck[64], msgpause[64]
  1850. formatex(msgcheck, 63, "Checkpoint - \y#%i", checknumbers[id])
  1851. formatex(msggocheck, 63, "Gocheck - \y#%i", gochecknumbers[id])
  1852. formatex(msgpause, 63, "Pause - %s^n", IsPaused[id] ? "\yON" : "\rOFF" )
  1853.  
  1854. menu_additem( menu, msgcheck, "1" )
  1855. menu_additem( menu, msggocheck, "2" )
  1856. menu_additem( menu, "Top 15^n", "3")
  1857. menu_additem( menu, "Start", "4")
  1858. menu_additem( menu, "Timer Menu", "5" )
  1859. menu_additem( menu, msgpause, "6" )
  1860. menu_additem( menu, "Invisible Menu", "7" )
  1861. menu_additem( menu, "Spectator/CT", "8" )
  1862. menu_additem( menu, "Reset Time^n", "9")
  1863. menu_additem( menu, "Exit", "MENU_EXIT" )
  1864.  
  1865. menu_setprop(menu, MPROP_PERPAGE, 0)
  1866. menu_display(id, menu, 0)
  1867. return PLUGIN_HANDLED
  1868. }
  1869.  
  1870. public MenuHandler(id , menu, item)
  1871. {
  1872. if( item == MENU_EXIT ) {
  1873. menu_destroy(menu)
  1874. return PLUGIN_HANDLED
  1875. }
  1876.  
  1877.  
  1878. switch(item) {
  1879. case 0:{
  1880. CheckPoint(id)
  1881. kz_menu(id)
  1882. }
  1883. case 1:{
  1884. GoCheck(id)
  1885. kz_menu(id)
  1886. }
  1887. case 2:{
  1888. top15menu(id)
  1889. }
  1890. case 3:{
  1891. goStart(id)
  1892. kz_menu(id)
  1893. }
  1894. case 4:{
  1895. ShowTimer_Menu(id)
  1896. }
  1897. case 5:{
  1898. Pause(id)
  1899. kz_menu(id)
  1900. }
  1901. case 6:{
  1902. InvisMenu(id)
  1903. }
  1904. case 7:{
  1905. ct(id)
  1906. }
  1907. case 8:{
  1908. reset_checkpoints(id)
  1909. kz_menu(id)
  1910. }
  1911. }
  1912.  
  1913. return PLUGIN_HANDLED
  1914. }
  1915.  
  1916. public InvisMenu(id)
  1917. {
  1918. new menu = menu_create("\yInvis Menu\w", "InvisMenuHandler")
  1919. new msginvis[64], msgwaterinvis[64]
  1920.  
  1921. formatex(msginvis, 63, "Players - %s", gViewInvisible[id] ? "\yON" : "\rOFF" )
  1922. formatex(msgwaterinvis, 63, "Water - %s^n^n", gWaterInvisible[id] ? "\yON" : "\rOFF" )
  1923.  
  1924. menu_additem( menu, msginvis, "1" )
  1925. menu_additem( menu, msgwaterinvis, "2" )
  1926.  
  1927.  
  1928. menu_display(id, menu, 0)
  1929. return PLUGIN_HANDLED
  1930. }
  1931.  
  1932. public InvisMenuHandler (id, menu, item)
  1933. {
  1934. if( item == MENU_EXIT )
  1935. {
  1936. menu_destroy(menu)
  1937. return PLUGIN_HANDLED
  1938. }
  1939.  
  1940. switch(item)
  1941. {
  1942. case 0:
  1943. {
  1944. cmdInvisible(id)
  1945. InvisMenu(id)
  1946. }
  1947. case 1:
  1948. {
  1949. cmdWaterInvisible(id)
  1950. InvisMenu(id)
  1951. }
  1952. case 2:
  1953. {
  1954. kz_menu(id)
  1955. }
  1956. }
  1957. return PLUGIN_HANDLED
  1958. }
  1959.  
  1960. public ShowTimer_Menu(id)
  1961. {
  1962. if (get_pcvar_num(kz_show_timer) == 0 )
  1963. {
  1964. kz_chat(id, "%L", id, "KZ_TIMER_DISABLED")
  1965. return PLUGIN_HANDLED
  1966. }
  1967. else
  1968. {
  1969. new menu = menu_create("\yTimer Menu\w", "TimerHandler")
  1970.  
  1971. new roundtimer[64], hudtimer[64], notimer[64];
  1972.  
  1973. formatex(roundtimer, 63, "Round Timer %s", ShowTime[id] == 2 ? "\y x" : "" )
  1974. formatex(hudtimer, 63, "HUD Timer %s", ShowTime[id] == 1 ? "\y x" : "" )
  1975. formatex(notimer, 63, "No Timer %s^n", ShowTime[id] == 0 ? "\y x" : "" )
  1976.  
  1977. menu_additem( menu, roundtimer, "1" )
  1978. menu_additem( menu, hudtimer, "2" )
  1979. menu_additem( menu, notimer, "3" )
  1980.  
  1981.  
  1982. menu_display(id, menu, 0)
  1983. return PLUGIN_HANDLED
  1984. }
  1985.  
  1986. return PLUGIN_HANDLED
  1987. }
  1988.  
  1989. public TimerHandler (id, menu, item)
  1990. {
  1991. if( item == MENU_EXIT )
  1992. {
  1993. menu_destroy(menu)
  1994. return PLUGIN_HANDLED
  1995. }
  1996.  
  1997. switch(item)
  1998. {
  1999.  
  2000. case 0:
  2001. {
  2002. ShowTime[id]= 2
  2003. ShowTimer_Menu(id)
  2004. }
  2005. case 1:
  2006. {
  2007. ShowTime[id]= 1
  2008. ShowTimer_Menu(id)
  2009. if (timer_started[id])
  2010. kz_showtime_roundtime(id, 0)
  2011. }
  2012. case 2:
  2013. {
  2014. ShowTime[id]= 0
  2015. ShowTimer_Menu(id)
  2016. if (timer_started[id])
  2017. kz_showtime_roundtime(id, 0)
  2018. }
  2019. case 3:
  2020. {
  2021. kz_menu(id)
  2022. }
  2023. }
  2024. return PLUGIN_HANDLED
  2025. }
  2026.  
  2027. public savepos_menu(id)
  2028. {
  2029. new menu = menu_create("SavePos Menu", "SavePosHandler")
  2030.  
  2031. menu_additem( menu, "Reload previous run", "1" )
  2032. menu_additem( menu, "Start a new run", "2" )
  2033.  
  2034. menu_display(id, menu, 0)
  2035. return PLUGIN_HANDLED
  2036. }
  2037.  
  2038. public SavePosHandler(id, menu, item)
  2039. {
  2040.  
  2041. switch(item)
  2042. {
  2043. case 0:
  2044. {
  2045. GoPos(id)
  2046. }
  2047. case 1:
  2048. {
  2049. Verif(id,0)
  2050. }
  2051. }
  2052. return PLUGIN_HANDLED
  2053. }
  2054.  
  2055. public top15menu(id)
  2056. {
  2057. new menu = menu_create("\rProKreedz \yTop15 \w", "top15handler")
  2058. menu_additem(menu, "\wPro 15", "1", 0)
  2059.  
  2060. #if defined USE_SQL
  2061. menu_additem(menu, "Pro Records","3")
  2062. menu_additem(menu, "Players Rankings^n","4")
  2063. menu_additem(menu, "Last 10 Pro Entries", "5")
  2064. menu_additem(menu, "Maps Statistic","6")
  2065.  
  2066. #else
  2067. menu_additem(menu, "\wMain Menu", "8", 0)
  2068. #endif
  2069.  
  2070. menu_display(id, menu, 0);
  2071.  
  2072. return PLUGIN_HANDLED;
  2073. }
  2074.  
  2075. public top15handler(id, menu, item)
  2076. {
  2077. if(item == MENU_EXIT)
  2078. {
  2079. menu_destroy(menu)
  2080. return PLUGIN_HANDLED
  2081. }
  2082. #if defined USE_SQL
  2083. switch(item)
  2084. {
  2085. case 0:
  2086. {
  2087. ProTop_show(id)
  2088. }
  2089.  
  2090. case 1:
  2091. {
  2092. kz_showhtml_motd(id, PRO_RECORDS, "")
  2093. }
  2094. case 2:
  2095. {
  2096. kz_showhtml_motd(id, PLAYERS_RANKING, "")
  2097. }
  2098. case 3:
  2099. {
  2100. kz_showhtml_motd(id, LAST_PRO10, "")
  2101. }
  2102. case 4:
  2103. {
  2104. kz_showhtml_motd(id, MAPS_STATISTIC, "")
  2105. }
  2106. case 5:
  2107. {
  2108. kz_menu(id)
  2109. }
  2110. }
  2111. #else
  2112. switch(item)
  2113. {
  2114. case 0:
  2115. {
  2116. ProTop_show(id)
  2117. }
  2118. case 1:
  2119. {
  2120. NoobTop_show(id)
  2121. }
  2122. case 2:
  2123. {
  2124. kz_menu(id)
  2125. }
  2126. }
  2127. #endif
  2128.  
  2129. return PLUGIN_HANDLED;
  2130. }
  2131.  
  2132. // =================================================================================================
  2133.  
  2134. //
  2135. // Timersystem
  2136. // =================================================================================================
  2137. public fwdUse(ent, id)
  2138. {
  2139. if( !ent || id > 32 )
  2140. {
  2141. return HAM_IGNORED;
  2142. }
  2143.  
  2144. if( !is_user_alive(id) )
  2145. {
  2146. return HAM_IGNORED;
  2147. }
  2148.  
  2149.  
  2150. new name[32]
  2151. get_user_name(id, name, 31)
  2152.  
  2153. new szTarget[ 32 ];
  2154. pev(ent, pev_target, szTarget, 31);
  2155.  
  2156. if( TrieKeyExists( g_tStarts, szTarget ) )
  2157. {
  2158.  
  2159. if ( get_gametime() - antihookcheat[id] < 3.0 )
  2160. {
  2161. kz_hud_message( id, "%L", id, "KZ_HOOK_PROTECTION" );
  2162. return PLUGIN_HANDLED
  2163. }
  2164.  
  2165. if(Verif(id,1))
  2166. {
  2167. ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SAVEPOS_SAVED")
  2168. savepos_menu(id)
  2169. return HAM_IGNORED
  2170. }
  2171.  
  2172. if ( reset_checkpoints(id) && !timer_started[id] )
  2173. {
  2174. start_climb(id)
  2175. new wpn=get_user_weapon(id)
  2176. for(new i = 0; i < 8; i++)
  2177. if( user_has_weapon(id, other_weapons[i]) )
  2178. {
  2179. strip_user_weapons(id)
  2180. give_item(id,"weapon_knife")
  2181. give_item(id,"weapon_usp")
  2182. set_pdata_int(id, 382, 24, 5)
  2183. if(wpn==CSW_SCOUT)
  2184. {
  2185. user_has_scout[id]=true
  2186. give_item(id,"weapon_scout")
  2187. }
  2188. else
  2189. user_has_scout[id]=false
  2190. }
  2191.  
  2192. if( get_user_health(id) < 100 )
  2193. set_user_health(id, 100)
  2194.  
  2195. pev(id, pev_origin, SavedStart[id])
  2196. if(get_pcvar_num(kz_save_autostart) == 1)
  2197. AutoStart[id] = true;
  2198.  
  2199. if( !DefaultStart )
  2200. {
  2201. kz_set_start(MapName, SavedStart[id])
  2202. ColorChat(id, GREEN, "%s^x01 %L", prefix, id, "KZ_SET_START")
  2203. }
  2204.  
  2205. remove_hook(id)
  2206. }
  2207.  
  2208. }
  2209.  
  2210. if( TrieKeyExists( g_tStops, szTarget ) )
  2211. {
  2212. if( timer_started[id] )
  2213. {
  2214. if(get_user_noclip(id))
  2215. return PLUGIN_HANDLED
  2216.  
  2217. finish_climb(id)
  2218.  
  2219. if(get_pcvar_num(kz_hook_prize) == 1 && !canusehook[id])
  2220. {
  2221. canusehook[id] = true
  2222. ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_HOOK")
  2223. }
  2224. }
  2225. else
  2226. kz_hud_message(id, "%L", id, "KZ_TIMER_NOT_STARTED")
  2227.  
  2228. }
  2229. return HAM_IGNORED
  2230. }
  2231.  
  2232. public start_climb(id)
  2233. {
  2234. kz_chat(id, "%L", id, "KZ_START_CLIMB")
  2235.  
  2236. if (get_pcvar_num(kz_reload_weapons) == 1)
  2237. {
  2238. strip_user_weapons(id)
  2239. give_item(id,"weapon_knife")
  2240. give_item(id,"weapon_usp")
  2241. }
  2242.  
  2243. if (ShowTime[id] == 2)
  2244. kz_showtime_roundtime(id, 0)
  2245. set_pev(id, pev_gravity, 1.0);
  2246. set_pev(id, pev_movetype, MOVETYPE_WALK)
  2247. set_user_godmode(id, 0)
  2248. reset_checkpoints(id)
  2249. IsPaused[id] = false
  2250. timer_started[id] = true
  2251. timer_time[id] = get_gametime()
  2252. }
  2253.  
  2254. public finish_climb(id)
  2255. {
  2256. if (!is_user_alive (id))
  2257. {
  2258. return;
  2259. }
  2260.  
  2261. if ( (get_pcvar_num(kz_top15_authid) > 1) || (get_pcvar_num(kz_top15_authid) < 0) )
  2262. {
  2263. ColorChat(id, GREEN, "%s^x01 %L.", prefix, id, "KZ_TOP15_DISABLED")
  2264. return;
  2265. }
  2266.  
  2267. #if defined USE_SQL
  2268. new Float: time, wpn
  2269. time = get_gametime() - timer_time[id]
  2270. show_finish_message(id, time)
  2271. timer_started[id] = false
  2272. if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
  2273. kz_showtime_roundtime(id, 0)
  2274. new checkpoints=checknumbers[id]
  2275. new gocheck=gochecknumbers[id]
  2276. if(user_has_scout[id])
  2277. wpn=CSW_SCOUT
  2278. else
  2279. wpn=get_user_weapon( id )
  2280.  
  2281. new steam[32], name[32]
  2282. get_user_name(id, name, 31)
  2283. get_user_authid(id, steam, 31 )
  2284. client_cmd(0, "spk buttons/bell1")
  2285. new createinto[1001]
  2286.  
  2287. new cData[192]
  2288. cData[0] = id
  2289. formatex(cData[2], charsmax(cData)-2, "^"%f^" ^"%d^" ^"%d^" ^"%d^"", time, wpn, checkpoints ,gocheck)
  2290.  
  2291.  
  2292. if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
  2293. {
  2294. if (gochecknumbers[id] == 0 && !user_has_scout[id] )
  2295. {
  2296. cData[1] = PRO_TOP
  2297. formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND name='%s'", MapName, name)
  2298. SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
  2299. }
  2300. if (gochecknumbers[id] > 0 || user_has_scout[id] )
  2301. {
  2302. cData[1] = NUB_TOP
  2303. formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND name='%s'", MapName, name)
  2304. SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
  2305. }
  2306. } else
  2307. {
  2308.  
  2309. if (gochecknumbers[id] == 0 && !user_has_scout[id] )
  2310. {
  2311. cData[1] = PRO_TOP
  2312. formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_pro15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
  2313. SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
  2314. }
  2315. if (gochecknumbers[id] > 0 || user_has_scout[id] )
  2316. {
  2317. cData[1] = NUB_TOP
  2318. formatex(createinto, sizeof createinto - 1, "SELECT time FROM `kz_nub15` WHERE mapname='%s' AND authid='%s'", MapName, steam)
  2319. SQL_ThreadQuery(g_SqlTuple, "Set_QueryHandler", createinto, cData, strlen(cData[2])+1)
  2320. }
  2321. }
  2322. #else
  2323. new Float: time, authid[32]
  2324. time = get_gametime() - timer_time[id]
  2325. get_user_authid(id, authid, 31)
  2326. show_finish_message(id, time)
  2327. timer_started[id] = false
  2328. if (get_pcvar_num(kz_show_timer) > 0 && ShowTime[id] == 2)
  2329. kz_showtime_roundtime(id, 0)
  2330.  
  2331. if (gochecknumbers[id] == 0 && !user_has_scout[id] )
  2332. ProTop_update(id, time)
  2333. if (gochecknumbers[id] > 0 || user_has_scout[id] )
  2334. NoobTop_update(id, time, checknumbers[id], gochecknumbers[id])
  2335. #endif
  2336. user_has_scout[id] = false
  2337.  
  2338. }
  2339.  
  2340. public show_finish_message(id, Float:kreedztime)
  2341. {
  2342. new name[32]
  2343. new imin,isec,ims, wpn
  2344. if(user_has_scout[id])
  2345. wpn=CSW_SCOUT
  2346. else
  2347. wpn=get_user_weapon( id )
  2348. get_user_name(id, name, 31)
  2349. imin = floatround(kreedztime / 60.0, floatround_floor)
  2350. isec = floatround(kreedztime - imin * 60.0,floatround_floor)
  2351. ims = floatround( ( kreedztime - ( imin * 60.0 + isec ) ) * 100.0, floatround_floor )
  2352.  
  2353. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x04 %02i:%02i.%02i ^x03(^x01 CPs: ^x04%d^x03 | ^x01 TPs: ^x04%d^x03 | ^x01 %L: ^x04%s^x03) ^x01 !", prefix, name, LANG_PLAYER, "KZ_FINISH_MSG", imin, isec, ims, checknumbers[id], gochecknumbers[id], LANG_PLAYER, "KZ_WEAPON", g_weaponsnames[wpn])
  2354. }
  2355.  
  2356. //==========================================================
  2357. #if defined USE_SQL
  2358. public Set_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  2359. {
  2360. new id = cData[0]
  2361. new style = cData[1]
  2362. if( iFailState != TQUERY_SUCCESS )
  2363. {
  2364. log_amx("[KZ] TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
  2365. ColorChat(0, GREEN, "%s^x01 %F", prefix, LANG_PLAYER, "KZ_TOP15_SQL_ERROR")
  2366. }
  2367.  
  2368. server_print("[KZ] Server Geting Info of SQL Server")
  2369.  
  2370. new createinto[1001]
  2371. new x1[16], x2[4], x3[5], x4[5]
  2372. parse(cData[2], x1, 15, x2, 3, x3, 4, x4, 4)
  2373.  
  2374. new dia[64], steam[32], name[32], ip[15], country[3], checkpoints[32], gochecks[32]
  2375. new Float:newtime = str_to_float(x1)
  2376. new iMin, iSec, iMs, server[64]
  2377. get_pcvar_string(kz_sql_name, server, 63)
  2378. get_time("%Y%m%d%H%M%S", dia, sizeof dia - 1)
  2379. get_user_authid(id, steam, 31)
  2380. get_user_name(id, name, sizeof name - 1)
  2381. get_user_ip (id, ip, sizeof ip - 1, 1)
  2382. geoip_code2_ex( ip, country)
  2383.  
  2384. replace_all(name, 31, "\", "")
  2385. replace_all(name, 31, "`", "")
  2386. replace_all(name, 31, "'", "")
  2387.  
  2388.  
  2389. if( SQL_NumResults(hQuery) == 0 )
  2390. {
  2391. formatex(checkpoints, 31, ", '%d'", str_to_num(x3))
  2392. formatex(gochecks, 31, ", '%d'", str_to_num(x4))
  2393. 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", MapName, steam, country, name, newtime, dia, g_weaponsnames[str_to_num(x2)], server, style == PRO_TOP ? "" : checkpoints, style == PRO_TOP ? "" : gochecks)
  2394. SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto)
  2395. GetNewRank(id, style)
  2396. }
  2397. else
  2398. {
  2399. new Float:oldtime, Float:thetime
  2400. SQL_ReadResult(hQuery, 0, oldtime)
  2401.  
  2402. if(newtime < oldtime)
  2403. {
  2404. thetime = oldtime - newtime
  2405. iMin = floatround(thetime / 60.0, floatround_floor)
  2406. iSec = floatround(thetime - iMin * 60.0,floatround_floor)
  2407. iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
  2408. ColorChat(id, GREEN, "[KZ]^x01 %L^x03 %02i:%02i.%02i^x01 in ^x03%s", id, "KZ_IMPROVE", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
  2409. formatex(checkpoints, 31, ", checkpoints='%d'", str_to_num(x3))
  2410. formatex(gochecks, 31, ", gocheck='%d'", str_to_num(x4))
  2411. if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
  2412. 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, MapName)
  2413. else
  2414. 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, MapName)
  2415.  
  2416. SQL_ThreadQuery(g_SqlTuple, "QueryHandle", createinto )
  2417. GetNewRank(id, style)
  2418. }
  2419. else
  2420. {
  2421. thetime = newtime - oldtime
  2422. iMin = floatround(thetime / 60.0, floatround_floor)
  2423. iSec = floatround(thetime - iMin * 60.0,floatround_floor)
  2424. iMs = floatround( ( thetime - ( iMin * 60.0 + iSec ) ) * 100.0, floatround_floor )
  2425. ColorChat(id, GREEN, "[KZ]^x01 %L^x03 %02i:%02i.%02i ^x01in ^x03%s", id, "KZ_SLOWER", iMin, iSec, iMs, style == PRO_TOP ? "Pro 15" : "Noob 15")
  2426. }
  2427. }
  2428.  
  2429. return PLUGIN_CONTINUE
  2430.  
  2431. }
  2432.  
  2433. public GetNewRank_QueryHandler(iFailState, Handle:hQuery, szError[], iErrnum, cData[], iSize, Float:fQueueTime)
  2434. {
  2435. new id = cData[0]
  2436. if( iFailState != TQUERY_SUCCESS )
  2437. {
  2438. return log_amx("TOP15 SQL: SQL Error #%d - %s", iErrnum, szError)
  2439. }
  2440.  
  2441. new steam[32], authid[32], namez[32], name[32], i = 0
  2442. get_user_authid(id, steam, 31)
  2443. get_user_name(id, namez, 31)
  2444.  
  2445. while( SQL_MoreResults(hQuery) )
  2446. {
  2447. i++
  2448. if(equal(steam, "VALVE_ID_LAN") || equal(steam, "STEAM_ID_LAN") || strlen(steam) > 18)
  2449. {
  2450. SQL_ReadResult(hQuery, 0, name, 31)
  2451. if( equal(name, namez) )
  2452. {
  2453. ColorChat(0, GREEN, "%s^x03 %s^x01 %L ^x03%d^x01 in^x03 %s^x01",prefix, namez, LANG_PLAYER, "KZ_PLACE", i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
  2454. break;
  2455. }
  2456. }
  2457. else
  2458. {
  2459. SQL_ReadResult(hQuery, 0, authid, 31)
  2460. if( equal(authid, steam) )
  2461. {
  2462. ColorChat(0, GREEN, "%s^x03 %s^x01 %L ^x03%d^x01 in^x03 %s^x01",prefix, namez, LANG_PLAYER, "KZ_PLACE", i, cData[1] == PRO_TOP ? "Pro 15" : "Noob 15");
  2463. break;
  2464. }
  2465. }
  2466. SQL_NextRow(hQuery)
  2467. }
  2468.  
  2469. return PLUGIN_CONTINUE
  2470. }
  2471.  
  2472. public ProTop_show(id)
  2473. {
  2474. kz_showhtml_motd(id, PRO_TOP, MapName)
  2475.  
  2476. return PLUGIN_HANDLED
  2477. }
  2478.  
  2479. public NoobTop_show(id)
  2480. {
  2481.  
  2482. kz_showhtml_motd(id, NUB_TOP, MapName)
  2483.  
  2484. return PLUGIN_HANDLED
  2485. }
  2486.  
  2487. public ProRecs_show(id)
  2488. {
  2489. new authid[32]
  2490. get_user_authid(id, authid, 31)
  2491.  
  2492. if(equal(authid, "VALVE_ID_LAN") || equal(authid, "STEAM_ID_LAN") || strlen(authid) > 18)
  2493. {
  2494. ColorChat (id, GREEN, "%s^x01 %L", prefix, id, "KZ_NO_STEAM")
  2495. return PLUGIN_HANDLED
  2496. }
  2497.  
  2498. kz_showhtml_motd(id, PRO_RECORDS, MapName)
  2499.  
  2500. return PLUGIN_HANDLED
  2501. }
  2502.  
  2503. stock kz_showhtml_motd(id, type, const map[])
  2504. {
  2505. new buffer[1001], namebuffer[64], filepath[96]
  2506. get_pcvar_string(kz_sql_files, filepath, 95)
  2507. new authid[32]
  2508. get_user_authid(id, authid, 31)
  2509.  
  2510. switch( type )
  2511. {
  2512. case PRO_TOP:
  2513. {
  2514. formatex(namebuffer, 63, "Pro 15 of %s", equal(map, "") ? "All Maps" : map)
  2515. 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)
  2516. }
  2517.  
  2518. case PRO_RECORDS:
  2519. {
  2520. formatex(namebuffer, 63, "ProRecords and Rank")
  2521. 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)
  2522. }
  2523. case PLAYERS_RANKING:
  2524. {
  2525. formatex(namebuffer, 63, "Players Ranking")
  2526. 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)
  2527. }
  2528. case LAST_PRO10:
  2529. {
  2530. formatex(namebuffer, 63, "Last 10 Pro Entries")
  2531. formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/lastpro.php^"></head><body><p>LOADING...</p></body></html>", filepath)
  2532. }
  2533. case MAPS_STATISTIC:
  2534. {
  2535. formatex(namebuffer, 63, "Maps Statistic")
  2536. formatex(buffer, 1000, "<html><head><meta http-equiv=^"Refresh^" content=^"0;url=http://%s/map.php^"></head><body><p>LOADING...</p></body></html>", filepath)
  2537. }
  2538. }
  2539.  
  2540. show_motd(id, buffer, namebuffer)
  2541. }
  2542. #else
  2543. public ProTop_update(id, Float:time)
  2544. {
  2545. new authid[32], name[32], thetime[32], Float: slower, Float: faster, Float:protiempo
  2546. get_user_name(id, name, 31);
  2547. get_user_authid(id, authid, 31);
  2548. get_time(" %d/%m/%Y ", thetime, 31);
  2549. new bool:Is_in_pro15
  2550. Is_in_pro15 = false
  2551.  
  2552. for(new i = 0; i < 15; i++)
  2553. {
  2554. if( (equali(Pro_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Pro_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
  2555. {
  2556. Is_in_pro15 = true
  2557. slower = time - Pro_Times[i]
  2558. faster = Pro_Times[i] - time
  2559. protiempo = Pro_Times[i]
  2560. }
  2561. }
  2562.  
  2563. for (new i = 0; i < 15; i++)
  2564. {
  2565. if( time < Pro_Times[i])
  2566. {
  2567. new pos = i
  2568. if ( get_pcvar_num(kz_top15_authid) == 0 )
  2569. while( !equal(Pro_Names[pos], name) && pos < 15 )
  2570. {
  2571. pos++;
  2572. }
  2573. else if ( get_pcvar_num(kz_top15_authid) == 1)
  2574. while( !equal(Pro_AuthIDS[pos], authid) && pos < 15 )
  2575. {
  2576. pos++;
  2577. }
  2578.  
  2579. for (new j = pos; j > i; j--)
  2580. {
  2581. formatex(Pro_AuthIDS[j], 31, Pro_AuthIDS[j-1]);
  2582. formatex(Pro_Names[j], 31, Pro_Names[j-1]);
  2583. formatex(Pro_Date[j], 31, Pro_Date[j-1])
  2584. Pro_Times[j] = Pro_Times[j-1];
  2585. }
  2586.  
  2587. formatex(Pro_AuthIDS[i], 31, authid);
  2588. formatex(Pro_Names[i], 31, name);
  2589. formatex(Pro_Date[i], 31, thetime)
  2590. Pro_Times[i] = time
  2591.  
  2592. save_pro15()
  2593.  
  2594. if( Is_in_pro15 )
  2595. {
  2596.  
  2597. if( time < protiempo )
  2598. {
  2599. new min, Float:sec;
  2600. min = floatround(faster, floatround_floor)/60;
  2601. sec = faster - (60*min);
  2602. ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_IMPROVE", min, sec < 10 ? "0" : "", sec);
  2603.  
  2604. if( (i + 1) == 1)
  2605. {
  2606. client_cmd(0, "spk woop");
  2607. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
  2608. }
  2609. else
  2610. {
  2611. client_cmd(0, "spk buttons/bell1");
  2612. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
  2613. }
  2614. }
  2615. }
  2616. else
  2617. {
  2618. if( (i + 1) == 1)
  2619. {
  2620. client_cmd(0, "spk woop");
  2621. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
  2622. }
  2623. else
  2624. {
  2625. client_cmd(0, "spk buttons/bell1");
  2626. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Pro 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
  2627. }
  2628. }
  2629.  
  2630. return;
  2631. }
  2632.  
  2633. if( (equali(Pro_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Pro_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
  2634. {
  2635. if( time > protiempo )
  2636. {
  2637. new min, Float:sec;
  2638. min = floatround(slower, floatround_floor)/60;
  2639. sec = slower - (60*min);
  2640. ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_SLOWER", min, sec < 10 ? "0" : "", sec);
  2641. return;
  2642. }
  2643. }
  2644.  
  2645. }
  2646. }
  2647.  
  2648. public save_pro15()
  2649. {
  2650. new profile[128]
  2651. formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
  2652.  
  2653. if( file_exists(profile) )
  2654. {
  2655. delete_file(profile)
  2656. }
  2657.  
  2658. new Data[256];
  2659. new f = fopen(profile, "at")
  2660.  
  2661. for(new i = 0; i < 15; i++)
  2662. {
  2663. formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%s^"^n", Pro_Times[i], Pro_AuthIDS[i], Pro_Names[i], Pro_Date[i])
  2664. fputs(f, Data)
  2665. }
  2666. fclose(f);
  2667. }
  2668.  
  2669. public read_pro15()
  2670. {
  2671. new profile[128], prodata[256]
  2672. formatex(profile, 127, "%s/pro_%s.cfg", Topdir, MapName)
  2673.  
  2674. new f = fopen(profile, "rt" )
  2675. new i = 0
  2676. while( !feof(f) && i < 16)
  2677. {
  2678. fgets(f, prodata, 255)
  2679. new totime[25]
  2680. parse(prodata, totime, 24, Pro_AuthIDS[i], 31, Pro_Names[i], 31, Pro_Date[i], 31)
  2681. Pro_Times[i] = str_to_float(totime)
  2682. i++;
  2683. }
  2684. fclose(f)
  2685. }
  2686.  
  2687. //==================================================================================================
  2688.  
  2689. public NoobTop_update(id, Float:time, checkpoints, gochecks)
  2690. {
  2691. new authid[32], name[32], thetime[32], wpn, Float: slower, Float: faster, Float:noobtiempo
  2692. get_user_name(id, name, 31);
  2693. get_user_authid(id, authid, 31);
  2694. get_time(" %d/%m/%Y ", thetime, 31);
  2695. new bool:Is_in_noob15
  2696. Is_in_noob15 = false
  2697. if(user_has_scout[id])
  2698. wpn=CSW_SCOUT
  2699. else
  2700. wpn=get_user_weapon(id)
  2701.  
  2702. for(new i = 0; i < 15; i++)
  2703. {
  2704. if( (equali(Noob_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Noob_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
  2705. {
  2706. Is_in_noob15 = true
  2707. slower = time - Noob_Tiempos[i];
  2708. faster = Noob_Tiempos[i] - time;
  2709. noobtiempo = Noob_Tiempos[i]
  2710. }
  2711. }
  2712.  
  2713. for (new i = 0; i < 15; i++)
  2714. {
  2715. if( time < Noob_Tiempos[i])
  2716. {
  2717. new pos = i
  2718.  
  2719. if ( get_pcvar_num(kz_top15_authid) == 0 )
  2720. while( !equal(Noob_Names[pos], name) && pos < 15 )
  2721. {
  2722. pos++;
  2723. }
  2724. else if ( get_pcvar_num(kz_top15_authid) == 1)
  2725. while( !equal(Noob_AuthIDS[pos], authid) && pos < 15 )
  2726. {
  2727. pos++;
  2728. }
  2729.  
  2730. for (new j = pos; j > i; j--)
  2731. {
  2732. formatex(Noob_AuthIDS[j], 31, Noob_AuthIDS[j-1])
  2733. formatex(Noob_Names[j], 31, Noob_Names[j-1])
  2734. formatex(Noob_Date[j], 31, Noob_Date[j-1])
  2735. formatex(Noob_Weapon[j], 31, Noob_Weapon[j-1])
  2736. Noob_Tiempos[j] = Noob_Tiempos[j-1]
  2737. Noob_CheckPoints[j] = Noob_CheckPoints[j-1]
  2738. Noob_GoChecks[j] = Noob_GoChecks[j-1]
  2739. }
  2740.  
  2741. formatex(Noob_AuthIDS[i], 31, authid);
  2742. formatex(Noob_Names[i], 31, name);
  2743. formatex(Noob_Date[i], 31, thetime)
  2744. formatex(Noob_Weapon[i], 31, g_weaponsnames[wpn])
  2745. Noob_Tiempos[i] = time
  2746. Noob_CheckPoints[i] = checkpoints
  2747. Noob_GoChecks[i] = gochecks
  2748.  
  2749. save_Noob15()
  2750.  
  2751. if( Is_in_noob15 )
  2752. {
  2753.  
  2754. if( time < noobtiempo )
  2755. {
  2756. new min, Float:sec;
  2757. min = floatround(faster, floatround_floor)/60;
  2758. sec = faster - (60*min);
  2759. ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_IMPROVE", min, sec < 10 ? "0" : "", sec);
  2760.  
  2761. if( (i + 1) == 1)
  2762. {
  2763. client_cmd(0, "spk woop");
  2764. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
  2765. }
  2766. else
  2767. {
  2768. client_cmd(0, "spk buttons/bell1");
  2769. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
  2770. }
  2771. }
  2772. }
  2773. else
  2774. {
  2775. if( (i + 1) == 1)
  2776. {
  2777. client_cmd(0, "spk woop");
  2778. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 1^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE");
  2779. }
  2780. else
  2781. {
  2782. client_cmd(0, "spk buttons/bell1");
  2783. ColorChat(0, GREEN, "%s^x01^x03 %s^x01 %L^x03 %d^x01 in ^x04Noob 15^x01", prefix, name, LANG_PLAYER, "KZ_PLACE", (i+1));
  2784. }
  2785. }
  2786. return;
  2787. }
  2788.  
  2789. if( (equali(Noob_Names[i], name) && (get_pcvar_num(kz_top15_authid) == 0)) || (equali(Noob_AuthIDS[i], authid) && (get_pcvar_num(kz_top15_authid) == 1)) )
  2790. {
  2791. if( time > noobtiempo )
  2792. {
  2793.  
  2794. new min, Float:sec;
  2795. min = floatround(slower, floatround_floor)/60;
  2796. sec = slower - (60*min);
  2797. ColorChat(id, GREEN, "%s^x01 %L ^x03%02d:%s%.2f^x01", prefix, id, "KZ_SLOWER", min, sec < 10 ? "0" : "", sec);
  2798. return;
  2799. }
  2800. }
  2801.  
  2802. }
  2803. }
  2804.  
  2805. public save_Noob15()
  2806. {
  2807. new profile[128]
  2808. formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
  2809.  
  2810. if( file_exists(profile) )
  2811. {
  2812. delete_file(profile)
  2813. }
  2814.  
  2815. new Data[256];
  2816. new f = fopen(profile, "at")
  2817.  
  2818. for(new i = 0; i < 15; i++)
  2819. {
  2820. formatex(Data, 255, "^"%.2f^" ^"%s^" ^"%s^" ^"%i^" ^"%i^" ^"%s^" ^"%s^" ^n", Noob_Tiempos[i], Noob_AuthIDS[i], Noob_Names[i], Noob_CheckPoints[i], Noob_GoChecks[i],Noob_Date[i],Noob_Weapon[i])
  2821. fputs(f, Data)
  2822. }
  2823. fclose(f);
  2824. }
  2825.  
  2826. public read_Noob15()
  2827. {
  2828. new profile[128], prodata[256]
  2829. formatex(profile, 127, "%s/Noob_%s.cfg", Topdir, MapName)
  2830.  
  2831. new f = fopen(profile, "rt" )
  2832. new i = 0
  2833. while( !feof(f) && i < 16)
  2834. {
  2835. fgets(f, prodata, 255)
  2836. new totime[25], checks[5], gochecks[5]
  2837. parse(prodata, totime, 24, Noob_AuthIDS[i], 31, Noob_Names[i], 31, checks, 4, gochecks, 4, Noob_Date[i], 31, Noob_Weapon[i], 31)
  2838. Noob_Tiempos[i] = str_to_float(totime)
  2839. Noob_CheckPoints[i] = str_to_num(checks)
  2840. Noob_GoChecks[i] = str_to_num(gochecks)
  2841. i++;
  2842. }
  2843. fclose(f)
  2844. }
  2845.  
  2846. public ProTop_show(id)
  2847. {
  2848. new buffer[2048], len, name[32]
  2849.  
  2850. len = formatex(buffer, 2047, "<body bgcolor=#3399FF><table width=100%% cellpadding=2 cellspacing=0 border=0>")
  2851. len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#0052FF><th width=5%%> # <th width=45%% align=center> Player <th width=30%%> Time <th width=20%%> Date ")
  2852.  
  2853. for (new i = 0; i < 10; i++)
  2854. {
  2855. name = Pro_Names[i]
  2856.  
  2857. if( Pro_Times[i] > 9999999.0 )
  2858. {
  2859. len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> %s <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), "", "", "")
  2860. }
  2861.  
  2862. else
  2863. {
  2864. new minutos, Float:segundos
  2865. minutos = floatround(Pro_Times[i], floatround_floor)/60
  2866. segundos = Pro_Times[i] - (60*minutos)
  2867.  
  2868. len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> <b>%02d:%s%.2f <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), Pro_Names[i], minutos, segundos < 10 ? "0" : "", segundos, Pro_Date[i])
  2869.  
  2870. }
  2871. }
  2872.  
  2873. len += formatex(buffer[len], 2047-len, "</table></body>")
  2874. len += formatex(buffer[len], 2047-len, "<tr><Center><b><BR>Plugin created by siim944")
  2875.  
  2876. show_motd(id, buffer, "Pro10 Climbers")
  2877.  
  2878. return PLUGIN_HANDLED
  2879. }
  2880.  
  2881. public NoobTop_show(id)
  2882. {
  2883. new buffer[2048], name[32], len
  2884.  
  2885. len = formatex(buffer, 2047, "<body bgcolor=#3399FF><table width=100%% cellpadding=2 cellspacing=0 border=0>")
  2886. len += formatex(buffer[len], 2047-len, "<tr align=center bgcolor=#0052FF><th width=5%%> # <th width=35%% align=center> Player <th width=20%%> Time <th width=10%%> CPs <th width=10%%> TPs <th width=10%%> Date")
  2887.  
  2888. for (new i = 0; i < 10; i++)
  2889. {
  2890. if( Noob_Tiempos[i] > 9999999.0 )
  2891. {
  2892. len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s <td> %s <td> %s <td> %s <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), "", "", "", "", "")
  2893. }
  2894.  
  2895. else
  2896. {
  2897. name = Noob_Names[i]
  2898. new minutos, Float:segundos
  2899. minutos = floatround(Noob_Tiempos[i], floatround_floor)/60
  2900. segundos = Noob_Tiempos[i] - (60*minutos)
  2901.  
  2902. len += formatex(buffer[len], 2047-len, "<tr align=center%s><td> %d <td align=center> %s%s <td> <b>%02d:%s%.2f <td> %d <td> %d <td> %s", ((i%2)==0) ? " bgcolor=#5DA5FF" : " bgcolor=#3399FF", (i+1), Noob_Names[i], equal(Noob_Weapon[i],"scout") ? "(scout)" : "", minutos, segundos < 10 ? "0" : "", segundos, Noob_CheckPoints[i], Noob_GoChecks[i], Noob_Date[i], Noob_Weapon[i])
  2903. }
  2904. }
  2905.  
  2906. len += formatex(buffer[len], 2047-len, "</table></body>")
  2907. len += formatex(buffer[len], 2047-len, "<tr><Center><b><BR>Plugin created by siim944")
  2908.  
  2909. show_motd(id, buffer, "Noob10 Climbers")
  2910.  
  2911. return PLUGIN_HANDLED
  2912. }
  2913. #endif
  2914.  
  2915. // You reached the end of file
  2916. // The original plugin was made by p4ddY
  2917. // This plugin was edited by siim944
  2918. // Version 2.31
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement