When you're developing an EXP system you should have all those functions in a player-joined class. Here have some bare-bones for one.
class: playerfunctions
PHP Code:
public function getEXP() {
return clientr.stat.exp;
}
public function getLevel() {
return clientr.stat.level;
}
public function addEXP(amount) {
clientr.stat.exp += amount;
checkEXP();
}
public function setEXP(amount) {
clientr.stat.exp = amount;
}
public function checkEXP() {
if (getEXP() > EXPRequired()) {
levelUP();
}
}
public function getEXPRequired() {
// Add a custom formula here.
return 10000;
}
public function levelUP() {
setEXP(0);
clientr.stat.level++;
clientr.stat.expneeded = getEXPRequired();
}
then in your Control-NPC:
PHP Code:
function onActionPlayerOnline() {
player.join("playerfunctions");
}
then in other scripts when you know the attacker or what not
PHP Code:
function onBaddyKilled(killedby) {
findplayer(killedby).addEXP(100);
}