SRL Archive - MSI Suggestions

Load players from INI?


nickrules

2010-10-15 10:01:07

TL;DR at bottom
With MSI, almost everything is changing, all the time. Except for RunMe(mostly). Since I have used MSI, I can probably count on one hand how many times a significant change has been made. However, every time MSI updates (at least, with the updater I use), it overwrites RunMe.simba, and all of my settings are gone. I honestly don't remember what subversion does.

Regardless of what it does, it still leaves the point that a system needs to be developed for loading players for the form.
The INIs structure could be something like this (may not be correct…)
[PHP][GENERAL]
PlayerCount = 1
smsUID = 999
smsPass = Passwordwhichisextremelylongbecauseyoureafraidofsupposedhackers
World = 0
DEBUG_SMART = True;
BREAK_TIME = 15;
SAVE_DEBUG = True
ENABLE_REMOTE = True
LEVEL_TO_DEBUG = 10
HUMAN_BREAKING = True
ANTIBAN_MIN_WAIT = 10000
CurrentPlayer := 0
CurrentScript := 0

[PLAYER0]
Name = noob
pass = noobpass
nick = oob
active = true
Member = True
Location = LOC_POWER_SKILL
Scripts = [SCRIPT_POWER_MINER]
Objects = [[ROCK_ADDY, ROCK_MITHRIL]]
Priority = [[75,25]]
DontDrop = [thing1]
LoadsPerLogin = 6
LoadsTotal = 30 [/PHP]
This is just a general Idea. The PLAYER0 section would become PLAYER1 and then PLAYER2 until it has all the players it needs. Using the playercont, the function would know how many PLAYERX sections to read

Discuss

TL;DR Version:
Read players from INI, that way they don't get overwritten every update. Also will be needed for form.

Sir R. M8gic1an

2010-10-15 10:46:55

Sounds good to me! Great even!

~RM

Coh3n

2010-10-15 19:08:59

I use TortoiseSVN and only the files that were updated are changed. RunMe.simba has never been overridden (unless it was edited by an SL). I do like the idea though, and it will definitely be done when the form is implemented (if not sooner). I actually made a breakthrough on the form yesterday, so it shouldn't be too far down the road. :)

nickrules

2010-10-15 19:45:45

Sweet! I can't wait till the form is added. Then magic can finally be added with ease. Or at least without more unnecessary setup.

On the topic of overriding, I use an updater (by Timer) that works like the SRL updater. Which means it overwrites everything.

Im going to read some tutorials on INI reading, as I only remember the general concept of it….

Coh3n

2010-10-16 02:56:46

From: nickrules
On the topic of overriding, I use an updater (by Timer) that works like the SRL updater. Which means it overwrites everything.

Do the Reflection and SRL auto-updaters also override all the files?

Nevertheless, when the form is done, there will be the option to save/load players, so this will be taken care of. :) BUT, if you get all the code done before (which I have no doubt you will), I'll be happy to add it.

nickrules

2010-10-16 10:15:04

Any Idea for the arrays?
INIs write/read strings, but pretty much every constant is an integer.

Nava2

2010-10-16 10:30:53

From: nickrules
Any Idea for the arrays?
INIs write/read strings, but pretty much every constant is an integer.


Check out Explode and Implode. Also, for integers, just use strings and do ToStr -> StrToInt(). It will work ;)

nickrules

2010-10-16 11:11:59

Oops, I probably should have clarified a bit more.
The constants are not strings, they are just a… word, which equals an integer. Either the user would have to set the objects/items/whatever-it-is using the integer equivalent (which probably wouldn't work anyways)…..

Heres a good way to explain it i guess
ROCK_IRON is not the same as 'ROCK_IRON', 'Iron rock' or anything else like that.

E: post was at 11:11. just felt like i needed to point that out…

Coh3n

2010-10-16 13:11:33

From: nickrules
Oops, I probably should have clarified a bit more.
The constants are not strings, they are just a… word, which equals an integer. Either the user would have to set the objects/items/whatever-it-is using the integer equivalent (which probably wouldn't work anyways)…..

Heres a good way to explain it i guess
ROCK_IRON is not the same as 'ROCK_IRON', 'Iron rock' or anything else like that.

E: post was at 11:11. just felt like i needed to point that out…

The function that saves the INI would just save the integer it represents, although I don't think you would be able to read from the INI like you're intending to (without using a form).

An alternative could be to just save a copy of DeclarePlayers and script setup in another file, so when the file is overridden, you can just copy/paste.

nickrules

2010-10-17 15:20:49

If we had StrToObject, StrToLocation, and StrToScript, it could work xD

Otherwise, we're at a bit of a standstill….

program new;

Function INIExists: boolean;
begin
if FileExists(ScriptPath+'\players.INI') then
begin
Result := true;
end else
result := false;
Writeln('Player INI not found :O! Making one now.')
end;

Procedure MakeNewINI;
begin
//General Settings
WriteINI('GENERAL', 'PlayerCount', '1', ScriptPath+'\players.INI');
WriteINI('GENERAL', 'smsID', ' ', ScriptPath+'\players.INI');
WriteINI('GENERAL', 'smsPass', ' ', ScriptPath+'\players.INI');
WriteINI('GENERAL', 'CurrentPlayer', ' ', ScriptPath+'\players.INI');
WriteINI('GENERAL', 'CurrentScript', ' ', ScriptPath+'\players.INI');

//Player0
WriteINI('PLAYER0', 'Name', ' ', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'Pass', ' ', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'Nick', ' ', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'Pin', ' ', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'Active', 'True', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'Member', 'False', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'Location', ' ', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'Objects', ' ', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'Priority', ' ', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'DontDrop', ' ', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'LoadsPerLogin', '10', ScriptPath+'\players.INI');
WriteINI('PLAYER0', 'LoadsTotal', '50', ScriptPath+'\players.INI');

end;

function ExtractEasyInfo: boolean;
var P: integer; //p = the player we are working on
G: integer; //Current string we are reading
F: TStringArray; //List of said strings
begin
F := ['Name','Pass','Nick','Pin','Active', 'Member', 'LoadsPerLogin','LoadsTotal']


//Write the general Information.
HowManyPlayers := ReadINI('GENERAL', 'PlayerCount', ScriptPath+'\players.INI');
//ReadINI('GENERAL', 'smsID', ScriptPath+'\players.INI');
//ReadINI('GENERAL', 'smsPass', ScriptPath+'\players.INI');
CurrentPlayer := ReadINI('GENERAL', 'CurrentPlayer', ScriptPath+'\players.INI');
CurrentScript := ReadINI('GENERAL', 'CurrentScript', ScriptPath+'\players.INI');

for 0 to HowManyPlayers - 1 do
//Player0
with MSI_Players[P] do
begin
Name := ReadINI('PLAYER'+IntToStr(p), F[g], ScriptPath+'\players.INI'); // Username
inc(g)
Pass := ReadINI('PLAYER'+IntToStr(p), F[g], ScriptPath+'\players.INI'); // Password
inc(g)
Nick := ReadINI('PLAYER'+IntToStr(p), F[g], ScriptPath+'\players.INI'); // Nickname
inc(g)
Pin := ReadINI('PLAYER'+IntToStr(p), F[g], ScriptPath+'\players.INI'); // Bank pin
inc(g)
Active := StrToBool((ReadINI('PLAYER'+IntToStr(p), F[g], ScriptPath+'\players.INI')); //active
inc(g)
Member := StrToBool(ReadINI('PLAYER'+IntToStr(p), F[g], ScriptPath+'\players.INI')); //member?
inc(g)
Loads[0] := StrToInt(ReadINI('PLAYER'+IntToStr(p), F[g], ScriptPath+'\players.INI')); // Amount of loads before breaking/switching players
inc(g)
Loads[1] := StrToInt(ReadINI('PLAYER'+IntToStr(p), F[g], ScriptPath+'\players.INI')); // Total loads for the player to do
end;


{
//What I need to add
Location := LOC_POWER_SKILL; // See instructions at the top
Scripts := [SCRIPT_POWER_MINER]; // See instructions at the top
Objects := [[ROCK_IRON]]; // See instructions at the top
Priority := [[]]; // See instructions at the top
DontDrop := []; // See instructions at the top

//random stuff
ReadINI('PLAYER'+IntToStr(p), 'Member', ScriptPath+'\players.INI');
ReadINI('PLAYER'+IntToStr(p), 'Location', ScriptPath+'\players.INI');
ReadINI('PLAYER'+IntToStr(p), 'Objects', ScriptPath+'\players.INI');
ReadINI('PLAYER'+IntToStr(p), 'Priority', ScriptPath+'\players.INI');
ReadINI('PLAYER'+IntToStr(p), 'DontDrop', ScriptPath+'\players.INI');
ReadINI('PLAYER'+IntToStr(p), 'LoadsPerLogin', ScriptPath+'\players.INI');
ReadINI('PLAYER'+IntToStr(p), 'LoadsTotal', ScriptPath+'\players.');
}
end;



begin
{if not INIExists then
MakeNewINI;
else }
end.

I'll have a function for don't drop and priority in a few. For now however, my brother who I rarely see is home :D

Gu3st...

2010-10-17 16:41:51

I couldn't agree more. :)
I even did this is my TUBI (an include I made)

Coh3n

2010-10-17 17:25:18


function ExtractEasyInfo: boolean;
var
P: integer; //p = the player we are working on
begin
//Write the general Information.
HowManyPlayers := ReadINI('GENERAL', 'PlayerCount', ScriptPath+'\players.INI');
//ReadINI('GENERAL', 'smsID', ScriptPath+'\players.INI');
//ReadINI('GENERAL', 'smsPass', ScriptPath+'\players.INI');
CurrentPlayer := ReadINI('GENERAL', 'CurrentPlayer', ScriptPath+'\players.INI');
CurrentScript := ReadINI('GENERAL', 'CurrentScript', ScriptPath+'\players.INI');

for P := 0 to HowManyPlayers - 1 do
//Player0
with MSI_Players[P] do
begin
Name := ReadINI('PLAYER'+IntToStr(p), 'Name', ScriptPath+'\players.INI'); // Username
Pass := ReadINI('PLAYER'+IntToStr(p), 'Pass', ScriptPath+'\players.INI'); // Password
Nick := ReadINI('PLAYER'+IntToStr(p), 'Nick', ScriptPath+'\players.INI'); // Nickname
Pin := ReadINI('PLAYER'+IntToStr(p), 'Pin', ScriptPath+'\players.INI'); // Bank pin
Active := StrToBool(ReadINI('PLAYER'+IntToStr(p), 'Active', ScriptPath+'\players.INI')); //active
Member := StrToBool(ReadINI('PLAYER'+IntToStr(p), 'Member', ScriptPath+'\players.INI')); //member?
Loads[0] := StrToInt(ReadINI('PLAYER'+IntToStr(p), 'LoadsPerLogin', ScriptPath+'\players.INI')); // Amount of loads before breaking/switching players
Loads[1] := StrToInt(ReadINI('PLAYER'+IntToStr(p), 'LoadsTotal', ScriptPath+'\players.INI')); // Total loads for the player to do
end;
end;
You didn't really need the F and G variables for what you wanted to do. I would also suggest making the file path a constant (we may actually be able to use the same file as the player remote). You should also name it as a text file rather than .INI. You will avoid a whole bunch of errors that way.

With the way this is headed, this would be used as a replacement for DeclarePlayers as all the player info would be read from a file. I'm not sure how I feel about this because the user would have to open the text file, fill everything out, and then open and run RunMe.simba. It's just another step that may not be necessary (at least not until the form is released).

nickrules

2010-10-17 21:28:32

Yeah… I originally had it the way you do, but made it an array as practice, realized it was really long but didn't feel like fixing it :P

—
To address your last point, This was made for people like me who have runme overwritten every time, as well as the fact that something like this will have to be made for the form. Two birds with one stone?

—
So what should be done about globals (objects, locations, scripts, etc)?


E: Priority array declaring finished.

Coh3n

2010-10-17 21:48:10

From: nickrules

To address your last point, This was made for people like me who have runme overwritten every time, as well as the fact that something like this will have to be made for the form. Two birds with one stone?

Well similar functions will be used, but not exactly the same. For example, the text file will be read/written to when the user saves/loads players. The script itself will read from the components of the form (test boxes, etc.).

From: nickrules

So what should be done about globals (objects, locations, scripts, etc)?

I think you'll have to use a loop since their arrays so it would be displayed something like:

Name = Cohen
Pass = Hello1
.
.
.
Scripts0 = 10
Objects[0]0 = 25
Objects[0]1 = 30
.
.
.
Know what I mean?

nickrules

2010-10-18 17:15:38

Well yeah, I think I do. but it sorta defeats the point. I could easily make it just grab numbers - Its basically a priority array, The idea is to have the user put in
[PLAYER0]
...
Objects ROCK_MITH|ROCK_COAL
...

not:

[PLAYER0]
...
Objects 17|14
...

I suppose a log of all objects, scripts, items etc. and their numerical equivalent could be created…

Coh3n

2010-10-19 01:55:25

From: nickrules
Well yeah, I think I do. but it sorta defeats the point. I could easily make it just grab numbers - Its basically a priority array, The idea is to have the user put in
[PLAYER0]
...
Objects ROCK_MITH|ROCK_COAL
...

not:

[PLAYER0]
...
Objects 17|14
...

I suppose a log of all objects, scripts, items etc. and their numerical equivalent could be created…

Actually the user could fill it out by name then when we read from the file it compares what's read to MSI_Scripts.Name. We'd have to make sure it isn't case sensitive though.

i luffs yeww

2010-10-19 01:58:20

^ LowerCase(str)? :)

Coh3n

2010-10-19 01:59:17

From: i luffs yeww
^ LowerCase(str)? :)

Well yeah, but I wanted him to figure it out. :p

nickrules

2010-10-19 21:54:29

Ok, so that could work for scripts…

Wait a second, im having a smart thought of smartly-ness….
For LOW_ITEMS(objects or w/e) to HIGH_ITEMS(objects or w/e) do
NameString := object[0].Name
Inc(i)

Then, im sure the wizzyplugin has something for checking the contents of an array….
This of course depends on how objects are done, but its late and I have to do stuff, so I can't check now….

Coh3n

2010-10-20 02:23:09

From: nickrules
Ok, so that could work for scripts…

Wait a second, im having a smart thought of smartly-ness….
For LOW_ITEMS(objects or w/e) to HIGH_ITEMS(objects or w/e) do
NameString := object[0].Name
Inc(i)

Then, im sure the wizzyplugin has something for checking the contents of an array….
This of course depends on how objects are done, but its late and I have to do stuff, so I can't check now….

Yeah you can just do:

for i := 0 to High(MSI_Objects) do
if (StringReadFromFileHere = MSI_Objects[i].Name) then
The same can be done for all attributes of the TMSObject.

nickrules

2010-10-20 17:09:01

Well we only need to declare it as a constant.

for i := 0 to High(MSI_Objects) do
if (ReadINI('PLAYER'+IntToStr(P), 'Object', FilePath = MSI_Objects[i].Name) then
ObjArray := ObjArray + MSI_Objects[i]

MSI_Player[P].Objects := [ObjArray]

Should work, right? Can't really test atm…

Coh3n

2010-10-21 03:28:28

From: nickrules
Well we only need to declare it as a constant.

for i := 0 to High(MSI_Objects) do
if (ReadINI('PLAYER'+IntToStr(P), 'Object', FilePath = MSI_Objects[i].Name) then
ObjArray := ObjArray + MSI_Objects[i]

MSI_Player[P].Objects := [ObjArray]

Should work, right? Can't really test atm…

Close. :)

for i := 0 to High(MSI_Players) do // For each player
for j := 0 to High(MSI_Players[i].Scripts) do // For each script
for k := 0 to High(MSI_Players[i].Objects[j] do // For each object per script
if (ReadINI('Player'+IntToStr(i), 'Object['+IntToStr(j)+']['+IntToStr(k)+']',
FilePath) = MSI_Objects[MSI_Players[i].Objects[j][k]].Name) then
MSI_Players[i].Objects[j][k] := MSI_Objects[MSI_Players[i].Objects[j][k]].Constant;
That kinda looks confusing, but I think it would work. May get an out of range error, but I think it should be okay.

nickrules

2010-10-26 16:47:41

Im gonna be really busy for awhile so here's what I have/had (haven't been able to work on it for over a week)

program new;
//{.include msi/runme.simba}
const
Path = ScriptPath+'\players.txt';

Function INIExists: boolean;
begin
if FileExists(Path) then
begin
Result := true;
end else
result := false;
Writeln('Player INI not found :O! Making one now.')
end;

Procedure MakeNewINI;
begin
//General Settings
WriteINI('GENERAL', 'PlayerCount', '1', path);
WriteINI('GENERAL', 'smsID', ' ', path);
WriteINI('GENERAL', 'smsPass', ' ', path);
WriteINI('GENERAL', 'CurrentPlayer', ' ', path);
WriteINI('GENERAL', 'CurrentScript', ' ', path);

//Player0
WriteINI('PLAYER0', 'Name', ' ', path);
WriteINI('PLAYER0', 'Pass', ' ', path);
WriteINI('PLAYER0', 'Nick', ' ', path);
WriteINI('PLAYER0', 'Pin', ' ', path);
WriteINI('PLAYER0', 'Active', 'True', path);
WriteINI('PLAYER0', 'Member', 'False', path);
WriteINI('PLAYER0', 'Location', ' ', path);
WriteINI('PLAYER0', 'Scripts', ' ', path);
WriteINI('PLAYER0', 'Objects', ' ', path);
WriteINI('PLAYER0', 'Priority', ' ', path);
WriteINI('PLAYER0', 'DontDrop', ' ', path);
WriteINI('PLAYER0', 'LoadsPerLogin', '10', path);
WriteINI('PLAYER0', 'LoadsTotal', '50', path);

end;

function ExtractEasyInfo: boolean;
var
P: integer; //p = the player we are working on
begin
Write the general Information.
HowManyPlayers := ReadINI('GENERAL', 'PlayerCount', path);
ReadINI('GENERAL', 'smsID', path);
ReadINI('GENERAL', 'smsPass', path);
CurrentPlayer := ReadINI('GENERAL', 'CurrentPlayer', path);
CurrentScript := ReadINI('GENERAL', 'CurrentScript', path);

for P := 0 to HowManyPlayers - 1 do
//Player0
with MSI_Players[P] do
begin
Name := ReadINI('PLAYER'+IntToStr(p), 'Name', path); // Username
Pass := ReadINI('PLAYER'+IntToStr(p), 'Pass', path); // Password
Nick := ReadINI('PLAYER'+IntToStr(p), 'Nick', path); // Nickname
Pin := ReadINI('PLAYER'+IntToStr(p), 'Pin', path); // Bank pin
Active := StrToBool(ReadINI('PLAYER'+IntToStr(p), 'Active', path)); //active
Member := StrToBool(ReadINI('PLAYER'+IntToStr(p), 'Member', path)); //member?
Loads[0] := StrToInt(ReadINI('PLAYER'+IntToStr(p), 'LoadsPerLogin', path)); // Amount of loads before breaking/switching p
Loads[1] := StrToInt(ReadINI('PLAYER'+IntToStr(p), 'LoadsTotal', path)); // Total loads for the player to do
end;
end;

{
//What I need to add
Location := LOC_POWER_SKILL; // See instructions at the top
Scripts := [SCRIPT_POWER_MINER]; // See instructions at the top
Objects := [[ROCK_IRON]]; // See instructions at the top
Priority := [[]]; // See instructions at the top
DontDrop := []; // See instructions at the top

ReadINI('PLAYER'+IntToStr(p), 'Location', path+'\p.');
ReadINI('PLAYER'+IntToStr(p), 'Objects', path+'\p.');
ReadINI('PLAYER'+IntToStr(p), 'Priority', path+'\p.');
ReadINI('PLAYER'+IntToStr(p), 'DontDrop', path+'\p.');
}

Procedure GrabMoreInfo;
var P, I: integer; //p = the player we are working on
ScriptsArray: TStringArray;
PriorityArray: TStringArray;
ConvertedArray: TIntegerArray;
begin
for 0 to HowManyPlayers - 1 do
//Grab the easy player info.
with MSI_Players[P] do
begin
Location := StrToLoc(ReadINI('PLAYER'+IntToStr(p), 'Location', path)); // location
Scripts := [SCRIPT_POWER_MINER]; // scripts

//Grab Objects for the player - Writen by coh3n
for i := 0 to High(MSI_Players) do // For each player
for j := 0 to High(MSI_Players[p].Scripts) do // For each script
for k := 0 to High(MSI_Players[p].Objects[j] do // For each object per script
if (Lowercase(ReadINI('Player'+IntToStr(i), 'Object['+IntToStr(j)+']['+IntToStr(k)+']',
FilePath)) = MSI_Objects[MSI_Players[P].Objects[j][k]].Name) then
MSI_Players[P].Objects[j][k] := MSI_Objects[MSI_Players[P].Objects[j][k]].Constant;
//end

//This bit needs to be fix for multipul scripts
PriorityArray := Explode('|',ReadINI('PLAYER'+IntToStr(p), 'Priority', path'))
SetArrayLength(ConvertedArray,High(PriorityArray))
for I := 0 to High(PriorityArray) do
begin
ConvertedArray[i] := StrToInt(PriorityArray[I]);
end;
//end

Priority := [ConvertedArray]; // Priority
DontDrop := []; // DontDrop
inc(P)
end;
end;



begin
{if not INIExists then
MakeNewINI;
else }
end.

If someone wants to work on this,I won't mind. Its not too hard to do…

Coh3n

2010-10-26 17:12:24

Hey looks pretty good. The more complicated info will be slightly easier now with the new DeclarePlayers, just so you know. ;)

Good luck with whatever's keeping you busy. :p

E: I also added this to the MSI Core Todo list.

KillerTHC

2010-12-12 16:08:08

I did some work on this today and have come up with a system that should work. However it has not been tested.

If we are going to implement this system then I can make a VB.Net application to create ini files with ease and manage the players etc…

Players.ini

[GENERAL]
PlayerCount = 1
smsUID = myuid
smsPass = mypass
World = 0
DEBUG_SMART = True
BREAK_TIME = 15
SAVE_DEBUG = True
ENABLE_REMOTE = True
LEVEL_TO_DEBUG = 10
HUMAN_BREAKING = True
SWITCH_WORLDS = False
ANTIBAN_MIN_WAIT = 14000
RANDOMS_MIN_WAIT = 10000
CurrentPlayer = 0
CurrentScript = 0

[PLAYER0]
Name = zezima
Pass = botftw
Nick = ima
Pin = 9098
Active = True
Member = False
BreakLoads = 0
BreakTime = 60
TotalLoads = 0
TotalTime = 0

[SCRIPT0]
Location = LOC_VW_BANK
Script = SCRIPT_VW_MINER
DontDrop = PICKAXE_DRAGON PICKAXE_IRON
Priority = 25 75
Trees = TREE_NORMAL TREE_OAK
Rocks = ROCK_IRON ROCK_CLAY
FishSpots = FISHSPOT_BAIT FISHSPOT_NET
Spells = Not used yet
AlchSlots = 1 2

String to constant functions
function StrToLoc(Input: String): Integer;
begin
case Input of
//Undefined
'LOC_POWER_SKILL': Result := LOC_POWER_SKILL;
'LOC_LOST': Result := LOC_LOST;

// Varrock
// East
'LOC_VE_TREES': Result := LOC_VE_TREES;
'LOC_VE_OAKS': Result := LOC_VE_OAKS;
'LOC_VE_BANK': Result := LOC_VE_BANK;
'LOC_VE_MINE': Result := LOC_VE_MINE;
'LOC_VE_RANGES': Result := LOC_VE_RANGES;

// West
'LOC_VW_BANK': Result := LOC_VW_BANK;
'LOC_VW_MINE': Result := LOC_VW_MINE;

// Grand Exchange
'LOC_GE_BANK': Result := LOC_GE_BANK;
'LOC_GE_YEWS': Result := LOC_GE_YEWS;

// Draynor
'LOC_DB_BANK': Result := LOC_DB_BANK;
'LOC_DB_WILLOWS': Result := LOC_DB_WILLOWS;
'LOC_DB_TREES': Result := LOC_DB_TREES;
'LOC_DB_OAKS': Result := LOC_DB_OAKS;
'LOC_DB_FISH': Result := LOC_DB_FISH;

// Rimmington
'LOC_RM_YEWS': Result := LOC_RM_YEWS;
'LOC_RM_CLAY': Result := LOC_RM_CLAY;
'LOC_RM_TIN': Result := LOC_RM_TIN;
'LOC_RM_COPPER': Result := LOC_RM_COPPER;
'LOC_RM_IRON_1': Result := LOC_RM_IRON_1;
'LOC_RM_IRON_2': Result := LOC_RM_IRON_2;
'LOC_RM_GOLD': Result := LOC_RM_GOLD;

// Falador
'LOC_FE_BANK': Result := LOC_FE_BANK;

// Port Sarim
'LOC_PS_WILLOWS': Result := LOC_PS_WILLOWS;
'LOC_PS_YEWS': Result := LOC_PS_YEWS;
'LOC_PS_DBOX': Result := LOC_PS_DBOX;

// Lumbridge
'LOC_LSW_MINE': Result := LOC_LSW_MINE;
'LOC_LSE_MINE': Result := LOC_LSE_MINE;

// Edgeville
'LOC_EV_BANK': Result := LOC_EV_BANK;
'LOC_EV_YEWS': Result := LOC_EV_YEWS;

// Barbarian Village
'LOC_BBV_MINE': Result := LOC_BBV_MINE;
'LOC_BBV_FISH': Result := LOC_BBV_FISH;

// Seers Village
'LOC_SV_MAGICS': Result := LOC_SV_MAGICS;
'LOC_SV_BANK': Result := LOC_SV_BANK;
'LOC_SV_MAPLES': Result := LOC_SV_MAPLES;
'LOC_SV_YEWS': Result := LOC_SV_YEWS;

// Guilds
'LOC_GUILD_MINE': Result := LOC_GUILD_MINE;
end;
end;

function StrToScript(Input: String): Integer;
begin
// Woodcutting
'SCRIPT_POWER_CHOP': Result := SCRIPT_POWER_CHOP;
'SCRIPT_VE_TREES': Result := SCRIPT_VE_TREES;
'SCRIPT_VE_OAKS': Result := SCRIPT_VE_OAKS;
'SCRIPT_GE_YEWS': Result := SCRIPT_GE_YEWS;
'SCRIPT_DB_WILLOWS': Result := SCRIPT_DB_WILLOWS;
'SCRIPT_DB_TREES': Result := SCRIPT_DB_TREES;
'SCRIPT_DB_OAKS': Result := SCRIPT_DB_OAKS;
'SCRIPT_RM_YEWS': Result := SCRIPT_RM_YEWS;
'SCRIPT_PS_WILLOWS': Result := SCRIPT_PS_WILLOWS;
'SCRIPT_PS_YEWS': Result := SCRIPT_PS_YEWS;
'SCRIPT_SV_MAGICS': Result := SCRIPT_SV_MAGICS;
'SCRIPT_SV_MAPLES': Result := SCRIPT_SV_MAPLES;
'SCRIPT_SV_YEWS': Result := SCRIPT_SV_YEWS;
'SCRIPT_EV_YEWS': Result := SCRIPT_EV_YEWS;

// Mining
'SCRIPT_POWER_MINER': Result := SCRIPT_POWER_MINER;
'SCRIPT_VE_MINER': Result := SCRIPT_VE_MINER;
'SCRIPT_VW_MINER': Result := SCRIPT_VW_MINER;
'SCRIPT_LSW_MINER': Result := SCRIPT_LSW_MINER;
'SCRIPT_BBV_MINER': Result := SCRIPT_BBV_MINER;
'SCRIPT_RM_CLAY': Result := SCRIPT_RM_CLAY;
'SCRIPT_RM_TIN': Result := SCRIPT_RM_TIN;
'SCRIPT_RM_COPPER': Result := SCRIPT_RM_COPPER;
'SCRIPT_RM_IRON_1': Result := SCRIPT_RM_IRON_1;
'SCRIPT_RM_IRON_2': Result := SCRIPT_RM_IRON_2;
'SCRIPT_RM_GOLD': Result := SCRIPT_RM_GOLD;
'SCRIPT_GUILD_MINER': Result := SCRIPT_GUILD_MINER;

// Fishing
'SCRIPT_POWER_FISHER': Result := SCRIPT_POWER_FISHER;
'SCRIPT_DB_FISHER': Result := SCRIPT_DB_FISHER;
'SCRIPT_BBV_FISHER': Result := SCRIPT_BBV_FISHER;

// Cooking
'SCRIPT_VE_COOKER': Result := SCRIPT_VE_COOKER;

// Magic
'SCRIPT_ALCHER': Result := SCRIPT_ALCHER;
end;

function StrToIntArray(Input: String): Array of Integer;
var
I: Integer;
IntStrArray: Array of String
IntArray: Array of Integer;
begin
IntStrArray := srl_Explode(Input, ' ');
for I := 0 to High(IntStrArray) do
begin
IntArray[I] := StrToInt(IntStrArray[I]);
end;
Result := IntArray;
end;

function StrToItem(Input: String): Array of Integer;
ItemsStringArray: Array of String;
ItemsArray: Array of Integer;
I: Integer;
begin
ItemsStringArray := srl_Explode(Input, ' ');
for I := 0 to High(ItemsStringArray) do
begin
case ItemsStringArray[I] of
'PICKAXE_BRONZE': ItemsArray[I] := PICKAXE_BRONZE;
'PICKAXE_IRON': ItemsArray[I] := PICKAXE_IRON;
'PICKAXE_STEEL': ItemsArray[I] := PICKAXE_STEEL;
'PICKAXE_MITHRIL': ItemsArray[I] := PICKAXE_MITHRIL;
'PICKAXE_ADAMANT': ItemsArray[I] := PICKAXE_ADAMANT;
'PICKAXE_RUNE': ItemsArray[I] := PICKAXE_RUNE;
'PICKAXE_DRAGON': ItemsArray[I] := PICKAXE_DRAGON;

'HATCHET_BRONZE': ItemsArray[I] := HATCHET_BRONZE;
'HATCHET_IRON': ItemsArray[I] := HATCHET_IRON;
'HATCHET_STEEL': ItemsArray[I] := HATCHET_STEEL;
'HATCHET_MITHRIL': ItemsArray[I] := HATCHET_MITHRIL;
'HATCHET_ADAMANT': ItemsArray[I] := HATCHET_ADAMANT;
'HATCHET_RUNE': ItemsArray[I] := HATCHET_RUNE;
'HATCHET_DRAGON': ItemsArray[I] := HATCHET_DRAGON;

'LOGS_NORMAL': ItemsArray[I] := LOGS_NORMAL;
'LOGS_OAK': ItemsArray[I] := LOGS_OAK;
'LOGS_WILLOW': ItemsArray[I] := LOGS_WILLOW;
'LOGS_MAPLE': ItemsArray[I] := LOGS_MAPLE;
'LOGS_YEW': ItemsArray[I] := LOGS_YEW;
'LOGS_MAGIC': ItemsArray[I] := LOGS_MAGIC;

'ORE_CLAY': ItemsArray[I] := ORE_CLAY;
'ORE_COPPER': ItemsArray[I] := ORE_COPPER;
'ORE_TIN': ItemsArray[I] := ORE_TIN;
'ORE_IRON': ItemsArray[I] := ORE_IRON;
'ORE_SILVER': ItemsArray[I] := ORE_SILVER;
'ORE_COAL': ItemsArray[I] := ORE_COAL;
'ORE_GOLD': ItemsArray[I] := ORE_GOLD;
'ORE_MITHRIL': ItemsArray[I] := ORE_MITHRIL;
'ORE_ADAMANTITE': ItemsArray[I] := ORE_ADAMANTITE;
'ORE_RUNITE': ItemsArray[I] := ORE_RUNITE;

'FISH_SMALLNET': ItemsArray[I] := FISH_SMALLNET;
'FISH_CAGE_CRAYFISH': ItemsArray[I] := FISH_CAGE_CRAYFISH;
'FISH_ROD_BAIT': ItemsArray[I] := FISH_ROD_BAIT;
'FISH_BAIT': ItemsArray[I] := FISH_BAIT;
'FISH_ROD_FLY': ItemsArray[I] := FISH_ROD_FLY;
'FISH_HARPOON': ItemsArray[I] := FISH_HARPOON;
'FISH_POT_LOBSTER': ItemsArray[I] := FISH_POT_LOBSTER;

'FISH_RAW_SHRIMP': ItemsArray[I] := FISH_RAW_SHRIMP;
'FISH_RAW_CRAYFISH': ItemsArray[I] := FISH_RAW_CRAYFISH;
'FISH_RAW_SARDINE': ItemsArray[I] := FISH_RAW_SARDINE;
'FISH_RAW_HERRING': ItemsArray[I] := FISH_RAW_HERRING;
'FISH_RAW_ANCHOVIE': ItemsArray[I] := FISH_RAW_ANCHOVIE;
'FISH_RAW_TROUT': ItemsArray[I] := FISH_RAW_TROUT;
'FISH_RAW_PIKE': ItemsArray[I] := FISH_RAW_PIKE;
'FISH_RAW_SALMON': ItemsArray[I] := FISH_RAW_SALMON;
'FISH_RAW_TUNA': ItemsArray[I] := FISH_RAW_TUNA;
'FISH_RAW_LOBSTER': ItemsArray[I] := FISH_RAW_LOBSTER;
'FISH_RAW_SWORDFISH': ItemsArray[I] := FISH_RAW_SWORDFISH;

'FISH_COOKED_SHRIMP': ItemsArray[I] := FISH_COOKED_SHRIMP;
'FISH_COOKED_CRAYFISH': ItemsArray[I] := FISH_COOKED_CRAYFISH;
'FISH_COOKED_SARDINE': ItemsArray[I] := FISH_COOKED_SARDINE;
'FISH_COOKED_HERRING': ItemsArray[I] := FISH_COOKED_HERRING;
'FISH_COOKED_ANCHOVIE': ItemsArray[I] := FISH_COOKED_ANCHOVIE;
'FISH_COOKED_TROUT': ItemsArray[I] := FISH_COOKED_TROUT;
'FISH_COOKED_PIKE': ItemsArray[I] := FISH_COOKED_PIKE;
'FISH_COOKED_SALMON': ItemsArray[I] := FISH_COOKED_SALMON;
'FISH_COOKED_TUNA': ItemsArray[I] := FISH_COOKED_TUNA;
'FISH_COOKED_LOBSTER': ItemsArray[I] := FISH_COOKED_LOBSTER;
'FISH_COOKED_SWORDFISH': ItemsArray[I] := FISH_COOKED_SWORDFISH;

'GEM_UNCUT_SAPPHIRE': ItemsArray[I] := GEM_UNCUT_SAPPHIRE;
'GEM_UNCUT_EMERALD': ItemsArray[I] := GEM_UNCUT_EMERALD;
'GEM_UNCUT_RUBY': ItemsArray[I] := GEM_UNCUT_RUBY;
'GEM_UNCUT_DIAMOND': ItemsArray[I] := GEM_UNCUT_DIAMOND;

'MISC_BIRD_NEST': ItemsArray[I] := MISC_BIRD_NEST;
'MISC_FEATHER': ItemsArray[I] := MISC_FEATHER;

'STAFF_AIR': ItemsArray[I] := STAFF_AIR;
'STAFF_WATER': ItemsArray[I] := STAFF_WATER;
'STAFF_EARTH': ItemsArray[I] := STAFF_EARTH;
'STAFF_FIRE': ItemsArray[I] := STAFF_FIRE;

'MSI_RUNE_AIR': ItemsArray[I] := MSI_RUNE_AIR;
'MSI_RUNE_BODY': ItemsArray[I] := MSI_RUNE_BODY;
'MSI_RUNE_MIND': ItemsArray[I] := MSI_RUNE_MIND;
'MSI_RUNE_EARTH': ItemsArray[I] := MSI_RUNE_EARTH;
'MSI_RUNE_FIRE': ItemsArray[I] := MSI_RUNE_FIRE;
'MSI_RUNE_WATER': ItemsArray[I] := MSI_RUNE_WATER;
'MSI_RUNE_CHAOS': ItemsArray[I] := MSI_RUNE_CHAOS;
'MSI_RUNE_LAW': ItemsArray[I] := MSI_RUNE_LAW;
'MSI_RUNE_COSMIC': ItemsArray[I] := MSI_RUNE_COSMIC;
'MSI_RUNE_DEATH': ItemsArray[I] := MSI_RUNE_DEATH;
'MSI_RUNE_NATURE': ItemsArray[I] := MSI_RUNE_NATURE;
'MSI_RUNE_BLOOD': ItemsArray[I] := MSI_RUNE_BLOOD;
'MSI_RUNE_SOUL': ItemsArray[I] := MSI_RUNE_SOUL;
'MSI_RUNE_ASTRAL': ItemsArray[I] := MSI_RUNE_ASTRAL;
end;
end;
Result := ItemsArray;
end;

function StrToObj(Input: String): Array of Integer;
ObjsStringArray: Array of String;
ObjsArray: Array of Integer;
I: Integer;
begin
ObjsStringArray := srl_Explode(Input, ' ');
for I := 0 to High(ObjsStringArray) do
begin
case ItemsStringArray[I] of
//Trees
'TREE_NORMAL': ObjsArray[I] := TREE_NORMAL;
'TREE_OAK': ObjsArray[I] := TREE_OAK;
'TREE_WILLOW': ObjsArray[I] := TREE_WILLOW;
'TREE_MAPLE': ObjsArray[I] := TREE_MAPLE;
'TREE_YEW': ObjsArray[I] := TREE_YEW;
'TREE_MAGIC': ObjsArray[I] := TREE_MAGIC;

//Rocks
'ROCK_CLAY': ObjsArray[I] := ROCK_CLAY;
'ROCK_TIN': ObjsArray[I] := ROCK_TIN;
'ROCK_COPPER': ObjsArray[I] := ROCK_COPPER;
'ROCK_IRON': ObjsArray[I] := ROCK_IRON;
'ROCK_SILVER': ObjsArray[I] := ROCK_SILVER;
'ROCK_COAL': ObjsArray[I] := ROCK_COAL;
'ROCK_GOLD': ObjsArray[I] := ROCK_GOLD;
'ROCK_MITHRIL': ObjsArray[I] := ROCK_MITHRIL;
'ROCK_ADAMANTITE': ObjsArray[I] := ROCK_ADAMANTITE;
'ROCK_RUNITE': ObjsArray[I] := ROCK_RUNITE;

//Fishing spots
'FISHSPOT_NET': ObjsArray[I] := FISHSPOT_NET;
'FISHSPOT_BAIT': ObjsArray[I] := FISHSPOT_BAIT;
'FISHSPOT_LURE': ObjsArray[I] := FISHSPOT_LURE;
'FISHSPOT_CAGE': ObjsArray[I] := FISHSPOT_CAGE;
'FISHSPOT_HARPOON': ObjsArray[I] := FISHSPOT_HARPOON;

//Cooking spots
'COOKSPOT_FIRE': ObjsArray[I] := COOKSPOT_FIRE;
'COOKSPOT_RANGE': ObjsArray[I] := COOKSPOT_RANGE;
end;
end;
Result := ObjsArray;
end;

LoadPlayersINI Function
function LoadPlayersINI(): Boolean;
var
PlayersFile: String;
I: Integer;
begin
PlayersFile := 'Players.ini';
if FileExists(PlayersFile) then
begin
HowManyPlayers := ReadINI('GENERAL', 'PlayerCount', PlayerFile);
NumberOfPlayers(HowManyPlayers);
SetLength(MSI_Players, HowManyPlayers);

for i := 0 to High(MSI_Players) do
SetLength(MSI_Players[i].Scripts, 100);

CurrentPlayer := ReadINI('GENERAL', 'CurrentPlayer', PlayerFile);
CurrentScript := ReadINI('GENERAL', 'CurrentScript', PlayerFile);

for I := 0 to High(MSI_Players) do
begin
with MSI_Players[I] do
begin
Name := ReadINI('PLAYER'+IntToStr(I), 'Name', PlayerFile); // Username
Pass := ReadINI('PLAYER'+IntToStr(I), 'Pass', PlayerFile);
Nick := ReadINI('PLAYER'+IntToStr(I), 'Nick', PlayerFile);
Pin := ReadINI('PLAYER'+IntToStr(I), 'Pin', PlayerFile);
Active := StrToBool(ReadINI('PLAYER'+IntToStr(I), 'Active', PlayerFile));
Member := StrToBool(ReadINI('PLAYER'+IntToStr(I), 'Member', PlayerFile));
Location := StrToLoc(ReadINI('SCRIPT'+IntToStr(I), 'Location', PlayerFile)); // See instructions at the top
BreakLoads := StrToInt(ReadINI('PLAYER'+IntToStr(I), 'BreakLoads', PlayerFile));
BreakTime := StrToInt(ReadINI('PLAYER'+IntToStr(I), 'BreakTime', PlayerFile));
TotalLoads := StrToInt(ReadINI('PLAYER'+IntToStr(I), 'TotalLoads', PlayerFile));
TotalTime := StrToInt(ReadINI('PLAYER'+IntToStr(I), 'TotalTime', PlayerFile);

with Scripts[I] do
begin
Name := StrToScript(ReadINI('SCRIPT'+IntToStr(I), 'Script', PlayerFile));
Rocks := StrToObj(ReadINI('SCRIPT'+IntToStr(I), 'Rocks', PlayerFile));
Trees := StrToObj(ReadINI('SCRIPT'+IntToStr(I), 'Trees', PlayerFile));
FishSpots:= StrToObj(ReadINI('SCRIPT'+IntToStr(I), 'FishSpots', PlayerFile));
//Spells := //Spells aren't used yet...
AlchSlots:= StrToIntArray(ReadINI('SCRIPT'+IntToStr(I), 'AlchSlots', PlayerFile));
DontDrop := StrToItem(ReadINI('SCRIPT'+IntToStr(I), 'DontDrop', PlayerFile));
end;
end;
end;
end else WriteLn('Could not find players file!');
end;

Coh3n

2010-12-13 00:03:18

Can you expand on you VB.net application idea please?

Also, would the user be filling out the INI file, or would the player information be saved to the file, then just loaded on startup? I would rather see the latter as the same functions could be transfered over when the form is finished. It would also negate the need of long cases for constants. So instead of the constants being in the INI file, the number they represent would be there.

i luffs yeww

2010-12-13 00:18:54

Coh3n, whatever you want can be done. ;)

Killer, why VB.NET? It is pretty great for forms and all I suppose, but Pascal has some pretty good forms as well. Personally I'd like to keep things in Pascal for this (not that it matters what I think would be best :p), simply for the learning aspects. I see no reason to use anything besides Pascal unless necessary (or for things like pyMML ;)). Of course it would be the best option if Pascal can't do something which VB.NET can.

KillerTHC

2010-12-13 08:01:29

I just thought VB.Net because it can be done in like 2 hours. Scrap that idea though, lets make it in pascal. I will have to learn forms first but shouldn't be too hard, I'm a fast learner. I agree if we store the constants in the INI file it will make life easier because we would only need to convert the strings into an integer array. After this week I won't be here though until after winter holidays. Ill see what I can do and keep you guys posted here.

Coh3n

2010-12-13 11:48:08

From: KillerTHC
I just thought VB.Net because it can be done in like 2 hours. Scrap that idea though, lets make it in pascal. I will have to learn forms first but shouldn't be too hard, I'm a fast learner. I agree if we store the constants in the INI file it will make life easier because we would only need to convert the strings into an integer array. After this week I won't be here though until after winter holidays. Ill see what I can do and keep you guys posted here.

I won't be here either. :p Finally get to go home. :)

And I must be missing something, what do you want to use a form for?

Shuttleu

2010-12-13 12:00:37

oh oh oh… i have a idea
i plugin that can set and change the players
then you dont need to set the players in the script, but it can load them on startup

~shut

KillerTHC

2010-12-13 14:48:10

The VB.Net idea is similar to the plugin idea that you have. With VB.Net I could make an app that can read/write the INI file, while giving a visual to the user.
ie. a form with tabs that allows the user to add tabs for each additional player, and a tab for general stuff.

The form that I was reffering to making in pascal would do the same thing as the VB.Net one; manage player settings.

EDIT:
Player information would be saved in the file and the script would load it at runtime.

Shuttleu

2010-12-13 15:08:22

From: KillerTHC
The VB.Net idea is similar to the plugin idea that you have. With VB.Net I could make an app that can read/write the INI file, while giving a visual to the user.
ie. a form with tabs that allows the user to add tabs for each additional player, and a tab for general stuff.

The form that I was reffering to making in pascal would do the same thing as the VB.Net one; manage player settings.

EDIT:
Player information would be saved in the file and the script would load it at runtime.

oh i see
i should have read the thread properly first then :s

~shut

Coh3n

2010-12-13 20:27:52

From: Shuttleu
oh oh oh… i have a idea
i plugin that can set and change the players
then you dont need to set the players in the script, but it can load them on startup

~shut

Well no matter what the user will have to input player information at least once.

From: KillerTHC
The VB.Net idea is similar to the plugin idea that you have. With VB.Net I could make an app that can read/write the INI file, while giving a visual to the user.
ie. a form with tabs that allows the user to add tabs for each additional player, and a tab for general stuff.

The form that I was reffering to making in pascal would do the same thing as the VB.Net one; manage player settings.

EDIT:
Player information would be saved in the file and the script would load it at runtime.

Check out the MSI Form. ;) It's actually almost done and so far it's looking amazing. :)

E: This is up and running with the form now. :)