SRL Archive - First Scripts

Report Calculater Test


Swatarianess

2011-11-21 04:11:13

So i am making a report for a merchanting script and just wanted to see if it was good and how i could improve it. Right now it calculates Profit margin + Total buying and total selling and if its above 1k it divides it by 1000 then adds a "k" if its below it doesn't divide it by 1000 and add "k". Also used the Declare players because i dont know how else to use strings, that and its easier to use it with the PlayerDeclares. So first Simba script i've made ^^ so how could i improve it? thanks in advance

program new;
{.include SRL\SRL.scar}
var
Abv1k: Integer;
By, sy, Mrj, buy1 : Double;

procedure DeclarePlayers;
begin
HowManyPlayers:= 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

{ Players[0].Name := 'Username';
Players[0].Pass := 'Password';
Players[0].Nick := 'Nickname';
Players[0].Pin := 'Pincode';
} Players[0].Strings[0]:= 'Rune scimi'; // Item to buy.
Players[0].Integers[0]:= 5; // Amount of Item to buy
Players[0].Integers[1]:= 10000; // Buying price (Sell item 1gp or way lower then med to aquire whilest flipping)
Players[0].Integers[2]:= 10550; // Selling price (buy higher med price of item)

Players[0].Active := true;

By := Players[CurrentPlayer].Integers[0] * Players[CurrentPlayer].Integers[1];
Sy := Players[CurrentPlayer].Integers[0] * Players[CurrentPlayer].Integers[2];
Mrj := Sy - By;

end;

begin

DeclarePlayers;

if(Players[0].Integers[1] and Players[0].Integers[2] > 1000) then
begin
writeln('----------------More_Than_1k--------------')
writeln('Buying: ' + Players[CurrentPlayer].Strings[0] + ' @' + IntToStr(Players[0].Integers[1] / 1000)+'k')
wait(100+randomrange(300,500))
writeln('Selling: ' + Players[CurrentPlayer].Strings[0] + ' x' + IntToStr(Players[CurrentPlayer].Integers[0]))
wait(100+randomrange(300,500))
writeln('Total Buy price= ' + FloatToStr(By / 1000)+ 'k')
wait(100+randomrange(300,500))
writeln('Total Sell price= ' + FloatToStr(Sy / 1000)+ 'k')
wait(100+randomrange(300,500))
writeln('Profit Majin = ' + FloatToStr(Mrj / 1000) + 'k')
writeln(FloatToStr(buy1 + 5.2))
writeln('------------------------------------------')
end;

if(Players[0].Integers[1] and Players[0].Integers[2] < 1000) then
begin
writeln('----------------Less_Than_1k--------------')
writeln('Buying: ' + Players[CurrentPlayer].Strings[0] + ' @' + IntToStr(Players[0].Integers[1]))
wait(100+randomrange(300,500))
writeln('Selling: ' + Players[CurrentPlayer].Strings[0] + ' x' + IntToStr(Players[CurrentPlayer].Integers[0]))
wait(100+randomrange(300,500))
writeln('Total Buy price= ' + FloatToStr(By))
wait(100+randomrange(300,500))
writeln('Total Sell price= ' + FloatToStr(Sy))
wait(100+randomrange(300,500))
writeln('Profit Majin = ' + FloatToStr(Mrj))
writeln('------------------------------------------')
end;

end.

nokkasiili

2011-11-21 11:19:28

I would add new function that manages k/m suffixes, it will make script look more clean.

Mark

2011-11-21 12:01:13

This is how you make a string

procedure DeclarePlayers;
begin
var
Item2Buy:string;
begin
Item2Buy:='rune Scim';

so in your script you would change yours
FROM THIS
writeln('Buying: ' + Players[CurrentPlayer].Strings[0] + ' @' + IntToStr(Players[0].Integers[1] / 1000)+'k')

TO THIS
writeln('Buying: ' + Item2Buy + ' @' + IntToStr(Players[0].Integers[1] / 1000)+'k');

nickrules

2011-11-21 22:04:50

Well, the only problem I see with it is to remove the waits.

Cru1zin's suggestion isn't really needed, though it is much shorter to type if you don't intend on running this on multiple players - which I don't think you do.

Swatarianess

2011-11-22 06:41:19

From: nickrules
Well, the only problem I see with it is to remove the waits.

Cru1zin's suggestion isn't really needed, though it is much shorter to type if you don't intend on running this on multiple players - which I don't think you do.


yah the script would be like 1 account :/ or maybe switching but i dunno wanna get it working fully for 1account before doing another account. Dam forgot about the Mills thanks for all the suggestions ppls ^^

Gu3st...

2011-11-22 06:50:36

I'd change / to div when working with integers, most of the time when you're dividing something with something else it wont turn out to be a whole number.

Also I think there's a function in SRL that does exactly this (?)

Swatarianess

2011-11-22 07:18:53

From: Zyt3x
I'd change / to div when working with integers, most of the time when you're dividing something with something else it wont turn out to be a whole number.

Also I think there's a function in SRL that does exactly this (?)



ahh reli :O if not i'd make one lol ;) also didnt know "Div" would work used to excel's "/" for dividing thanks ^^