SRL Archive - OSR Help

ScriptTerminate;


3Garrett3

2009-09-01 04:27:17

To start, my script terminate function:


procedure ScriptTerminate;
var
MT : Array of String;
MessageF, PlayerString, EmailF : String;
TP, I, W : Integer;
begin
Debug('Final Proggy');
Proggy;
TP := (ProfitB * BSmith);
{W := HowManyPlayers - 1;
repeat
MT[i] := IntToStr(i) + ': ' + Players[i].Nick + ' | ' + Left(BoolToStr(Players[i].active), 1) + ' | ' + IntToStr(Players[i].Integers[1]) + ' Loads | ' + IntToStr(Players[i].Integers[2]) + ' Bars | ' + IntToStr(Players[i].Integers[3]) + ' Profit | ' + Players[i].Loc;
Inc(i);
if i >= W then break;
until I >= W
PlayerString := Implode(#13, MT); }
Debug('Creating Message');
if YourEmail = '' Then EmailF := 'Garrettsemail' else EmailF := YourEmail;
MessageF := ' ' +
'3Garrett3s Baby Melter ' + VersionN + ' Progress Report' + #13 +
'*********************************************' + #13 +
'Ran for: ' + TimeRunning + #13 +
'Loads: ' + IntToStr(LD) + #13 +
'Bars: ' + IntToStr(BSmith) + #13 +
'Profit: ' + IntToStr(TP) + 'gp' + #13 +
'Leveled: ' + IntToStr(Levels) + ' Times' + #13 +
'Rested: ' + IntToStr(RAmount) + ' Times' + #13 +
'Rested for: ' + MsToTime(RTTime, 0) + #13 +
'Slept: ' + IntToStr(Sleeped) + ' Times' + #13 +
'Slept for: ' + MsToTime(SleepT, 0) + #13 +
'*********************************************' + #13 +
//PlayerString + #13 +
' ';
SendEmail('', '', MessageF, '', '', '');
Debug('Sent Email');
end;

And yeah, I have the email thing set up right, I just removed all of my information until I release the script.

Anyway. To the real problem. As you can see, parts of the script are commented out. IMO, the important part of the procedure is to tell me what the players did. This is the part that will not work.

I have tried a simple For To Do loop, and also tried using this repeat loop, but the result is the same.

If I comment out the parts that are commented, the script will terminate right and will send an email (minus the important parts) but when it is uncommented, the script will simply die after writing the progress report (first thing) and will not make it to creating the message and sending the email before it dies.

The thing I would like to know is:

- Can this be done somehow to stop the script from prematurely stopping?

Edit: Wording might have been bad.

"Can I rewrite this so that it doesn't stop the script before it reaches the end of the procedure, and why does it do that?"

3Garrett3

2009-09-01 04:51:21

To add more detail to this:

Here is a different approach:


begin
Debug('Final Proggy');
Proggy;
TP := (ProfitB * BSmith);
Debug('Loop Start');
for i := 0 to HowManyPlayers - 1 do
MT[i] := (IntToStr(i) + ': ' + Players[i].Nick + ' | ' + Left(BoolToStr(Players[i].active), 1) + ' | ' + IntToStr(Players[i].Integers[1]) + ' Loads | ' + IntToStr(Players[i].Integers[2]) + ' Bars | ' + IntToStr(Players[i].Integers[3]) + ' Profit | ' + Players[i].Loc);
Debug('Loop End');
PlayerString := Implode(#13, MT);
Debug('Implode end');
//And so on...

So this uses a for to do loop, which works in my proggy.

In my debug box, I get

[php]
[21:55:36] Final Proggy
[21:55:36] Loop Start
Successfully executed
[/php]

So it doesn't make it through the loop before it ends. I have no idea why though.

Edit: Sorry for the double post, but I figured it would get more attention if I added a post instead of editting.

Derek-

2009-09-01 07:16:45

This works fine for me.

Successfully compiled (4265 ms)
Final Proggy
Loop Start
Loop End
Implode end
Successfully executed

It must either be another piece of your code or your SRL/SCAR?

Sabzi

2009-09-01 09:40:13

Hmm…
So scar just die and it exits?, totally?
I got that too when I was trying to write in a file in ScriptTerminate.
I solved the problem by making another "script terminate". What will terminate/switch accounts but if just one player left(so the script will end) it makes the final proggy.
And then I use that function everywhere the script can fail.
The problem with that that when the user stops the script it won't give out the final thing :(

3Garrett3

2009-09-01 11:57:26

From: Derek-
This works fine for me.

Successfully compiled (4265 ms)
Final Proggy
Loop Start
Loop End
Implode end
Successfully executed

It must either be another piece of your code or your SRL/SCAR?


You didnt use the very first code, uncommenting the commented part though. comment sendemail if you want. it will die before the end.

Narcle

2009-09-01 14:26:02

Something wrong with ur player array? Did you set the number wrong or something?

Only thing i could think of that would stop in the middle of the loop and just end.

3Garrett3

2009-09-01 21:59:32

Well there are two players, and howmanyplayers = 2… so no?

I will pm you the script if you want? It's not ready for public release yet

Bionicle

2009-09-09 01:36:46

are your players listed as 1 and 2 or 0 and 1?


also, baby melter? wtf? lol

3Garrett3

2009-09-09 01:40:01

From: bionicle1800
are your players listed as 1 and 2 or 0 and 1?


also, baby melter? wtf? lol


Wow. I didn't think anyone would help with this XD. It still isn't fixed. I'm pretty sure I just scrapped the idea.

They are 0,1,2 and so on.

Baby Melter- The name was given to me by Ian. I think he made the best choice.