Advertisement
Guest User

Untitled

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