PHP Code:
function onActionServerside() {
switch(params[0]) {
case "levelup":
// Add leveling up code here
break;
case "report":
makevar(params[4]) = params[2]; // Resets level to old level
sendtorc("[LEVELING ABUSE]: "@ params[1] @" leveled from "@ params[2] @" to "@ params[3] @"!");
break;
}
}
//#CLIENTSIDE
function onCreated() {
/* Change this to your level variable being used,
for example: "clientr.level" */
this.levelvar = "clientr.level";
/* Change this to your exp variables being used,
for example: {"clientr.exp", "clientr.maxexp"} */
this.exp = {"clientr.exp", "clientr.maxexp"};
// Don't change anything below, unless you want to change
// the timeout or edit the anti-abuse yourself :)
this.leveling = false;
this.lvl = makevar(this.levelvar);
setTimer(1);
}
function onTimeout() {
if (!this.leveling) {
if (makevar(this.exp[0]) >= makevar(this.exp[1])) {
this.leveling = true;
triggerserver("gui", this.name, "levelup", player.account);
}
}else if (this.lvl < makevar(this.levelvar)) {
if ((makevar(this.levelvar)-this.lvl) == 1) {
this.leveling = false;
this.lvl = makevar(this.levelvar);
}else if ((makevar(this.levelvar)-this.lvl) > 1) {
player.triggerserver("gui", this.name, "report", player.account, this.lvl, makevar(this.levelvar), this.levelvar);
sleep(0.5);
serverwarp("login2");
}
}
setTimer(1);
}
Well, a basic leveling system with a little anti-abuse system. Basicly, with this system you can't level up 2 levels at once. If your level changes by 2 or above from your old level it will register by echo'ing at rc that the person got his levels up by 2 or above, reset his level and then serverwarp him to login2.
It might look kinda messy, but that's because I added support so you could modify it by only changing two vars listed in the
onCreated() event (this.levelvar and this.exp).
If you want to add more logging, simple edit the switch case labeled reset with code you want in. I have not added any leveling up code, that you have to make yourself, so it will fit your server's leveling up plans etc.
Any questions, suggestions to improve it etc are welcome.
And.. uhm.. enjoy?