[Half-Life AMXX] / climb.sma Repository:
ViewVC logotype

Diff of /climb.sma

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 19, Sun Nov 18 00:26:46 2007 UTC revision 23, Sun Nov 18 17:46:23 2007 UTC
# Line 268  Line 268 
268  #include <cstrike>  #include <cstrike>
269  #include <cstrike2>  #include <cstrike2>
270    
271  #define VERSION "a3.7.0 Nov 17 16:17 MST"  new const VERSION[ ] = "a3.7.2 Nov 18 10:31 MST"
272    new const TRKCVAR[ ] = "climb_version"
273    new const DONOTHING[ ] = "donothing"
274    new const NULLSTR[ ] = ""
275    
276  #define IN_ATTACK_EITHER ( IN_ATTACK + IN_ATTACK2 )  #define IN_ATTACK_EITHER ( IN_ATTACK + IN_ATTACK2 )
277    
# Line 308  Line 311 
311  #define TS_CPGC 3 //This one holds a flag, not a timestamp so it can be < 1 second  #define TS_CPGC 3 //This one holds a flag, not a timestamp so it can be < 1 second
312  #define TS_KNIFE 4  #define TS_KNIFE 4
313    
314  #define TIMER_SIZE 16  #define TIMER_SIZE 15
315  new timer[33][TIMER_SIZE]//timer[id][x]:  new timer[33][TIMER_SIZE]//timer[id][x]:
316  #define TMR_CFLAGS 0    //Status  #define TMR_CFLAGS 0    //Status
317  #define TMR_STARTD 1    //Start Time  #define TMR_CNTTME 1    //Time / in deciseconds
318  #define TMR_FINISH 2    //Finish Time  #define TMR_CNTCPS 2    //CP Count
319  #define TMR_CNTCPS 3    //CP Count  #define TMR_CNTGCS 3    //GC Count
320  #define TMR_CNTGCS 4    //GC Count  #define TMR_CNTBST 4    //Boosts
321  #define TMR_CNTBST 5    //Boosts  #define TMR_BSTTME 5    //Best Time / in deciseconds
322  #define TMR_BSTTME 6    //Best Time  #define TMR_BSTCPS 6    //Best CP
323  #define TMR_BSTCPS 7    //Best CP  #define TMR_BSTGCS 7    //Best GC
324  #define TMR_BSTGCS 8    //Best GC  #define TMR_BSTBST 8    //Number of boosts used
325  #define TMR_BSTBST 9    //Number of boosts used  #define TMR_SESFIN 9    //Finished this session
326  #define TMR_SESFIN 10   //Finished this session  #define TMR_MAPFIN 10   //Total times finished this map
327  #define TMR_MAPFIN 11   //Total times finished this map  #define TMR_DBUSER 11   //Database player ID; 0=not registered; -1=not registered & shared steam id
328  #define TMR_DBUSER 12   //Database player ID; 0=not registered; -1=not registered & shared steam id  #define TMR_CPPOS  12   //Current CP offset, for cycling back and forward through cps
329  #define TMR_CPPOS  13   //Current CP offset, for cycling back and forward through cps  #define TMR_CNTWPN 13 //Current weapon rank modifier
330  #define TMR_CNTWPN 14 //Current weapon rank modifier  #define TMR_BSTWPN 14 //Best score weapon rank modifier
 #define TMR_BSTWPN 15 //Best score weapon rank modifier  
331    
332  //Temp save vars  //Temp save vars
333  new savepos = 0, steamid[32][32], Float:originssave[32][ORIGINS_SIZE], timersave[32][TIMER_SIZE]  new savepos = 0, steamid[32][32], Float:originssave[32][ORIGINS_SIZE], timersave[32][TIMER_SIZE]
# Line 389  Line 391 
391  #define CF_COUNTDOWN   (1<<11)  #define CF_COUNTDOWN   (1<<11)
392  #define CF_SUNGLASSES  (1<<12)  #define CF_SUNGLASSES  (1<<12)
393    
394  new WPN_CLASS[30][17] = { "weapon_p228",  #define SILENT 1
                                                                                                         "",  
                                                                                                         "weapon_scout",  
                                                                                                         "", //"weapon_hegrenade",  
                                                                                                         "weapon_xm1014",  
                                                                                                         "", //"weapon_c4",  
                                                                                                         "weapon_mac10",  
                                                                                                         "weapon_aug",  
                                                                                                         "", //"weapon_smokegrenade",  
                                                                                                         "weapon_elite",  
                                                                                                         "weapon_fiveseven",  
                                                                                                         "weapon_ump45",  
                                                                                                         "weapon_sg550",  
                                                                                                         "weapon_galil",  
                                                                                                         "weapon_famas",  
                                                                                                         "weapon_usp",  
                                                                                                         "weapon_glock18",  
                                                                                                         "weapon_awp",  
                                                                                                         "weapon_mp5navy",  
                                                                                                         "weapon_m249",  
                                                                                                         "weapon_m3",  
                                                                                                         "weapon_m4a1",  
                                                                                                         "weapon_tmp",  
                                                                                                         "weapon_g3sg1",  
                                                                                                         "", //"weapon_flashbang",  
                                                                                                         "weapon_deagle",  
                                                                                                         "weapon_sg552",  
                                                                                                         "weapon_ak47",  
                                                                                                         "", //"weapon_knife",  
                                                                                                         "weapon_p90" }  
395    
396  new SVC_STATUSICON, SVC_TEAMINFO, SVC_ROUNDTIME, SVC_FLASHLIGHT, SVC_SCREENFADE  new SVC_STATUSICON, SVC_TEAMINFO, SVC_ROUNDTIME, SVC_FLASHLIGHT, SVC_SCREENFADE
397    
# Line 429  Line 402 
402  ////////////////////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////////////////////
403  public plugin_init( )  public plugin_init( )
404  {  {
         MAXPLAYERS = get_maxplayers( )  
405          register_plugin( "Climb", VERSION, "Ian Cammarata" )          register_plugin( "Climb", VERSION, "Ian Cammarata" )
406          register_cvar( "climb_version", VERSION, FCVAR_SERVER )          register_cvar( TRKCVAR, VERSION, FCVAR_SERVER )
407            set_cvar_string( TRKCVAR, VERSION )
         //This line is for nightly builds only, to keep tracking cvar updated.  
         set_cvar_string( "climb_version", VERSION )  
408    
409          p_climb = register_cvar( "climb", "0", FCVAR_SERVER )          p_climb = register_cvar( "climb", "0", FCVAR_SERVER )
410          p_auto = register_cvar( "climb_auto", "1" )          p_auto = register_cvar( "climb_auto", "1" )
# Line 445  Line 415 
415          register_cvar( "climb_save", "1" )          register_cvar( "climb_save", "1" )
416          register_cvar( "climb_db_type", "sqlite" )          register_cvar( "climb_db_type", "sqlite" )
417          register_cvar( "climb_db_host", "127.0.0.1" )          register_cvar( "climb_db_host", "127.0.0.1" )
418          register_cvar( "climb_db_user", "" )          register_cvar( "climb_db_user", NULLSTR )
419          register_cvar( "climb_db_pass", "", FCVAR_PROTECTED )          register_cvar( "climb_db_pass", NULLSTR, FCVAR_PROTECTED )
420          register_cvar( "climb_db_name", "climb" )          register_cvar( "climb_db_name", "climb" )
421          register_cvar( "climb_db_prefix", "climb_" )          register_cvar( "climb_db_prefix", "climb_" )
422          register_cvar( "climb_db_serverid", "" )          register_cvar( "climb_db_serverid", NULLSTR )
423          register_cvar( "climb_db_exists", "0" )          register_cvar( "climb_db_exists", "0" )
424    
425          p_msg_r = register_cvar( "climb_msg_r", "0" )          p_msg_r = register_cvar( "climb_msg_r", "0" )
# Line 467  Line 437 
437          p_start_respawn = register_cvar( "climb_start_respawn", "0" )          p_start_respawn = register_cvar( "climb_start_respawn", "0" )
438          p_water_nodraw = register_cvar( "climb_water_nodraw", "0" )          p_water_nodraw = register_cvar( "climb_water_nodraw", "0" )
439    
440          p_stats_hsurl = register_cvar( "climb_stats_hsurl", "" ) //Use %s in place of map name          p_stats_hsurl = register_cvar( "climb_stats_hsurl", NULLSTR ) //Use %s in place of map name
441          p_stats_msg = register_cvar( "climb_stats_msg", "" )          p_stats_msg = register_cvar( "climb_stats_msg", NULLSTR )
442    
443          p_allow_spectators = get_cvar_pointer( "allow_spectators" )          p_allow_spectators = get_cvar_pointer( "allow_spectators" )
444          p_teambalance = get_cvar_pointer( "mp_autoteambalance" )          p_teambalance = get_cvar_pointer( "mp_autoteambalance" )
445          p_limitteams = get_cvar_pointer( "mp_limitteams" )          p_limitteams = get_cvar_pointer( "mp_limitteams" )
446    
447            MAXPLAYERS = get_maxplayers( )
448    
449          TEAM_BALANCE_OLD = get_pcvar_num( p_teambalance )          TEAM_BALANCE_OLD = get_pcvar_num( p_teambalance )
450          LIMIT_TEAMS_OLD = get_pcvar_num( p_limitteams )          LIMIT_TEAMS_OLD = get_pcvar_num( p_limitteams )
451    
# Line 505  Line 477 
477          //Commands referencing function 'donothing' are picked up by the more flexible code in the client_command forward.          //Commands referencing function 'donothing' are picked up by the more flexible code in the client_command forward.
478          register_clcmd( "say help", "help_msg" )          register_clcmd( "say help", "help_msg" )
479          register_clcmd( "say /help", "help_msg" )          register_clcmd( "say /help", "help_msg" )
480          register_clcmd( "climbhelp", "donothing", 0, "- Veiw climb help." )          register_clcmd( "climbhelp", DONOTHING, 0, "- Veiw climb help." )
481          register_clcmd( "cp", "donothing", _, "- Make a checkpoint" )          register_clcmd( "cp", DONOTHING, _, "- Make a checkpoint" )
482          register_clcmd( "gc", "donothing", _, "- Teleport to last checkpoint" )          register_clcmd( "gc", DONOTHING, _, "- Teleport to last checkpoint" )
483          register_clcmd( "stuck", "donothing", _, "- Teleport to previous checkpoint" )          register_clcmd( "stuck", DONOTHING, _, "- Teleport to previous checkpoint" )
484          register_clcmd( "restart","donothing", _, "- Stop and respawn." )          register_clcmd( "restart", DONOTHING, _, "- Stop and respawn." )
485          register_clcmd( "stop", "donothing", _, "- End current climbing run." )          register_clcmd( "stop", DONOTHING, _, "- End current climbing run." )
486          register_clcmd( "pause", "donothing", _, "- Pause yourself." )          register_clcmd( "pause", DONOTHING, _, "- Pause yourself." )
487          register_clcmd( "scoreboard", "donothing", _, "- View score board." )          register_clcmd( "scoreboard", DONOTHING, _, "- View score board." )
488          register_clcmd( "respawn", "donothing", _, "- Force respawn" )          register_clcmd( "respawn", DONOTHING, _, "- Force respawn" )
489          register_clcmd( "boost", "donothing", _, "- Boost." )          register_clcmd( "boost", DONOTHING, _, "- Boost." )
490          register_clcmd( "spec", "donothing", _, "- Spectate mode." )          register_clcmd( "spec", DONOTHING, _, "- Spectate mode." )
491          register_clcmd( "ungc", "donothing", _, "- Undo last gocheck." )          register_clcmd( "ungc", DONOTHING, _, "- Undo last gocheck." )
492    
493          //Commands related to stats account system.          //Commands related to stats account system.
494          //register_clcmd( "register", "reg", _, "- (Console Only) Register for stats tracking." )          //register_clcmd( "register", "reg", _, "- (Console Only) Register for stats tracking." )
# Line 540  Line 512 
512          //Events          //Events
513          register_event("DeathMsg","DeathMsg","a")          register_event("DeathMsg","DeathMsg","a")
514          register_event("ResetHUD","ResetHUD","b")          register_event("ResetHUD","ResetHUD","b")
515          register_event("Health","damage","b")          register_event("Health","Health","b")
516          register_event("ShowMenu","menuclass","b","4&CT_Select","4&Terrorist_Select")          register_event("ShowMenu","menuclass","b","4&CT_Select","4&Terrorist_Select")
517          register_event("ShowMenu","menuteam","b","4&Team_Select_Spect","4&Team_Select","4&IG_Team_Select")          register_event("ShowMenu","menuteam","b","4&Team_Select_Spect","4&Team_Select","4&IG_Team_Select")
518    
# Line 554  Line 526 
526          set_task( 0.5, "hudtime", _, _, _, "b" ) //Task to update time on clients HUD; Task set for half second to minimize flickering of the timer.          set_task( 0.5, "hudtime", _, _, _, "b" ) //Task to update time on clients HUD; Task set for half second to minimize flickering of the timer.
527          set_task( 1.0, "spec_update", _, _, _, "b" ) //Task to update spectator array          set_task( 1.0, "spec_update", _, _, _, "b" ) //Task to update spectator array
528          set_task( 5.0, "run_tasks", _, _, _, "b" )          set_task( 5.0, "run_tasks", _, _, _, "b" )
529            set_task( 0.1, "timer_tick", _, _, _, "b" )
530    
531          register_message( get_user_msgid( "CurWeapon" ), "CurWeapon" )          register_message( get_user_msgid( "CurWeapon" ), "CurWeapon" )
         register_message( get_user_msgid( "ReqState" ), "bot_msg_block" )  
         register_message( get_user_msgid( "Radar" ), "bot_msg_block" )  
532    
533          register_forward( FM_UpdateClientData, "PostUpdateClientData", 1 )          register_forward( FM_UpdateClientData, "PostUpdateClientData", 1 )
534    
# Line 958  Line 929 
929    
930                  //erase previous save if exists                  //erase previous save if exists
931                  for( new i=0; i<32; i++ )                  for( new i=0; i<32; i++ )
932                          if( equal( saveid, steamid[i] ) ) steamid[i] = ""                          if( equal( saveid, steamid[i] ) ) steamid[i] = NULLSTR
933    
934                  if( timer[id][TMR_CFLAGS] & CF_START ) change_status( id, CF_PAUSE ) //Pause if running                  if( timer[id][TMR_CFLAGS] & CF_START ) change_status( id, CF_PAUSE ) //Pause if running
935                  steamid[savepos] = saveid //save steamid to position reference                  steamid[savepos] = saveid //save steamid to position reference
# Line 1175  Line 1146 
1146                  if( cflags_old & CF_PAUSE ) //unpause                  if( cflags_old & CF_PAUSE ) //unpause
1147                  {                  {
1148                          cflags_new += CF_START                          cflags_new += CF_START
                         timer[id][TMR_STARTD] = get_systime() - timer[id][TMR_STARTD]  
1149                          set_entity_flags( id, FL_FROZEN, 0 )                          set_entity_flags( id, FL_FROZEN, 0 )
1150                          unsolid( id )                          unsolid( id )
1151                          entity_set_float( id, EV_FL_gravity, origins[id][ORIG_PAUS + ORIG_GRAV] )                          entity_set_float( id, EV_FL_gravity, origins[id][ORIG_PAUS + ORIG_GRAV] )
# Line 1184  Line 1154 
1154                  }                  }
1155                  else if( cflags_old & CF_START ) //pause                  else if( cflags_old & CF_START ) //pause
1156                  {                  {
                         timer[id][TMR_STARTD] = get_systime() - timer[id][TMR_STARTD]  
1157                          cl_pause( id )                          cl_pause( id )
1158                          cflags_new += CF_PAUSE                          cflags_new += CF_PAUSE
1159                  }                  }
# Line 1211  Line 1180 
1180          return PLUGIN_HANDLED          return PLUGIN_HANDLED
1181  }  }
1182    
1183    public timer_tick( )
1184    {
1185            new players[32], num, id
1186            get_players( players, num, "ach" )
1187    
1188            for( new i = 0; i < num; i++ )
1189            {
1190                    id = players[i]
1191                    if( timer[id][TMR_CFLAGS] & CF_START )
1192                            timer[id][TMR_CNTTME]++
1193            }
1194    }
1195    
1196  public stop( id )  public stop( id )
1197  {  {
1198          if( get_pcvar_num( p_climb ) && timer[id][TMR_CFLAGS] & CF_START )          if( get_pcvar_num( p_climb ) && timer[id][TMR_CFLAGS] & CF_START )
# Line 1218  Line 1200 
1200                  change_status( id, CF_STOP )                  change_status( id, CF_STOP )
1201                  heal(id)                  heal(id)
1202                  //Erase start/finish time stamps, prevents crazy number on scoreboard                  //Erase start/finish time stamps, prevents crazy number on scoreboard
1203                  timer[id][TMR_STARTD]=0                  timer[id][TMR_CNTTME] = 0
                 timer[id][TMR_FINISH]=0  
1204    
1205                  sfexec(id,4)    //Execute commands from start/finish config                  sfexec(id,4)    //Execute commands from start/finish config
1206          }          }
# Line 1259  Line 1240 
1240    
1241          client_oldwpn[id] = wpn          client_oldwpn[id] = wpn
1242    
1243            if( wpn == CSW_C4 ||
1244                            wpn == CSW_HEGRENADE ||
1245                            wpn == CSW_FLASHBANG ||
1246                            wpn == CSW_SMOKEGRENADE ||
1247                            wpn == CSW_KNIFE
1248            ) return PLUGIN_CONTINUE
1249    
1250          //If it's a gun, update pack and clip ammo & silencer          //If it's a gun, update pack and clip ammo & silencer
1251          if( strlen( WPN_CLASS[wpn-1] ) )          new wpn_id = get_user_weapon( id )
         {  
                 new wpn_id = find_ent_by_owner( -1, WPN_CLASS[wpn-1], id )  
1252                  if( !wpn_id ) return PLUGIN_CONTINUE                  if( !wpn_id ) return PLUGIN_CONTINUE
1253    
1254                  new clip = get_msg_arg_int( 3 )                  new clip = get_msg_arg_int( 3 )
# Line 1291  Line 1277 
1277                          set_msg_arg_int( 3, ARG_BYTE, maxammo )                          set_msg_arg_int( 3, ARG_BYTE, maxammo )
1278                          cs_set_weapon_ammo( wpn_id, maxammo )                          cs_set_weapon_ammo( wpn_id, maxammo )
1279                  }                  }
         }  
1280    
1281          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
1282  }  }
# Line 1352  Line 1337 
1337          formatex( ret_name, len, name )          formatex( ret_name, len, name )
1338  }  }
1339    
 public bot_msg_block(msg_id,msg_dest,id)  
 {  
         if(get_pcvar_num(p_climb)&&is_user_bot(id))return PLUGIN_HANDLED  
         return PLUGIN_CONTINUE  
 }  
   
1340  public DeathMsg( )  public DeathMsg( )
1341  {//Respawn client when they die unless switching to spec  {//Respawn client when they die unless switching to spec
1342          if( get_pcvar_num( p_climb ) )          if( get_pcvar_num( p_climb ) )
# Line 1580  Line 1559 
1559          return dif          return dif
1560  }  }
1561    
1562  public change_boost( id, newboost )  stock change_boost( id, newboost, silent = 0 )
1563  {//Change Boost flags  {//Change Boost flags
1564          if( !( cvar_enabled( id, p_boost ) && isalive( id ) ) && notpaused( id ) ) return PLUGIN_HANDLED          if( !( cvar_enabled( id, p_boost, silent ) && isalive( id ) ) && notpaused( id ) ) return PLUGIN_HANDLED
1565    
1566          new msg[151], rmflag, cflags = timer[ id - 1 ][ TMR_CFLAGS ]          new msg[151], rmflag, cflags = timer[ id - 1 ][ TMR_CFLAGS ]
1567          if( cflags & CF_SOLID )          if( cflags & CF_SOLID )
# Line 1603  Line 1582 
1582          }          }
1583          if( rmflag > 0 ) timer[ id - 1 ][ TMR_CFLAGS ] -= rmflag          if( rmflag > 0 ) timer[ id - 1 ][ TMR_CFLAGS ] -= rmflag
1584          if( !( rmflag & newboost ) && \          if( !( rmflag & newboost ) && \
1585                  !check_timeout( id, time_stamps[id][TS_BOOST], BOOST_TIMEOUT, ( cflags & CF_START ? get_climber_time( id ) : get_systime() ) ) )                  !check_timeout( id, time_stamps[id][TS_BOOST], BOOST_TIMEOUT, ( cflags & CF_START ? timer[id][TMR_CNTTME] / 10 : get_systime() ) ) )
1586          {          {
1587                  if( newboost == CF_SOLID )                  if( newboost == CF_SOLID )
1588                  {                  {
# Line 1889  Line 1868 
1868                  for( new i = 0; i < 48; i++ ) origins[id][i] = 0.0 //Erase checkpoints                  for( new i = 0; i < 48; i++ ) origins[id][i] = 0.0 //Erase checkpoints
1869    
1870                  //Set all associated variables                  //Set all associated variables
1871                  timer[id][TMR_STARTD] = get_systime()                  timer[id][TMR_CNTTME] = 0
                 change_status(id,CF_START)  
1872                  timer[id][TMR_CNTCPS] = 0                  timer[id][TMR_CNTCPS] = 0
1873                  timer[id][TMR_CNTGCS] = 0                  timer[id][TMR_CNTGCS] = 0
1874                  timer[id][TMR_CNTBST] = 0                  timer[id][TMR_CNTBST] = 0
1875                  timer[id][TMR_CPPOS] = 0                  timer[id][TMR_CPPOS] = 0
1876                  timer[id][TMR_CNTWPN] = 0                  timer[id][TMR_CNTWPN] = 0
1877                  time_stamps[id][TS_BOOST] = BOOST_TIMEOUT                  time_stamps[id][TS_BOOST] = BOOST_TIMEOUT
1878                    change_status(id,CF_START)
1879    
1880                  if( timer[id][TMR_CFLAGS] & CF_COUNTDOWN ) set_countdown_time( id )                  if( timer[id][TMR_CFLAGS] & CF_COUNTDOWN ) set_countdown_time( id )
1881    
# Line 1925  Line 1904 
1904                          case 2:client_cmd( id, "spk barney/c1a2_ba_climb" )                          case 2:client_cmd( id, "spk barney/c1a2_ba_climb" )
1905                  }                  }
1906    
1907                  change_boost( id, CF_NULL ) //Disable Boosts                  change_boost( id, CF_NULL, SILENT ) //Disable Boosts
1908                  //time_stamps[id][TS_BOOST]=0                  //time_stamps[id][TS_BOOST]=0
1909                  clmsg(id,"Timer started. Go Go Go!!!")                  clmsg(id,"Timer started. Go Go Go!!!")
1910                  //client_print(id,print_chat,"Timer started. Go Go Go!!!")                  //client_print(id,print_chat,"Timer started. Go Go Go!!!")
# Line 1938  Line 1917 
1917          {          {
1918                  if( timer[id][TMR_CFLAGS] & CF_START)                  if( timer[id][TMR_CFLAGS] & CF_START)
1919                  {                  {
1920                            new cnttme = timer[id][TMR_CNTTME] / 10
1921                            new cntbst = timer[id][TMR_CNTBST]
1922                            new cntcps = timer[id][TMR_CNTCPS]
1923                            new cntgcs = timer[id][TMR_CNTGCS]
1924                            new cntwpn = timer[id][TMR_CNTWPN]
1925    
1926                          //Set client variables                          //Set client variables
                         timer[id][TMR_FINISH] = get_systime( )  
1927                          change_status( id, CF_STOP )                          change_status( id, CF_STOP )
1928                          timer[id][TMR_SESFIN]++                          timer[id][TMR_SESFIN]++
1929                          timer[id][TMR_MAPFIN]++                          timer[id][TMR_MAPFIN]++
# Line 1948  Line 1932 
1932                          if( get_pcvar_num( p_sounds ) ) client_cmd( 0, "spk woop" )                          if( get_pcvar_num( p_sounds ) ) client_cmd( 0, "spk woop" )
1933                          clmsg( id, "Congratulations 1337 climber." )                          clmsg( id, "Congratulations 1337 climber." )
1934                          //client_print(id,print_chat,"Congratulations 1337 climber.")                          //client_print(id,print_chat,"Congratulations 1337 climber.")
1935                          new name[32], msg[21]                          new name[32], msg[23]
1936                          formatex( msg, sizeof( msg ) - 1, "%s^t%s", getuserstatus( id ), parsetime( get_climber_time( id ) ) )                          formatex( msg, 22, "%s^t%s", getuserstatus( id ), parsetime( timer[id][TMR_CNTTME] ) )
1937                          //clmsg(id,msg)                          //clmsg(id,msg)
1938                          //client_print(id,print_chat,msg)                          //client_print(id,print_chat,msg)
1939    
1940                          new wpn[11]                          new wpn[11]
1941                          get_weapon_name( timer[id][TMR_CNTWPN], wpn, 10 )                          get_weapon_name( cntwpn, wpn, 10 )
1942    
1943                          //Announce to all                          //Announce to all
1944                          get_user_name( id, name, 32 )                          get_user_name( id, name, 32 )
1945                          client_print( 0, print_chat, "%s^t%s^t(%s/ %d CPS/ %d GCS/ %d Boosts)^tCompleted (%d, %d)",                          client_print( 0, print_chat,
1946                                  name, msg,                                  "%s^t%s^t(%s/ %d CPS/ %d GCS/ %d Boosts)^tCompleted (%d, %d)",
1947                                  wpn, timer[id][TMR_CNTCPS], timer[id][TMR_CNTGCS], timer[id][TMR_CNTBST],                                  name, msg, wpn, cntcps, cntgcs, cntbst,
1948                                  timer[id][TMR_SESFIN], timer[id][TMR_MAPFIN] )                                  timer[id][TMR_SESFIN], timer[id][TMR_MAPFIN]
1949                            )
1950    
1951                            new cntscore = ( ( ( cntbst > 0 ? 1 : 0 ) * 1000000 ) +
1952                                    ( ( cntcps > 0 ? 1 : 0 ) * 100000 ) +
1953                                    ( cntwpn * 10000 ) +
1954                                    cnttme )
1955    
1956                          new cnt_score = ( ( ( timer[id][TMR_CNTBST] > 0 ? 1 : 0 ) * 1000000 ) +                          new bstscore = ( ( ( timer[id][TMR_BSTBST] > 0 ? 1 : 0 ) * 1000000 ) +
                                 ( ( timer[id][TMR_CNTCPS] > 0 ? 1 : 0 ) * 100000 ) +  
                                 ( timer[id][TMR_CNTWPN] * 10000 ) +  
                                 get_climber_time( id ) )  
   
                         new bst_score = ( ( ( timer[id][TMR_BSTBST] > 0 ? 1 : 0 ) * 1000000 ) +  
1957                                  ( ( timer[id][TMR_BSTCPS] > 0 ? 1 : 0 ) * 100000 ) +                                  ( ( timer[id][TMR_BSTCPS] > 0 ? 1 : 0 ) * 100000 ) +
1958                                  ( timer[id][TMR_BSTWPN] * 10000 ) +                                  ( timer[id][TMR_BSTWPN] * 10000 ) +
1959                                  timer[id][TMR_BSTTME] )                                  timer[id][TMR_BSTTME] / 10 )
1960    
1961                          if( cnt_score < bst_score || bst_score == 0 )                          if( cntscore < bstscore || bstscore == 0 )
1962                          {                          {
1963                                  timer[id][TMR_BSTTME] = get_climber_time( id )                                  timer[id][TMR_BSTTME] = cnttme
1964                                  timer[id][TMR_BSTCPS] = timer[id][TMR_CNTCPS]                                  timer[id][TMR_BSTCPS] = cntcps
1965                                  timer[id][TMR_BSTGCS] = timer[id][TMR_CNTGCS]                                  timer[id][TMR_BSTGCS] = cntgcs
1966                                  timer[id][TMR_BSTBST] = timer[id][TMR_CNTBST]                                  timer[id][TMR_BSTBST] = cntbst
1967                                  timer[id][TMR_BSTWPN] = timer[id][TMR_CNTWPN]                                  timer[id][TMR_BSTWPN] = cntwpn
1968                          }                          }
1969    
1970                          sfexec( id, 2 )//Execute commands from start/finish config                          sfexec( id, 2 )//Execute commands from start/finish config
# Line 2082  Line 2067 
2067                          pdata[i][1] = ( ( ( timer[id][TMR_BSTBST] > 0 ? 1 : 0 ) * 1000000 ) +                          pdata[i][1] = ( ( ( timer[id][TMR_BSTBST] > 0 ? 1 : 0 ) * 1000000 ) +
2068                                  ( ( timer[id][TMR_BSTCPS] > 0 ? 1 : 0 ) * 100000 ) +                                  ( ( timer[id][TMR_BSTCPS] > 0 ? 1 : 0 ) * 100000 ) +
2069                                  ( timer[id][TMR_BSTWPN] * 10000 ) +                                  ( timer[id][TMR_BSTWPN] * 10000 ) +
2070                                  timer[id][TMR_BSTTME] )                                  timer[id][TMR_BSTTME] / 10 )
2071                  }                  }
2072                  else if( timer[id][TMR_CFLAGS] & CF_START || timer[id][TMR_CFLAGS] & CF_PAUSE )                  else if( timer[id][TMR_CFLAGS] & CF_START || timer[id][TMR_CFLAGS] & CF_PAUSE )
2073                  {//Has time but no high score                  {//Has time but no high score
# Line 2090  Line 2075 
2075                          pdata[i][1] = ( ( ( timer[id][TMR_CNTBST] > 0 ? 1 : 0 ) * 1000000 ) +                          pdata[i][1] = ( ( ( timer[id][TMR_CNTBST] > 0 ? 1 : 0 ) * 1000000 ) +
2076                                  ( ( timer[id][TMR_CNTCPS] > 0 ? 1 : 0 ) * 100000 ) +                                  ( ( timer[id][TMR_CNTCPS] > 0 ? 1 : 0 ) * 100000 ) +
2077                                  ( timer[id][TMR_CNTWPN] * 10000 ) +                                  ( timer[id][TMR_CNTWPN] * 10000 ) +
2078                                  get_climber_time( id ) )                                  timer[id][TMR_CNTTME] / 10 )
2079                  }                  }
2080                  else pdata[i][0] = 2 //No time or high score                  else pdata[i][0] = 2 //No time or high score
2081          }          }
# Line 2136  Line 2121 
2121    
2122  public climbscores( id )  public climbscores( id )
2123  {//Show scoreboard  {//Show scoreboard
2124          if( get_pcvar_num( p_climb ) )          if( !get_pcvar_num( p_climb ) ) return PLUGIN_HANDLED
2125          {  
2126                  if( get_systime() - ts_score > 2 )                  if( get_systime() - ts_score > 2 )
2127                  {                  {
2128                          new fh = fopen( SCORES_PATH, "w" )                          new fh = fopen( SCORES_PATH, "w" )
# Line 2161  Line 2146 
2146                                  get_user_name( tid, name, NAMELEN)                                  get_user_name( tid, name, NAMELEN)
2147                                  sb_add_tabs( name, NAMELEN+2 )                                  sb_add_tabs( name, NAMELEN+2 )
2148    
2149                                  ctime = get_climber_time(tid)                          ctime = timer[tid][TMR_CNTTME]
2150                                  cwpn = timer[tid][TMR_CNTWPN]                                  cwpn = timer[tid][TMR_CNTWPN]
2151                                  ccp = timer[tid][TMR_CNTCPS]                                  ccp = timer[tid][TMR_CNTCPS]
2152                                  cgc = timer[tid][TMR_CNTGCS]                                  cgc = timer[tid][TMR_CNTGCS]
# Line 2179  Line 2164 
2164    
2165                                  formatex( line, 250,                                  formatex( line, 250,
2166                                          "%s%d   %s%s    %s      %s%s    %s%d%s",                                          "%s%d   %s%s    %s      %s%s    %s%d%s",
2167                                          i % 2 ? "" : "<div>",                                  i % 2 ? NULLSTR : "<div>",
2168                                          i, htmlspecialchars( name ),                                          i, htmlspecialchars( name ),
2169                                          getuserstatus( tid ),                                          getuserstatus( tid ),
2170                                          parsetime( ctime ), ctime_str,                                          parsetime( ctime ), ctime_str,
2171                                          parsetime( btime ), btime_str,                                          parsetime( btime ), btime_str,
2172                                          timer[tid][TMR_MAPFIN],                                          timer[tid][TMR_MAPFIN],
2173                                          i % 2 ? "" : "</div>" )                                  i % 2 ? NULLSTR : "</div>" )
2174                                  written_len += strlen( line )                                  written_len += strlen( line )
2175                                  //if( limit && written_len > ( 1263 - strlen( cust_msg ) ) ) break                                  //if( limit && written_len > ( 1263 - strlen( cust_msg ) ) ) break
2176                                  if( written_len > 1263 ) break                                  if( written_len > 1263 ) break
# Line 2202  Line 2187 
2187                  }                  }
2188    
2189                  show_motd( id, SCORES_PATH, "Current Scores" )                  show_motd( id, SCORES_PATH, "Current Scores" )
2190          }  
2191          return PLUGIN_HANDLED          return PLUGIN_HANDLED
2192  }  }
2193    
2194  public parsetime(sec){//Convert seconds to time string with zero padded seconds field  //Convert seconds to time string with zero padded seconds field
2195          new timestr[9],mins  public parsetime( decisec )
2196    {
2197            new timestr[11], mins, sec, dec, decstr[3]
2198    
2199            sec = decisec / 10
2200            dec = decisec % 10
2201          mins=sec/60          mins=sec/60
2202          sec=sec%60          sec=sec%60
2203          formatex(timestr,8,"%d:%s%d",mins,sec<10?"0":"",sec)          if( dec ) formatex( decstr, 2, ".%d", dec )
2204            formatex( timestr, 10, "%d:%s%d%s", mins, sec < 10 ? "0" : NULLSTR , sec, decstr )
2205          return timestr          return timestr
2206  }  }
2207    
 public get_climber_time( id )  
 {//Calculate client climb time in seconds  
         /*new ptime,cflags=timer[id][TMR_CFLAGS]  
         ptime=timer[id][TMR_FINISH]-timer[id][TMR_STARTD]  
         if(cflags&CF_STOP&&timer[id=1][TMR_SESFIN]>0)ptime=timer[id][TMR_FINISH]-timer[id][TMR_STARTD]  
         else if(cflags&CF_STOP)ptime=0  
         else if(cflags&CF_START)ptime=get_systime()-timer[id][TMR_STARTD]  
         else if(cflags&CF_PAUSE)ptime=timer[id][TMR_STARTD]*/  
         new cflags = timer[id][TMR_CFLAGS]  
         if( cflags & CF_START ) return get_systime()-timer[id][TMR_STARTD]  
         else if( cflags & CF_PAUSE ) return timer[id][TMR_STARTD]  
         return timer[id][TMR_FINISH]-timer[id][TMR_STARTD]  
 }  
   
2208  public hudtime( )  public hudtime( )
2209  {//Set clock on HUD to current climb time  {//Set clock on HUD to current climb time
2210          if( !get_pcvar_num( p_climb ) ) return          if( !get_pcvar_num( p_climb ) ) return
# Line 2238  Line 2215 
2215          {          {
2216                  id = players[i]                  id = players[i]
2217                  cflags = timer[id][TMR_CFLAGS]                  cflags = timer[id][TMR_CFLAGS]
2218                  cltime = get_climber_time(id) + 1                  cltime = timer[id][TMR_CNTTME] / 10 + 1
2219                  if( cflags & CF_PAUSE )                  if( cflags & CF_PAUSE )
2220                  {                  {
2221                          clmsg( id, "PAUSED - say '/unpause' to resume." )                          clmsg( id, "PAUSED - say '/unpause' to resume." )
2222                          cl_pause( id )                          cl_pause( id )
2223                  }                  }
2224    
2225                  if( !( cflags & CF_COUNTDOWN ) || ( timer[id][TMR_BSTTME] - get_climber_time( id ) < 0 ) )                  if( !( cflags & CF_COUNTDOWN ) || ( timer[id][TMR_BSTTME] >= timer[id][TMR_CNTTME] ) )
2226                          hudtime_msg( id, cltime )                          hudtime_msg( id, cltime )
2227                  else if( cflags & CF_PAUSE )                  else if( cflags & CF_PAUSE )
2228                          hudtime_msg( id, timer[id][TMR_BSTTME] - cltime + 1 )                          hudtime_msg( id, timer[id][TMR_BSTTME] / 10 - cltime + 1 )
2229    
2230                  for( new j = 1; j <= spec_ids[id][0]; j++ )                  for( new j = 1; j <= spec_ids[id][0]; j++ )
2231                          hudtime_msg( spec_ids[id][j], cltime )                          hudtime_msg( spec_ids[id][j], cltime )
# Line 2270  Line 2247 
2247    
2248  public bool:set_countdown_time( id )  public bool:set_countdown_time( id )
2249  {  {
2250          new bsttime = timer[id][TMR_BSTTME]          new bsttme = timer[id][TMR_BSTTME] / 10
2251          if( bsttime > 0 )          if( bsttme > 0 )
2252          {          {
2253                  new cflags = timer[id][TMR_CFLAGS]                  new cflags = timer[id][TMR_CFLAGS]
2254                  if( cflags & CF_START || cflags & CF_PAUSE )                  if( cflags & CF_START || cflags & CF_PAUSE )
2255                          hudtime_msg( id, timer[id][TMR_BSTTME] - get_climber_time( id ) )                          hudtime_msg( id, bsttme - timer[id][TMR_CNTTME] / 10 )
2256                  return true                  return true
2257          }          }
2258          clmsg( id, "Countdown disabled: No high score available." )          clmsg( id, "Countdown disabled: No high score available." )
# Line 2405  Line 2382 
2382  ////////////////////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////////////////////
2383  //      Start: Auto Heal functions  //      Start: Auto Heal functions
2384  ////////////////////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////////////////////
2385  public damage(id){//Called when client takes damage  public Health( id )
2386    {//Called when client takes damage
2387          new ida[1]          new ida[1]
2388          ida[0]=id          ida[0]=id
2389          set_task(0.1,"damage_handle",_,ida,1)          set_task(0.1,"damage_handle",_,ida,1)
# Line 2679  Line 2657 
2657          set_entity_flags(ida[0],FL_DUCKING,1)          set_entity_flags(ida[0],FL_DUCKING,1)
2658  }  }
2659    
2660  public cvar_enabled(id,p_cvar){//Used in IF statements to automatically print error if false  //Used in IF statements to automatically print error if false
2661          if(get_pcvar_num(p_cvar)==0){  stock cvar_enabled( id, p_cvar, silent = 0 )
2662    {
2663            if( get_pcvar_num(p_cvar) == 0 )
2664            {
2665                    if( !silent )
2666                    {
2667                  clmsg(id,"This command is disabled.")                  clmsg(id,"This command is disabled.")
2668                  client_print(id,print_chat,"This command has been disabled by the server administrator.")                  client_print(id,print_chat,"This command has been disabled by the server administrator.")
2669                    }
2670                  return 0                  return 0
2671          }          }
2672          return 1          return 1
# Line 3303  Line 3287 
3287                                          server_ip char(15),\                                          server_ip char(15),\
3288                                          user_id integer,\                                          user_id integer,\
3289                                          map_name varchar(32),\                                          map_name varchar(32),\
3290                                          fin_time integer,\                                          fin_time float,\
3291                                          cps integer,\                                          cps integer,\
3292                                          gcs integer,\                                          gcs integer,\
3293                                          boosts integer,\                                          boosts integer,\
# Line 3487  Line 3471 
3471                          msg="^x04No stats available for this account on the current map."                          msg="^x04No stats available for this account on the current map."
3472                  else                  else
3473                  {                  {
3474                          new mapname[33],timestr[9]                          new mapname[33]
3475                          get_mapname(mapname,32)                          get_mapname(mapname,32)
3476                          timer[id][TMR_BSTTME] = SQL_ReadResult( query, 0 )                          SQL_ReadResult( query, 0, timer[id][TMR_BSTTME] )
3477                            timer[id][TMR_BSTTME] *= 10
3478                          timer[id][TMR_BSTCPS] = SQL_ReadResult( query, 1 )                          timer[id][TMR_BSTCPS] = SQL_ReadResult( query, 1 )
3479                          timer[id][TMR_BSTGCS] = SQL_ReadResult( query, 2 )                          timer[id][TMR_BSTGCS] = SQL_ReadResult( query, 2 )
3480                          timer[id][TMR_MAPFIN] = SQL_ReadResult( query, 3 )                          timer[id][TMR_MAPFIN] = SQL_ReadResult( query, 3 )
# Line 3497  Line 3482 
3482                          timer[id][TMR_BSTWPN] = SQL_ReadResult( query, 5 )                          timer[id][TMR_BSTWPN] = SQL_ReadResult( query, 5 )
3483                          //timer[id][TMR_CFLAGS]+=SQL_ReadResult(query,5)?CF_BSTSCT:0                          //timer[id][TMR_CFLAGS]+=SQL_ReadResult(query,5)?CF_BSTSCT:0
3484    
                         timestr = parsetime(timer[id][TMR_BSTTME])  
3485                          formatex( msg, 99,                          formatex( msg, 99,
3486                                  "^x04Stats loaded for %s - %s^t(%d/ %d CP/%d GC/%d Boost)^tCompleted %d",                                  "^x04Stats loaded for %s - %s^t(%d/ %d CP/%d GC/%d Boost)^tCompleted %d",
3487                                  mapname, timestr, timer[id][TMR_BSTWPN], timer[id][TMR_BSTCPS],                                  mapname, parsetime( timer[id][TMR_BSTTME] ), timer[id][TMR_BSTWPN], timer[id][TMR_BSTCPS],
3488                                  timer[id][TMR_BSTGCS], timer[id][TMR_BSTBST], timer[id][TMR_MAPFIN] )                                  timer[id][TMR_BSTGCS], timer[id][TMR_BSTBST], timer[id][TMR_MAPFIN] )
3489                  }                  }
3490                  saytext( id, id, msg )                  saytext( id, id, msg )
# Line 3511  Line 3495 
3495    
3496  public db_save( id )  public db_save( id )
3497  {  {
3498          if( timer[id][TMR_DBUSER] < 1 )          new user_id = timer[id][TMR_DBUSER]
3499    
3500            if( user_id < 1 )
3501          {          {
3502                  auto_reg( id )                  auto_reg( id )
3503                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
3504          }          }
3505    
3506          new query[351], name[33], data[2]          new query[351], name[33], data[2]
3507          data[0] = id          data[0] = id
3508          get_mapname( name, 32 )          get_mapname( name, 32 )
3509          strtolower( name )          strtolower( name )
3510    
3511          new user_id = timer[id][TMR_DBUSER]          new cntbst = timer[id][TMR_CNTBST]
3512          new fin_time = get_climber_time( id )          new cntcps = timer[id][TMR_CNTCPS]
3513            new cntwpn = timer[id][TMR_CNTWPN]
3514          new wpn_rank = timer[id][TMR_CNTWPN]  
3515            new score = ( ( ( cntbst > 0 ? 1 : 0 ) * 1000000 ) +
3516          new score = ( ( ( timer[id][TMR_CNTBST] > 0 ? 1 : 0 ) * 1000000 ) +                  ( ( cntcps > 0 ? 1 : 0 ) * 100000 ) +
3517                  ( ( timer[id][TMR_CNTCPS] > 0 ? 1 : 0 ) * 100000 ) +                  ( cntwpn * 10000 ) +
3518                  ( wpn_rank * 10000 ) +                  timer[id][TMR_CNTTME] / 10 )
                 fin_time )  
3519    
         /*if( timer[id][TMR_MAPFIN] == 1 )  
3520                  formatex( query, 350,                  formatex( query, 350,
3521                          "insert into %sscores (user_id, map_name, fin_time, cps, gcs, fin_cnt, boosts, wpns, score, server_time_stamp) values (%d, ^"%s^", %d, %d, %d, %d, %d, %d, %d, %d);",\                  "insert into %sscores (server_ip, user_id, map_name, fin_time, cps, gcs, boosts, wpns, score, server_time_stamp) values (^"%s^", %d, ^"%s^", %f, %d, %d, %d, %d, %d, %d)",\
3522                          DB_PREFIX, user_id, name, fin_time, timer[id][TMR_BSTCPS], timer[id][TMR_BSTGCS], timer[id][TMR_MAPFIN], timer[id][TMR_BSTBST], sctd, sort, get_systime() )                  DB_PREFIX, DB_SERVER_ID, user_id, name, timer[id][TMR_CNTTME] * 0.1, cntcps, timer[id][TMR_CNTGCS], cntbst, cntwpn, score, get_systime() )
         else*/  
         formatex( query, 350,  
                 "insert into %sscores (server_ip, user_id, map_name, fin_time, cps, gcs, boosts, wpns, score, server_time_stamp) values (^"%s^", %d, ^"%s^", %d, %d, %d, %d, %d, %d, %d)",\  
                 DB_PREFIX, DB_SERVER_ID, user_id, name, fin_time, timer[id][TMR_CNTCPS], timer[id][TMR_CNTGCS], timer[id][TMR_CNTBST], wpn_rank, score, get_systime() )  
3523          SQL_ThreadQuery(DB_TUPLE,"db_save_handler",query,data,2)          SQL_ThreadQuery(DB_TUPLE,"db_save_handler",query,data,2)
3524    
3525          data[1] = 0          data[1] = 0
3526          get_user_name( id, name, 32 )          get_user_name( id, name, 32 )
3527          formatex( query, 350, "update %splayers set alias=^"%s^" where user_id=%d;", DB_PREFIX, name, timer[id][TMR_DBUSER] )          formatex( query, 350, "update %splayers set alias=^"%s^" where user_id=%d;", DB_PREFIX, name, user_id )
3528          SQL_ThreadQuery( DB_TUPLE, "db_name_update_handler", query, data, 2 )          SQL_ThreadQuery( DB_TUPLE, "db_name_update_handler", query, data, 2 )
3529          return PLUGIN_HANDLED          return PLUGIN_HANDLED
3530  }  }
# Line 3626  Line 3607 
3607                                  formatex(query,99,"insert into %splayers (user_name,password,alias) values (^"%s^",^"%s^",^"%s^")",DB_PREFIX,user,pass,name)                                  formatex(query,99,"insert into %splayers (user_name,password,alias) values (^"%s^",^"%s^",^"%s^")",DB_PREFIX,user,pass,name)
3608                                  SQL_ThreadQuery(DB_TUPLE,"reg_handler",query,data,43)                                  SQL_ThreadQuery(DB_TUPLE,"reg_handler",query,data,43)
3609                          }                          }
                         //Else register SteamID  
                         /*else if(timer[id][TMR_DBUSER]<1){  
                                 data[1]=2  
                                 formatex(query,99,"insert into %splayers (steam_id,alias) values (^"%s^",^"%s^")",DB_PREFIX,sid,name)  
                                 SQL_ThreadQuery(DB_TUPLE,"reg_handler",query,data,43)  
                         }*/  
3610                  }                  }
3611                  else client_print(id,print_console,"[Climb] Registration Error: Can't Register; Stats not enabled.")                  else client_print(id,print_console,"[Climb] Registration Error: Can't Register; Stats not enabled.")
3612          }          }
# Line 3677  Line 3652 
3652  }  }
3653    
3654  public highscores(id)  public highscores(id)
3655  {//Show High Scores  {
3656          if( !CLIMB_SAVE ) return clmsg( id, "Stats not enabled.")          if( !CLIMB_SAVE ) return clmsg( id, "Stats not enabled.")
3657    
3658          new hsurl[150], mapname[33]          new hsurl[150], mapname[33]
# Line 3693  Line 3668 
3668          {          {
3669                  new query[501], data[1]                  new query[501], data[1]
3670                  data[0] = id                  data[0] = id
3671                  /*formatex( query, 249,\  
                         "select p.alias, s.fin_time, s.cps, s.gcs, s.fin_cnt, s.boosts, s.wpns from %sscores s, %splayers p where s.map_name=^"%s^" and p.user_id=s.user_id order by s.score, s.fin_time limit 20;",\  
                         DB_PREFIX, DB_PREFIX, mapname )*/  
3672                  formatex( query, 500,                  formatex( query, 500,
3673                          "select distinct p.alias, s.fin_time, s.cps, s.gcs, g.fin_cnt, s.boosts, s.wpns, s.score from %sscores s join %splayers p on s.user_id = p.user_id join (select user_id, min(score) minscore, count(*) fin_cnt from %sscores where map_name=^"%s^" group by user_id, wpns) g on p.user_id=g.user_id where map_name=^"%s^" and s.score=g.minscore order by s.score limit 20",                          "select distinct p.alias, s.fin_time, s.cps, s.gcs, g.fin_cnt, s.boosts, s.wpns, s.score from %sscores s join %splayers p on s.user_id = p.user_id join (select user_id, min(score) minscore, count(*) fin_cnt from %sscores where map_name=^"%s^" group by user_id, wpns) g on p.user_id=g.user_id where map_name=^"%s^" and s.score=g.minscore order by s.score limit 20",
3674                          DB_PREFIX, DB_PREFIX, DB_PREFIX, mapname, mapname )                          DB_PREFIX, DB_PREFIX, DB_PREFIX, mapname, mapname )
# Line 3742  Line 3715 
3715                          sb_add_tabs( name, NAMELEN+2 )                          sb_add_tabs( name, NAMELEN+2 )
3716    
3717    
3718                          format( btime_str, 19, "%d/%d/%d/%d",\                          format( btime_str, 19, "%d/%d/%d/%d",
3719                                  SQL_ReadResult( query, 6 ),\                                  SQL_ReadResult( query, 6 ),
3720                                  SQL_ReadResult( query, 2 ),\                                  SQL_ReadResult( query, 2 ),
3721                                  SQL_ReadResult( query, 3 ),\                                  SQL_ReadResult( query, 3 ),
3722                                  SQL_ReadResult( query, 5 ) )                                  SQL_ReadResult( query, 5 )
3723                            )
3724                          sb_add_tabs( btime_str, 19 )                          sb_add_tabs( btime_str, 19 )
3725    
3726                          formatex( line, 150,\                          formatex( line, 150,\
3727                                  "%s%d   %s%s    %s      %d%s",                                  "%s%d   %s%s    %s      %d%s",
3728                                  i % 2 ? "" : "<div>",                                  i % 2 ? NULLSTR : "<div>",
3729                                  i, htmlspecialchars( name ),                                  i, htmlspecialchars( name ),
3730                                  parsetime( SQL_ReadResult( query, 1 ) ),                                  parsetime( SQL_ReadResult( query, 1 ) * 10 ),
3731                                  btime_str,                                  btime_str,
3732                                  SQL_ReadResult( query, 4 ),                                  SQL_ReadResult( query, 4 ),
3733                                  i % 2 ? "" : "</div>" )                                  i % 2 ? NULLSTR : "</div>" )
3734                          written_len += strlen( line )                          written_len += strlen( line )
3735                          if( written_len > 1263 ) break                          if( written_len > 1263 ) break
3736                          fprintf( fh, line )                          fprintf( fh, line )
# Line 3806  Line 3780 
3780                  new query[501], data[1]                  new query[501], data[1]
3781                  data[0]=id                  data[0]=id
3782    
                 /*formatex( query, 500,  
                         "select          p.alias, s.score_id, s.fin_time, s.cps, s.gcs, s.boosts, s.wpns from %sscores s, %splayers p where s.map_name=^"%s^" and p.user_id=s.user_id order by s.score, s.fin_time limit 20;",  
                         DB_PREFIX, DB_PREFIX, mapname)*/  
3783                  formatex( query, 500,                  formatex( query, 500,
3784                          "select distinct p.alias, s.score_id, s.fin_time, s.cps, s.gcs, s.boosts, s.wpns from %sscores s join %splayers p on s.user_id = p.user_id join (select user_id, min(score) minscore, count(*) fin_cnt from %sscores where map_name=^"%s^" group by user_id, wpns) g on p.user_id=g.user_id where map_name=^"%s^" and s.score=g.minscore order by s.score limit 20",                          "select distinct p.alias, s.score_id, s.fin_time, s.cps, s.gcs, s.boosts, s.wpns from %sscores s join %splayers p on s.user_id = p.user_id join (select user_id, min(score) minscore, count(*) fin_cnt from %sscores where map_name=^"%s^" group by user_id, wpns) g on p.user_id=g.user_id where map_name=^"%s^" and s.score=g.minscore order by s.score limit 20",
3785                          DB_PREFIX, DB_PREFIX, DB_PREFIX, mapname, mapname )                          DB_PREFIX, DB_PREFIX, DB_PREFIX, mapname, mapname )

Legend:
Removed from v.19  
changed lines
  Added in v.23

Contact
ViewVC Help
Powered by ViewVC 1.0.4