SRL Archive - OSR Help

Adding a XP/Hour and more to a script


eXystis

2013-04-14 18:07:36

Hello, I'm having some trouble adding an XP/Hour, Tickets Gained, Time Running, and games played feature.

I ripped this just to give me an idea of how it will work, but I keep getting errors with it.
This is for a range guild script, so there is no set XP.

It's telling me SMART_DrawText and SMART_ClearCanvas are undefined strings. I just want it to display in the client, above the chat box.

procedure Progress;
var
i:Integer;
begin
ClearDebug;
Line[0] := '|| XP/Hour: ' + inttostr(((3600*TotalXpGain) / (1+(GetTimeRunning/1000))));
Line[1] := '|| Total Xp: ' + inttostr(TotalXpGain);
Line[2] := '|| Time Running: ' + MsToTime(GetTimeRunning,3);
for i:=0 to High(Line) do
begin
writeln(Line[i]);
end;
SMART_ClearCanvas;
SMART_DrawText(10,270-50,StatChars,Line[0] ,clWhite);
SMART_DrawText(10,290-50,StatChars,Line[1] ,clWhite);
SMART_DrawText(10,310-50,StatChars,Line[2] ,clWhite);
end;
begin
SetupSRL;
P07_DeclarePlayer;
SetupP07Include;
ActivateClient;
ClearDebug;
TotalXpGain := 0;
ClearDebug;
Wait(1000);
If (Not P07_LoggedIn) then
begin
P07_LogInPlayer;
end;
DTM;
repeat
Progress;
AntiBan;
Open_Inv_Tab;
Start_Comp;
Click_to_Continue;
Wield_Arrow;
AntiBan;
Fire_Target;
until(competitionsplayedcount = PlayCompetitions);
begin
writeln('Number of Competitions completed!');
writeln('Logging out...');
MMouse(644,483,5,5);
ClickMouse2(mouse_left);
wait(randomrange(500,1500));
MMouse(633,378,5,5)
ClickMouse2(mouse_left);
end;
AddOnTerminate('FreeDTMz');
TerminateScript;
end.

Errors:
[Error] C:\Users\Cameron\Downloads\AutoRangeGuilder_11[1.55] (1).simba(317:3): Unknown identifier 'SMART_ClearCanvas' at line 316
Compiling failed.

[Error] C:\Users\Cameron\Downloads\AutoRangeGuilder_11[1.55] (1).simba(318:3): Unknown identifier 'SMART_DrawText' at line 317
Compiling failed.


This is at the very bottom of the script.

Rich

2013-04-14 18:16:44

This should work fine as long as TotalXpGain is actually a declared variable, which might be one of the errors you're getting/

procedure Progress;
begin
ClearDebug;
WriteLn(' XP/Hour: ' + FloatToStr(TotalXpGain / (GetTimeRunning/3600000)));
WriteLn(' Total Xp: ' + IntToStr(TotalXpGain));
WriteLn(' Time Running: ' + TimeRunning);
end;

eXystis

2013-04-14 18:23:03

I'm using your way, but now I'm getting an error on this line.

WriteLn(' Total Xp: ' + IntToStr(TotalXpGain);


[Error] C:\Users\Cameron\Downloads\AutoRangeGuilder_11[1.55] (1).simba(311:50): Syntax error at line 310
Compiling failed.

Rich

2013-04-14 18:26:27

My bad, I missed a bracket off the end. Just add an extra closing bracket after TotalXpGain on the line in your post and that should sort it out for you.

eXystis

2013-04-14 18:30:57

Well, it compiled, going to see if it worked now.

eXystis

2013-04-14 18:33:45

Now it's saying
Error: divide by Zero at line 308
The following DTMs were not freed: [SRL - Lamp bitmap, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14]
The following bitmaps were not freed: [SRL - Mod bitmap, SRL - Admin bitmap, SRL - Flag bitmap, SRL - NavBar Bitmap, SRL - Options Bitmap]

On this line
WriteLn(' XP/Hour: ' + FloatToStr(TotalXpGain / (GetTimeRunning/3600000)));

Rich

2013-04-14 18:51:09

To be honest I have no idea. I've been playing around with it for a little bit and I'm still getting the same error. I even grabbed some code from one of my old scripts, adapted that and I was getting the error.

Sorry bud, can't help you :/

Sjoe

2013-04-14 18:52:51

TimeRan := (GetTimeRunning / 1000);
XPHour := (3600 * (XP)) / ((TimeRan));

jelknab

2013-04-14 18:55:47

When you haven't earned any xp yet, it try's to devide by 0. You could exit the procedure to stop that.


procedure Progress;
begin
ClearDebug;
WriteLn(' Time Running: ' + TimeRunning);
if (TotalXpGain < 1) then exit;

WriteLn(' XP/Hour: ' + FloatToStr(TotalXpGain / (GetTimeRunning/3600000)));
WriteLn(' Total Xp: ' + IntToStr(TotalXpGain));
end;

eXystis

2013-04-14 18:58:05

Well, I got it to work, but only in the Debug box..

But it's not actually updating the numbers.. any idea how I can get it to display in the SMART8 Client?

XP/Hour: 0
Total Xp: 0
Time Running: 44 Seconds

Judge Found! Talking to the Judge…

Sjoe

2013-04-14 19:01:04

From: eXystis
Well, I got it to work, but only in the Debug box..

But it's not actually updating the numbers.. any idea how I can get it to display in the SMART8 Client?


Like in your script:

SMART_DrawText(10,270-50,StatChars,Line[0] ,clWhite);
SMART_DrawText(10,290-50,StatChars,Line[1] ,clWhite);
SMART_DrawText(10,310-50,StatChars,Line[2] ,clWhite);

That would do it.

It updates everytime u call Progress;

eXystis

2013-04-14 19:04:37

Where would my Identifier go for SMART_DrawText?


[Error] C:\Users\Cameron\Downloads\AutoRangeGuilder_11[1.55] (1).simba(319:3): Unknown identifier 'SMART_DrawText' at line 318
Compiling failed.



By the way, thanks for all the help, guys. I appreciate it.

Rich

2013-04-14 19:16:33

From: jelknab
When you haven't earned any xp yet, it try's to devide by 0. You could exit the procedure to stop that.


procedure Progress;
begin
ClearDebug;
WriteLn(' Time Running: ' + TimeRunning);
if (TotalXpGain < 1) then exit;

WriteLn(' XP/Hour: ' + FloatToStr(TotalXpGain / (GetTimeRunning/3600000)));
WriteLn(' Total Xp: ' + IntToStr(TotalXpGain));
end;
I plugged in some numbers to replace the variables and I was still getting the error.

Anyway, OP got it working so I suppose that's all that matters.

With regards to the new SMART related error, I believe you need to add SmartGraphics.simba as an include at the top.

Sjoe

2013-04-14 19:22:35

yeah add : {$I SRL-OSR/SRL/Misc/SmartGraphics.Simba}

eXystis

2013-04-14 20:21:00

I've been able to display a XP/Hour and Time running, and Total XP. But the only problem is, how do I gather the XP earned from the game? Would I use a competition count/10 and then distribute the XP like that? also, How would I add a Bitmap to the SMART screen, and display live XP/Hour and XP gained, Tickets Gained, etc to the screen?

eXystis

2013-04-14 23:52:29

This, so far is what I've done. I haven't been able to figure out how to find a system to find out the XP gained, and XP per hour, because a range guild does not have a set XP rate.

I could possibly do it on the number of tickets gained, since the amount of tickets received is divided by 10. Maybe there's a way to multiply it by 10, then divide by the XP given for a certain score that is divisible by that number, such as 10.


[ATTACH=CONFIG]20695[/ATTACH]

The Mayor

2013-04-15 00:07:58

From: eXystis
This, so far is what I've done. I haven't been able to figure out how to find a system to find out the XP gained, and XP per hour, because a range guild does not have a set XP rate.

I could possibly do it on the number of tickets gained, since the amount of tickets received is divided by 10. Maybe there's a way to multiply it by 10, then divide by the XP given for a certain score that is divisible by that number, such as 10.


[ATTACH=CONFIG]20695[/ATTACH]


If it was EOC you would just get the amount gained from the XP bar. I guess you could use GetXP when you start the script to get the starting xp, and then call it again to get the amount gained.


function GetXP(skill: variant): integer;

So maybe something like:

 
StartXP := GetXP('range');
which you would call at the beginning of your script after you login.

Then during your script you would go:
 
CurrentXP := GetXP('range');
XPGained := CurrentXP - StartXP;

As for the SMART paint not updating, you would need to call the procedure (where you use the SMART_draw text) each time you want it to update.


E: just read the thing about range tickets. Do you get a certain number of XP per ticket? If so you could just get the ticket amount and multiply it.

eXystis

2013-04-15 00:14:25

This isn't for EOC, and no, you get tickets based on your score. Say I got a score of 350, I would get 35 tickets. I'm just wondering, how much XP would it be per 10 score, I could just do something that way.

This is for a 07 range guild script.

The Mayor

2013-04-15 00:29:17

From: eXystis
This isn't for EOC, and no, you get tickets based on your score. Say I got a score of 350, I would get 35 tickets. I'm just wondering, how much XP would it be per 10 score, I could just do something that way.

This is for a 07 range guild script.


I know, just do what I said :)