After having a lovely night of scripting and such I have near completed my Leveling exp system
Only two things remain slight errors:
1: You lose your current EXP progression when you go offline (setting a client.var would set this straight but I can't seem to get my head around how to go about setting it)
2: The system currently keeps all existing EXP after you level and continues from where the last exp counter was (EG when 50/60 to level you level and then it stays at 60/100 Ect…) This second one really isn't much of an issue since I can just up the amount needed Till next level.
Any advice would be helpful I will add the code in now, Sorry about the mess its in ^^'
[code]// NPC made by Hashi
if (playerenters) {toweapons EXPSYS;
}
if (playerenters&&!sysexp) {
insertstring client.exp,0,50; //till next level
insertstring client.exp,1,0; //current exp
insertstring client.level,0,1; //players level
insertstring client.level,1,10; //players max level
insertstring client.perkill,0,0; //exp per kill
set sysexp;
timeout = 0.05;
}
if (isweapon || timeout) {
showtext 300,32,32,Arial,Saved:(#I(client.exp,2));
showtext 301,32,34,Arial,EXP:(#I(client.exp,1)/#I(client.exp,0));
showtext 302,32,36,Arial,LVL:(#I(client.level,0));
showtext 303,32,38,Arial,MAXLVL:(#I(client.level,1));
timeout = 0.05;
}
if (strequals(#I(client.level,0),#I(client.level,0))) {
client.nextlvl = strtofloat(#I(client.level,0))+1;
}
client.curlvl =strtofloat(#I(client.level,0));
client.curexp =strtofloat(#I(client.exp,1));
client.tnlexp =strtofloat(#I(client.exp,0));
client.getexp =strtofloat(#I(client.exp,0))+50;
if (client.curexp>client.tnlexp){
replacestring client.level,0,#v(client.nextlvl);
setplayerprop #c,congrats! you are now level #v(client.curlvl+1);
replacestring client.exp,0,#v(client.getexp+strtofloat(#I(client.exp,0)));
}
// Save exp
//if (strequals(#I(client.exp,1),#I(client.exp,1))) {
//
//}
//Stop player going over Maxlevel
if (strequals(#I(client.level,1),#I(client.level,0))) {
insertstring client.exp,0,-1;
insertstring client.exp,1,-2;
showtext 301,32,34,Arial,EXP:(-/-);[/code]
You can see what I was thinking when I started to add the save exp part but kind of realised it would reset everytime you got more exp… which obviously brings a problem if it keeps resetting.
This part of the code is on the NPC enemy and it triggers the exp gain from the NPC you kill :
client.ep += 25; // how much exp this npc gives when killed
replacestring client.exp,1,#v(strtofloat(#I(client.perkill,0))+client.ep);
its obviously built into his death function
Thanks for any help that I get in advance! <3 sleep time now :3