PDA

View Full Version : Basic leveling system


Chandler
03-08-2007, 06:26 PM
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);


gainExperience(levelName, amountGain);
//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
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
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
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