Results 1 to 22 of 22

Thread: Online News to your script

  1. #1
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Cool Online News to your script

    You have propably noticed that some scripts show news on startup, like this
    SCAR Code:
    DUCKHUNTERSCRIPT NEWS!
    22/04/2009: Duckhunt released

    Ofcourse you want to be as as those guys, and ima' tell you how.
    First you need a website host. Like geocities or some other place where you can upload an html page.

    Okay, i have a place where to upload my news, but how do i make the newspage? First, open notepad. Write there the following things:
    SCAR Code:
    <line1>MyNews</line1>
    <line2>22/04/2009: i made my first SCAR news!</line2>
    <line3> - marpis</line3>

    Now what the heck do the <line> and </line> signs mean? They dont actually mean anything. You could write there <rofl1> and </rofl1> as well, or [noob1] and [/noob1]. They just tell where the lines start and where they end.
    important: Make the tags (<line> signs) identical, expect the number.

    SCAR Code:
    <line1>MyNews</line1> //good
    <line1>MyNews</line 1> //bad

    You can add as many lines as you want. When you have made all the lines, put them all in one row like this:
    SCAR Code:
    <line1>MyNews</line1><line2>22/04/2009: i made my first SCAR news!</line2><line3> - marpis</line3>
    Save it as a .html
    (Save as -> news.html)

    Now your newstext is ready to be shown in your script's startup! Here's how to do that:
    SCAR Code:
    procedure PrintNews;
    var
      content: string;
      i: integer;
    begin
     Content:= GetPage('http://yourhost.com/news.html');
     for i:= 1 to 10 do
     if pos('<line'+inttostr(i)+'>', Content) > 0 then
      writeln(Between('<line'+inttostr(i)+'>', '</line'+inttostr(i)+'>', Content));
    end;

    Ehh, what does all that mean?
    1 : Content:= GetPage('http://yourhost.com/news.html');
    Here we copy the text from the URL (http://yourhost.com/news.html)
    to the variable: content.

    2 : if pos('<line'+inttostr(i)+'>', Content) > 0 then
    Here we check if the line number 'i' exists. Note that i gets numbers from 1
    to 10, so if you have more that 10 lines, increase the latter number in row
    7. if pos('rin', 'string') = 0, then word 'string' does not contain substring 'rin'

    3 : writeln(Between('<line'+inttostr(i)+'>', '</line'+inttostr(i)+'>', Content));
    okay, this might look very confusing. Lets tidy it a bit, and say that i = 3,
    which means that we are printing the text of line 3. then the line would show like this:

    SCAR Code:
    writeln(Between('<line'+inttostr(3)+'>', '</line'+inttostr(3)+'>', Content));
    // inttostr(3) -> add '3' to the string we are writing
    writeln(Between('<line3>', '</line3>', Content));
    // We set content:= GetPage('http://yourhost.com/news.html'); remember?
    // That means that we are printing everything that is between tags <line3>
    // and </line3> in our website.

    VERSION CHECKER TO SCRIPT (thanks to impiwimpi)
    its very easy. To your script add this somewhere outside functions/procedures and before main execution:
    SCAR Code:
    const
      version = 0.01;

    and edit your newspage (the one you uploaded to internet)
    Add there this:
    [/scar]<latestversion>0.02</latestversion>[/scar] (No spaces!)
    and update is whenever you release a new version of your script.
    Now lets edit your PrintNews procedure to look like this:
    SCAR Code:
    const
      version = 0.01; //this is written when the script is made

    procedure PrintNews;
    var
      content: string;
      i: integer;
      latestversion: extended;
    begin
     Content:= GetPage('http://yourhost.com/news.html');
     for i:= 1 to 10 do
     if pos('<line'+inttostr(i)+'>', Content) > 0 then
      writeln(Between('<line'+inttostr(i)+'>', '</line'+inttostr(i)+'>', Content));
     latestversion:= StrToFloat(Between('<latestversion>', '</latestversion'>, Content));
     if (version < latestversion) then
      writeln('SCRIPT IS OUTDATED! download the latest version at SRL-forums');
    end;


    If you wish to add something to the tutorial, please help me be helpful and post it here!
    Last edited by marpis; 04-23-2009 at 12:06 AM.

  2. #2
    Join Date
    Nov 2008
    Location
    Belgium
    Posts
    254
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    A little version checker part?

  3. #3
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    The <line#> or whatever in .html is good, but maybe better to use XML? Then you can _really_ make custom tags
    Ce ne sont que des gueux


  4. #4
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    ehh you can make how custom tags you want with html
    SCAR Code:
    writeln(Between('<[/{tHis taGG startzz a NEW and AWESOME line number '+inttostr(i)+', i mean!! }?/&',
    ')(&&da&/THIS FUKINTAG ends teeeh KEWL LINE NUMBER '+inttostr(i)+' MAAN!!?! ???()', Content));
    this works just fine when u write the same crap to your html page :P
    Last edited by marpis; 04-23-2009 at 12:07 AM.

  5. #5
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    Yeah but they aren't like real HTML tags ;P
    Ce ne sont que des gueux


  6. #6
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    lol we arent using real html here no need to.
    We create our own language!!! zomgz!! ok, no more dialogue here.

  7. #7
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    yaah! SCARTML! ^^
    Ce ne sont que des gueux


  8. #8
    Join Date
    Apr 2007
    Location
    The Netherlands
    Posts
    5,553
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You're just reading the HTML file like a normal .txt file and look between the tags.
    No, SCARTML sorry.
    ~Hermen

  9. #9
    Join Date
    Feb 2007
    Location
    Access Violation at 0x00000000
    Posts
    2,865
    Mentioned
    3 Post(s)
    Quoted
    18 Post(s)

    Default

    I know, but it sounds kwl ^^
    Ce ne sont que des gueux


  10. #10
    Join Date
    Nov 2007
    Location
    Chile
    Posts
    1,901
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Why doing the the tags thing(</>)? Just use GetPage to get the whole text. If you want Writeln to separate them in paragraphs then get the number of #13(Enter) in the text, so it would write X times of paragraphs. Maybe I didn't explain it crearly, but if you have any question just ask.


  11. #11
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Quote Originally Posted by Cazax View Post
    Why doing the the tags thing(</>)? Just use GetPage to get the whole text. If you want Writeln to separate them in paragraphs then get the number of #13(Enter) in the text, so it would write X times of paragraphs. Maybe I didn't explain it crearly, but if you have any question just ask.
    You mean like if i have a page which has text
    hello #13 world

    and do i like this
    writeln(GetPage('www.com/news.html'));

    it prints out
    hello
    world

    ?!

  12. #12
    Join Date
    Dec 2008
    Posts
    2,813
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    It would have to be 'hello'+#13+'world' I believe.

  13. #13
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    SCAR Code:
    program New;
    var
      YoString: string;
     
    begin
      YoString:= 'Hello'+#13+'world';
      writeln(YoString);
    end.

    This prints out just 'hello world' in one line. So it doesnt work

  14. #14
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    SCAR Code:
    program New;
    begin
      writeln('Hello' #13 'World.');
    end.

    And to get news etc.

    SCAR Code:
    program New;
    begin
      Writeln(Replace(GetPage('http://kyleis1337.info/testing.txt'), '#13', #13));
    end.

    You're making it a lot more complicated then it is...
    Last edited by Da 0wner; 04-23-2009 at 08:37 PM.

  15. #15
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    did you even try
    writeln('hello'#13'world');
    ??

    it still prints on one line.

    EDIT: DaOwner, your program doesnt work.
    SCAR Code:
    IOHandler value is not valid

  16. #16
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    What SCAR version are you using...mine works fine on 3.20 dude.

  17. #17
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    doesnt work on 3.15 -> i don't recommend using it.

  18. #18
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    You should always use the latest version. 3.20 is stable. That may have been one of the bug fixes..

  19. #19
    Join Date
    Oct 2006
    Location
    ithurtsithurtsithurtsithurts
    Posts
    2,930
    Mentioned
    7 Post(s)
    Quoted
    135 Post(s)

    Default

    Quote Originally Posted by Da 0wner View Post
    You should always use the latest version. 3.20 is stable. That may have been one of the bug fixes..
    Actually, switching to 3.20 is not recommended, as SRL doesn't support it.

  20. #20
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Yeah, but regardless, what I did still works and is not wrong. It may not work with 3.15(b) but it works with 3.20...and SRL will support it soon enough. It doesn't seem like a whole lot of changes.

    And marpis, just download 3.20 and test it and tell me what you get.

  21. #21
    Join Date
    Aug 2008
    Location
    Finland
    Posts
    2,851
    Mentioned
    3 Post(s)
    Quoted
    2 Post(s)

    Default

    Da Owner:
    Ofcourse i make a procedure that works with all versions, rather than one that works with only the latest version?

    I downloaded and 3.20 didnt work.
    You shouldn't always use the latest version, as long as everything works better with the older one.

  22. #22
    Join Date
    Jan 2008
    Location
    California, US
    Posts
    2,765
    Mentioned
    0 Post(s)
    Quoted
    0 Post(s)

    Default

    Well that is something with your computer then marpis.

Thread Information

Users Browsing this Thread

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

Posting Permissions

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