View Single Post
  #1  
Old 03-08-2007, 06:26 PM
Chandler Chandler is offline
Banned
Join Date: Jan 2007
Posts: 656
Chandler will become famous soon enough
Basic leveling system

HTML Code:
public function gainExperience(levelName, amountGain)
  {
  if (!temp.levelName || !temp.amountGain)
    return false;
  
  temp.amountNeeded = this.expNeeded(temp.levelName);
  this.clientr.("stat_exp-" @ temp.levelName) += temp.amountGain;
 
  if (this.gatherExperience(temp.levelName) >= temp.amountNeeded)
    this.gainLevel(temp.levelName);  
  
  if (temp.levelName != "main")
    {
    this.gainExperience("main", temp.amountGain);
    this.chat = temp.levelName @"--"@ this.gatherExperience(temp.levelName) @"/" @ temp.amountNeeded;
    }
  }
function gainLevel(levelName)
  {
  this.clientr.("stat_level-" @ temp.levelName) += 1;
  this.chat = "Gained a level in" SPC temp.levelName @"! New level:" SPC this.gatherLevel(temp.levelName);
  //Add anything else you would like here, such as a bonus for gaining levels
  }
  
public function expNeeded(levelName)
  return int(((this.clientr.("stat_level-" @ temp.levelName) ^ 2) / 70) * 100) ^ 2;

public function gatherExperience(levelName)
  return this.clientr.("stat_exp-" @ temp.levelName);
  
public function gatherLevel(levelName)
  return this.clientr.("stat_level-" @ temp.levelName);
PHP Code:
  gainExperience(levelNameamountGain);
    
//gainExperience("stength", 45)
    // Gives the player 45 exp for a strength level. It also creates a stat for overall experience gained. This stat is saved as "clientr.stat_exp-main".

  
expNeeded(levelName);
    
//expNeeded("strength");
    // Returns how much EXP is needed for gaining a level.

  
gatherExperience(levelName);
    
//gatherExperience("strength");
    // How much experience the player currently has in that level. 
  
  
gatherLevel(levelName);
    
//gatherLevel("strength");
    // Returns the players current level 
Reply With Quote