Advertisement
Guest User

Untitled

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