Ian
2014-03-21 17:05:05
This is something I made for the script I'm working on, what it does is it gets the players skill level in any skill using their xp in that skill. This has the advantage of not needing to change from your current tab to your skill tab and back if you want to be able to check your skill level at any time.
To use this you'll need a TIntegerArray of the amounts of XP for each level. This can be stored locally or globally depending on what you want to use it for for other things in the script. For mine I will store it globally and declare it at the start of the script where I'm declaring other arrays that will be referenced throughout the script.
You will also need to know how much XP you have in the skill you want to check. In my script, it checks the existing XP at startup, then uses TRSChatbox.getXP by @Ashaman88; to keep track of additional gains.
TIntegerArray:
Function:
Example:
:)
To use this you'll need a TIntegerArray of the amounts of XP for each level. This can be stored locally or globally depending on what you want to use it for for other things in the script. For mine I will store it globally and declare it at the start of the script where I'm declaring other arrays that will be referenced throughout the script.
You will also need to know how much XP you have in the skill you want to check. In my script, it checks the existing XP at startup, then uses TRSChatbox.getXP by @Ashaman88; to keep track of additional gains.
TIntegerArray:
XPByLevel:= [0, 83, 174, 276, 388, 512, 650, 801, 969, 1154, 1358, 1584, 1833,
2107, 2411, 2746, 3115, 3523, 3973, 4470, 5018, 5624, 6291, 7028, 7842, 8740,
9730, 10824, 12031, 13363, 14833, 16456, 18247, 20224, 22406, 24815, 27473,
30408, 33648, 37224, 41171, 45529, 50339, 55649, 61512, 67983, 75127, 83014,
91721, 101333, 111945, 123660, 136594, 150872, 166636, 184040, 203254, 224466,
247886, 273742, 302288, 333804, 368599, 407015, 449428, 496254, 547953,
605032, 668051, 737627, 814445, 899257, 992895, 1096278, 1210421, 1336443,
1475581, 1629200, 1798808, 1986068, 2192818, 2421087, 2673114, 2951373,
3258594, 3597792, 3972294, 4385776, 4842295, 5346332, 5902831, 6517253,
7195629, 7944614, 8771558, 9684577, 10692629, 11805606, 13034431, 200000000];
Function:
function getLevelFromXP(XP: Integer): Integer;
var
i: Integer;
begin
for i:= 0 to (length(XPByLevel) - 1) do
begin
if (XP > XPByLevel[i]) and (XP < XPByLevel[i + 1]) then
result:= (i + 1);
if result then
break();
end;
end;
Example:
writeLn('Your current Mining Level is ' + ToStr(getLevelFromXP(MiningXP)) + '.');
:)
