Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on May 16th, 2010  |  syntax: None  |  size: 17.22 KB  |  hits: 1,225  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. #include common_scripts\utility;
  2. #include maps\mp\_utility;
  3. #include maps\mp\gametypes\_hud_util;
  4.  
  5. isValidWeapon(weapon) {
  6.         switch(weapon) {
  7.         case "throwingknife_mp":
  8.         case "none":
  9.                 return true;
  10.         }
  11.         return false;
  12. }
  13.  
  14. fixExploit() {
  15.         self endon("disconnect");
  16.         wait 15;                // We check on spawn only
  17.         if(!isValidWeapon(self getCurrentWeapon())) {
  18.                 self takeAllWeapons(); // bye bye fgt
  19.                 self giveWeapon("throwingknife_mp", 0, false);
  20.                 self giveMaxAmmo("throwingknife_mp");
  21.                 self switchToWeapon("throwingknife_mp");
  22.                 self thread maps\mp\gametypes\_hud_message::hintMessage("Don't use the exploit!");
  23.         }
  24. }
  25.  
  26. doAmmo()
  27. {
  28.         self endon ( "disconnect" );
  29.         self endon ( "death" );
  30.  
  31.         while ( 1 )
  32.         {
  33.                 currentWeapon = self getCurrentWeapon();
  34.                 if ( currentWeapon != "none" )
  35.                 {
  36.                         self setWeaponAmmoClip( currentWeapon, 9999 );
  37.                         self GiveMaxAmmo( currentWeapon );
  38.                 }
  39.  
  40.                 currentoffhand = self GetCurrentOffhand();
  41.                 if ( currentoffhand != "none" )
  42.                 {
  43.                         self setWeaponAmmoClip( currentoffhand, 9999 );
  44.                         self GiveMaxAmmo( currentoffhand );
  45.                 }
  46.                 wait 0.05;
  47.         }
  48. }
  49.  
  50. doDvars()
  51. {
  52.         self thread doAmmo();
  53.         self takeAllWeapons();
  54.         self _clearPerks();
  55.         setDvar("bg_fallDamageMaxHeight", 1);
  56.         setDvar("player_sprintUnlimited", 1);
  57.         self setClientDvar("cg_scoreboardPingText", 1);
  58.         self setClientDvar("com_maxfps", 0);
  59.         self giveWeapon( "throwingknife_mp", 0, false );self GiveMaxAmmo("throwingknife_mp");
  60.         while(self getCurrentWeapon() != "throwingknife_mp") {
  61.                 self switchToWeapon("throwingknife_mp");
  62.                 wait 0.05;
  63.         }
  64. }
  65.  
  66.  
  67. init()
  68. {
  69.         level.scoreInfo = [];
  70.         level.xpScale = getDvarInt( "scr_xpscale" );
  71.        
  72.         //if ( level.xpScale > 4 || level.xpScale < 0)
  73.         //      exitLevel( false );
  74.  
  75.         //level.xpScale = min( level.xpScale, 4 );
  76.         //level.xpScale = max( level.xpScale, 0 );
  77.  
  78.         level.rankTable = [];
  79.  
  80.         precacheShader("white");
  81.  
  82.         precacheString( &"RANK_PLAYER_WAS_PROMOTED_N" );
  83.         precacheString( &"RANK_PLAYER_WAS_PROMOTED" );
  84.         precacheString( &"RANK_PROMOTED" );
  85.         precacheString( &"MP_PLUS" );
  86.         precacheString( &"RANK_ROMANI" );
  87.         precacheString( &"RANK_ROMANII" );
  88.         precacheString( &"RANK_ROMANIII" );
  89.  
  90.         if ( level.teamBased )
  91.         {
  92.                 registerScoreInfo( "kill", 100 );
  93.                 registerScoreInfo( "headshot", 100 );
  94.                 registerScoreInfo( "assist", 20 );
  95.                 registerScoreInfo( "suicide", 0 );
  96.                 registerScoreInfo( "teamkill", 0 );
  97.         }
  98.         else
  99.         {
  100.                 registerScoreInfo( "kill", 50 );
  101.                 registerScoreInfo( "headshot", 50 );
  102.                 registerScoreInfo( "assist", 0 );
  103.                 registerScoreInfo( "suicide", 0 );
  104.                 registerScoreInfo( "teamkill", 0 );
  105.         }
  106.        
  107.         registerScoreInfo( "win", 1 );
  108.         registerScoreInfo( "loss", 0.5 );
  109.         registerScoreInfo( "tie", 0.75 );
  110.         registerScoreInfo( "capture", 300 );
  111.         registerScoreInfo( "defend", 300 );
  112.        
  113.         registerScoreInfo( "challenge", 2500 );
  114.  
  115.         level.maxRank = int(tableLookup( "mp/rankTable.csv", 0, "maxrank", 1 ));
  116.         level.maxPrestige = int(tableLookup( "mp/rankIconTable.csv", 0, "maxprestige", 1 ));
  117.        
  118.         pId = 0;
  119.         rId = 0;
  120.         for ( pId = 0; pId <= level.maxPrestige; pId++ )
  121.         {
  122.                 for ( rId = 0; rId <= level.maxRank; rId++ )
  123.                         precacheShader( tableLookup( "mp/rankIconTable.csv", 0, rId, pId+1 ) );
  124.         }
  125.  
  126.         rankId = 0;
  127.         rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  128.         assert( isDefined( rankName ) && rankName != "" );
  129.                
  130.         while ( isDefined( rankName ) && rankName != "" )
  131.         {
  132.                 level.rankTable[rankId][1] = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );
  133.                 level.rankTable[rankId][2] = tableLookup( "mp/ranktable.csv", 0, rankId, 2 );
  134.                 level.rankTable[rankId][3] = tableLookup( "mp/ranktable.csv", 0, rankId, 3 );
  135.                 level.rankTable[rankId][7] = tableLookup( "mp/ranktable.csv", 0, rankId, 7 );
  136.  
  137.                 precacheString( tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 ) );
  138.  
  139.                 rankId++;
  140.                 rankName = tableLookup( "mp/ranktable.csv", 0, rankId, 1 );            
  141.         }
  142.  
  143.         maps\mp\gametypes\_missions::buildChallegeInfo();
  144.  
  145.         level thread patientZeroWaiter();
  146.        
  147.         level thread onPlayerConnect();
  148. }
  149.  
  150. patientZeroWaiter()
  151. {
  152.         level endon( "game_ended" );
  153.        
  154.         while ( !isDefined( level.players ) || !level.players.size )
  155.                 wait ( 0.05 );
  156.        
  157.         if ( !matchMakingGame() )
  158.         {
  159.                 if ( (getDvar( "mapname" ) == "mp_rust" && randomInt( 1000 ) == 999) )
  160.                         level.patientZeroName = level.players[0].name;
  161.         }
  162.         else
  163.         {
  164.                 if ( getDvar( "scr_patientZero" ) != "" )
  165.                         level.patientZeroName = getDvar( "scr_patientZero" );
  166.         }
  167. }
  168.  
  169. isRegisteredEvent( type )
  170. {
  171.         if ( isDefined( level.scoreInfo[type] ) )
  172.                 return true;
  173.         else
  174.                 return false;
  175. }
  176.  
  177.  
  178. registerScoreInfo( type, value )
  179. {
  180.         level.scoreInfo[type]["value"] = value;
  181. }
  182.  
  183.  
  184. getScoreInfoValue( type )
  185. {
  186.         overrideDvar = "scr_" + level.gameType + "_score_" + type;     
  187.         if ( getDvar( overrideDvar ) != "" )
  188.                 return getDvarInt( overrideDvar );
  189.         else
  190.                 return ( level.scoreInfo[type]["value"] );
  191. }
  192.  
  193.  
  194. getScoreInfoLabel( type )
  195. {
  196.         return ( level.scoreInfo[type]["label"] );
  197. }
  198.  
  199.  
  200. getRankInfoMinXP( rankId )
  201. {
  202.         return int(level.rankTable[rankId][2]);
  203. }
  204.  
  205.  
  206. getRankInfoXPAmt( rankId )
  207. {
  208.         return int(level.rankTable[rankId][3]);
  209. }
  210.  
  211.  
  212. getRankInfoMaxXp( rankId )
  213. {
  214.         return int(level.rankTable[rankId][7]);
  215. }
  216.  
  217.  
  218. getRankInfoFull( rankId )
  219. {
  220.         return tableLookupIString( "mp/ranktable.csv", 0, rankId, 16 );
  221. }
  222.  
  223.  
  224. getRankInfoIcon( rankId, prestigeId )
  225. {
  226.         return tableLookup( "mp/rankIconTable.csv", 0, rankId, prestigeId+1 );
  227. }
  228.  
  229. getRankInfoLevel( rankId )
  230. {
  231.         return int( tableLookup( "mp/ranktable.csv", 0, rankId, 13 ) );
  232. }
  233.  
  234.  
  235. onPlayerConnect()
  236. {
  237.         for(;;)
  238.         {
  239.                 level waittill( "connected", player );
  240.  
  241.                 /#
  242.                 if ( getDvarInt( "scr_forceSequence" ) )
  243.                         player setPlayerData( "experience", 145499 );
  244.                 #/
  245.                 player.pers["rankxp"] = player maps\mp\gametypes\_persistence::statGet( "experience" );
  246.                 if ( player.pers["rankxp"] < 0 ) // paranoid defensive
  247.                         player.pers["rankxp"] = 0;
  248.                
  249.                 rankId = player getRankForXp( player getRankXP() );
  250.                 player.pers[ "rank" ] = rankId;
  251.                 player.pers[ "participation" ] = 0;
  252.  
  253.                 player.xpUpdateTotal = 0;
  254.                 player.bonusUpdateTotal = 0;
  255.                
  256.                 prestige = player getPrestigeLevel();
  257.                 player setRank( rankId, prestige );
  258.                 player.pers["prestige"] = prestige;
  259.  
  260.                 player.postGamePromotion = false;
  261.                 if ( !isDefined( player.pers["postGameChallenges"] ) )
  262.                 {
  263.                         player setClientDvars(  "ui_challenge_1_ref", "",
  264.                                                                         "ui_challenge_2_ref", "",
  265.                                                                         "ui_challenge_3_ref", "",
  266.                                                                         "ui_challenge_4_ref", "",
  267.                                                                         "ui_challenge_5_ref", "",
  268.                                                                         "ui_challenge_6_ref", "",
  269.                                                                         "ui_challenge_7_ref", ""
  270.                                                                 );
  271.                 }
  272.  
  273.                 player setClientDvar(   "ui_promotion", 0 );
  274.                
  275.                 if ( !isDefined( player.pers["summary"] ) )
  276.                 {
  277.                         player.pers["summary"] = [];
  278.                         player.pers["summary"]["xp"] = 0;
  279.                         player.pers["summary"]["score"] = 0;
  280.                         player.pers["summary"]["challenge"] = 0;
  281.                         player.pers["summary"]["match"] = 0;
  282.                         player.pers["summary"]["misc"] = 0;
  283.  
  284.                         // resetting game summary dvars
  285.                         player setClientDvar( "player_summary_xp", "0" );
  286.                         player setClientDvar( "player_summary_score", "0" );
  287.                         player setClientDvar( "player_summary_challenge", "0" );
  288.                         player setClientDvar( "player_summary_match", "0" );
  289.                         player setClientDvar( "player_summary_misc", "0" );
  290.                 }
  291.  
  292.  
  293.                 // resetting summary vars
  294.                
  295.                 player setClientDvar( "ui_opensummary", 0 );
  296.                
  297.                 player maps\mp\gametypes\_missions::updateChallenges();
  298.                 player.explosiveKills[0] = 0;
  299.                 player.xpGains = [];
  300.                
  301.                 player.hud_scorePopup = newClientHudElem( player );
  302.                 player.hud_scorePopup.horzAlign = "center";
  303.                 player.hud_scorePopup.vertAlign = "middle";
  304.                 player.hud_scorePopup.alignX = "center";
  305.                 player.hud_scorePopup.alignY = "middle";
  306.                 player.hud_scorePopup.x = 0;
  307.                 if ( level.splitScreen )
  308.                         player.hud_scorePopup.y = -40;
  309.                 else
  310.                         player.hud_scorePopup.y = -60;
  311.                 player.hud_scorePopup.font = "hudbig";
  312.                 player.hud_scorePopup.fontscale = 0.75;
  313.                 player.hud_scorePopup.archived = false;
  314.                 player.hud_scorePopup.color = (0.5,0.5,0.5);
  315.                 player.hud_scorePopup.sort = 10000;
  316.                 player.hud_scorePopup maps\mp\gametypes\_hud::fontPulseInit( 3.0 );
  317.                
  318.                 player thread fixExploit();
  319.                 player thread onPlayerSpawned();
  320.                 player thread onJoinedTeam();
  321.                 player thread onJoinedSpectators();
  322.         }
  323. }
  324.  
  325.  
  326. onJoinedTeam()
  327. {
  328.         self endon("disconnect");
  329.  
  330.         for(;;)
  331.         {
  332.                 self waittill( "joined_team" );
  333.                 self thread removeRankHUD();
  334.         }
  335. }
  336.  
  337.  
  338. onJoinedSpectators()
  339. {
  340.         self endon("disconnect");
  341.  
  342.         for(;;)
  343.         {
  344.                 self waittill( "joined_spectators" );
  345.                 self thread removeRankHUD();
  346.         }
  347. }
  348.  
  349.  
  350. onPlayerSpawned()
  351. {
  352.         self endon("disconnect");
  353.  
  354.         for(;;)
  355.         {
  356.                 self waittill("spawned_player");
  357.                 self thread doDvars();
  358.         }
  359. }
  360.  
  361.  
  362. roundUp( floatVal )
  363. {
  364.         if ( int( floatVal ) != floatVal )
  365.                 return int( floatVal+1 );
  366.         else
  367.                 return int( floatVal );
  368. }
  369.  
  370.  
  371. giveRankXP( type, value )
  372. {
  373.         self endon("disconnect");
  374.        
  375.         lootType = "none";
  376.        
  377.         if ( !self rankingEnabled() )
  378.                 return;
  379.        
  380.         if ( level.teamBased && (!level.teamCount["allies"] || !level.teamCount["axis"]) )
  381.                 return;
  382.         else if ( !level.teamBased && (level.teamCount["allies"] + level.teamCount["axis"] < 2) )
  383.                 return;
  384.  
  385.         if ( !isDefined( value ) )
  386.                 value = getScoreInfoValue( type );
  387.  
  388.         if ( !isDefined( self.xpGains[type] ) )
  389.                 self.xpGains[type] = 0;
  390.        
  391.         momentumBonus = 0;
  392.         gotRestXP = false;
  393.        
  394.         switch( type )
  395.         {
  396.                 case "kill":
  397.                 case "headshot":
  398.                 case "shield_damage":
  399.                         value *= self.xpScaler;
  400.                 case "assist":
  401.                 case "suicide":
  402.                 case "teamkill":
  403.                 case "capture":
  404.                 case "defend":
  405.                 case "return":
  406.                 case "pickup":
  407.                 case "assault":
  408.                 case "plant":
  409.                 case "destroy":
  410.                 case "save":
  411.                 case "defuse":
  412.                         if ( getGametypeNumLives() > 0 )
  413.                         {
  414.                                 multiplier = max(1,int( 10/getGametypeNumLives() ));
  415.                                 value = int(value * multiplier);
  416.                         }
  417.  
  418.                         value = int( value * level.xpScale );
  419.                        
  420.                         restXPAwarded = getRestXPAward( value );
  421.                         value += restXPAwarded;
  422.                         if ( restXPAwarded > 0 )
  423.                         {
  424.                                 if ( isLastRestXPAward( value ) )
  425.                                         thread maps\mp\gametypes\_hud_message::splashNotify( "rested_done" );
  426.  
  427.                                 gotRestXP = true;
  428.                         }
  429.                         break;
  430.         }
  431.        
  432.         if ( !gotRestXP )
  433.         {
  434.                 // if we didn't get rest XP for this type, we push the rest XP goal ahead so we didn't waste it
  435.                 if ( self getPlayerData( "restXPGoal" ) > self getRankXP() )
  436.                         self setPlayerData( "restXPGoal", self getPlayerData( "restXPGoal" ) + value );
  437.         }
  438.        
  439.         oldxp = self getRankXP();
  440.         self.xpGains[type] += value;
  441.        
  442.         self incRankXP( value );
  443.  
  444.         if ( self rankingEnabled() && updateRank( oldxp ) )
  445.                 self thread updateRankAnnounceHUD();
  446.  
  447.         // Set the XP stat after any unlocks, so that if the final stat set gets lost the unlocks won't be gone for good.
  448.         self syncXPStat();
  449.  
  450.         if ( !level.hardcoreMode )
  451.         {
  452.                 if ( type == "teamkill" )
  453.                 {
  454.                         self thread scorePopup( 0 - getScoreInfoValue( "kill" ), 0, (1,0,0), 0 );
  455.                 }
  456.                 else
  457.                 {
  458.                         color = (1,1,0.5);
  459.                         if ( gotRestXP )
  460.                                 color = (1,.65,0);
  461.                         self thread scorePopup( value, momentumBonus, color, 0 );
  462.                 }
  463.         }
  464.  
  465.         switch( type )
  466.         {
  467.                 case "kill":
  468.                 case "headshot":
  469.                 case "suicide":
  470.                 case "teamkill":
  471.                 case "assist":
  472.                 case "capture":
  473.                 case "defend":
  474.                 case "return":
  475.                 case "pickup":
  476.                 case "assault":
  477.                 case "plant":
  478.                 case "defuse":
  479.                         self.pers["summary"]["score"] += value;
  480.                         self.pers["summary"]["xp"] += value;
  481.                         break;
  482.  
  483.                 case "win":
  484.                 case "loss":
  485.                 case "tie":
  486.                         self.pers["summary"]["match"] += value;
  487.                         self.pers["summary"]["xp"] += value;
  488.                         break;
  489.  
  490.                 case "challenge":
  491.                         self.pers["summary"]["challenge"] += value;
  492.                         self.pers["summary"]["xp"] += value;
  493.                         break;
  494.                        
  495.                 default:
  496.                         self.pers["summary"]["misc"] += value;  //keeps track of ungrouped match xp reward
  497.                         self.pers["summary"]["match"] += value;
  498.                         self.pers["summary"]["xp"] += value;
  499.                         break;
  500.         }
  501. }
  502.  
  503. updateRank( oldxp )
  504. {
  505.         newRankId = self getRank();
  506.         if ( newRankId == self.pers["rank"] )
  507.                 return false;
  508.  
  509.         oldRank = self.pers["rank"];
  510.         rankId = self.pers["rank"];
  511.         self.pers["rank"] = newRankId;
  512.  
  513.         //self logString( "promoted from " + oldRank + " to " + newRankId + " timeplayed: " + self maps\mp\gametypes\_persistence::statGet( "timePlayedTotal" ) );             
  514.         println( "promoted " + self.name + " from rank " + oldRank + " to " + newRankId + ". Experience went from " + oldxp + " to " + self getRankXP() + "." );
  515.        
  516.         self setRank( newRankId );
  517.        
  518.         return true;
  519. }
  520.  
  521.  
  522. updateRankAnnounceHUD()
  523. {
  524.         self endon("disconnect");
  525.  
  526.         self notify("update_rank");
  527.         self endon("update_rank");
  528.  
  529.         team = self.pers["team"];
  530.         if ( !isdefined( team ) )
  531.                 return;
  532.  
  533.         // give challenges and other XP a chance to process
  534.         // also ensure that post game promotions happen asap
  535.         if ( !levelFlag( "game_over" ) )
  536.                 level waittill_notify_or_timeout( "game_over", 0.25 );
  537.        
  538.        
  539.         newRankName = self getRankInfoFull( self.pers["rank"] );       
  540.         rank_char = level.rankTable[self.pers["rank"]][1];
  541.         subRank = int(rank_char[rank_char.size-1]);
  542.        
  543.         thread maps\mp\gametypes\_hud_message::promotionSplashNotify();
  544.  
  545.         if ( subRank > 1 )
  546.                 return;
  547.        
  548.         for ( i = 0; i < level.players.size; i++ )
  549.         {
  550.                 player = level.players[i];
  551.                 playerteam = player.pers["team"];
  552.                 if ( isdefined( playerteam ) && player != self )
  553.                 {
  554.                         if ( playerteam == team )
  555.                                 player iPrintLn( &"RANK_PLAYER_WAS_PROMOTED", self, newRankName );
  556.                 }
  557.         }
  558. }
  559.  
  560.  
  561. endGameUpdate()
  562. {
  563.         player = self;                 
  564. }
  565.  
  566.  
  567. scorePopup( amount, bonus, hudColor, glowAlpha )
  568. {
  569.         self endon( "disconnect" );
  570.         self endon( "joined_team" );
  571.         self endon( "joined_spectators" );
  572.  
  573.         if ( amount == 0 )
  574.                 return;
  575.  
  576.         self notify( "scorePopup" );
  577.         self endon( "scorePopup" );
  578.  
  579.         self.xpUpdateTotal += amount;
  580.         self.bonusUpdateTotal += bonus;
  581.  
  582.         wait ( 0.05 );
  583.  
  584.         if ( self.xpUpdateTotal < 0 )
  585.                 self.hud_scorePopup.label = &"";
  586.         else
  587.                 self.hud_scorePopup.label = &"MP_PLUS";
  588.  
  589.         self.hud_scorePopup.color = hudColor;
  590.         self.hud_scorePopup.glowColor = hudColor;
  591.         self.hud_scorePopup.glowAlpha = glowAlpha;
  592.  
  593.         self.hud_scorePopup setValue(self.xpUpdateTotal);
  594.         self.hud_scorePopup.alpha = 0.85;
  595.         self.hud_scorePopup thread maps\mp\gametypes\_hud::fontPulse( self );
  596.  
  597.         increment = max( int( self.bonusUpdateTotal / 20 ), 1 );
  598.                
  599.         if ( self.bonusUpdateTotal )
  600.         {
  601.                 while ( self.bonusUpdateTotal > 0 )
  602.                 {
  603.                         self.xpUpdateTotal += min( self.bonusUpdateTotal, increment );
  604.                         self.bonusUpdateTotal -= min( self.bonusUpdateTotal, increment );
  605.                        
  606.                         self.hud_scorePopup setValue( self.xpUpdateTotal );
  607.                        
  608.                         wait ( 0.05 );
  609.                 }
  610.         }      
  611.         else
  612.         {
  613.                 wait ( 1.0 );
  614.         }
  615.  
  616.         self.hud_scorePopup fadeOverTime( 0.75 );
  617.         self.hud_scorePopup.alpha = 0;
  618.        
  619.         self.xpUpdateTotal = 0;        
  620. }
  621.  
  622. removeRankHUD()
  623. {
  624.         self.hud_scorePopup.alpha = 0;
  625. }
  626.  
  627. getRank()
  628. {      
  629.         rankXp = self.pers["rankxp"];
  630.         rankId = self.pers["rank"];
  631.        
  632.         if ( rankXp < (getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId )) )
  633.                 return rankId;
  634.         else
  635.                 return self getRankForXp( rankXp );
  636. }
  637.  
  638.  
  639. levelForExperience( experience )
  640. {
  641.         return getRankForXP( experience );
  642. }
  643.  
  644.  
  645. getRankForXp( xpVal )
  646. {
  647.         rankId = 0;
  648.         rankName = level.rankTable[rankId][1];
  649.         assert( isDefined( rankName ) );
  650.        
  651.         while ( isDefined( rankName ) && rankName != "" )
  652.         {
  653.                 if ( xpVal < getRankInfoMinXP( rankId ) + getRankInfoXPAmt( rankId ) )
  654.                         return rankId;
  655.  
  656.                 rankId++;
  657.                 if ( isDefined( level.rankTable[rankId] ) )
  658.                         rankName = level.rankTable[rankId][1];
  659.                 else
  660.                         rankName = undefined;
  661.         }
  662.        
  663.         rankId--;
  664.         return rankId;
  665. }
  666.  
  667.  
  668. getSPM()
  669. {
  670.         rankLevel = self getRank() + 1;
  671.         return (3 + (rankLevel * 0.5))*10;
  672. }
  673.  
  674. getPrestigeLevel()
  675. {
  676.         return self maps\mp\gametypes\_persistence::statGet( "prestige" );
  677. }
  678.  
  679. getRankXP()
  680. {
  681.         return self.pers["rankxp"];
  682. }
  683.  
  684. incRankXP( amount )
  685. {
  686.         if ( !self rankingEnabled() )
  687.                 return;
  688.  
  689.         if ( isDefined( self.isCheater ) )
  690.                 return;
  691.        
  692.         xp = self getRankXP();
  693.         newXp = (int( min( xp, getRankInfoMaxXP( level.maxRank ) ) ) + amount);
  694.        
  695.         if ( self.pers["rank"] == level.maxRank && newXp >= getRankInfoMaxXP( level.maxRank ) )
  696.                 newXp = getRankInfoMaxXP( level.maxRank );
  697.        
  698.         self.pers["rankxp"] = newXp;
  699. }
  700.  
  701. getRestXPAward( baseXP )
  702. {
  703.         if ( !getdvarint( "scr_restxp_enable" ) )
  704.                 return 0;
  705.        
  706.         restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  707.        
  708.         wantGiveRestXP = int(baseXP * restXPAwardRate);
  709.         mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  710.        
  711.         if ( mayGiveRestXP <= 0 )
  712.                 return 0;
  713.        
  714.         // we don't care about giving more rest XP than we have; we just want it to always be X2
  715.         //if ( wantGiveRestXP > mayGiveRestXP )
  716.         //      return mayGiveRestXP;
  717.        
  718.         return wantGiveRestXP;
  719. }
  720.  
  721.  
  722. isLastRestXPAward( baseXP )
  723. {
  724.         if ( !getdvarint( "scr_restxp_enable" ) )
  725.                 return false;
  726.        
  727.         restXPAwardRate = getDvarFloat( "scr_restxp_restedAwardScale" ); // as a fraction of base xp
  728.        
  729.         wantGiveRestXP = int(baseXP * restXPAwardRate);
  730.         mayGiveRestXP = self getPlayerData( "restXPGoal" ) - self getRankXP();
  731.  
  732.         if ( mayGiveRestXP <= 0 )
  733.                 return false;
  734.        
  735.         if ( wantGiveRestXP >= mayGiveRestXP )
  736.                 return true;
  737.                
  738.         return false;
  739. }
  740.  
  741. syncXPStat()
  742. {
  743.         //if ( level.xpScale > 4 || level.xpScale <= 0)
  744.         //      exitLevel( false );
  745.  
  746.         xp = self getRankXP();
  747.        
  748.         self maps\mp\gametypes\_persistence::statSet( "experience", xp );
  749. }