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

Diff of /climb.sma

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

revision 1, Tue Oct 30 09:08:11 2007 UTC revision 23, Sun Nov 18 17:46:23 2007 UTC
# Line 155  Line 155 
155  f: An exploit that involved a paused player with their view attached to something else.  f: An exploit that involved a paused player with their view attached to something else.
156  f: Bug where respawn command would spawn clients at maps origin if plugin was enabled without running init functions.  f: Bug where respawn command would spawn clients at maps origin if plugin was enabled without running init functions.
157  f: Bug where multiple players could connect and get logged in with the same db user id.  f: Bug where multiple players could connect and get logged in with the same db user id.
 //f: Scoreboard buffer overflow that made players names get replaced with a path string.  
158    
159  v2.0a3 (JUNE 21, 2007)  v2.0a3 (JUNE 21, 2007)
160  +: New alias for restart, /start.  +: New alias for restart, /start.
# Line 269  Line 268 
268  #include <cstrike>  #include <cstrike>
269  #include <cstrike2>  #include <cstrike2>
270    
271  #define VERSION "a3.6.19 Oct 08 04:41 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 294  Line 296 
296    
297  //Client flags arrays  //Client flags arrays
298  #define ORIGINS_SIZE 48  #define ORIGINS_SIZE 48
299  new Float:origins[32][ORIGINS_SIZE]  new Float:origins[33][ORIGINS_SIZE]
300  #define ORIG_UNGC 40  #define ORIG_UNGC 40
301  #define ORIG_PAUS 44  #define ORIG_PAUS 44
302  //#define ORIG_X 0  //#define ORIG_X 0
# Line 302  Line 304 
304  //#define ORIG_Z 2  //#define ORIG_Z 2
305  #define ORIG_GRAV 3  #define ORIG_GRAV 3
306    
307  new time_stamps[32][5]//time_stamps[id-1][x]  new time_stamps[33][5]//time_stamps[id][x]
308  #define TS_SPAWN 0  #define TS_SPAWN 0
309  #define TS_BOOST 1  #define TS_BOOST 1
310  #define TS_WPN 2  #define TS_WPN 2
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[32][TIMER_SIZE]//timer[id-1][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]
334    
335  //Other stuff  //Other stuff
336  new hooked[32], hp = 100  new hooked[33], hp = 100
337  new sfactions[SF_MAX][50], sfcount = 0  new sfactions[SF_MAX][50], sfcount = 0
338  new ts_score, ts_hscore, bool:has_hscores = false //scoreboard timeouts  new ts_score, ts_hscore, bool:has_hscores = false //scoreboard timeouts
339  new spec_ids[32][32]  new spec_ids[33][33]
340  new beam_sprite  new beam_sprite
341    
342  new ST_BTNS[9], FN_BTNS[9], ST_BTN_CNT = 0, FN_BTN_CNT = 0  new ST_BTNS[9], FN_BTNS[9], ST_BTN_CNT = 0, FN_BTN_CNT = 0
343  new dyn_spawn_ids[32], dyn_spawn_count, Float:spawn_tp_orig[3], Float:start_tp_orig[3]  new dyn_spawn_ids[32], dyn_spawn_count, Float:spawn_tp_orig[3], Float:start_tp_orig[3]
344    
345  new bool:sclip[32],Float:post_think_vel[32][3],sc_fcount  new bool:sclip[33],Float:post_think_vel[33][3],sc_fcount
346    
347  new LIMIT_TEAMS_OLD, TEAM_BALANCE_OLD  new LIMIT_TEAMS_OLD, TEAM_BALANCE_OLD
348    
349  //Bhop fix vars  //Bhop fix vars
350  #define MAX_DOORS 500  #define MAX_DOORS 500
351  new door_count = 0, func_doors[MAX_DOORS][3], Float:door_tp_pos[MAX_DOORS][3]  new door_count = 0, func_doors[MAX_DOORS][3], Float:door_tp_pos[MAX_DOORS][3]
352  new bhop_failid[32], bool:bhop_fail[32]  new bhop_failid[33], bool:bhop_fail[33]
353  //func_doors[x]{ id, speed, angles }  //func_doors[x]{ id, speed, angles }
354    
355  //Cvar Pointers  //Cvar Pointers
# Line 373  Line 374 
374  #define TSK_CLEAR_FAIL 300  #define TSK_CLEAR_FAIL 300
375  #define TSK_MEASURE2 350  #define TSK_MEASURE2 350
376    
377  //Status timer[id-1][TMR_CFLAGS]&=x  //Status timer[id][TMR_CFLAGS]&=x
378  #define CF_NULL        0        //Passed to change_boost() to remove all boost flags  #define CF_NULL        0        //Passed to change_boost() to remove all boost flags
379  #define CF_STOP        (1<<0)   //STATUS FLAG: Not Started  #define CF_STOP        (1<<0)   //STATUS FLAG: Not Started
380  #define CF_START       (1<<1)   //STATUS FLAG: Climbing  #define CF_START       (1<<1)   //STATUS FLAG: Climbing
# Line 390  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 430  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 446  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 468  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 506  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 541  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 555  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 923  Line 893 
893  {  {
894          if( get_pcvar_num( p_climb ) && !is_user_bot( id ) && !is_user_hltv( id ) )          if( get_pcvar_num( p_climb ) && !is_user_bot( id ) && !is_user_hltv( id ) )
895          {          {
896                  timer[id-1][TMR_DBUSER] = 0                  timer[id][TMR_DBUSER] = 0
897    
898                  //search steamid to position reference for match                  //search steamid to position reference for match
899                  new searchid[32]                  new searchid[32]
# Line 931  Line 901 
901                  for(new i = 0; i < 32; i++ )                  for(new i = 0; i < 32; i++ )
902                          if( equal( searchid, steamid[i] ) )                          if( equal( searchid, steamid[i] ) )
903                          {//load origins & timer array if match found                          {//load origins & timer array if match found
904                                  origins[id-1] = originssave[i]                                  origins[id] = originssave[i]
905                                  timer[id-1] = timersave[i]                                  timer[id] = timersave[i]
906                                  return PLUGIN_CONTINUE                                  return PLUGIN_CONTINUE
907                          }                          }
908    
909                  timer[id-1][TMR_CFLAGS] += CF_STOP                  timer[id][TMR_CFLAGS] += CF_STOP
910    
911                  new ida[1]                  new ida[1]
912                  ida[0]=id                  ida[0]=id
913    
914                  if( CLIMB_SAVE && timer[id-1][TMR_DBUSER] < 1 )                  if( CLIMB_SAVE && timer[id][TMR_DBUSER] < 1 )
915                          set_task( 5.0, "auto_login", 0, ida, 1 )                          set_task( 5.0, "auto_login", 0, ida, 1 )
916          }          }
917          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
# Line 959  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-1][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
936                  originssave[savepos] = origins[id-1] //save origins                  originssave[savepos] = origins[id] //save origins
937                  timersave[savepos] = timer[id-1] //save timer array                  timersave[savepos] = timer[id] //save timer array
938    
939                  //clear data for new client in that slot                  //clear data for new client in that slot
940                  for( new i = 0; i < 48; i++ ) origins[id-1][i] = 0.0                  for( new i = 0; i < 48; i++ ) origins[id][i] = 0.0
941                  for( new i = 0; i < 14; i++ ) timer[id-1][i] = 0                  for( new i = 0; i < 14; i++ ) timer[id][i] = 0
942                  hooked[id] = 0                  hooked[id] = 0
943                  sortcssb( ) //Update frags to reorder scoreboard                  sortcssb( ) //Update frags to reorder scoreboard
944          }          }
# Line 982  Line 952 
952          //Set timeout flag and set_task to clear it          //Set timeout flag and set_task to clear it
953          new ida[1]          new ida[1]
954          ida[0] = id          ida[0] = id
955          time_stamps[id-1][TS_CPGC] = 1          time_stamps[id][TS_CPGC] = 1
956          set_task( CPGC_TIMEOUT, "clear_cpgc_timeout", _, ida, 1 )          set_task( CPGC_TIMEOUT, "clear_cpgc_timeout", _, ida, 1 )
957  }  }
958    
959  public clear_cpgc_timeout( ida[1] )  public clear_cpgc_timeout( ida[1] )
960          return time_stamps[ida[0]-1][TS_CPGC]=0          return time_stamps[ida[0]][TS_CPGC]=0
961    
962  //Save a checkpoint  //Save a checkpoint
963  public check( id )  public check( id )
# Line 1016  Line 986 
986                                  entity_get_vector( id, EV_VEC_origin, coords )                                  entity_get_vector( id, EV_VEC_origin, coords )
987                                  if( coords[0] || coords[1] || coords[2] )//and they're not at world origin, then save checkpoint                                  if( coords[0] || coords[1] || coords[2] )//and they're not at world origin, then save checkpoint
988                                  {                                  {
989                                          if( timer[id-1][TMR_CPPOS] > 0 ) timer[id-1][TMR_CPPOS]--                                          if( timer[id][TMR_CPPOS] > 0 ) timer[id][TMR_CPPOS]--
990                                          new cppos = timer[id-1][TMR_CPPOS] * 4                                          new cppos = timer[id][TMR_CPPOS] * 4
991    
992                                          //If cp position is 0 then bump all cps back before saving.                                          //If cp position is 0 then bump all cps back before saving.
993                                          if( !cppos ) for(new i=39; i>3 ;i-- ) origins[id-1][i] = origins[id-1][i-4]                                          if( !cppos ) for(new i=39; i>3 ;i-- ) origins[id][i] = origins[id][i-4]
994    
995                                          for( new i=0; i<3; i++ ) origins[id-1][cppos + i] = coords[i]                                          for( new i=0; i<3; i++ ) origins[id][cppos + i] = coords[i]
996                                          origins[id-1][3]=entity_get_float(id, EV_FL_gravity)                                          origins[id][3]=entity_get_float(id, EV_FL_gravity)
997    
998                                          new msg[100]="Checkpoint saved."                                          new msg[100]="Checkpoint saved."
999                                          if(timer[id-1][TMR_CFLAGS]&CF_START){                                          if(timer[id][TMR_CFLAGS]&CF_START){
1000                                                  timer[id-1][TMR_CNTCPS]++                                                  timer[id][TMR_CNTCPS]++
1001                                                  formatex(msg,99,"Checkpoint saved. (%d CPS/ %d GCS/ %d Boosts)",timer[id-1][TMR_CNTCPS],timer[id-1][TMR_CNTGCS],timer[id-1][TMR_CNTBST])                                                  formatex(msg,99,"Checkpoint saved. (%d CPS/ %d GCS/ %d Boosts)",timer[id][TMR_CNTCPS],timer[id][TMR_CNTGCS],timer[id][TMR_CNTBST])
1002                                          }                                          }
1003                                          clmsg(id,msg)                                          clmsg(id,msg)
1004    
# Line 1046  Line 1016 
1016  //Go to most recent checkpoint  //Go to most recent checkpoint
1017  public gocheck( id )  public gocheck( id )
1018  {  {
1019          if( get_pcvar_num( p_climb ) && isalive( id ) && notpaused( id ) && !time_stamps[id-1][TS_CPGC] )          if( get_pcvar_num( p_climb ) && isalive( id ) && notpaused( id ) && !time_stamps[id][TS_CPGC] )
1020          {          {
1021                  if( origins[id-1][0] || origins[id-1][1] || origins[id-1][2] )                  if( origins[id][0] || origins[id][1] || origins[id][2] )
1022                  {                  {
1023                          new Float:coords[3]                          new Float:coords[3]
1024    
1025                          //Store ungocheck data                          //Store ungocheck data
1026                          entity_get_vector( id, EV_VEC_origin, coords )                          entity_get_vector( id, EV_VEC_origin, coords )
1027                          for( new i=0; i<3; i++ ) origins[id-1][ORIG_UNGC + i] = coords[i]                          for( new i=0; i<3; i++ ) origins[id][ORIG_UNGC + i] = coords[i]
1028                          origins[id-1][ORIG_UNGC + 3] = entity_get_float( id, EV_FL_gravity )                          origins[id][ORIG_UNGC + 3] = entity_get_float( id, EV_FL_gravity )
1029    
1030                          //Do gocheck                          //Do gocheck
1031                          new cppos = timer[id-1][TMR_CPPOS] * 4                          new cppos = timer[id][TMR_CPPOS] * 4
1032                          for( new i=0; i<3; i++ ) coords[i] = origins[id-1][cppos + i]                          for( new i=0; i<3; i++ ) coords[i] = origins[id][cppos + i]
1033                          entity_set_float( id, EV_FL_gravity, origins[id-1][3] )                          entity_set_float( id, EV_FL_gravity, origins[id][3] )
1034                          teleport( id, coords )                          teleport( id, coords )
1035    
1036                          new msg[100]="Checkpoint restored."                          new msg[100]="Checkpoint restored."
1037                          if(timer[id-1][TMR_CFLAGS]&CF_START){                          if(timer[id][TMR_CFLAGS]&CF_START){
1038                                  timer[id-1][TMR_CNTGCS]++                                  timer[id][TMR_CNTGCS]++
1039                                  formatex(msg,99,"Checkpoint restored. (%d CPS/ %d GCS/ %d Boosts)",timer[id-1][TMR_CNTCPS],timer[id-1][TMR_CNTGCS],timer[id-1][TMR_CNTBST])                                  formatex(msg,99,"Checkpoint restored. (%d CPS/ %d GCS/ %d Boosts)",timer[id][TMR_CNTCPS],timer[id][TMR_CNTGCS],timer[id][TMR_CNTBST])
1040                          }                          }
1041                          clmsg(id,msg)                          clmsg(id,msg)
1042    
# Line 1083  Line 1053 
1053  //Undo a gocheck  //Undo a gocheck
1054  public ungocheck( id )  public ungocheck( id )
1055  {  {
1056          if( get_pcvar_num(p_climb) && isalive(id) && notpaused(id) && !time_stamps[id-1][TS_CPGC] )          if( get_pcvar_num(p_climb) && isalive(id) && notpaused(id) && !time_stamps[id][TS_CPGC] )
1057          {          {
1058                  if( origins[id-1][ORIG_UNGC] || origins[id-1][ORIG_UNGC + 1] || origins[id-1][ORIG_UNGC + 2])                  if( origins[id][ORIG_UNGC] || origins[id][ORIG_UNGC + 1] || origins[id][ORIG_UNGC + 2])
1059                  {                  {
1060                          new Float:coords[3]                          new Float:coords[3]
1061                          for( new i=0; i<3; i++ )coords[i] = origins[id-1][ORIG_UNGC + i]                          for( new i=0; i<3; i++ )coords[i] = origins[id][ORIG_UNGC + i]
1062                          teleport( id, coords )                          teleport( id, coords )
1063                          entity_set_float( id, EV_FL_gravity, origins[id-1][ORIG_UNGC + 3] )                          entity_set_float( id, EV_FL_gravity, origins[id][ORIG_UNGC + 3] )
1064                          if( timer[id-1][TMR_CFLAGS] & CF_START ) timer[id-1][TMR_CNTGCS]++                          if( timer[id][TMR_CFLAGS] & CF_START ) timer[id][TMR_CNTGCS]++
1065                          clmsg( id, "You have been ungochecked." )                          clmsg( id, "You have been ungochecked." )
1066    
1067                          set_cpgc_timeout( id )                          set_cpgc_timeout( id )
# Line 1103  Line 1073 
1073  //Cycle back through CPs  //Cycle back through CPs
1074  public cp_back( id )  public cp_back( id )
1075  {  {
1076          if( get_pcvar_num( p_climb ) && isalive( id ) && notpaused( id ) && !time_stamps[id-1][TS_CPGC] )          if( get_pcvar_num( p_climb ) && isalive( id ) && notpaused( id ) && !time_stamps[id][TS_CPGC] )
1077          {          {
1078                  if( timer[id-1][TMR_CPPOS] < 9 ) timer[id-1][TMR_CPPOS]++                  if( timer[id][TMR_CPPOS] < 9 ) timer[id][TMR_CPPOS]++
1079                  new cppos = timer[id-1][TMR_CPPOS] * 4                  new cppos = timer[id][TMR_CPPOS] * 4
1080                  if( origins[id-1][cppos] || origins[id-1][cppos + 1] || origins[id-1][cppos + 2] )                  if( origins[id][cppos] || origins[id][cppos + 1] || origins[id][cppos + 2] )
1081                  {                  {
1082                          new Float:coords[3]                          new Float:coords[3]
1083                          //for( new i=0; i<36; i++ ) origins[id-1][i] = origins[id-1][i+4]                          //for( new i=0; i<36; i++ ) origins[id][i] = origins[id][i+4]
1084                          for( new i=0; i<3; i++ ) coords[i] = origins[id-1][cppos + i]                          for( new i=0; i<3; i++ ) coords[i] = origins[id][cppos + i]
1085                          entity_set_float( id, EV_FL_gravity, origins[id-1][cppos + ORIG_GRAV] )                          entity_set_float( id, EV_FL_gravity, origins[id][cppos + ORIG_GRAV] )
1086                          teleport( id, coords )                          teleport( id, coords )
1087    
1088                          if( timer[id-1][TMR_CFLAGS] & CF_START ) timer[id-1][TMR_CNTGCS]++                          if( timer[id][TMR_CFLAGS] & CF_START ) timer[id][TMR_CNTGCS]++
1089    
1090                          /*new msg[100]="Previous checkpoint restored."                          /*new msg[100]="Previous checkpoint restored."
1091                          if( timer[id-1][TMR_CFLAGS] & CF_START )                          if( timer[id][TMR_CFLAGS] & CF_START )
1092                          {                          {
1093                                  timer[id-1][TMR_CNTCPS]--                                  timer[id][TMR_CNTCPS]--
1094                                  formatex( msg, 99, "Previous checkpoint restored. (%d CPS/ %d GCS/ %d Boosts)",\                                  formatex( msg, 99, "Previous checkpoint restored. (%d CPS/ %d GCS/ %d Boosts)",\
1095                                          timer[id-1][TMR_CNTCPS], timer[id-1][TMR_CNTGCS], timer[id-1][TMR_CNTBST] )                                          timer[id][TMR_CNTCPS], timer[id][TMR_CNTGCS], timer[id][TMR_CNTBST] )
1096                          }                          }
1097                          clmsg( id, msg )*/                          clmsg( id, msg )*/
1098    
# Line 1138  Line 1108 
1108                  else                  else
1109                  {                  {
1110                          clmsg(id,"You have no previous checkpoints remaining.")                          clmsg(id,"You have no previous checkpoints remaining.")
1111                          timer[id-1][TMR_CPPOS]--                          timer[id][TMR_CPPOS]--
1112                  }                  }
1113          }          }
1114          return PLUGIN_HANDLED          return PLUGIN_HANDLED
# Line 1147  Line 1117 
1117  //Cycle forward through CPs  //Cycle forward through CPs
1118  public cp_forward( id )  public cp_forward( id )
1119  {  {
1120          if( get_pcvar_num( p_climb ) && isalive( id ) && notpaused( id ) && !time_stamps[id-1][TS_CPGC] && timer[id-1][TMR_CPPOS] > 0 )          if( get_pcvar_num( p_climb ) && isalive( id ) && notpaused( id ) && !time_stamps[id][TS_CPGC] && timer[id][TMR_CPPOS] > 0 )
1121          {          {
1122                  timer[id-1][TMR_CPPOS]--                  timer[id][TMR_CPPOS]--
1123                  new cppos = timer[id-1][TMR_CPPOS] * 4                  new cppos = timer[id][TMR_CPPOS] * 4
1124    
1125                  new Float:coords[3]                  new Float:coords[3]
1126                  for( new i=0; i<3; i++ ) coords[i] = origins[id-1][cppos + i]                  for( new i=0; i<3; i++ ) coords[i] = origins[id][cppos + i]
1127                  entity_set_float( id, EV_FL_gravity, origins[id-1][cppos + ORIG_GRAV] )                  entity_set_float( id, EV_FL_gravity, origins[id][cppos + ORIG_GRAV] )
1128                  teleport( id, coords )                  teleport( id, coords )
1129    
1130                  if( timer[id-1][TMR_CFLAGS] & CF_START ) timer[id-1][TMR_CNTGCS]++                  if( timer[id][TMR_CFLAGS] & CF_START ) timer[id][TMR_CNTGCS]++
1131    
1132                  set_cpgc_timeout( id )                  set_cpgc_timeout( id )
1133          }          }
# Line 1168  Line 1138 
1138  ////////////////////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////////////////////
1139  public change_status( id, newstat )  public change_status( id, newstat )
1140  {  {
1141          new cflags_old = timer[id-1][TMR_CFLAGS]          new cflags_old = timer[id][TMR_CFLAGS]
1142          new cflags_new = cflags_old & ~CF_STATUSFLAGS          new cflags_new = cflags_old & ~CF_STATUSFLAGS
1143    
1144          if( newstat & CF_PAUSE )          if( newstat & CF_PAUSE )
# Line 1176  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-1][TMR_STARTD] = get_systime() - timer[id-1][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-1][ORIG_PAUS + ORIG_GRAV] )                          entity_set_float( id, EV_FL_gravity, origins[id][ORIG_PAUS + ORIG_GRAV] )
1152                          clmsg( id, "UNPAUSED" )                          clmsg( id, "UNPAUSED" )
1153                          sfexec( id, 2 )                          sfexec( id, 2 )
1154                  }                  }
1155                  else if( cflags_old & CF_START ) //pause                  else if( cflags_old & CF_START ) //pause
1156                  {                  {
                         timer[id-1][TMR_STARTD] = get_systime() - timer[id-1][TMR_STARTD]  
1157                          cl_pause( id )                          cl_pause( id )
1158                          cflags_new += CF_PAUSE                          cflags_new += CF_PAUSE
1159                  }                  }
# Line 1196  Line 1164 
1164                  }                  }
1165          }          }
1166          else cflags_new += newstat          else cflags_new += newstat
1167          timer[id-1][TMR_CFLAGS] = cflags_new          timer[id][TMR_CFLAGS] = cflags_new
1168          return PLUGIN_HANDLED          return PLUGIN_HANDLED
1169  }  }
1170    
# Line 1212  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-1][TMR_CFLAGS] & CF_START )          if( get_pcvar_num( p_climb ) && timer[id][TMR_CFLAGS] & CF_START )
1199          {          {
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-1][TMR_STARTD]=0                  timer[id][TMR_CNTTME] = 0
                 timer[id-1][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 1236  Line 1216 
1216                  wpn = get_user_weapon( id, clip, ammo )                  wpn = get_user_weapon( id, clip, ammo )
1217                  if( wpn == CSW_KNIFE )                  if( wpn == CSW_KNIFE )
1218                  {                  {
1219                          new remain = check_timeout( 0, time_stamps[id-1][TS_KNIFE], KNIFE_TIMEOUT, _, 1 )                          new remain = check_timeout( 0, time_stamps[id][TS_KNIFE], KNIFE_TIMEOUT, _, 1 )
1220                          if( remain )                          if( remain )
1221                          {                          {
1222                                  set_cd(cd_handle, CD_flNextAttack, halflife_time() + remain )                                  set_cd(cd_handle, CD_flNextAttack, halflife_time() + remain )
# Line 1254  Line 1234 
1234          if( !get_pcvar_num( p_climb ) || !( 0 < wpn <= 30 ) )          if( !get_pcvar_num( p_climb ) || !( 0 < wpn <= 30 ) )
1235                  return PLUGIN_CONTINUE                  return PLUGIN_CONTINUE
1236    
1237          static client_oldwpn[32]          static client_oldwpn[33]
1238          if( wpn != client_oldwpn[id-1] )          if( wpn != client_oldwpn[id] )
1239                  rank_mod_update( id )                  rank_mod_update( id )
1240    
1241          client_oldwpn[id-1] = 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 1292  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 1320  Line 1304 
1304                          rank = 7                          rank = 7
1305          }          }
1306    
1307          if( rank > timer[id-1][TMR_CNTWPN] )          if( rank > timer[id][TMR_CNTWPN] )
1308                          timer[id-1][TMR_CNTWPN] = rank                          timer[id][TMR_CNTWPN] = rank
1309    
1310          new msg[100]          new msg[100]
1311          format( msg, 99, "Weapon Max Speed: %d^nRank Modifier: %d", maxspeed, rank )          format( msg, 99, "Weapon Max Speed: %d^nRank Modifier: %d", maxspeed, rank )
# Line 1353  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 1388  Line 1366 
1366  {  {
1367          stop(id)          stop(id)
1368          if( is_climber_alive( id ) ) teleport( id, spawn_tp_orig )          if( is_climber_alive( id ) ) teleport( id, spawn_tp_orig )
1369          else if( !check_timeout( id, time_stamps[id-1][TS_SPAWN], SPAWN_TIMEOUT ) )          else if( !check_timeout( id, time_stamps[id][TS_SPAWN], SPAWN_TIMEOUT ) )
1370          {          {
1371                  //if( get_user_team ( id ) == 3 ) cs_set_user_team( id, 2 )                  //if( get_user_team ( id ) == 3 ) cs_set_user_team( id, 2 )
1372                  //cs_user_spawn( id )                  //cs_user_spawn( id )
# Line 1447  Line 1425 
1425                                  sfexec( id, 1 )//Execute commands from start/finish config                                  sfexec( id, 1 )//Execute commands from start/finish config
1426                                  if( get_user_flags( id ) & VIP ) cs_set_user_scoreattrib( id, 4 )//Show admin as VIP on Scoreboard.                                  if( get_user_flags( id ) & VIP ) cs_set_user_scoreattrib( id, 4 )//Show admin as VIP on Scoreboard.
1427    
1428                                  if( timer[id-1][TMR_CFLAGS] & CF_PAUSE )                                  if( timer[id][TMR_CFLAGS] & CF_PAUSE )
1429                                  {//If they are paused tp to pause spot and freeze them again.                                  {//If they are paused tp to pause spot and freeze them again.
1430                                          new Float:coords[3]                                          new Float:coords[3]
1431                                          for( new i=0; i<3; i++ ) coords[i] = origins[ id - 1 ][ ORIG_PAUS + i ]                                          for( new i=0; i<3; i++ ) coords[i] = origins[ id - 1 ][ ORIG_PAUS + i ]
# Line 1581  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 1604  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-1][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 1638  Line 1616 
1616                  for( i = 0; i < num; i++ )                  for( i = 0; i < num; i++ )
1617                  {                  {
1618                          id_i = players[i]                          id_i = players[i]
1619                          cflags_i = timer[id_i-1][TMR_CFLAGS]                          cflags_i = timer[id_i][TMR_CFLAGS]
1620    
1621                          if( !( cflags_i & CF_PAUSE ) )                          if( !( cflags_i & CF_PAUSE ) )
1622                          {                          {
# Line 1658  Line 1636 
1636                                          if( i != j )                                          if( i != j )
1637                                          {                                          {
1638                                                  id_j = players[j]                                                  id_j = players[j]
1639                                                  cflags_j = timer[id_j-1][TMR_CFLAGS]                                                  cflags_j = timer[id_j][TMR_CFLAGS]
1640    
1641                                                  if( ( !( cflags_i & CF_SOLID && cflags_j & CF_SOLID ) || skip[i] ) && !( cflags_j & CF_PAUSE ) )                                                  if( ( !( cflags_i & CF_SOLID && cflags_j & CF_SOLID ) || skip[i] ) && !( cflags_j & CF_PAUSE ) )
1642                                                  {                                                  {
# Line 1699  Line 1677 
1677          //new Float:c1d[3],Float:c2d[3],xyadd,zadd          //new Float:c1d[3],Float:c2d[3],xyadd,zadd
1678          for(i=0;i<num;i++){          for(i=0;i<num;i++){
1679                  id_i=players[i]                  id_i=players[i]
1680                  cflags_i=timer[id_i-1][TMR_CFLAGS]                  cflags_i=timer[id_i][TMR_CFLAGS]
1681                  if(!(cflags_i&CF_PAUSE)){                  if(!(cflags_i&CF_PAUSE)){
1682                          //solid(players[i])                          //solid(players[i])
1683                          entity_get_vector(id_i,EV_VEC_origin,c1)                          entity_get_vector(id_i,EV_VEC_origin,c1)
# Line 1708  Line 1686 
1686                          c1[2]=0.0                          c1[2]=0.0
1687                          for(j=0;j<num;j++){                          for(j=0;j<num;j++){
1688                                  id_j=players[j]                                  id_j=players[j]
1689                                  cflags_j=timer[id_j-1][TMR_CFLAGS]                                  cflags_j=timer[id_j][TMR_CFLAGS]
1690                                  if(!(cflags_j&CF_SOLID)&&i!=j){                                  if(!(cflags_j&CF_SOLID)&&i!=j){
1691                                          entity_get_vector(id_j,EV_VEC_origin,c2)                                          entity_get_vector(id_j,EV_VEC_origin,c2)
1692                                          //entity_get_vector(players[j],EV_VEC_velocity,c2d)                                          //entity_get_vector(players[j],EV_VEC_velocity,c2d)
# Line 1751  Line 1729 
1729          if( !get_pcvar_num( p_climb ) || is_user_bot( id ) || !is_climber_alive( id ) )          if( !get_pcvar_num( p_climb ) || is_user_bot( id ) || !is_climber_alive( id ) )
1730                  return PLUGIN_CONTINUE                  return PLUGIN_CONTINUE
1731    
1732          if( sclip[id-1] && sc_fcount == 9 ) entity_set_int( id, EV_INT_solid, SOLID_BBOX )          if( sclip[id] && sc_fcount == 9 ) entity_set_int( id, EV_INT_solid, SOLID_BBOX )
1733    
1734          //Detect button use. Replicated from HL SDK          //Detect button use. Replicated from HL SDK
1735          if( get_user_button( id ) & IN_USE && !( get_user_oldbutton( id ) & IN_USE ) )          if( get_user_button( id ) & IN_USE && !( get_user_oldbutton( id ) & IN_USE ) )
# Line 1769  Line 1747 
1747                  }                  }
1748          }          }
1749    
1750          new cflags = timer[id-1][TMR_CFLAGS]          new cflags = timer[id][TMR_CFLAGS]
1751    
1752          //Double and super jump boosts          //Double and super jump boosts
1753          if( get_pcvar_num( p_boost ) )          if( get_pcvar_num( p_boost ) )
# Line 1780  Line 1758 
1758                  {                  {
1759                          if( cflags & CF_SUPER_JUMP && onground )                          if( cflags & CF_SUPER_JUMP && onground )
1760                          {                          {
1761                                  entity_get_vector( id, EV_VEC_velocity, post_think_vel[id-1] )                                  entity_get_vector( id, EV_VEC_velocity, post_think_vel[id] )
1762                                  if( post_think_vel[id-1][0] != 0.0 || post_think_vel[id-1][1] != 0.0)                                  if( post_think_vel[id][0] != 0.0 || post_think_vel[id][1] != 0.0)
1763                                  {                                  {
1764                                          velocity_by_aim( id, 400, post_think_vel[id-1] )                                          velocity_by_aim( id, 400, post_think_vel[id] )
1765                                          if( post_think_vel[id-1][2] < 250.0) post_think_vel[id-1][2] = 250.0                                          if( post_think_vel[id][2] < 250.0) post_think_vel[id][2] = 250.0
1766                                          if( post_think_vel[id-1][2] > 350.0) post_think_vel[id-1][2] = 350.0                                          if( post_think_vel[id][2] > 350.0) post_think_vel[id][2] = 350.0
1767                                  }                                  }
1768                                  else post_think_vel[id-1] = Float:{0.0,0.0,0.0}                                  else post_think_vel[id] = Float:{0.0,0.0,0.0}
1769                          }                          }
1770                          else if( cflags & CF_DOUBLE_JUMP )                          else if( cflags & CF_DOUBLE_JUMP )
1771                          {                          {
1772                                  if( !onground && !(get_user_oldbutton( id ) & IN_JUMP ) )                                  if( !onground && !(get_user_oldbutton( id ) & IN_JUMP ) )
1773                                  {                                  {
1774                                          entity_get_vector( id, EV_VEC_velocity, post_think_vel[id-1] )                                          entity_get_vector( id, EV_VEC_velocity, post_think_vel[id] )
1775                                          float_clamp( post_think_vel[id-1][0], -150.0, 150.0 )                                          float_clamp( post_think_vel[id][0], -150.0, 150.0 )
1776                                          float_clamp( post_think_vel[id-1][1], -150.0, 150.0 )                                          float_clamp( post_think_vel[id][1], -150.0, 150.0 )
1777                                          if( is_finished( id ) || post_think_vel[id-1][2] > -500 ) post_think_vel[id-1][2] = 250.0                                          if( is_finished( id ) || post_think_vel[id][2] > -500 ) post_think_vel[id][2] = 250.0
1778                                          else post_think_vel[id-1] = Float:{ 0.0, 0.0, 0.0 }                                          else post_think_vel[id] = Float:{ 0.0, 0.0, 0.0 }
1779                                  }                                  }
1780                          }                          }
1781                  }                  }
# Line 1825  Line 1803 
1803          {          {
1804    
1805                  if( button & IN_ATTACK || button & IN_ATTACK2 )                  if( button & IN_ATTACK || button & IN_ATTACK2 )
1806                  if( check_timeout( 0, time_stamps[id-1][TS_KNIFE], KNIFE_TIMEOUT ) )                  if( check_timeout( 0, time_stamps[id][TS_KNIFE], KNIFE_TIMEOUT ) )
1807                          set_pev( id, pev_button, pev( id, pev_button ) & ~IN_ATTACK_EITHER )                          set_pev( id, pev_button, pev( id, pev_button ) & ~IN_ATTACK_EITHER )
1808          }          }
1809          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
# Line 1836  Line 1814 
1814          if( !( get_pcvar_num(p_climb) && get_pcvar_num(p_boost) && is_climber_alive( id ) ) || is_user_bot(id) )          if( !( get_pcvar_num(p_climb) && get_pcvar_num(p_boost) && is_climber_alive( id ) ) || is_user_bot(id) )
1815                  return PLUGIN_CONTINUE                  return PLUGIN_CONTINUE
1816    
1817          if( sclip[id-1] ) entity_set_int( id, EV_INT_solid, SOLID_NOT )          if( sclip[id] ) entity_set_int( id, EV_INT_solid, SOLID_NOT )
1818    
1819          if( _:get_distance( _:post_think_vel[id-1], { 0, 0, 0 } ) )          if( _:get_distance( _:post_think_vel[id], { 0, 0, 0 } ) )
1820          {          {
1821                  entity_set_vector( id, EV_VEC_velocity, post_think_vel[id-1] )                  entity_set_vector( id, EV_VEC_velocity, post_think_vel[id] )
1822                  post_think_vel[id-1] = Float:{ 0.0, 0.0, 0.0 }                  post_think_vel[id] = Float:{ 0.0, 0.0, 0.0 }
1823                  if( timer[id-1][TMR_CFLAGS] & CF_START )                  if( timer[id][TMR_CFLAGS] & CF_START )
1824                  {                  {
1825                          timer[id-1][TMR_CNTBST]++       //Increment client boost count                          timer[id][TMR_CNTBST]++ //Increment client boost count
1826                          change_boost( id, CF_NULL )                          change_boost( id, CF_NULL )
1827                  }                  }
1828                  else if( !is_finished(id) )change_boost( id, CF_NULL )                  else if( !is_finished(id) )change_boost( id, CF_NULL )
1829          }          }
1830    
1831          //Store pause data          //Store pause data
1832          if( !( timer[id-1][TMR_CFLAGS] & CF_PAUSE ) )          if( !( timer[id][TMR_CFLAGS] & CF_PAUSE ) )
1833          {          {
1834                  new Float:coords[3]                  new Float:coords[3]
1835                  entity_get_vector( id, EV_VEC_origin, coords )                  entity_get_vector( id, EV_VEC_origin, coords )
1836                  for( new i=0; i<3; i++ ) origins[id-1][ORIG_PAUS+i] = coords[i]                  for( new i=0; i<3; i++ ) origins[id][ORIG_PAUS+i] = coords[i]
1837                  origins[id-1][ORIG_PAUS+3] = entity_get_float( id, EV_FL_gravity )                  origins[id][ORIG_PAUS+3] = entity_get_float( id, EV_FL_gravity )
1838          }          }
1839          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
1840  }  }
# Line 1880  Line 1858 
1858                          }                          }
1859          }          }
1860    
1861          //new cflags = timer[id-1][TMR_CFLAGS]          //new cflags = timer[id][TMR_CFLAGS]
1862    
1863          if( btn_type == 1 )//Start Button          if( btn_type == 1 )//Start Button
1864          {          {
1865                  new Float:orig[3], bool:need_respawn = true //Float:view[3]                  new Float:orig[3], bool:need_respawn = true //Float:view[3]
1866                  if( timer[id-1][TMR_CFLAGS] & CF_START ) need_respawn = false                  if( timer[id][TMR_CFLAGS] & CF_START ) need_respawn = false
1867    
1868                  for( new i = 0; i < 48; i++ ) origins[id-1][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-1][TMR_STARTD] = get_systime()                  timer[id][TMR_CNTTME] = 0
1872                    timer[id][TMR_CNTCPS] = 0
1873                    timer[id][TMR_CNTGCS] = 0
1874                    timer[id][TMR_CNTBST] = 0
1875                    timer[id][TMR_CPPOS] = 0
1876                    timer[id][TMR_CNTWPN] = 0
1877                    time_stamps[id][TS_BOOST] = BOOST_TIMEOUT
1878                  change_status(id,CF_START)                  change_status(id,CF_START)
                 timer[id-1][TMR_CNTCPS] = 0  
                 timer[id-1][TMR_CNTGCS] = 0  
                 timer[id-1][TMR_CNTBST] = 0  
                 timer[id-1][TMR_CPPOS] = 0  
                 timer[id-1][TMR_CNTWPN] = 0  
                 time_stamps[id-1][TS_BOOST] = BOOST_TIMEOUT  
1879    
1880                  if( timer[id-1][TMR_CFLAGS] & CF_COUNTDOWN ) set_countdown_time( id )                  if( timer[id][TMR_CFLAGS] & CF_COUNTDOWN ) set_countdown_time( id )
1881    
1882                  //Record starting weapon                  //Record starting weapon
1883                  rank_mod_update( id )                  rank_mod_update( id )
# Line 1913  Line 1891 
1891                          entity_set_vector( id, EV_VEC_origin, orig )                          entity_set_vector( id, EV_VEC_origin, orig )
1892                          //entity_set_vector( id, EV_VEC_angles, view )                          //entity_set_vector( id, EV_VEC_angles, view )
1893                          delay_duck( id )                          delay_duck( id )
1894                          //time_stamps[id-1][TS_SPAWN]=get_systime()                          //time_stamps[id][TS_SPAWN]=get_systime()
1895                  }                  }
1896                  heal( id )                  heal( id )
1897                  cs_set_user_money( id, get_pcvar_num( p_startmoney ) )                  cs_set_user_money( id, get_pcvar_num( p_startmoney ) )
# Line 1926  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-1][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!!!")
1911    
# Line 1937  Line 1915 
1915          }          }
1916          else if( btn_type == 2 )//Finish Button          else if( btn_type == 2 )//Finish Button
1917          {          {
1918                  if( timer[id-1][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-1][TMR_FINISH] = get_systime( )  
1927                          change_status( id, CF_STOP )                          change_status( id, CF_STOP )
1928                          timer[id-1][TMR_SESFIN]++                          timer[id][TMR_SESFIN]++
1929                          timer[id-1][TMR_MAPFIN]++                          timer[id][TMR_MAPFIN]++
1930    
1931                          //Announce to client                          //Announce to client
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-1][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-1][TMR_CNTCPS], timer[id-1][TMR_CNTGCS], timer[id-1][TMR_CNTBST],                                  name, msg, wpn, cntcps, cntgcs, cntbst,
1948                                  timer[id-1][TMR_SESFIN], timer[id-1][TMR_MAPFIN] )                                  timer[id][TMR_SESFIN], timer[id][TMR_MAPFIN]
1949                            )
1950                          new cnt_score = ( ( ( timer[id-1][TMR_CNTBST] > 0 ? 1 : 0 ) * 1000000 ) +  
1951                                  ( ( timer[id-1][TMR_CNTCPS] > 0 ? 1 : 0 ) * 100000 ) +                          new cntscore = ( ( ( cntbst > 0 ? 1 : 0 ) * 1000000 ) +
1952                                  ( timer[id-1][TMR_CNTWPN] * 10000 ) +                                  ( ( cntcps > 0 ? 1 : 0 ) * 100000 ) +
1953                                  get_climber_time( id ) )                                  ( cntwpn * 10000 ) +
1954                                    cnttme )
1955                          new bst_score = ( ( ( timer[id-1][TMR_BSTBST] > 0 ? 1 : 0 ) * 1000000 ) +  
1956                                  ( ( timer[id-1][TMR_BSTCPS] > 0 ? 1 : 0 ) * 100000 ) +                          new bstscore = ( ( ( timer[id][TMR_BSTBST] > 0 ? 1 : 0 ) * 1000000 ) +
1957                                  ( timer[id-1][TMR_BSTWPN] * 10000 ) +                                  ( ( timer[id][TMR_BSTCPS] > 0 ? 1 : 0 ) * 100000 ) +
1958                                  timer[id-1][TMR_BSTTME] )                                  ( timer[id][TMR_BSTWPN] * 10000 ) +
1959                                    timer[id][TMR_BSTTME] / 10 )
1960                          if( cnt_score < bst_score || bst_score == 0 )  
1961                          {                          if( cntscore < bstscore || bstscore == 0 )
1962                                  timer[id-1][TMR_BSTTME] = get_climber_time( id )                          {
1963                                  timer[id-1][TMR_BSTCPS] = timer[id-1][TMR_CNTCPS]                                  timer[id][TMR_BSTTME] = cnttme
1964                                  timer[id-1][TMR_BSTGCS] = timer[id-1][TMR_CNTGCS]                                  timer[id][TMR_BSTCPS] = cntcps
1965                                  timer[id-1][TMR_BSTBST] = timer[id-1][TMR_CNTBST]                                  timer[id][TMR_BSTGCS] = cntgcs
1966                                  timer[id-1][TMR_BSTWPN] = timer[id-1][TMR_CNTWPN]                                  timer[id][TMR_BSTBST] = cntbst
1967                                    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 1989  Line 1973 
1973    
1974                          sortcssb( ) //Update frags to reorder scoreboard                          sortcssb( ) //Update frags to reorder scoreboard
1975                  }                  }
1976                  else if(timer[id-1][TMR_CFLAGS]&CF_STOP&&timer[id-1][TMR_SESFIN]==0){                  else if(timer[id][TMR_CFLAGS]&CF_STOP&&timer[id][TMR_SESFIN]==0){
1977                          //change_status(id,CF_FINISH)                          //change_status(id,CF_FINISH)
1978                          timer[id-1][TMR_SESFIN]++                          timer[id][TMR_SESFIN]++
1979                          new msg[100]="Congratulations, you finished! But you didn't start the timer. :("                          new msg[100]="Congratulations, you finished! But you didn't start the timer. :("
1980                          clmsg(id,msg)                          clmsg(id,msg)
1981                          client_print(id,print_chat,msg)                          client_print(id,print_chat,msg)
# Line 2007  Line 1991 
1991    
1992  //Execute commands from start/finish config  //Execute commands from start/finish config
1993  public sfexec(id,clevent){  public sfexec(id,clevent){
1994          new clstat[3],cflags=timer[id-1][TMR_CFLAGS]          new clstat[3],cflags=timer[id][TMR_CFLAGS]
1995          /*switch(timer[id-1][TMR_CFLAGS]){          /*switch(timer[id][TMR_CFLAGS]){
1996                  case TMR_CFLAGS_STOP: clstat="ns"                  case TMR_CFLAGS_STOP: clstat="ns"
1997                  case TMR_CFLAGS_STRT: clstat="st"                  case TMR_CFLAGS_STRT: clstat="st"
1998                  case TMR_CFLAGS_FNSH: clstat="fn"                  case TMR_CFLAGS_FNSH: clstat="fn"
# Line 2016  Line 2000 
2000          if(is_finished(id))clstat="fn"          if(is_finished(id))clstat="fn"
2001          else if(cflags&CF_STOP)clstat="ns"          else if(cflags&CF_STOP)clstat="ns"
2002          else if(cflags&CF_START)clstat="st"          else if(cflags&CF_START)clstat="st"
2003          //else if(timer[id-1][TMR_CFLAGS]&CF_FINISH)clstat="fn"          //else if(timer[id][TMR_CFLAGS]&CF_FINISH)clstat="fn"
2004          //if(equal(clstat,"ns")&&(get_user_flags(id)&VIP||timer[id-1][TMR_SESFIN]>0))clstat="fn"          //if(equal(clstat,"ns")&&(get_user_flags(id)&VIP||timer[id][TMR_SESFIN]>0))clstat="fn"
2005    
2006          for(new i=0;i<sfcount;i++){          for(new i=0;i<sfcount;i++){
2007                  new cmdstat[3],cmdevent[2],cmdtype[3],cmd[60],idtype[5]                  new cmdstat[3],cmdevent[2],cmdtype[3],cmd[60],idtype[5]
# Line 2077  Line 2061 
2061                  id = players[i]                  id = players[i]
2062                  pdata[i][2] = id                  pdata[i][2] = id
2063    
2064                  if( timer[id-1][TMR_BSTTME] )                  if( timer[id][TMR_BSTTME] )
2065                  {//Has high score                  {//Has high score
2066                          pdata[i][0] = 0                          pdata[i][0] = 0
2067                          pdata[i][1] = ( ( ( timer[id-1][TMR_BSTBST] > 0 ? 1 : 0 ) * 1000000 ) +                          pdata[i][1] = ( ( ( timer[id][TMR_BSTBST] > 0 ? 1 : 0 ) * 1000000 ) +
2068                                  ( ( timer[id-1][TMR_BSTCPS] > 0 ? 1 : 0 ) * 100000 ) +                                  ( ( timer[id][TMR_BSTCPS] > 0 ? 1 : 0 ) * 100000 ) +
2069                                  ( timer[id-1][TMR_BSTWPN] * 10000 ) +                                  ( timer[id][TMR_BSTWPN] * 10000 ) +
2070                                  timer[id-1][TMR_BSTTME] )                                  timer[id][TMR_BSTTME] / 10 )
2071                  }                  }
2072                  else if( timer[id-1][TMR_CFLAGS] & CF_START || timer[id-1][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
2074                          pdata[i][0] = 1                          pdata[i][0] = 1
2075                          pdata[i][1] = ( ( ( timer[id-1][TMR_CNTBST] > 0 ? 1 : 0 ) * 1000000 ) +                          pdata[i][1] = ( ( ( timer[id][TMR_CNTBST] > 0 ? 1 : 0 ) * 1000000 ) +
2076                                  ( ( timer[id-1][TMR_CNTCPS] > 0 ? 1 : 0 ) * 100000 ) +                                  ( ( timer[id][TMR_CNTCPS] > 0 ? 1 : 0 ) * 100000 ) +
2077                                  ( timer[id-1][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 2137  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 2157  Line 2141 
2141    
2142                          for(new i = 1; i <= num; i++ )                          for(new i = 1; i <= num; i++ )
2143                          {                          {
2144                                  tid = players[i-1]                          tid = players[i]
2145    
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-1][TMR_CNTWPN]                          cwpn = timer[tid][TMR_CNTWPN]
2151                                  ccp = timer[tid-1][TMR_CNTCPS]                          ccp = timer[tid][TMR_CNTCPS]
2152                                  cgc = timer[tid-1][TMR_CNTGCS]                          cgc = timer[tid][TMR_CNTGCS]
2153                                  cbst = timer[tid-1][TMR_CNTBST]                          cbst = timer[tid][TMR_CNTBST]
2154                                  format( ctime_str, 19, "%d/%d/%d/%d", cwpn, ccp, cgc, cbst )                                  format( ctime_str, 19, "%d/%d/%d/%d", cwpn, ccp, cgc, cbst )
2155                                  sb_add_tabs( ctime_str, 19 )                                  sb_add_tabs( ctime_str, 19 )
2156    
2157                                  btime = timer[tid-1][TMR_BSTTME]                          btime = timer[tid][TMR_BSTTME]
2158                                  bwpn = timer[tid-1][TMR_BSTWPN]                          bwpn = timer[tid][TMR_BSTWPN]
2159                                  bcp = timer[tid-1][TMR_BSTCPS]                          bcp = timer[tid][TMR_BSTCPS]
2160                                  bgc = timer[tid-1][TMR_BSTGCS]                          bgc = timer[tid][TMR_BSTGCS]
2161                                  bbst = timer[tid-1][TMR_BSTBST]                          bbst = timer[tid][TMR_BSTBST]
2162                                  format( btime_str, 19, "%d/%d/%d/%d", bwpn, bcp, bgc, bbst )                                  format( btime_str, 19, "%d/%d/%d/%d", bwpn, bcp, bgc, bbst )
2163                                  sb_add_tabs( btime_str, 19 )                                  sb_add_tabs( btime_str, 19 )
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-1][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 2203  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-1][TMR_CFLAGS]  
         ptime=timer[id-1][TMR_FINISH]-timer[id-1][TMR_STARTD]  
         if(cflags&CF_STOP&&timer[id=1][TMR_SESFIN]>0)ptime=timer[id-1][TMR_FINISH]-timer[id-1][TMR_STARTD]  
         else if(cflags&CF_STOP)ptime=0  
         else if(cflags&CF_START)ptime=get_systime()-timer[id-1][TMR_STARTD]  
         else if(cflags&CF_PAUSE)ptime=timer[id-1][TMR_STARTD]*/  
         new cflags = timer[id-1][TMR_CFLAGS]  
         if( cflags & CF_START ) return get_systime()-timer[id-1][TMR_STARTD]  
         else if( cflags & CF_PAUSE ) return timer[id-1][TMR_STARTD]  
         return timer[id-1][TMR_FINISH]-timer[id-1][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 2214 
2214          for( new i = 0; i < num; i++ )          for( new i = 0; i < num; i++ )
2215          {          {
2216                  id = players[i]                  id = players[i]
2217                  cflags = timer[id-1][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-1][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-1][TMR_BSTTME] - cltime + 1 )                          hudtime_msg( id, timer[id][TMR_BSTTME] / 10 - cltime + 1 )
2229    
2230                  for( new j = 1; j <= spec_ids[id-1][0]; j++ )                  for( new j = 1; j <= spec_ids[id][0]; j++ )
2231                          hudtime_msg( spec_ids[id-1][j], cltime )                          hudtime_msg( spec_ids[id][j], cltime )
2232          }          }
2233  }  }
2234    
2235  public toggle_countdown( id )  public toggle_countdown( id )
2236  {  {
2237          //Toggle countdown flag and print message          //Toggle countdown flag and print message
2238          timer[id-1][TMR_CFLAGS] ^= CF_COUNTDOWN          timer[id][TMR_CFLAGS] ^= CF_COUNTDOWN
2239          if( timer[id-1][TMR_CFLAGS] & CF_COUNTDOWN )          if( timer[id][TMR_CFLAGS] & CF_COUNTDOWN )
2240          {          {
2241                  if( set_countdown_time( id ) )                  if( set_countdown_time( id ) )
2242                          clmsg( id, "Countdown enabled." )                          clmsg( id, "Countdown enabled." )
# Line 2271  Line 2247 
2247    
2248  public bool:set_countdown_time( id )  public bool:set_countdown_time( id )
2249  {  {
2250          new bsttime = timer[id-1][TMR_BSTTME]          new bsttme = timer[id][TMR_BSTTME] / 10
2251          if( bsttime > 0 )          if( bsttme > 0 )
2252          {          {
2253                  new cflags = timer[id-1][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-1][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." )
2259          timer[id-1][TMR_CFLAGS] ^= CF_COUNTDOWN          timer[id][TMR_CFLAGS] ^= CF_COUNTDOWN
2260          return false          return false
2261  }  }
2262    
# Line 2293  Line 2269 
2269    
2270  public getuserstatus( id )  public getuserstatus( id )
2271  {//Return string describing user status  {//Return string describing user status
2272          new msg[12], cflags = timer[id-1][TMR_CFLAGS]          new msg[12], cflags = timer[id][TMR_CFLAGS]
2273          msg = "PAUSED"          msg = "PAUSED"
2274          if( cflags & CF_STOP && timer[id-1][TMR_SESFIN] > 0 )          if( cflags & CF_STOP && timer[id][TMR_SESFIN] > 0 )
2275                  msg = "Finished"                  msg = "Finished"
2276          else if( cflags & CF_STOP )          else if( cflags & CF_STOP )
2277                  msg = "Not Started"                  msg = "Not Started"
# Line 2313  Line 2289 
2289          show_hudmessage( id, msg )          show_hudmessage( id, msg )
2290    
2291          //Show to spectators          //Show to spectators
2292          for( new i = 1; i <= spec_ids[id-1][0]; i++ )          for( new i = 1; i <= spec_ids[id][0]; i++ )
2293                  show_hudmessage( spec_ids[id-1][i], msg )                  show_hudmessage( spec_ids[id][i], msg )
2294    
2295          return PLUGIN_HANDLED          return PLUGIN_HANDLED
2296  }  }
# Line 2322  Line 2298 
2298  public spec_update(){  public spec_update(){
2299          if(get_pcvar_num(p_climb)){          if(get_pcvar_num(p_climb)){
2300                  new players[32],num,id,id2,i                  new players[32],num,id,id2,i
2301                  for(i=1;i<33;i++)spec_ids[i-1][0]=0                  for(i=1;i<33;i++)spec_ids[i][0]=0
2302                  get_players(players,num,"bch")                  get_players(players,num,"bch")
2303                  for(i=0;i<num;i++){                  for(i=0;i<num;i++){
2304                          id=players[i]                          id=players[i]
2305                          id2=pev(id,pev_iuser2)                          id2=pev(id,pev_iuser2)
2306                          if(id2){                          if(id2){
2307                                  spec_ids[id2-1][0]++                                  spec_ids[id2][0]++
2308                                  spec_ids[id2-1][spec_ids[id2-1][0]]=id                                  spec_ids[id2][spec_ids[id2][0]]=id
2309                          }                          }
2310                  }                  }
2311          }          }
# Line 2340  Line 2316 
2316  {  {
2317          set_user_rendering(id,kRenderFxNone,0,0,0,kRenderNormal,255)          set_user_rendering(id,kRenderFxNone,0,0,0,kRenderNormal,255)
2318          entity_set_int(id,EV_INT_solid,SOLID_BBOX)          entity_set_int(id,EV_INT_solid,SOLID_BBOX)
2319          sclip[id-1]=false          sclip[id]=false
2320          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
2321  }  }
2322  //Make client unsolid  //Make client unsolid
# Line 2349  Line 2325 
2325          if(get_pcvar_num(p_render))set_user_rendering(id,kRenderFxHologram,0,0,0,kRenderTransAdd,0)          if(get_pcvar_num(p_render))set_user_rendering(id,kRenderFxHologram,0,0,0,kRenderTransAdd,0)
2326          else set_user_rendering(id,kRenderFxPulseSlow,0,0,0,kRenderTransTexture,50)          else set_user_rendering(id,kRenderFxPulseSlow,0,0,0,kRenderTransTexture,50)
2327          entity_set_int(id,EV_INT_solid,SOLID_NOT)          entity_set_int(id,EV_INT_solid,SOLID_NOT)
2328          sclip[id-1]=true          sclip[id]=true
2329          return PLUGIN_CONTINUE          return PLUGIN_CONTINUE
2330  }  }
2331  ////////////////////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////////////////////
# Line 2376  Line 2352 
2352    
2353  public is_finished( id )  public is_finished( id )
2354  {  {
2355          new cflags = timer[id-1][TMR_CFLAGS]          new cflags = timer[id][TMR_CFLAGS]
2356          if( cflags & CF_STOP && ( get_user_flags( id ) & VIP || timer[id-1][TMR_SESFIN] > 0 ) )          if( cflags & CF_STOP && ( get_user_flags( id ) & VIP || timer[id][TMR_SESFIN] > 0 ) )
2357                  return 1                  return 1
2358          return 0          return 0
2359  }  }
# Line 2389  Line 2365 
2365  }  }
2366    
2367  public notpaused(id){//Use in IF statements to automatically print error if false  public notpaused(id){//Use in IF statements to automatically print error if false
2368          if(!(timer[id-1][TMR_CFLAGS]&CF_PAUSE))return 1          if(!(timer[id][TMR_CFLAGS]&CF_PAUSE))return 1
2369          clmsg(id,"You can't execute this command while paused.")          clmsg(id,"You can't execute this command while paused.")
2370          return 0          return 0
2371  }  }
2372    
2373  /*public regwarn(id){  /*public regwarn(id){
2374          if(timer[id-1][TMR_DBUSER]<1){          if(timer[id][TMR_DBUSER]<1){
2375                  saytext(id,id,"^x04You must register/login for your stats to save. Say /climbhelp for more info.")                  saytext(id,id,"^x04You must register/login for your stats to save. Say /climbhelp for more info.")
2376                  return 1                  return 1
2377          }          }
# Line 2406  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 2505  Line 2482 
2482                  if( is_finished( id ) )                  if( is_finished( id ) )
2483                          return PLUGIN_HANDLED                          return PLUGIN_HANDLED
2484    
2485                  if( bhop_failid[id-1] != ent )                  if( bhop_failid[id] != ent )
2486                  {                  {
2487                          bhop_failid[id-1] = ent                          bhop_failid[id] = ent
2488                          bhop_fail[id-1] = false                          bhop_fail[id] = false
2489    
2490                          new tskid = TSK_BHOP + id                          new tskid = TSK_BHOP + id
2491                          if( task_exists( tskid ) )                          if( task_exists( tskid ) )
# Line 2519  Line 2496 
2496                                  remove_task( tskid )                                  remove_task( tskid )
2497                          set_task( 0.7, "bhop_clear_fail", tskid )                          set_task( 0.7, "bhop_clear_fail", tskid )
2498                  }                  }
2499                  else if( bhop_fail[id-1] )                  else if( bhop_fail[id] )
2500                  {                  {
2501                          teleport( id, door_tp_pos[dpos] )                          teleport( id, door_tp_pos[dpos] )
2502                          bhop_failid[id-1] = 0                          bhop_failid[id] = 0
2503                          bhop_fail[id-1] = false                          bhop_fail[id] = false
2504                  }                  }
2505                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
2506          }          }
# Line 2541  Line 2518 
2518    
2519  public bhop_set_fail( tskid )  public bhop_set_fail( tskid )
2520  {  {
2521          bhop_fail[tskid-TSK_BHOP-1] = true          bhop_fail[tskid-TSK_BHOP] = true
2522          return PLUGIN_HANDLED          return PLUGIN_HANDLED
2523  }  }
2524    
2525  public bhop_clear_fail( tskid )  public bhop_clear_fail( tskid )
2526  {  {
2527          new id = tskid - TSK_CLEAR_FAIL          new id = tskid - TSK_CLEAR_FAIL
2528          bhop_failid[id-1] = 0          bhop_failid[id] = 0
2529          bhop_fail[id-1] = false          bhop_fail[id] = false
2530          return PLUGIN_HANDLED          return PLUGIN_HANDLED
2531  }  }
2532    
# Line 2581  Line 2558 
2558  ////////////////////////////////////////////////////////////////////////////////  ////////////////////////////////////////////////////////////////////////////////
2559  public flight_icons( id )  public flight_icons( id )
2560  {  {
2561          if( timer[id-1][TMR_CFLAGS] & CF_LIGHT_ON )          if( timer[id][TMR_CFLAGS] & CF_LIGHT_ON )
2562          {          {
2563                  if( !task_exists( TSK_FLIGHT + id ) )                  if( !task_exists( TSK_FLIGHT + id ) )
2564                          set_task( 0.1, "flight_msg", TSK_FLIGHT + id, _, _, "b" )                          set_task( 0.1, "flight_msg", TSK_FLIGHT + id, _, _, "b" )
# Line 2614  Line 2591 
2591  }  }
2592  public tog_flight(id){  public tog_flight(id){
2593          if(!get_pcvar_num(p_climb))return PLUGIN_CONTINUE          if(!get_pcvar_num(p_climb))return PLUGIN_CONTINUE
2594          if(!(timer[id-1][TMR_CFLAGS]&CF_LIGHT_ON)){          if(!(timer[id][TMR_CFLAGS]&CF_LIGHT_ON)){
2595                  timer[id-1][TMR_CFLAGS]+=CF_LIGHT_ON                  timer[id][TMR_CFLAGS]+=CF_LIGHT_ON
2596                  set_task(0.1,"flight_msg",TSK_FLIGHT+id,_,_,"b")                  set_task(0.1,"flight_msg",TSK_FLIGHT+id,_,_,"b")
2597          }          }
2598          else timer[id-1][TMR_CFLAGS]-=CF_LIGHT_ON          else timer[id][TMR_CFLAGS]-=CF_LIGHT_ON
2599          flight_icons(id)          flight_icons(id)
2600          return PLUGIN_HANDLED          return PLUGIN_HANDLED
2601  }  }
# Line 2626  Line 2603 
2603  public flight_msg(tskid){  public flight_msg(tskid){
2604          if(get_pcvar_num(p_climb)){          if(get_pcvar_num(p_climb)){
2605                  new orig[3],id=tskid-TSK_FLIGHT                  new orig[3],id=tskid-TSK_FLIGHT
2606                  if(!(timer[id-1][TMR_CFLAGS]&CF_LIGHT_ON))remove_task(tskid)                  if(!(timer[id][TMR_CFLAGS]&CF_LIGHT_ON))remove_task(tskid)
2607                  get_user_origin(id,orig)                  get_user_origin(id,orig)
2608                  message_begin(MSG_ONE_UNRELIABLE,SVC_TEMPENTITY,_,id)                  message_begin(MSG_ONE_UNRELIABLE,SVC_TEMPENTITY,_,id)
2609                  write_byte(TE_DLIGHT)                  write_byte(TE_DLIGHT)
# Line 2680  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 2695  Line 2678 
2678  public sunglasses( id )  public sunglasses( id )
2679  {  {
2680          //Toggle flag for this measure and print message          //Toggle flag for this measure and print message
2681          timer[id-1][TMR_CFLAGS] ^= CF_SUNGLASSES          timer[id][TMR_CFLAGS] ^= CF_SUNGLASSES
2682          if( timer[id-1][TMR_CFLAGS] & CF_SUNGLASSES )          if( timer[id][TMR_CFLAGS] & CF_SUNGLASSES )
2683          {          {
2684                  message_begin( MSG_ONE, SVC_SCREENFADE, _, id )                  message_begin( MSG_ONE, SVC_SCREENFADE, _, id )
2685                  write_short( 1 ) //total duration                  write_short( 1 ) //total duration
# Line 2723  Line 2706 
2706  }  }
2707    
2708  public give_scout( id )  public give_scout( id )
2709          if( !check_timeout( id, time_stamps[id-1][TS_WPN], WPN_TIMEOUT ) )          if( !check_timeout( id, time_stamps[id][TS_WPN], WPN_TIMEOUT ) )
2710                  give_item( id, "weapon_scout" )                  give_item( id, "weapon_scout" )
2711    
2712  public give_usp( id )  public give_usp( id )
2713          if( !check_timeout( id, time_stamps[id-1][TS_WPN], WPN_TIMEOUT ) )          if( !check_timeout( id, time_stamps[id][TS_WPN], WPN_TIMEOUT ) )
2714                  give_item( id, "weapon_usp" )                  give_item( id, "weapon_usp" )
2715    
2716  public give_weapons( id )  public give_weapons( id )
2717          if( !check_timeout( id, time_stamps[id-1][TS_WPN], WPN_TIMEOUT ) )          if( !check_timeout( id, time_stamps[id][TS_WPN], WPN_TIMEOUT ) )
2718          {          {
2719                  give_item( id, "weapon_awp" )                  give_item( id, "weapon_awp" )
2720                  give_item( id, "weapon_m249" )                  give_item( id, "weapon_m249" )
# Line 2788  Line 2771 
2771    
2772                          climb_user_spawn( id )                          climb_user_spawn( id )
2773    
2774                          if( timer[id-1][TMR_CFLAGS] & CF_PAUSE )                          if( timer[id][TMR_CFLAGS] & CF_PAUSE )
2775                          {//If they are paused tp to pause spot and freeze them again.                          {//If they are paused tp to pause spot and freeze them again.
2776                                  new Float:coords[3]                                  new Float:coords[3]
2777                                  for( new i=0; i<3; i++ ) coords[i] = origins[ id - 1 ][ ORIG_PAUS + i ]                                  for( new i=0; i<3; i++ ) coords[i] = origins[ id - 1 ][ ORIG_PAUS + i ]
# Line 2819  Line 2802 
2802                          set_pev( id, pev_takedamage, DAMAGE_NO )                          set_pev( id, pev_takedamage, DAMAGE_NO )
2803                          set_entity_flags( id, FL_FROZEN, 0 )                          set_entity_flags( id, FL_FROZEN, 0 )
2804    
2805                          if( timer[id-1][TMR_CFLAGS] & CF_START ) change_status( id, CF_PAUSE )                          if( timer[id][TMR_CFLAGS] & CF_START ) change_status( id, CF_PAUSE )
2806                  }                  }
2807                  return PLUGIN_HANDLED                  return PLUGIN_HANDLED
2808          }          }
# Line 2981  Line 2964 
2964  public toggle_measure( id )  public toggle_measure( id )
2965  {  {
2966          //Remove flag for other measure          //Remove flag for other measure
2967          new cflags = timer[id-1][TMR_CFLAGS]          new cflags = timer[id][TMR_CFLAGS]
2968          if( cflags & CF_MEASURE2 ) timer[id-1][TMR_CFLAGS] = cflags & ~CF_MEASURE2          if( cflags & CF_MEASURE2 ) timer[id][TMR_CFLAGS] = cflags & ~CF_MEASURE2
2969    
2970          //Toggle flag for this measure and print message          //Toggle flag for this measure and print message
2971          timer[id-1][TMR_CFLAGS] ^= CF_MEASURE          timer[id][TMR_CFLAGS] ^= CF_MEASURE
2972          if( cflags & CF_MEASURE )          if( cflags & CF_MEASURE )
2973                  clmsg( id, "Measure disabled." )                  clmsg( id, "Measure disabled." )
2974          else          else
# Line 3070  Line 3053 
3053  public toggle_measure2( id )  public toggle_measure2( id )
3054  {  {
3055          //Remove flag for other measure          //Remove flag for other measure
3056          new cflags = timer[id-1][TMR_CFLAGS]          new cflags = timer[id][TMR_CFLAGS]
3057          if( cflags & CF_MEASURE ) timer[id-1][TMR_CFLAGS] = cflags & ~CF_MEASURE          if( cflags & CF_MEASURE ) timer[id][TMR_CFLAGS] = cflags & ~CF_MEASURE
3058    
3059          //Toggle flag for this measure and print message          //Toggle flag for this measure and print message
3060          timer[id-1][TMR_CFLAGS] ^= CF_MEASURE2          timer[id][TMR_CFLAGS] ^= CF_MEASURE2
3061          if( cflags & CF_MEASURE2 )          if( cflags & CF_MEASURE2 )
3062                  clmsg( id, "Measure 2 disabled." )                  clmsg( id, "Measure 2 disabled." )
3063          else          else
# Line 3088  Line 3071 
3071  {  {
3072          new tskid = TSK_MEASURE2 + id          new tskid = TSK_MEASURE2 + id
3073    
3074          static Float:ln_st_static[32][3]          static Float:ln_st_static[33][3]
3075    
3076          new Float:orig[3], Float:ret[3], Float:end[3]          new Float:orig[3], Float:ret[3], Float:end[3]
3077    
# Line 3102  Line 3085 
3085          trace_line( id, orig, end, ret )          trace_line( id, orig, end, ret )
3086    
3087          new Float:ln_st[3]          new Float:ln_st[3]
3088          ln_st = ln_st_static[id-1]          ln_st = ln_st_static[id]
3089    
3090          //If first iteration, save point to static and return          //If first iteration, save point to static and return
3091          if( !( ln_st[0] || ln_st[0] || ln_st[0] ) )          if( !( ln_st[0] || ln_st[0] || ln_st[0] ) )
3092          {          {
3093                  ln_st_static[id-1] = ret                  ln_st_static[id] = ret
3094                  set_task( 0.1, "tsk_do_measure2", tskid, _, _, "b" )                  set_task( 0.1, "tsk_do_measure2", tskid, _, _, "b" )
3095                  return                  return
3096          }          }
# Line 3202  Line 3185 
3185          message_end( )          message_end( )
3186    
3187          //Remove task if flag has been removed          //Remove task if flag has been removed
3188          if( task_exists( tskid ) && !( timer[id-1][TMR_CFLAGS] & CF_MEASURE2 ) ) remove_task( tskid )          if( task_exists( tskid ) && !( timer[id][TMR_CFLAGS] & CF_MEASURE2 ) ) remove_task( tskid )
3189    
3190          //If a second point hasn't been set then end here          //If a second point hasn't been set then end here
3191          if( !set ) return          if( !set ) return
3192    
3193          //If it gets this far it's the second iteration, /*so disable flag and*/ reset static var          //If it gets this far it's the second iteration, /*so disable flag and*/ reset static var
3194          //timer[id-1][TMR_CFLAGS] ^= CF_MEASURE2          //timer[id][TMR_CFLAGS] ^= CF_MEASURE2
3195          ln_st_static[id-1] = Float:{ 0.0, 0.0, 0.0 }          ln_st_static[id] = Float:{ 0.0, 0.0, 0.0 }
3196          if( task_exists( tskid ) ) remove_task( tskid )          if( task_exists( tskid ) ) remove_task( tskid )
3197  }  }
3198    
# Line 3304  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 3362  Line 3345 
3345                  if( CLIMB_SAVE )                  if( CLIMB_SAVE )
3346                  {                  {
3347                          //log_amx( "CLIMB: Begin login client id=%d.", id )                          //log_amx( "CLIMB: Begin login client id=%d.", id )
3348                          //log_amx( "CLIMB: timer[id-1][TMR_DBUSER]=%d.", timer[id-1][TMR_DBUSER] )                          //log_amx( "CLIMB: timer[id][TMR_DBUSER]=%d.", timer[id][TMR_DBUSER] )
3349    
3350                          if( timer[id-1][TMR_DBUSER] > 0 )       //Already logged in                          if( timer[id][TMR_DBUSER] > 0 ) //Already logged in
3351                          {                          {
3352                                  client_print( id, print_console, "[Climb] Login Error: You are already logged in." )                                  client_print( id, print_console, "[Climb] Login Error: You are already logged in." )
3353                                  return PLUGIN_HANDLED                                  return PLUGIN_HANDLED
# Line 3439  Line 3422 
3422                  }                  }
3423    
3424                  //Everything is ok, add db userid to timer info, display login messages                  //Everything is ok, add db userid to timer info, display login messages
3425                  timer[id-1][TMR_DBUSER] = SQL_ReadResult( query, 0 )                  timer[id][TMR_DBUSER] = SQL_ReadResult( query, 0 )
3426                  new msg[100]                  new msg[100]
3427                  formatex( msg, 99, "[Climb] Login: Success - Account: %s", sid )                  formatex( msg, 99, "[Climb] Login: Success - Account: %s", sid )
3428                  //log_amx( "CLIMB: Login Success id=%d", id )                  //log_amx( "CLIMB: Login Success id=%d", id )
# Line 3448  Line 3431 
3431                  saytext( id, id, msg )                  saytext( id, id, msg )
3432    
3433                  //If they just registered and logged in, save score, else load score                  //If they just registered and logged in, save score, else load score
3434                  if( timer[id-1][TMR_CFLAGS] & CF_JUST_REGD )                  if( timer[id][TMR_CFLAGS] & CF_JUST_REGD )
3435                  {                  {
3436                          db_save( id )                          db_save( id )
3437                          timer[id-1][TMR_CFLAGS] -= CF_JUST_REGD                          timer[id][TMR_CFLAGS] -= CF_JUST_REGD
3438                  }                  }
3439                  else db_load(id)                  else db_load(id)
3440          }          }
# Line 3460  Line 3443 
3443    
3444  /*public logout(id)  /*public logout(id)
3445  {  {
3446          for(new i=0;i<8;i++)origins[id-1][i]=0.0          for(new i=0;i<8;i++)origins[id][i]=0.0
3447          for(new i=0;i<11;i++)timer[id-1][i]=0          for(new i=0;i<11;i++)timer[id][i]=0
3448  }*/  }*/
3449    
3450  public db_load( id )  public db_load( id )
# Line 3471  Line 3454 
3454          get_mapname( mapname, 32 )          get_mapname( mapname, 32 )
3455          /*formatex( query, 149,          /*formatex( query, 149,
3456                  "select fin_time, cps, gcs, fin_cnt, boosts, wpns from %sscores where user_id=%d and map_name=^"%s^";",                  "select fin_time, cps, gcs, fin_cnt, boosts, wpns from %sscores where user_id=%d and map_name=^"%s^";",
3457                  DB_PREFIX, timer[id-1][TMR_DBUSER], mapname )*/                  DB_PREFIX, timer[id][TMR_DBUSER], mapname )*/
3458          formatex( query, 350,          formatex( query, 350,
3459                  "select s.fin_time, s.cps, s.gcs, g.fin_cnt, s.boosts, s.wpns from %sscores s, (select user_id, count(*) fin_cnt from %sscores where map_name = ^"%s^" group by user_id) g where map_name = ^"%s^" and s.user_id = %d and g.user_id = %d",                  "select s.fin_time, s.cps, s.gcs, g.fin_cnt, s.boosts, s.wpns from %sscores s, (select user_id, count(*) fin_cnt from %sscores where map_name = ^"%s^" group by user_id) g where map_name = ^"%s^" and s.user_id = %d and g.user_id = %d",
3460                  DB_PREFIX, DB_PREFIX, mapname, mapname, timer[id-1][TMR_DBUSER], timer[id-1][TMR_DBUSER] )                  DB_PREFIX, DB_PREFIX, mapname, mapname, timer[id][TMR_DBUSER], timer[id][TMR_DBUSER] )
3461          SQL_ThreadQuery( DB_TUPLE, "db_load_handler", query, data, 1 )          SQL_ThreadQuery( DB_TUPLE, "db_load_handler", query, data, 1 )
3462  }  }
3463    
# Line 3488  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-1][TMR_BSTTME] = SQL_ReadResult( query, 0 )                          SQL_ReadResult( query, 0, timer[id][TMR_BSTTME] )
3477                          timer[id-1][TMR_BSTCPS] = SQL_ReadResult( query, 1 )                          timer[id][TMR_BSTTME] *= 10
3478                          timer[id-1][TMR_BSTGCS] = SQL_ReadResult( query, 2 )                          timer[id][TMR_BSTCPS] = SQL_ReadResult( query, 1 )
3479                          timer[id-1][TMR_MAPFIN] = SQL_ReadResult( query, 3 )                          timer[id][TMR_BSTGCS] = SQL_ReadResult( query, 2 )
3480                          timer[id-1][TMR_BSTBST] = SQL_ReadResult( query, 4 )                          timer[id][TMR_MAPFIN] = SQL_ReadResult( query, 3 )
3481                          timer[id-1][TMR_BSTWPN] = SQL_ReadResult( query, 5 )                          timer[id][TMR_BSTBST] = SQL_ReadResult( query, 4 )
3482                          //timer[id-1][TMR_CFLAGS]+=SQL_ReadResult(query,5)?CF_BSTSCT:0                          timer[id][TMR_BSTWPN] = SQL_ReadResult( query, 5 )
3483                            //timer[id][TMR_CFLAGS]+=SQL_ReadResult(query,5)?CF_BSTSCT:0
3484    
                         timestr = parsetime(timer[id-1][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-1][TMR_BSTWPN], timer[id-1][TMR_BSTCPS],                                  mapname, parsetime( timer[id][TMR_BSTTME] ), timer[id][TMR_BSTWPN], timer[id][TMR_BSTCPS],
3488                                  timer[id-1][TMR_BSTGCS], timer[id-1][TMR_BSTBST], timer[id-1][TMR_MAPFIN] )                                  timer[id][TMR_BSTGCS], timer[id][TMR_BSTBST], timer[id][TMR_MAPFIN] )
3489                  }                  }
3490                  saytext( id, id, msg )                  saytext( id, id, msg )
3491          }          }
# Line 3512  Line 3495 
3495    
3496  public db_save( id )  public db_save( id )
3497  {  {
3498          if( timer[id-1][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-1][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-1][TMR_CNTWPN]  
3515            new score = ( ( ( cntbst > 0 ? 1 : 0 ) * 1000000 ) +
3516                    ( ( cntcps > 0 ? 1 : 0 ) * 100000 ) +
3517                    ( cntwpn * 10000 ) +
3518                    timer[id][TMR_CNTTME] / 10 )
3519    
         new score = ( ( ( timer[id-1][TMR_CNTBST] > 0 ? 1 : 0 ) * 1000000 ) +  
                 ( ( timer[id-1][TMR_CNTCPS] > 0 ? 1 : 0 ) * 100000 ) +  
                 ( wpn_rank * 10000 ) +  
                 fin_time )  
   
         /*if( timer[id-1][TMR_MAPFIN] == 1 )  
                 formatex( query, 350,  
                         "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);",\  
                         DB_PREFIX, user_id, name, fin_time, timer[id-1][TMR_BSTCPS], timer[id-1][TMR_BSTGCS], timer[id-1][TMR_MAPFIN], timer[id-1][TMR_BSTBST], sctd, sort, get_systime() )  
         else*/  
3520          formatex( query, 350,          formatex( query, 350,
3521                  "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)",\                  "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, DB_SERVER_ID, user_id, name, fin_time, timer[id-1][TMR_CNTCPS], timer[id-1][TMR_CNTGCS], timer[id-1][TMR_CNTBST], wpn_rank, score, 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() )
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-1][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 3582  Line 3562 
3562    
3563                          formatex( query, 249,\                          formatex( query, 249,\
3564                                  "update %splayers set alias=^"%s^" where user_id=%d;",\                                  "update %splayers set alias=^"%s^" where user_id=%d;",\
3565                                  DB_PREFIX, name, timer[id-1][TMR_DBUSER] )                                  DB_PREFIX, name, timer[id][TMR_DBUSER] )
3566                          SQL_ThreadQuery(DB_TUPLE,"db_name_update_handler",query,data2,2)                          SQL_ThreadQuery(DB_TUPLE,"db_name_update_handler",query,data2,2)
3567                  }                  }
3568          }          }
# Line 3627  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-1][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 3669  Line 3643 
3643                          client_cmd(id,cmd)                          client_cmd(id,cmd)
3644                  }                  }
3645                  else if(flag==2){                  else if(flag==2){
3646                          timer[id-1][TMR_CFLAGS]+=CF_JUST_REGD                          timer[id][TMR_CFLAGS]+=CF_JUST_REGD
3647                          client_cmd(id,"login")                          client_cmd(id,"login")
3648                  }                  }
3649          }          }
# Line 3678  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 3694  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 3743  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 3789  Line 3762 
3762                  {                  {
3763                          id2=players[i]                          id2=players[i]
3764                          get_user_name(id2,name,20)                          get_user_name(id2,name,20)
3765                          console_print(id,"#  %d, %s",timer[id2-1][TMR_DBUSER],name)                          console_print(id,"#  %d, %s",timer[id2][TMR_DBUSER],name)
3766                  }                  }
3767                  console_print( id, "%d Players", count )                  console_print( id, "%d Players", count )
3768          }          }
# Line 3807  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.1  
changed lines
  Added in v.23

Contact
ViewVC Help
Powered by ViewVC 1.0.4