SRL Archive - MSI Suggestions

[EXTRA] Stats Grabber


Bobzilla69

2011-01-14 15:48:01

Hey,

i made a Character Skill Level grabber for MSI.

i PMed Coh3n about it and he said its good and to post it here so that him or someone else when they get time can add it into MSI Extras.

So basically what i have done is made it so that after a character finished there Loads/Time or the player is unset it will call my include and save all of the current players skill levels to a file.
The file will be stored in MSI\MSI\Extras\Accounts and will have the character name as the file name. i.e. MSI\MSI\Extras\Accounts\Bobzilla.txt

Here is the Main Script to be added into the Extras Folder.

CharacterStats.Simba
{==============================================================================\
| MSI Group Scripting Include |
| CharacterStats.Simba |
|==============================================================================|
| For Storing Player Skill levels after Time/Loads are reached |
| |
| * procedure CheckFile; * by Bobzilla69 |
| * procedure WriteFile(); * by Bobzilla69 |
| * procedure GetData; * by Bobzilla69 |
| * procedure WriteData; * by Bobzilla69 |
| * procedure StoreCharacterLevels; * by Bobzilla69 |
\_____________________________________________________________________________}


var
Accounts:Integer;
oldInfo:String;
Skills:TStringArray;

Const
Path = IncludePath + 'MSI\MSI\Extras\Accounts\';
StartNew = True; //keeps adding to end of file, True to overwrite anythign in file

{******************************************************************************}
{ procedure CheckFile; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Check if File exists if it doent creates file. }
{ Also handles if file will be added to or rewritten }
{******************************************************************************}
Procedure Bobzilla_CheckFile;
begin
if FileExists(Path + Players[CurrentPlayer].Name +'.txt') then
begin
//Writeln('File all ready created');
Accounts:= OpenFile(Path + Players[CurrentPlayer].Name +'.txt' , False);
if (not StartNew) then ReadFileString(Accounts, oldInfo, FileSize(Accounts));
CloseFile(Accounts);
end else
begin
//WriteLn('File not Found, Creating new file')
Accounts := CreateFile(Path + Players[CurrentPlayer].Name +'.txt');
CloseFile(Accounts);
end;
end;

{******************************************************************************}
{ procedure WriteFile(New, Old:string); }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Writes Character data to the file. }
{ New is new data to be added to file. }
{ Old is data that was in file to be re writen }
{******************************************************************************}
Procedure Bobzilla_WriteFile(New, Old:string);
begin
Accounts := RewriteFile(Path + Players[CurrentPlayer].Name +'.txt', False);
WriteFileString(Accounts, Old + #13 + #10 + New);
CloseFile(Accounts);
end;

{******************************************************************************}
{ procedure GetData; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Using reflection gets all character skill levels }
{ and stores it to a Array for that character }
{******************************************************************************}
Procedure Bobzilla_GetData;
begin
Players[CurrentPlayer].Arrays[1]:= [
R_GetSkillLevel(SKILL_ATTACK), R_GetSkillLevel(SKILL_DEFENCE), R_GetSkillLevel(SKILL_STRENGTH),
R_GetSkillLevel(SKILL_HITPOINTS), R_GetSkillLevel(SKILL_RANGE), R_GetSkillLevel(SKILL_PRAYER),
R_GetSkillLevel(SKILL_MAGIC), R_GetSkillLevel(SKILL_COOKING), R_GetSkillLevel(SKILL_WOODCUTTING),
R_GetSkillLevel(SKILL_FLETCHING), R_GetSkillLevel(SKILL_FISHING), R_GetSkillLevel(SKILL_FIREMAKING),
R_GetSkillLevel(SKILL_CRAFTING), R_GetSkillLevel(SKILL_SMITHING), R_GetSkillLevel(SKILL_MINING),
R_GetSkillLevel(SKILL_HERBLORE), R_GetSkillLevel(SKILL_AGILITY), R_GetSkillLevel(SKILL_THIEVING),
R_GetSkillLevel(SKILL_SLAYER), R_GetSkillLevel(SKILL_FARMING), R_GetSkillLevel(SKILL_RUNECRAFTING),
R_GetSkillLevel(SKILL_HUNTER), R_GetSkillLevel(SKILL_CONSTRUCTION), R_GetSkillLevel(SKILL_SUMMONING),
R_GetSkillLevel(SKILL_DUNGEONEERING)]
end;

{******************************************************************************}
{ procedure WriteData; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Handles extracting data from array and sending to WriteFile; }
{******************************************************************************}
Procedure Bobzilla_WriteData;
var
B:integer;
newInfo:String;
begin
Skills:= ['Attack Skill :', 'Defence Skill :', 'Strength Skill :', 'Hitpoints Skill :', 'Range Skill :', 'Prayer Skill :', 'Magic Skill :', 'Cooking Skill :', 'Woodcutting Skill :', 'Fletching Skill :', 'Fishing Skill :', 'Firemaking Skill :', 'Crafting Skill :', 'Smithing Skill :', 'Mining Skill :', 'Hreblore Skill :', 'Agility Skill :', 'Thieving Skill :', 'Slayer Skill :', 'Farming Skill :', 'Runercrafting Skill :', 'Hunter Skill :', 'Conctruction Skill :', 'Summining Skill :', 'Dungeoneering Skill :'];
newInfo:= newInfo + Players[CurrentPlayer].Name + ' Skill Levels are :'+#13+#10;
for B:=0 to high(Players[CurrentPlayer].Arrays[1]) do
begin
newInfo := newInfo + ' '+Skills[B] + IntToStr(Players[CurrentPlayer].Arrays[1][B])+#13+#10;
end;
newInfo := newInfo + #13 + #10;

WriteFile(newInfo, oldInfo);
end;

{******************************************************************************}
{ procedure StoreCharacterLevels; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Simply calles all procedures in order }
{ means only one lines is called in MSI }
{******************************************************************************}
Procedure Bobzilla_StoreCharacterLevels;
begin
CheckFile;
GetData;
WriteData;
end;

Changes to Setup.Simba

//Extras
{$include_once MSI/MSI/Core/Extras.simba}
{$include_once MSI/MSI/Extras/WorldWalker_cstrike.simba}
{$include_once MSI/MSI/Extras/CharacterStats.simba}

Changed to MainLoop.simba
{******************************************************************************}
{ procedure MSI_UnsetPlayer(func, reason: String; setReason: Boolean); }
{ By: RM and Coh3n }
{ Date: 03 July 2010 }
{ Description: Sets the player to false if something fails }
{******************************************************************************}
procedure MSI_UnsetPlayer(reason: String; setReason: Boolean);
begin
MSI_AddHeader('MSI_UnsetPlayer');

if (BankScreen) then
CloseBank;

MSI_Debug(reason);
MSI_Players[CurrentPlayer].Active := False;
Players[CurrentPlayer].Active := False;

if (setReason) then
MSI_Players[CurrentPlayer].ReportInfo.FalseReason := reason;

if (Players[CurrentPlayer].Rand <> '') then
MSI_Players[CurrentPlayer].ReportInfo.FalseReason := 'In random: '+Players[CurrentPlayer].Rand;

Bobzilla_StoreCharacterLevels;


MSI_ProgressReport;
NextPlayer(False);
stats_IncVariable('Total Logins', 1);

MSI_CloseHeader('MSI_ReflectionWalk: Finished');
end;

{******************************************************************************}
{ function MSI_CheckLoads(...): Boolean; }
{ By: Coh3n }
{ Date: 03 December 2010 }
{ Description: Returns true if it's time to break or set player inactive }
{******************************************************************************}
function MSI_CheckLoads(TempLoads: Integer; var Reason: string; var TakeBreak: Boolean): Boolean;
var
_avg: Integer;
begin
with MSI_Players[CurrentPlayer] do
begin
// Handle finishing total loads
if (TotalLoads > 0) then
begin
MSI_SubDebug('Total loads done: '+IntToStr(ReportInfo.LoadsDone));

_avg := Round(TotalLoads * RANDOM_TIME_PERCENT);

if (ReportInfo.LoadsDone >= (TotalLoads + RandomRange(-_avg, _avg))) then
begin
MSI_SubDebug('Finished total loads');
Reason := 'Finished total loads!';
Result := True;
Exit;

Bobzilla_StoreCharacterLevels;

end;
end;

// Breaking via loads
if (BreakLoads > 0) then
begin
MSI_SubDebug('Temp loads done: '+IntToStr(TempLoads));

_avg := Round(BreakLoads * RANDOM_TIME_PERCENT);

if (TempLoads >= (BreakLoads + RandomRange(-_avg, _avg))) then
begin
MSI_SubDebug('Finished loads before breaking');
TakeBreak := True;
Result := True;
Exit;
end;
end;
end;
end;

{******************************************************************************}
{ function MSI_CheckLoads(...): Boolean; }
{ By: Coh3n }
{ Date: 03 December 2010 }
{ Description: Returns true if it's time to break or set player inactive }
{******************************************************************************}
function MSI_CheckTime(TempTime: Integer; var Reason: string; var TakeBreak: Boolean): Boolean;
var
_avg: Integer;
begin
with MSI_Players[CurrentPlayer] do
begin
// Completed total time (common for all skills)
if (TotalTime > 0) then
begin
MSI_SubDebug('Total playing time: '+IntToStr(Round(ReportInfo.PlayerTime / 60000)));
MSI_SubDebug('Max playing time: '+IntToStr(TotalTime));

Bobzilla_StoreCharacterLevels;

_avg := Round(TotalTime * RANDOM_TIME_PERCENT);

if (Round(ReportInfo.PlayerTime / 60000) >= (TotalTime + RandomRange(-_avg, _avg))) then
begin
MSI_SubDebug('Finished total time');
Reason := 'Finished total time!';
Result := True;
Exit;
end;
end;

// Handle breaking via time (common for all skills)
if (BreakTime > 0) then
begin
MSI_SubDebug('Temp playing time: '+IntToStr(TempTime));

_avg := Round(BreakTime * RANDOM_TIME_PERCENT);

if (Round(TempTime / 60000) >= (BreakTime + RandomRange(-_avg, _avg))) then
begin
MSI_SubDebug('Finished total time before breaking');
TakeBreak := True;
Result := True;
Exit;
end;
end;
end;
end;

Sir R. M8gic1an

2011-01-14 16:13:38

Looks good :)

~RM

Frement

2011-01-14 16:31:31

Could this be integrated into scripts? Like have a global setting to save these to a file? Each character would have its own file.

Sir R. M8gic1an

2011-01-14 16:35:44

From: Frement
Could this be integrated into scripts? Like have a global setting to save these to a file? Each character would have its own file.


That's what he did. On every character change it saves the character's stats

Frement

2011-01-14 16:37:02

Oh, sorry, I misread then ;)

Dgby714

2011-01-14 16:38:32

Is it sopost to do something like?

Attack: 51
Defence: 16
Strength: 17
Constitution: 84
Range: 10
Prayer: 61
Magic: 20
Cooking: 1
Woodcutting: 32
Fleching: 81
Fishing: 64
Firemaking: 16
Crafting: 49
Smithing: 91
Mining: 51
Herblore: 19
Agility: 90
Thieving: 21
Slayer: 90
Farming: 17
Runecrafting: 11
Hunter: 60
Construction: 77
Summoning: 44
Dungeoneering: 89

NCDS

2011-01-14 16:54:57

Forgot the ifdef's but I'll be making quite a few commits tonight so after a test this may be added as well. Nice job. :)

Is the purpose of this to sort of keep records of your players as you build them over time?

Dgby714

2011-01-14 16:57:36

If it does what I think it does, Here's a much cleaner version.

E: Changed something…
E2: The forums font makes the header look ugly….

{==============================================================================\
| MSI Group Scripting Include |
| CharacterStats.Simba |
|==============================================================================|
| For Storing Player Skill levels after Time/Loads are reached |
| |
| * procedure StoreLevels; * by Dgby714 |
\_____________________________________________________________________________}

const
APPENDSKILLS = False;

{******************************************************************************}
{ procedure StoreLevels; }
{ By: Dgby714 }
{ Date: 14 January 2011 }
{ Description: Saves a characters levels to a file }
{******************************************************************************}
procedure StoreLevels;
var
I: integer;
Skills: TStringArray;
begin
ForceDirectories(IncludePath + 'msi\MSI\Extras\Accounts\');
Skills := ['Attack', 'Defence', 'Strength', 'Constitution', 'Range', 'Prayer',
'Magic', 'Cooking', 'Woodcutting', 'Fleching', 'Fishing',
'Firemaking', 'Crafting', 'Smithing', 'Mining', 'Herblore',
'Agility', 'Thieving', 'Slayer', 'Farming', 'Runecrafting',
'Hunter', 'Construction', 'Summoning', 'Dungeoneering'];
with TStringList.Create do
try
try
if (APPENDSKILLS) then
begin
LoadFromFile(IncludePath + 'msi\MSI\Extras\Accounts\' + Players[CurrentPlayer].Name + '.txt');
Add('');
end;
except end;

Add('Player Skills: ');

for I := SKILL_ATTACK to SKILL_DUNGEONEERING do
begin
Players[CurrentPlayer].Level[I] := R_GetSkillLevel(I);
Add(' ' + Skills[I] + ': ' + IntToStr(Players[CurrentPlayer].Level[I]));
end;

SaveToFile(IncludePath + 'msi\MSI\Extras\Accounts\' + Players[CurrentPlayer].Name + '.txt');
finally
Free;
end;
end;

Bobzilla69

2011-01-14 17:21:40

this is what my include will output

I also kept an option at the top StartNew = True; which will if set to true will keep updating the file and not keep old data.

but if you set is yo false you can have it add to the bottom of the file, if you want to keep track of the progress.

i am also working on another part of this, but thats under wraps for now

Dgby714

2011-01-14 17:28:30

From: bobzilla69
this is what my include will output

I also kept an option at the top StartNew = True; which will if set to true will keep updating the file and not keep old data.

but if you set is yo false you can have it add to the bottom of the file, if you want to keep track of the progress.

i am also working on another part of this, but thats under wraps for now


Mine outputs a file like this

Dgby714.txt
Player Skills: 
Attack: 1
Defence: 1
Strength: 1
Constitution: 1
Range: 1
Prayer: 1
Magic: 1
Cooking: 1
Woodcutting: 1
Fleching: 1
Fishing: 1
Firemaking: 1
Crafting: 1
Smithing: 1
Mining: 1
Herblore: 1
Agility: 1
Thieving: 1
Slayer: 1
Farming: 1
Runecrafting: 1
Hunter: 1
Construction: 1
Summoning: 1
Dungeoneering: 1

NCDS

2011-01-14 17:33:55

I kind of like it better without 'SKILL' after each skill name, but that's a small thing.

Honestly, I don't see why both couldn't be added as it's the users choice to compile/use them anyways. This doesn't mean they both will be as I don't see them being all too useful as you could just look at the RS client. (not putting down anyones work by any means as any effort is greatly appreciated :))

Like I said, I've got a few things to commit tonight and I'm sure me and Coh3n will have our (basically) nightly chat, so I'll see what he has to say as well as any other SL's that feel like including their 2 cents.

Dgby714

2011-01-14 17:37:02

From: NCDS
(not putting down anyones work by any means as any effort is greatly appreciated :))


lol took me a whole 3 mins to make that >..> I also don't see it being useful I was just throwing up a cleaner one.

Sir R. M8gic1an

2011-01-14 18:55:07

I didn't know TStringList :) I didn't even know something like this was possible in Simba.

~RM

Nava2

2011-01-14 19:04:31

Definitely remove anything extra in files that is NOT information. You are not trying to make it human legible, you want it to be computer legible.

I would almost suggest creating a large file then using something like JSON to hold all the information for the players.

Dgby714

2011-01-14 19:17:28

From: Nava2
Definitely remove anything extra in files that is NOT information. You are not trying to make it human legible, you want it to be computer legible.

I would almost suggest creating a large file then using something like JSON to hold all the information for the players.


procedure StoreLevels;
var
I: integer;
begin
ForceDirectories(IncludePath + 'msi\MSI\Extras\Accounts\');
with TStringList.Create do
try
for I := SKILL_ATTACK to SKILL_DUNGEONEERING do
Values[IntToStr(I)] := IntToStr(R_GetSkillLevel(I));

SaveToFile(IncludePath + 'msi\MSI\Extras\Accounts\' + Players[CurrentPlayer].Name + '.txt');
finally
Free;
end;
end;

Dgby714.txt
0=1
1=1
2=1
3=1
4=1
5=1
6=1
7=1
8=1
9=1
10=1
11=1
12=1
13=1
14=1
15=1
16=1
17=1
18=1
19=1
20=1
21=1
22=1
23=1
24=1

Coh3n

2011-01-14 19:20:35

From: Nava2
Definitely remove anything extra in files that is NOT information. You are not trying to make it human legible, you want it to be computer legible.

The purpose of it is to track how each player is doing, so I would say it should be human legible (I'm assuming you're talking about the output file).

@NCDS: I won't be around much for the next week and a bit as I'm going on a road trip, but you can add this if you have time. You just need defines, etc. :)

NCDS

2011-01-14 19:28:19

From: Coh3n

@NCDS: I won't be around much for the next week and a bit as I'm going on a road trip, but you can add this if you have time. You just need defines, etc. :)


And here I was waiting for you to get on MSN >.<

Nava2

2011-01-14 20:05:56

From: Coh3n
The purpose of it is to track how each player is doing, so I would say it should be human legible (I'm assuming you're talking about the output file).

@NCDS: I won't be around much for the next week and a bit as I'm going on a road trip, but you can add this if you have time. You just need defines, etc. :)


I thought the premise for this was for scripts to track progress.. o.O

NCDS

2011-01-14 21:15:46

From: Nava2
I thought the premise for this was for scripts to track progress.. o.O


Nah I think it's more for user info, which is why I said I didn't see much use for it as you could just look at the RS client.

XRaye

2011-01-14 22:28:11

This isn't completely on-topic, but does the gametab need to be changed for reflection to get the skill level and exp?

Sir R. M8gic1an

2011-01-14 22:50:39

From: XRaye
This isn't completely on-topic, but does the gametab need to be changed for reflection to get the skill level and exp?


nope.

~RM

Coh3n

2011-01-15 02:04:54

From: NCDS
Nah I think it's more for user info, which is why I said I didn't see much use for it as you could just look at the RS client.

I think the same thing, but Bobzilla isn't the first person that wanted a feature like this.

Bobzilla69

2011-01-15 03:33:16

I simply made this because i saw it was on the list of things people wanted so i made it, See Here

From: NCDS
Nah I think it's more for user info, which is why I said I didn't see much use for it as you could just look at the RS client.


Sure you can do this but why would you log back into runescape after logging out simply to check this when you can have it all in a file?

but yeh its up to the preference of the user.

no harm in having the feature there is it.

*Runs back to his failed Tutorial Runner "Work I say WORK!!!"*

Sir R. M8gic1an

2011-01-15 09:09:19

I really like the stats grabber.

I love the fact that I can just go to a folder to check how my army is doing.

~RM

Dgby714

2011-01-15 09:18:47

From: Sir R. Magician
I really like the stats grabber.

I love the fact that I can just go to a folder to check how my army is doing.

~RM


If its for you to check on your armys status, I'll make you one that keeps all the info in one file and generates a html file for you to use.

Sir R. M8gic1an

2011-01-15 09:26:15

From: Dgby714
If its for you to check on your armys status, I'll make you that keeps all the info in one file and generates a html file for you to use.


I love you?

Bobzilla69

2011-01-31 14:09:14

ok, i have kinda revamped my first version of the system.

changed it to use a xml style to save the data then you can have it looking like this to view.

think it should work quite well

Edit: only a online example we can have it offline :)

ok so what it now does is simply write one XML file to store all the data for the players.

it will overwrite all the time which i think is the only problem so far, so if you run 3 players then 1 it will only store the last run details.

if the script terminates before doing all players it will not write the info for players that didnt run, because obviously it doesn't have the info.

as long as its called before the script stops it will save the data


CharacterStats.simba

procedures have bobzilla in front to stop duplicates in future
{==============================================================================\
| MSI Group Scripting Include |
| CharacterStats.Simba |
|==============================================================================|
| For Storing Player Skill levels after Time/Loads are reached |
| |
| * procedure CheckFile; * by Bobzilla69 |
| * procedure WriteFile(); * by Bobzilla69 |
| * procedure GetData; * by Bobzilla69 |
| * procedure WriteData; * by Bobzilla69 |
\_____________________________________________________________________________}


var
Accounts:Integer;

Const
Path = IncludePath + 'MSI\MSI\Extras\Accounts\';

{******************************************************************************}
{ procedure CheckFile; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Check if File exists if it doent creates file. }
{ Also handles if file will be added to or rewritten }
{******************************************************************************}
Procedure Bobzilla_CheckFile;
begin
if FileExists(Path + 'Characters.xml') then
begin
//Writeln('File all ready created');
Accounts:= OpenFile(Path + 'Characters.xml' , False);
CloseFile(Accounts);
end else
begin
//WriteLn('File not Found, Creating new file')
Accounts := CreateFile(Path + 'Characters.xml');
CloseFile(Accounts);
end;
end;

{******************************************************************************}
{ procedure WriteFile(New, Old:string); }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Writes Character data to the file. }
{ New is new data to be added to file. }
{ Old is data that was in file to be re writen }
{******************************************************************************}
Procedure Bobzilla_WriteFile(New:String);
begin
Accounts := RewriteFile(Path + 'Characters.xml', False);
WriteFileString(Accounts, New);
CloseFile(Accounts);
end;

{******************************************************************************}
{ procedure GetData; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Using reflection gets all character skill levels }
{ and stores it to a Array for that character }
{******************************************************************************}
Procedure Bobzilla_GetData;
begin
Players[CurrentPlayer].Arrays[1]:= [
R_GetSkillLevel(SKILL_ATTACK), R_GetSkillLevel(SKILL_DEFENCE), R_GetSkillLevel(SKILL_STRENGTH),
R_GetSkillLevel(SKILL_HITPOINTS), R_GetSkillLevel(SKILL_RANGE), R_GetSkillLevel(SKILL_PRAYER),
R_GetSkillLevel(SKILL_MAGIC), R_GetSkillLevel(SKILL_COOKING), R_GetSkillLevel(SKILL_WOODCUTTING),
R_GetSkillLevel(SKILL_FLETCHING), R_GetSkillLevel(SKILL_FISHING), R_GetSkillLevel(SKILL_FIREMAKING),
R_GetSkillLevel(SKILL_CRAFTING), R_GetSkillLevel(SKILL_SMITHING), R_GetSkillLevel(SKILL_MINING),
R_GetSkillLevel(SKILL_HERBLORE), R_GetSkillLevel(SKILL_AGILITY), R_GetSkillLevel(SKILL_THIEVING),
R_GetSkillLevel(SKILL_SLAYER), R_GetSkillLevel(SKILL_FARMING), R_GetSkillLevel(SKILL_RUNECRAFTING),
R_GetSkillLevel(SKILL_HUNTER), R_GetSkillLevel(SKILL_CONSTRUCTION), R_GetSkillLevel(SKILL_SUMMONING),
R_GetSkillLevel(SKILL_DUNGEONEERING)]
end;

{******************************************************************************}
{ procedure WriteData; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Handles extracting data from array and sending to WriteFile; }
{******************************************************************************}
Procedure Bobzilla_WriteData;
var
B, I:integer; //will only write when script is completely finished
newInfo:String; //if all players have not got data will not write any and simply not change data when clicked
Skills, Skills2:TStringArray;
begin
Bobzilla_CheckFile;
newInfo:= '<Characters>'+#13; //start of xml file
for I:=0 to HowManyPlayers - 1 do
begin
newInfo:= newInfo + '<Character>' + #13; //start for a palyer
newInfo := newInfo + '<Name>'+Players[I].Name+'</Name>'+#13;
Skills:= ['<Attack>','<Defence>','<Strength>','<Hitpoints>','<Range>','<Prayer>','<Magic>','<Cooking>','<Woodcutting>','<Fletching>','<Fishing>','<Firemaking>','<Crafting>','<Smithing>','<Mining>','<Herblore>','<Agility>','<Thieving>','<Slayer>','<Farming>','<Runercrafting>','<Hunter>','<Conctruction>','<Summining>','<Dungeoneering>'];
Skills2:= ['</Attack>','</Defence>','</Strength>','</Hitpoints>','</Range>','</Prayer>','</Magic>','</Cooking>','</Woodcutting>','</Fletching>','</Fishing>','</Firemaking>','</Crafting>','</Smithing>','</Mining>','</Herblore>','</Agility>','</Thieving>','</Slayer>','</Farming>','</Runercrafting>','</Hunter>','</Conctruction>','</Summining>','</Dungeoneering>'];
for B:=0 to high(Players[I].Arrays[1]) do
begin
newInfo := newInfo + Skills[B] + IntToStr(Players[I].Arrays[1][B]) + Skills2[B] + #13;
end; //IntToStr(Players[CurrentPlayer].Arrays[1][B]
newInfo:= newInfo + '</Character>' + #13; //end of character
end;
newInfo:= newInfo +'</Characters>'; //file end
Bobzilla_WriteFile(newInfo);
end;

Characters.html


<html>
<head>

<script type="text/javascript">
if (window.XMLHttpRequest)
{// code for IE7+, Firefox, Chrome, Opera, Safari
xmlhttp=new XMLHttpRequest();
}
else
{// code for IE6, IE5
xmlhttp=new ActiveXObject("Microsoft.XMLHTTP");
}
xmlhttp.open("GET","Characters.xml",false);
xmlhttp.send();
xmlDoc=xmlhttp.responseXML;
x=xmlDoc.getElementsByTagName("Character");

function displayRSCInfo(i)
{
Name=(x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue);
Attack=(x[i].getElementsByTagName("Attack")[0].childNodes[0].nodeValue);
Defence=(x[i].getElementsByTagName("Defence")[0].childNodes[0].nodeValue);
Strength=(x[i].getElementsByTagName("Strength")[0].childNodes[0].nodeValue);
Hitpoints=(x[i].getElementsByTagName("Hitpoints")[0].childNodes[0].nodeValue);
Range=(x[i].getElementsByTagName("Range")[0].childNodes[0].nodeValue);
Prayer=(x[i].getElementsByTagName("Prayer")[0].childNodes[0].nodeValue);
Magic=(x[i].getElementsByTagName("Magic")[0].childNodes[0].nodeValue);
Cooking=(x[i].getElementsByTagName("Cooking")[0].childNodes[0].nodeValue);
Woodcutting=(x[i].getElementsByTagName("Woodcutting")[0].childNodes[0].nodeValue);
Fletching=(x[i].getElementsByTagName("Fletching")[0].childNodes[0].nodeValue);
Fishing=(x[i].getElementsByTagName("Fishing")[0].childNodes[0].nodeValue);
Firemaking=(x[i].getElementsByTagName("Firemaking")[0].childNodes[0].nodeValue);
Crafting=(x[i].getElementsByTagName("Crafting")[0].childNodes[0].nodeValue);
Smithing=(x[i].getElementsByTagName("Smithing")[0].childNodes[0].nodeValue);
Mining=(x[i].getElementsByTagName("Mining")[0].childNodes[0].nodeValue);
Herblore=(x[i].getElementsByTagName("Herblore")[0].childNodes[0].nodeValue);
Agility=(x[i].getElementsByTagName("Agility")[0].childNodes[0].nodeValue);
Thieving=(x[i].getElementsByTagName("Thieving")[0].childNodes[0].nodeValue);
Slayer=(x[i].getElementsByTagName("Slayer")[0].childNodes[0].nodeValue);
Farming=(x[i].getElementsByTagName("Farming")[0].childNodes[0].nodeValue);
Runercrafting=(x[i].getElementsByTagName("Runercrafting")[0].childNodes[0].nodeValue);
Hunter=(x[i].getElementsByTagName("Hunter")[0].childNodes[0].nodeValue);
Conctruction=(x[i].getElementsByTagName("Conctruction")[0].childNodes[0].nodeValue);
Summining=(x[i].getElementsByTagName("Summining")[0].childNodes[0].nodeValue);
Dungeoneering=(x[i].getElementsByTagName("Dungeoneering")[0].childNodes[0].nodeValue);
txt="Attack: "+Attack +"<br />Defence: "+Defence +"<br />Strength: "+Strength +"<br />Hitpoints: "+Hitpoints +"<br />Range: " +Range+"<br />Prayer: " +Prayer+"<br />Magic: " +Magic+"<br />Cooking: " +Cooking+"<br />Woodcutting: " +Woodcutting+"<br />Fletching: " +Fletching+"<br />Fishing: " +Fishing+"<br />Firemaking: " +Firemaking+"<br />Crafting: " +Crafting+"<br />Smithing: " +Smithing+"<br />Mining: " +Mining+"<br />Herblore: " +Herblore+"<br />Agility: "+Agility+"<br />Thieving: " +Thieving+"<br />Slayer: " +Slayer+"<br />Farming: " +Farming+"<br />Runercrafting: " +Runercrafting+"<br />Hunter: " +Hunter+"<br />Conctruction: " +Conctruction+"<br />Summining: "+Summining +"<br />Dungeoneering: "+Dungeoneering ;
document.getElementById("ShowInfo").innerHTML=txt;
}
</script>
</head>
<body>
<title>RS Character Levels</title>
<table border='1'>
<tr><td>Character Name</td><td>SkillLevels</td></tr>
<tr><td>

<table border='1'>
<script type="text/javascript">
for (var i=0;i<x.length;i++)
{
document.write("<tr onclick='displayRSCInfo(" + i + ")'>");
document.write("<td>");
document.write(x[i].getElementsByTagName("Name")[0].childNodes[0].nodeValue);
document.write("</td></tr>");
}
</script>
</table>

</td>
<td><div id='ShowInfo'>Click on character name for skill info.</div></td></tr>
</table>



</body>
</html>

any thoughts on this?

Coh3n

2011-01-31 15:31:15

That's actually really cool. Can the XML file (or whatever) be saved so it can be viewed offline? E: Nvm, just read your edit.

Can't you just have it add to the list each time the script is run, rather than overwriting the whole file? You should also be able to check if a player is already on the list, so it doesn't duplicate the player.

Bobzilla69

2011-01-31 15:45:11

i am not to sure, i am pretty new to XML, never actually used it till now.

i will have to look into that but would be better than the way i am doing it atm just need to learn how.

Edit:

Doesn't look like it will be easy.

you have to follow its structure for it to read correctly, notice indents for each section (think array in a array)

xml format

<Characters> //all characters stored in
<Character> //store individual characters
<Name>charactername1</Name> //unique per entry
<Attack>42</Attack>
<Defence>13</Defence>
<Strength>31</Strength>
<Hitpoints>34</Hitpoints>
<Range>3</Range>
<Prayer>1</Prayer>
<Magic>1</Magic>
<Cooking>1</Cooking>
<Woodcutting>6</Woodcutting>
<Fletching>1</Fletching>
<Fishing>1</Fishing>
<Firemaking>1</Firemaking>
<Crafting>1</Crafting>
<Smithing>50</Smithing>
<Mining>60</Mining>
<Herblore>1</Herblore>
<Agility>1</Agility>
<Thieving>1</Thieving>
<Slayer>1</Slayer>
<Farming>1</Farming>
<Runercrafting>1</Runercrafting>
<Hunter>1</Hunter>
<Conctruction>1</Conctruction>
<Summining>1</Summining>
<Dungeoneering>1</Dungeoneering>
</Character>
<Character>
<Name>charactername2</Name>
<Attack>42</Attack>
<Defence>13</Defence>
<Strength>31</Strength>
<Hitpoints>34</Hitpoints>
<Range>3</Range>
<Prayer>1</Prayer>
<Magic>1</Magic>
<Cooking>1</Cooking>
<Woodcutting>6</Woodcutting>
<Fletching>1</Fletching>
<Fishing>1</Fishing>
<Firemaking>1</Firemaking>
<Crafting>1</Crafting>
<Smithing>50</Smithing>
<Mining>60</Mining>
<Herblore>1</Herblore>
<Agility>1</Agility>
<Thieving>1</Thieving>
<Slayer>1</Slayer>
<Farming>1</Farming>
<Runercrafting>1</Runercrafting>
<Hunter>1</Hunter>
<Conctruction>1</Conctruction>
<Summining>1</Summining>
<Dungeoneering>1</Dungeoneering>
</Character>
</Characters>


Coh3n

2011-01-31 16:28:32

If that's the format, you should just be able to read the file's text (get the string), and then use string methods to read the character's name. Or am I missing something?

Bobzilla69

2011-01-31 16:32:45

yeh i suppose that would work.

knowing when to rewire and where could be a problem.

can anyone point me to some examples of script that do that? or any info on how to i work best from examples :)

Coh3n

2011-01-31 16:50:57

From: Bobzilla69
yeh i suppose that would work.

knowing when to rewire and where could be a problem.

can anyone point me to some examples of script that do that? or any info on how to i work best from examples :)

I would say have it check the file in the procedure that writes to the file. Be something like:

if (PlayerAlreadyInFile) then
UpdatePlayer()
else
AddNewPlayer();
And sorry, I don't know of any examples and I'm not that familiar with the string functions myself.

Bobzilla69

2011-02-03 06:50:14

ok, i think have have managed to get it right so that it updates the XML sheet for relevant players and adds if its not in the XML sheet :)

just tested with 6 players, added two, stopped the script then started again and it updated the two already in the sheet and added the other 4 to bottom :)

left in bits so that it can be tested by you guys/girls, still uses the previously posted .html file to run locally, simply make sure you have the following folder in MSI (Includes\MSI\MSI\Extras\Accounts) this is where the .xml will save to.

also have the .html file in the folder to load the information

CharacterStats.simba (version 2)
program CharacterStatsV2;
{$DEFINE SMART}
{$i SRL\SRL.scar}
{$i Reflection\Reflection.simba}
{==============================================================================\
| MSI Group Scripting Include |
| CharacterStats.Simba |
|==============================================================================|
| For Storing Player Skill levels after Time/Loads are reached |
| |
| * procedure CheckFile; * by Bobzilla69 |
| * procedure WriteFile(); * by Bobzilla69 |
| * procedure GetData; * by Bobzilla69 |
| * procedure WriteData; * by Bobzilla69 |
| * procedure StoreCharacterLevels; * by Bobzilla69 |
\_____________________________________________________________________________}

Const
Path = IncludePath + 'MSI\MSI\Extras\Accounts\';

procedure DeclarePlayers;
var
I: integer;
begin
HowManyPlayers := 6;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

with Players[0] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

{with Players[1] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

with Players[2] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

with Players[3] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

with Players[4] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

with Players[5] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

{with Players[6] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

with Players[7] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

with Players[8] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end;

with Players[9] do
begin
Name := ''; //Username
Pass := ''; //Password
Nick := ''; //3-4 non uppercase, number, or space characters on your username
Pin := ''; //Bank Pin (Blank if none) not currently used, but might be later
Active := True; //Player Active?

end; }

for I := 0 to HowManyPlayers - 1 do
with Players[I] do
begin
BoxRewards := ['Xp', 'mote', 'ostume', 'oins', 'aphire', 'ssence'];
end;
end;


{******************************************************************************}
{ procedure CheckFile; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Check if File exists if it doent creates file. }
{ Also handles if file will be added to or rewritten }
{******************************************************************************}
Procedure Bobzilla_CheckFile;
var
Accounts:Integer;
begin
if FileExists(Path + 'Characters.xml') then
begin
//Writeln('File all ready created');
Accounts:= OpenFile(Path + 'Characters.xml' , False);
CloseFile(Accounts);
end else
begin
//WriteLn('File not Found, Creating new file')
Accounts := CreateFile(Path + 'Characters.xml');
CloseFile(Accounts);
end;
end;

{******************************************************************************}
{ procedure WriteFile(New, Old:string); }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Writes Character data to the file. }
{ New is new data to be added to file. }
{ Old is data that was in file to be re writen }
{******************************************************************************}
Procedure Bobzilla_WriteFile(New:String);
var
Accounts:Integer;
begin
Accounts := RewriteFile(Path + 'Characters.xml', False);
WriteFileString(Accounts, New);
CloseFile(Accounts);
end;

{******************************************************************************}
{ procedure GetData; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Using reflection gets all character skill levels }
{ and stores it to a Array for that character }
{******************************************************************************}
Procedure Bobzilla_GetData;
begin
Players[CurrentPlayer].Arrays[1]:= [
R_GetSkillLevel(SKILL_ATTACK), R_GetSkillLevel(SKILL_DEFENCE), R_GetSkillLevel(SKILL_STRENGTH),
R_GetSkillLevel(SKILL_HITPOINTS), R_GetSkillLevel(SKILL_RANGE), R_GetSkillLevel(SKILL_PRAYER),
R_GetSkillLevel(SKILL_MAGIC), R_GetSkillLevel(SKILL_COOKING), R_GetSkillLevel(SKILL_WOODCUTTING),
R_GetSkillLevel(SKILL_FLETCHING), R_GetSkillLevel(SKILL_FISHING), R_GetSkillLevel(SKILL_FIREMAKING),
R_GetSkillLevel(SKILL_CRAFTING), R_GetSkillLevel(SKILL_SMITHING), R_GetSkillLevel(SKILL_MINING),
R_GetSkillLevel(SKILL_HERBLORE), R_GetSkillLevel(SKILL_AGILITY), R_GetSkillLevel(SKILL_THIEVING),
R_GetSkillLevel(SKILL_SLAYER), R_GetSkillLevel(SKILL_FARMING), R_GetSkillLevel(SKILL_RUNECRAFTING),
R_GetSkillLevel(SKILL_HUNTER), R_GetSkillLevel(SKILL_CONSTRUCTION), R_GetSkillLevel(SKILL_SUMMONING),
R_GetSkillLevel(SKILL_DUNGEONEERING)]
end;

{******************************************************************************}
{ procedure UpdatePlayer; }
{ By: Bobzilla69 }
{ Date: 13 January 2011 }
{ Description: Handels checking if player is in File and updating or adding }
{ Should be called before logging out }
{******************************************************************************}

procedure Bobzilla_UpdatePlayer;
var
Text, After:String;
SplitText, Skills, Skills2: TStringArray;
Updated:Boolean;
I, S, Accounts:integer;
begin
Updated:= False; //used for checkign if updating or adding

Bobzilla_CheckFile; //checks file is created if nto makes file

Bobzilla_GetData; //uses reflection to get players skill levels

Accounts:= OpenFile(Path + 'Characters.xml' , False); //opens file to get data inside it
ReadFileString(Accounts, Text, FileSize(accounts));
CloseFile(Accounts);

SplitText:= srl_Explode(Text, '</Character>'); //splits characters into sections

for I:=0 to high(Splittext) -1 do //0 = start <characters> <character>, last number = </characters>
begin
if PosEx(Players[CurrentPlayer].Name ,SplitText[I], 1) > 0 then //checks for player name in sections
begin
Writeln('Player Found in XML, Updating');
if I = 0 then //because of the way they are split the first split needs to readd all this info
begin
After:= '<Characters>' + #13;
After:= After + '<Character>' + #13;
After := After + '<Name>' + Players[CurrentPlayer].Name + '</Name>' + #13;
Skills:= ['<Attack>','<Defence>','<Strength>','<Hitpoints>','<Range>','<Prayer>','<Magic>','<Cooking>','<Woodcutting>','<Fletching>','<Fishing>','<Firemaking>','<Crafting>','<Smithing>','<Mining>','<Herblore>','<Agility>','<Thieving>','<Slayer>','<Farming>','<Runercrafting>','<Hunter>','<Conctruction>','<Summining>','<Dungeoneering>'];
Skills2:= ['</Attack>','</Defence>','</Strength>','</Hitpoints>','</Range>','</Prayer>','</Magic>','</Cooking>','</Woodcutting>','</Fletching>','</Fishing>','</Firemaking>','</Crafting>','</Smithing>','</Mining>','</Herblore>','</Agility>','</Thieving>','</Slayer>','</Farming>','</Runercrafting>','</Hunter>','</Conctruction>','</Summining>','</Dungeoneering>'];
for S:=0 to high(Skills) do
begin
After := After + Skills[S] + IntToStr(Players[CurrentPlayer].Arrays[1][S]) + Skills2[S] + #13;
end; //IntToStr(Players[CurrentPlayer].Arrays[1][B]
After:= After + '</Character>'+#13;
end else
begin
After:= After + '<Character>'+#13;
After := After + '<Name>'+Players[CurrentPlayer].Name+'</Name>'+#13;
Skills:= ['<Attack>','<Defence>','<Strength>','<Hitpoints>','<Range>','<Prayer>','<Magic>','<Cooking>','<Woodcutting>','<Fletching>','<Fishing>','<Firemaking>','<Crafting>','<Smithing>','<Mining>','<Herblore>','<Agility>','<Thieving>','<Slayer>','<Farming>','<Runercrafting>','<Hunter>','<Conctruction>','<Summining>','<Dungeoneering>'];
Skills2:= ['</Attack>','</Defence>','</Strength>','</Hitpoints>','</Range>','</Prayer>','</Magic>','</Cooking>','</Woodcutting>','</Fletching>','</Fishing>','</Firemaking>','</Crafting>','</Smithing>','</Mining>','</Herblore>','</Agility>','</Thieving>','</Slayer>','</Farming>','</Runercrafting>','</Hunter>','</Conctruction>','</Summining>','</Dungeoneering>'];
for S:=0 to high(Skills) do
begin
After := After + Skills[S] + IntToStr(Players[CurrentPlayer].Arrays[1][S]) + Skills2[S] + #13;
end;
After:= After + '</Character>' + #13;
end;
Updated:= True; //we updated plaer so no need to add one
end else
begin //if player is not in split section simply store data that is in it
After:= After + SplitText[I];
After:= After + '</Character>' + #13;
end;
end;
if (not Updated) then //no player in section so we add onto end of file
begin
writeln('Player not found, Adding Player');
if I = 0 then //same as previouse if its a new file we need to write starting info
begin
After:= '<Characters>' + #13;
After:= After + '<Character>' + #13;
After := After + '<Name>' + Players[CurrentPlayer].Name + '</Name>' + #13;
Skills:= ['<Attack>','<Defence>','<Strength>','<Hitpoints>','<Range>','<Prayer>','<Magic>','<Cooking>','<Woodcutting>','<Fletching>','<Fishing>','<Firemaking>','<Crafting>','<Smithing>','<Mining>','<Herblore>','<Agility>','<Thieving>','<Slayer>','<Farming>','<Runercrafting>','<Hunter>','<Conctruction>','<Summining>','<Dungeoneering>'];
Skills2:= ['</Attack>','</Defence>','</Strength>','</Hitpoints>','</Range>','</Prayer>','</Magic>','</Cooking>','</Woodcutting>','</Fletching>','</Fishing>','</Firemaking>','</Crafting>','</Smithing>','</Mining>','</Herblore>','</Agility>','</Thieving>','</Slayer>','</Farming>','</Runercrafting>','</Hunter>','</Conctruction>','</Summining>','</Dungeoneering>'];
for S:=0 to high(Skills) do
begin
After := After + Skills[S] + IntToStr(Players[CurrentPlayer].Arrays[1][S]) + Skills2[S] + #13;
end; //IntToStr(Players[CurrentPlayer].Arrays[1][B]
After:= After + '</Character>' + #13;
end else
begin
After:= After + '<Character>'+#13;
After := After + '<Name>'+Players[CurrentPlayer].Name+'</Name>'+#13;
Skills:= ['<Attack>','<Defence>','<Strength>','<Hitpoints>','<Range>','<Prayer>','<Magic>','<Cooking>','<Woodcutting>','<Fletching>','<Fishing>','<Firemaking>','<Crafting>','<Smithing>','<Mining>','<Herblore>','<Agility>','<Thieving>','<Slayer>','<Farming>','<Runercrafting>','<Hunter>','<Conctruction>','<Summining>','<Dungeoneering>'];
Skills2:= ['</Attack>','</Defence>','</Strength>','</Hitpoints>','</Range>','</Prayer>','</Magic>','</Cooking>','</Woodcutting>','</Fletching>','</Fishing>','</Firemaking>','</Crafting>','</Smithing>','</Mining>','</Herblore>','</Agility>','</Thieving>','</Slayer>','</Farming>','</Runercrafting>','</Hunter>','</Conctruction>','</Summining>','</Dungeoneering>'];
for S:=0 to high(Skills) do
begin
After := After + Skills[S] + IntToStr(Players[CurrentPlayer].Arrays[1][S]) + Skills2[S] + #13;
end;
After:= After + '</Character>' + #13;
end;
end;
After:= After + '</Characters>' + #13; //writes end of file

Bobzilla_WriteFile(After); //Writes data back to file


end;

begin
Smart_Server := 134;
Smart_Signed := True;
SetupSRL;
DeclarePlayers;
repeat
LoginPlayer;
Wait(1500);
Bobzilla_UpdatePlayer;
Wait(500);
Players[CurrentPlayer].Active := False;
Logout;
until(AllPlayersInactive)
end.

So tell me what you think of the new version. (i am sure you can improve my messy code)

Coh3n

2011-02-04 03:30:47

Looks good to me. :) Sorry it took so long to reply, I had to catch up on a lot of threads. Have you tried adding it to MSI? I you can, you'll be making adding it a lot easier for us. :)

Bobzilla69

2011-02-04 03:35:26

Thanks for the reply, hope your trip is going well :)

adding to MSI will be easy and would be done the same way i did it previously in the thread, simply adding in the Bobzilla_UpdatePlayer; where i had Bobzilla_GetData;

i will run a test with it to confirm later.

Coh3n

2011-02-04 03:49:50

From: Bobzilla69
Thanks for the reply, hope your trip is going well :)

adding to MSI will be easy and would be done the same way i did it previously in the thread, simply adding in the Bobzilla_UpdatePlayer; where i had Bobzilla_GetData;

i will run a test with it to confirm later.

Wonderful, thanks. :) Also, you may want to look in to a feature Zyt3x added about adding Extras. He wrote a new system (very simple, won't change your code much at all). I don't think he's written a guide on it yet, so you may want to PM him. Just a suggestion. :)

Bobzilla69

2011-02-04 03:52:34

ok, i will do. thanks

Coh3n

2011-02-15 03:21:16

Just want to make sure you know I haven't forgotten about this. A new Extras system is in the works, so this will get added eventually (maybe before the new system, if I get to it on my list). Quick suggestion: if it doesn't already, get the stats with color if reflection is broken/not being used. You can just use the {$IFDEF REFLETION} defines. ;)

Bobzilla69

2011-02-15 06:02:26

i aint forgetten about this, been waiting to find out more about how to use the extras system, i kinda get it but a tutorial would be better.

Yeh i can do that and add the color method, how does the {$IFDEF REFLETION} work? what does it do, i am not to keyed up on these things

Gu3st...

2011-02-15 06:11:02

From: Bobzilla69
i aint forgetten about this, been waiting to find out more about how to use the extras system, i kinda get it but a tutorial would be better.

Yeh i can do that and add the color method, how does the {$IFDEF REFLETION} work? what does it do, i am not to keyed up on these things
I'm doing some changes to the system, by the way, so be ready for some changes :)

code between {$IFDEF REFLECTION} and {$ENDIF} will not be compiled if REFLECTION isn't defined using {$DEFINE REFLECTION}

Bobzilla69

2011-02-15 06:26:10

ok, so i dont have to do the {$DEFINE REFLECTION} bit because MSI will set that so i simply put the reflection stuff inside that and color outside it.

Ok will wait till changes are done then hassle you for a tutorial :)

Sir R. M8gic1an

2011-02-15 08:46:55

Should be simple


{$IFDEF REFLECTION}
CODE
{$ENDIF}


//MSI Hybrid =
function DoSomething(someparams: TParam): boolean;
begin
{$IFDEF REFLECTION}
Track(DoSomething, TRACK_START);
Result := MSIREF_DoSomething(someparams);
if Result = MSICol_DoSomething(someparams) then
track(DoSomething, TRACK_SUCCESS);

exit;
{$ENDIF}

Result := MSICol_DoSomething(someParams);
end;

*This is my opinion, not necessarily how it'll happen nor what Zytex was saying*

edit: Hybridity can probably be made into a single function, or close to it.

MSI_Hybrid(Function_A, Function_B, TrackRecord);

~RM

Bobzilla69

2011-02-15 11:42:20

From: Zyt3x
I'm doing some changes to the system, by the way, so be ready for some changes :)

code between {$IFDEF REFLECTION} and {$ENDIF} will not be compiled if REFLECTION isn't defined using {$DEFINE REFLECTION}


does this look right?

Procedure Bobzilla_GetData;
begin
{$IFDEF REFLECTION}
Players[CurrentPlayer].Arrays[1]:= [
R_GetSkillLevel(SKILL_ATTACK), R_GetSkillLevel(SKILL_DEFENCE), R_GetSkillLevel(SKILL_STRENGTH),
R_GetSkillLevel(SKILL_HITPOINTS), R_GetSkillLevel(SKILL_RANGE), R_GetSkillLevel(SKILL_PRAYER),
R_GetSkillLevel(SKILL_MAGIC), R_GetSkillLevel(SKILL_COOKING), R_GetSkillLevel(SKILL_WOODCUTTING),
R_GetSkillLevel(SKILL_FLETCHING), R_GetSkillLevel(SKILL_FISHING), R_GetSkillLevel(SKILL_FIREMAKING),
R_GetSkillLevel(SKILL_CRAFTING), R_GetSkillLevel(SKILL_SMITHING), R_GetSkillLevel(SKILL_MINING),
R_GetSkillLevel(SKILL_HERBLORE), R_GetSkillLevel(SKILL_AGILITY), R_GetSkillLevel(SKILL_THIEVING),
R_GetSkillLevel(SKILL_SLAYER), R_GetSkillLevel(SKILL_FARMING), R_GetSkillLevel(SKILL_RUNECRAFTING),
R_GetSkillLevel(SKILL_HUNTER), R_GetSkillLevel(SKILL_CONSTRUCTION), R_GetSkillLevel(SKILL_SUMMONING),
R_GetSkillLevel(SKILL_DUNGEONEERING)];
{$ELSE}
Players[CurrentPlayer].Arrays[1]:= [
GetSkillLevel(SKILL_ATTACK), GetSkillLevel(SKILL_DEFENCE), GetSkillLevel(SKILL_STRENGTH),
GetSkillLevel(SKILL_HITPOINTS), GetSkillLevel(SKILL_RANGE), GetSkillLevel(SKILL_PRAYER),
GetSkillLevel(SKILL_MAGIC), GetSkillLevel(SKILL_COOKING), GetSkillLevel(SKILL_WOODCUTTING),
GetSkillLevel(SKILL_FLETCHING), GetSkillLevel(SKILL_FISHING), GetSkillLevel(SKILL_FIREMAKING),
GetSkillLevel(SKILL_CRAFTING), GetSkillLevel(SKILL_SMITHING), GetSkillLevel(SKILL_MINING),
GetSkillLevel(SKILL_HERBLORE), GetSkillLevel(SKILL_AGILITY), GetSkillLevel(SKILL_THIEVING),
GetSkillLevel(SKILL_SLAYER), GetSkillLevel(SKILL_FARMING), GetSkillLevel(SKILL_RUNECRAFTING),
GetSkillLevel(SKILL_HUNTER), GetSkillLevel(SKILL_CONSTRUCTION), GetSkillLevel(SKILL_SUMMONING),
GetSkillLevel(SKILL_DUNGEONEERING)];
{$ENDIF}
end;

Gu3st...

2011-02-15 11:44:52

From: Bobzilla69
does this look right?

Procedure Bobzilla_GetData;
begin
{$IFDEF REFLECTION}
Players[CurrentPlayer].Arrays[1]:= [
R_GetSkillLevel(SKILL_ATTACK), R_GetSkillLevel(SKILL_DEFENCE), R_GetSkillLevel(SKILL_STRENGTH),
R_GetSkillLevel(SKILL_HITPOINTS), R_GetSkillLevel(SKILL_RANGE), R_GetSkillLevel(SKILL_PRAYER),
R_GetSkillLevel(SKILL_MAGIC), R_GetSkillLevel(SKILL_COOKING), R_GetSkillLevel(SKILL_WOODCUTTING),
R_GetSkillLevel(SKILL_FLETCHING), R_GetSkillLevel(SKILL_FISHING), R_GetSkillLevel(SKILL_FIREMAKING),
R_GetSkillLevel(SKILL_CRAFTING), R_GetSkillLevel(SKILL_SMITHING), R_GetSkillLevel(SKILL_MINING),
R_GetSkillLevel(SKILL_HERBLORE), R_GetSkillLevel(SKILL_AGILITY), R_GetSkillLevel(SKILL_THIEVING),
R_GetSkillLevel(SKILL_SLAYER), R_GetSkillLevel(SKILL_FARMING), R_GetSkillLevel(SKILL_RUNECRAFTING),
R_GetSkillLevel(SKILL_HUNTER), R_GetSkillLevel(SKILL_CONSTRUCTION), R_GetSkillLevel(SKILL_SUMMONING),
R_GetSkillLevel(SKILL_DUNGEONEERING)];
{$ELSE}
Players[CurrentPlayer].Arrays[1]:= [
GetSkillLevel(SKILL_ATTACK), GetSkillLevel(SKILL_DEFENCE), GetSkillLevel(SKILL_STRENGTH),
GetSkillLevel(SKILL_HITPOINTS), GetSkillLevel(SKILL_RANGE), GetSkillLevel(SKILL_PRAYER),
GetSkillLevel(SKILL_MAGIC), GetSkillLevel(SKILL_COOKING), GetSkillLevel(SKILL_WOODCUTTING),
GetSkillLevel(SKILL_FLETCHING), GetSkillLevel(SKILL_FISHING), GetSkillLevel(SKILL_FIREMAKING),
GetSkillLevel(SKILL_CRAFTING), GetSkillLevel(SKILL_SMITHING), GetSkillLevel(SKILL_MINING),
GetSkillLevel(SKILL_HERBLORE), GetSkillLevel(SKILL_AGILITY), GetSkillLevel(SKILL_THIEVING),
GetSkillLevel(SKILL_SLAYER), GetSkillLevel(SKILL_FARMING), GetSkillLevel(SKILL_RUNECRAFTING),
GetSkillLevel(SKILL_HUNTER), GetSkillLevel(SKILL_CONSTRUCTION), GetSkillLevel(SKILL_SUMMONING),
GetSkillLevel(SKILL_DUNGEONEERING)];
{$ENDIF}
end;
Yes :) That looks just fine to me

Coh3n

2011-02-15 13:18:38

Yeah that looks right; although it could probably be done using a loop.

Bobzilla69

2011-02-15 13:30:51

what do you mean a loop?

Gu3st...

2011-02-15 13:49:18

From: Bobzilla69
what do you mean a loop?
Procedure Bobzilla_GetData;
var
I : Integer;
begin
{$IFDEF REFLECTION}
for I := SKILL_ATTACK to SKILL_DUNGEONEERING do
Players[CurrentPlayer].Arrays[1][I] := R_GetSkillLevel(I);
{$ELSE}
for I := SKILL_ATTACK to SKILL_DUNGEONEERING do
Players[CurrentPlayer].Arrays[1][I] := GetSkillLevel(I);
{$ENDIF}
end;

Bobzilla69

2011-02-15 13:50:51

ahh i see, well that makes alot of sense, :)

see you never stop learning

Gu3st...

2011-10-29 09:56:10

Seems like the .html file isn't working properly…

Bobzilla, would you like to take a look at it?

Coh3n

2011-10-31 00:56:26

From: Zyt3x
Seems like the .html file isn't working properly…

Bobzilla, would you like to take a look at it?
It's working fine for me? I'm using Firefox, but I'm pretty sure it should work in all browsers.

Gu3st...

2011-10-31 01:52:00

From: Coh3n
It's working fine for me? I'm using Firefox, but I'm pretty sure it should work in all browsers.
Weird, must be a problem with my browser then.. :( I'm using Chrome with IE tabs

Coh3n

2011-10-31 02:20:39

Hm that should be okay. I did the same thing before I switched to FF. Maybe Bobzilla made some updates that I can't remember? Do you get an error or what?

Bobzilla69

2011-10-31 08:02:04

It seems to be due to you needing something enabled, if you launch IE9? or whatever the latest is it will have a dialogue that asks if you want to enable it.

chrome doesnt seem to do this.

FF just works :)

it may be javascript that needs to be on, i cant remember