nght spud
2007-05-29 18:59:54
Ok in this thread, I will post all of my functions that I have used in my scripts.
Their all in one include at the bottom.
Random Functions
Functions from my RC script found here
Their all in one include at the bottom.
Random Functions
{
function: IsOdd(a:integer):Boolean;
By: Nght Spud
Description: Checks if the number is odd}
Function IsOdd(a:integer):Boolean;
var b:integer;
begin
b:=a+1;
if ((a/2)+0.5=b/2)then Result:=(true)else Result:=(False)
end;very similar{
function: IsEven(a:integer):Boolean;
By: Nght Spud
Description: Checks if the number is even}
Function IsEven(a:integer):Boolean;
var b:integer;
begin
b:=a+1;
if ((a/2)+0.5=b/2)then Result:=(False)else Result:=(true)
end;Functions from my RC script found here
{
function: ToOrFrom: String;
By: Nght Spud
Description: Finds out if you messaged someone, or they messaged you.
Returns with 'to' or 'from'.}
function ToOrFrom: String;
begin
if (IsTextAtEx(20, 415,'To',0, SmallChars, False,
False, 0, 1, 0))
then result:='to';
if (IsTextAtEx(20, 415,'From',0, SmallChars, False,
False, 0, 1, 0))
then result:='from';
end;{
function: GetBlackChatName: String;
By: Nght Spud
Description: Gets the name of who your talking to.
Returns with their name}
function GetBlackChatName: String;
var messagefrom:string;
begin
if (IsTextAtEx(20, 415,'To',0, SmallChars, False,
False, 0, 1, 0))
then messagefrom:='to';
if (IsTextAtEx(20, 415,'From',0, SmallChars, False,
False, 0, 1, 0))
then messagefrom:='from';
if (messagefrom='from') then
Result := Trim(GetTextAtEx(50, 415, 0, SmallChars, False,
False, 0, 1, 0, 80, False, tr_AlphaNumericChars));
if (messagefrom='to') then
Result := Trim(GetTextAtEx(35, 415, 0, SmallChars, False,
False, 0, 1, 0, 80, False, tr_AlphaNumericChars));
end;{
function: IsWordSaid(Text:string):boolean;
By: Nght Spud
Description: Looks across the whole PM for a certain word
works even if there is text before, or after
the word. Returns true if word is found.}
function IsWordSaid(Text:string):boolean;
var x,y:integer;
begin
if (IsTextInAreaEx(20, 415,470, 430,x,y,Text,0,SmallChars, False,
False,0,1,128)=true)then result:=true
else result:=false;
end;{
function: RcSayCommand(Start,Finish:string):String ;
By: Nght Spud
Description: Looks at what is said, and returns what is
said between the words you declared.
i.e. RcSayCommand('Say:','Fin:')would return
the words between Say: and Fin:}
function RcSayCommand(Start,Finish:string):String ;
var text:string;
begin
Text:=Trim(GetTextAtEx(20, 415, 0, SmallChars, False,
False, 0, 1, 128, 80, False, tr_AllChars));
Result:=Between(Start,Finish, Text);
end;{
function: GetLvlCommand(Command:string):String ;
By: Nght Spud
Description: Finds a users level by looking at the runescape
highscores}
function GetLvlCommand(Command:string):String ;
var a,b,c,text,Level,Name:string;
begin
Text:=Trim(GetTextAtEx(20, 415, 0, SmallChars, False,False, 0, 1, 128, 80, False, tr_AllChars))
Name:=(between(Command+' ',',',Text));
Level:=(Trim(between(',','?',text)))
a:=(GetPage('http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1='+Name) )
b:=(between(Level,'</tr>',a))
c:=((between('</td>'+Chr(10)+'<td align="right">','</td>',b)))
Result:=(between(c+'</td>'+Chr(10)+'<td align="right">','</td>',b))
end;{
function: CombatCalc(username:String):String;
By: Nght Spud
Description: Finds a users combat level by looking at the
runescape highscores}
function CombatCalc(username:String):String;
var A,B,C,Base,D,E,F,G,MeleeClass,RangeClass,MageClass,M,CMB:Extended;
Attack,Strength,Defence,Mage,Range,Prayer,Hitpoints,k:integer;
Page,t1,t2,t3:String ;
begin
Page:=(GetPage('http://hiscore.runescape.com/lang/en/aff/runescape/hiscorepersonal.ws?user1='+username) );
t1:=(between('Attack','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Attack:=(strtoint(t3)) else Attack:=1
t1:=(between('Strength','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Strength:=(strtoint(t3)) else Strength:=1
t1:=(between('Defence','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Defence:=(strtoint(t3)) else Defence:=1
t1:=(between('Magic','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Mage:=(strtoint(t3)) else Mage:=1
t1:=(between('Range','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Range:=(strtoint(t3)) else Range:=1
t1:=(between('Prayer','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Prayer:=(strtoint(t3)) else Prayer:=1
t1:=(between('Hitpoints','</tr>',Page)) ;
t2:=(between('</td>'+Chr(10)+'<td align="right">','</td>',t1))
t3:=(between(t2+'</td>'+Chr(10)+'<td align="right">','</td>',t1))
if (not(t3=''))then Hitpoints:=(strtoint(t3)) else Hitpoints:=10
A:= (Defence*100)
B:= (Hitpoints*100)
k:=Prayer+1;
if ((Prayer/2)+0.5=k/2)then C:=((Prayer-1)*50)else C:=Prayer*50;
Base:=((a+b+c)/400)
D:=Attack*130
E:=Strength*130
k:=Range+1;
if ((Range/2)+0.5=k/2)then F:=((Range*195)-65)else F:=Range*195;
k:=Mage+1;
if ((Mage/2)+0.5=k/2)then G:=((Mage*195)-65)else G:=Mage*195;
MeleeClass:=((D+E)/400)
RangeClass:=(F/400)
MageClass:=(G/400)
M:=MaxE(MeleeClass,RangeClass)
M:=MaxE(M,MageClass)
CMB:=M+Base
Result:=(floattostr(CMB))
end;