Results 1 to 5 of 5

Thread: All of my functions (7 so far)

  1. #1
    Join Date
    Jun 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default All of my functions (8 so far)

    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


    SCAR Code:
    {
    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
    SCAR Code:
    {
    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

    SCAR Code:
    {
    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;

    SCAR Code:
    {
    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;

    SCAR Code:
    {
    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;

    SCAR Code:
    {
    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;

    SCAR Code:
    {
    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;
    SCAR Code:
    {
    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;

  2. #2
    Join Date
    May 2007
    Location
    in a pineapple under the sea
    Posts
    1,040
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    nice info (h)
    [SIZE="4"][CENTER][URL="http://www.youtube.com/watch?v=5YsGJz3j4os"]LOL u mad bro?[/URL][/CENTER][/SIZE]

  3. #3
    Join Date
    Feb 2006
    Location
    London, England
    Posts
    2,045
    Mentioned
    2 Post(s)
    Quoted
    0 Post(s)

    Default

    PHP Code:
    Function IsEven(NumberInteger): Boolean;
    Begin
      Result 
    := (Number mod 2 0);
    end;

    Function 
    IsOdd(NumberInteger): Boolean;
    Begin
      Result 
    := (Number mod 2 <> 0);
    end
    Much simpler
    SRL Wiki | SRL Rules | SRL Stats
    Ultimate SCAR Scripting Tutorial | Starblaster100's Auth System | Join the official SRL IRC now!


    Help Keep SRL Alive! Please disable Advert Blockers on SRL! Help Keep SRL Alive!


  4. #4
    Join Date
    Jun 2006
    Posts
    31
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    Hmmm, ok thanks, I saw the mod thing in a few scripts, and wondered what it did, can someone explain what the 'mod' thing does?

  5. #5
    Join Date
    Jul 2007
    Location
    UK
    Posts
    307
    Mentioned
    0 Post(s)
    Quoted
    5 Post(s)

    Default

    It returns the remainder

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Functions
    By lordsaturn in forum OSR Help
    Replies: 1
    Last Post: 08-13-2007, 10:12 PM
  2. Help with some functions
    By Pinqvin in forum OSR Help
    Replies: 6
    Last Post: 03-06-2007, 01:34 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •