Well, in case you guys forgot about what was causing the sh_set_user_lvl bug, I'll point it out here:
In sheroapi.cpp, this:
Code:
//Set user LVL
void SheroAPI::setLVL(int iPlayer, int LVL)
{
s_vars.DebugMessage("SheroAPI::setLVL");
this->setXP(iPlayer,this->XPGiven(LVL)); //this->XPGiven(LVL) is wrong (the bug)
//play sound here
if(MF_IsPlayerAlive(iPlayer) && MF_IsPlayerValid(iPlayer))
sPlayers.displayPowers(iPlayer);
}
Should be this:
Code:
//Set user LVL
void SheroAPI::setLVL(int iPlayer, int LVL)
{
s_vars.DebugMessage("SheroAPI::setLVL");
this->setXP(iPlayer,this->XPLevels(LVL)); //Bug fixed
//play sound here
if(MF_IsPlayerAlive(iPlayer) && MF_IsPlayerValid(iPlayer))
sPlayers.displayPowers(iPlayer);
}
Here's a reference of what the XPLevels and XPGiven function look like:
Code:
//Thnx to u
int SheroAPI::XPLevels(int lvl)
{
s_vars.DebugMessage("SheroAPI::XPLevels");
// mode: 1 saveXP , 0 no save
int i = 100;
int lastAdd = 0;
if(!lvl)
return 0;
else if(lvl == 1)
return 100;
int result = 0;
if(s_vars.g_LongTermXP() == 1)
{
//0 100 300 600 1000 1500 2100 2800 3600 4500 5500
for(int x = 1; x <= lvl; x++)
{
result = result + lastAdd + i;
lastAdd += i;
}
}
else
{
//0 100 200 400 800 1600 3200 6400 12800 25600 51200
result = (2 << (lvl - 2)) * 100;
}
return result;
}
int SheroAPI::XPGiven(int lvl)
{
s_vars.DebugMessage("SheroAPI::XPGiven");
int result;
if(s_vars.g_LongTermXP() == 1)
{
//60 80 100 120 140 160 180 200 220 240 260 + 20
result = 60 + (lvl * 20);
}
else
{
//6 8 10 12 14 16 20 24 28 32 40 50 60 70 80 90 etc.. +10
if ( lvl >= 0 && lvl <= 5 )
{
result = (lvl * 2) + 6;
}
else if ( lvl >= 6 && lvl <= 9 )
{
result = ((lvl - 6) * 4) + 20;
}
else
{
result = ((lvl - 10) * 10) + 40;
}
}
return result;
}
This was why when emp` was setting the levels, particularily in this post:
http://forums.alliedmods.net/showthr...p=302944#51271, the player's level was actually set to a low level, when he tried setting it to 20, since the XPGiven returns 140 (with short terem xp), and sets the player's exp to 140 rather than the exp required for level 20.
__________________