We have a few number of skills in our PW, where the xp is persistent and is used to level up.
We've recently hit an unexplained error, where the XP has completely stopped being persistent. Again, this is extremely annoying, as it was created by a programmer who was with us, but isn't no more. He locked us out on what he was doing, so half of our team never learnt anything he worked on, but what he produced was a good standard.
Of course we always discussed what was going in, but now that it's hit an error, I can't do anything as I didn't create it, nor do I have knowledge of scripting (slowly learning..).
How it works is, to my knowledge, is that when you gain experience, it's stored on your character every so often, to reduce effects on server performance.
These are the two scripts I know of so far, on how loading and saving the xp works..
Saving xp:
#include "leg_all_masterinclude"
#include "tb_skillsandxp"
/* (12/04/15) Legends team made us persistent
-ModuleProperties>variables>LEG_CUSTOM_ONAREAEXIT
/used in these scripts
(leg_all_masteronexit)
tb_skillsandxp
*/
object oPC = OBJECT_SELF;
string sTable = LEG_COMMON_GetPC2Table(oPC);
void DoLoc(float quittime, float delay)
{
float step = 1.0;
object oArea = GetArea(oPC);
if (GetName(oArea) != "")
{
if (delay <= 0.0)
{
DeleteLocalInt(oPC, "TBLocSavePending");
LEG_COMMON_SetPersistentLocation("NWNX", oPC, "TB_Jobs_serverloc", GetLocation(oPC), sTable);
//SendMessageToPC(oPC, "<color=white>"+GetName(oArea)+" tb_savexp: Saving location data for post-server loading>> "+LocationToString(LEG_COMMON_GetPersistentLocation("NWNX", oPC, "TB_Jobs_serverloc", sTable))+"<<");
}
else DelayCommand(step, DoLoc(0.0, delay-step));
}
else
{
if (quittime <= 0.0) {DeleteLocalInt(oPC, "TBLocSavePending");return;}
DelayCommand(step, DoLoc(quittime-step, delay));
}
}
void main()
{
DeleteLocalInt(oPC, "TB_databaseaccess");
DeleteLocalString(oPC, "activity"); //just throwing it in there incase someone's skills are bugged
//SendMessageToPC(oPC, "<color=white>" + "Skills xp saved to server database table "+sTable+".");
//making sure skills are at least 1
if (GetSkillRank(SKILL_COOKING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_COOKING, 1, FALSE);}
if (GetSkillRank(SKILL_FIREMAKING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_FIREMAKING, 1, FALSE);}
if (GetSkillRank(SKILL_SMITHING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_SMITHING, 1, FALSE);}
if (GetSkillRank(SKILL_WOODCUTTING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_WOODCUTTING, 1, FALSE);}
if (GetSkillRank(SKILL_MINING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_MINING, 1, FALSE);}
if (GetSkillRank(SKILL_RUNECRAFTING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_RUNECRAFTING, 1, FALSE);}
if (GetSkillRank(SKILL_CRAFTING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_CRAFTING, 1, FALSE);}
if (GetSkillRank(SKILL_PRAYER, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_PRAYER, 1, FALSE);}
//Agility is Hide skill
if (GetSkillRank(SKILL_AGILITY, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_AGILITY, 1, FALSE);}
if (GetSkillRank(SKILL_FLETCHING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_FLETCHING, 1, FALSE);}
if (GetSkillRank(SKILL_SLAYER, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_SLAYER, 1, FALSE);}
if (GetSkillRank(SKILL_FARMING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_FARMING, 1, FALSE);}
if (GetSkillRank(SKILL_THIEVING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_THIEVING, 1, FALSE);}
if (GetSkillRank(SKILL_HUNTER, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_HUNTER, 1, FALSE);}
if (GetSkillRank(SKILL_CONSTRUCTION, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_CONSTRUCTION, 1, FALSE);}
//getting xp
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_fishingxp", GetLocalInt(oPC, "fishingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_cookingxp", GetLocalInt(oPC, "cookingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_firemakingxp", GetLocalInt(oPC, "firemakingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_smithingxp", GetLocalInt(oPC, "smithingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_woodcuttingxp", GetLocalInt(oPC, "woodcuttingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_miningxp", GetLocalInt(oPC, "miningxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_runecraftingxp", GetLocalInt(oPC, "runecraftingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_craftingxp", GetLocalInt(oPC, "craftingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_prayerxp", GetLocalInt(oPC, "prayerxp"), sTable);
//ptp
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_agilityxp", GetLocalInt(oPC, "agilityxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_fletchingxp", GetLocalInt(oPC, "fletchingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_slayerxp", GetLocalInt(oPC, "slayerxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_farmingxp", GetLocalInt(oPC, "farmingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_thievingxp", GetLocalInt(oPC, "thievingxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_hunterxp", GetLocalInt(oPC, "hunterxp"), sTable);
LEG_COMMON_SetPersistentInt("NWNX", oPC, "TB_SkillSystem_constructionxp", GetLocalInt(oPC, "constructionxp"), sTable);
// Experimental server spawning players
if (GetLocalInt(oPC, "TBLocSavePending") == 0)
{
SetLocalInt(oPC, "TBLocSavePending", 1);
DoLoc(30.0, IntToFloat(10+Random(10)));
} else {SendMessageToPC(oPC, "TBLocSavePending");}
}
Loading xp:
#include "leg_all_masterinclude"
#include "tb_skillsandxp"
/* (12/04/15) Legends team made us persistent
/-ModuleProperties>variables>LEG_CUSTOM_PCINIT (leg_all_masteronenter)
*/
object oPC = OBJECT_SELF;
string sTable = LEG_COMMON_GetPC2Table(oPC);
void ActionSpam(float duration)
{
if (duration <= 0.0) {return;}
float step = 0.1;
//body
// All skills should be at least level one.
if (GetSkillRank(SKILL_FISHING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_FISHING, 1, FALSE);
//use temporarily unless you can remove starter armor some other way
DestroyObject(GetItemInSlot(INVENTORY_SLOT_CHEST,oPC));
}
if (GetSkillRank(SKILL_COOKING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_COOKING, 1, FALSE);}
if (GetSkillRank(SKILL_FIREMAKING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_FIREMAKING, 1, FALSE);}
if (GetSkillRank(SKILL_SMITHING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_SMITHING, 1, FALSE);}
if (GetSkillRank(SKILL_WOODCUTTING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_WOODCUTTING, 1, FALSE);}
if (GetSkillRank(SKILL_MINING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_MINING, 1, FALSE);}
if (GetSkillRank(SKILL_RUNECRAFTING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_RUNECRAFTING, 1, FALSE);}
if (GetSkillRank(SKILL_CRAFTING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_CRAFTING, 1, FALSE);}
if (GetSkillRank(SKILL_PRAYER, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_PRAYER, 1, FALSE);}
//Agility is Hide skill
if (GetSkillRank(SKILL_AGILITY, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_AGILITY, 1, FALSE);}
if (GetSkillRank(SKILL_FLETCHING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_FLETCHING, 1, FALSE);}
if (GetSkillRank(SKILL_SLAYER, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_SLAYER, 1, FALSE);}
if (GetSkillRank(SKILL_FARMING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_FARMING, 1, FALSE);}
if (GetSkillRank(SKILL_THIEVING, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_THIEVING, 1, FALSE);}
if (GetSkillRank(SKILL_HUNTER, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_HUNTER, 1, FALSE);}
if (GetSkillRank(SKILL_CONSTRUCTION, oPC) == 0) {SetBaseSkillRank(oPC, SKILL_CONSTRUCTION, 1, FALSE);}
//repeater
DelayCommand(step, ActionSpam(duration-step));
}
void main()
{
//SendMessageToPC(oPC, "<color=white>" + "Skills xp loaded from server database table "+sTable+".");
//TRISTON temporary boots for testing
//SendMessageToPC(oPC, "<color=white>" + "'tb_loadxp'Some temporary boots for testing");
//CreateItemOnObject("leatherboots", oPC, 1);
// Load each skill onto the player as a local variable
SetLocalInt(oPC, "fishingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_fishingxp", sTable));
SetLocalInt(oPC, "cookingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_cookingxp", sTable));
SetLocalInt(oPC, "firemakingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_firemakingxp", sTable));
SetLocalInt(oPC, "smithingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_smithingxp", sTable));
SetLocalInt(oPC, "woodcuttingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_woodcuttingxp", sTable));
SetLocalInt(oPC, "miningxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_miningxp", sTable));
SetLocalInt(oPC, "runecraftingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_runecraftingxp", sTable));
SetLocalInt(oPC, "craftingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_craftingxp", sTable));
SetLocalInt(oPC, "prayerxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_prayerxp", sTable));
SetLocalInt(oPC, "agilityxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_agilityxp", sTable));
SetLocalInt(oPC, "fletchingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_fletchingxp", sTable));
SetLocalInt(oPC, "slayerxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_slayerxp", sTable));
SetLocalInt(oPC, "farmingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_farmingxp", sTable));
SetLocalInt(oPC, "thievingxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_thievingxp", sTable));
SetLocalInt(oPC, "hunterxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_hunterxp", sTable));
SetLocalInt(oPC, "constructionxp", LEG_COMMON_GetPersistentInt("NWNX", oPC, "TB_SkillSystem_constructionxp", sTable));
// and so on for each skill you have.
AssignCommand(oPC, ClearAllActions());
ActionSpam(2.0); //incase we have to fight lag
//Functional location jumper
location loc = LEG_COMMON_GetPersistentLocation("NWNX", oPC, "TB_Jobs_serverloc", sTable);
//SendMessageToPC(oPC, "debug "+GetName(oPC) + " : "+IntToString(GetSkillRank(SKILL_CRAFTING, oPC)) + " : " + LocationToString(loc));
AssignCommand(oPC, JumpToLocation(loc));
//SendMessageToPC(oPC, "<color=white>" + "tb_loadxp: Loading in pre-server load data. ");
}
Any help would be extremely grateful, this stuff is depressing >_<