Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   Code Gallery (https://forums.graalonline.com/forums/forumdisplay.php?f=179)
-   -   Basic leveling system (https://forums.graalonline.com/forums/showthread.php?t=72678)

Chandler 03-08-2007 06:26 PM

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 


Chompy 03-08-2007 06:32 PM

Nice!

killerogue 03-08-2007 10:51 PM

So this gains an experience for a multitude of differently named levels/stats and NOT one overall level? :o

Chandler 03-08-2007 11:17 PM

Quote:

Originally Posted by killerogue (Post 1286450)
So this gains an experience for a multitude of differently named levels/stats and NOT one overall level? :o

Read the PHP part of the script, you'll find you're mistaken! ;)

killerogue 03-15-2007 11:23 AM

Quote:

Originally Posted by Chandler (Post 1286482)
Read the PHP part of the script, you'll find you're mistaken! ;)

Like I said Chandler, this gains levels for each stat? As you have strength their. Which is a stat so I assumed this gained levels for each stat.

Chandler 03-15-2007 11:30 AM

Quote:

Originally Posted by killerogue (Post 1288870)
Like I said Chandler, this gains levels for each stat? As you have strength their. Which is a stat so I assumed this gained levels for each stat.

Ah yes, you're correct!
Please, fix your pms! I can't reply back to you! :p


All times are GMT +2. The time now is 11:02 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.