PDA

View Full Version : Online News to your script



marpis
04-22-2009, 07:57 PM
You have propably noticed that some scripts show news on startup, like this

DUCKHUNTERSCRIPT NEWS!
22/04/2009: Duckhunt released


Ofcourse you want to be as :norris: 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:

<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 and . They just tell where the lines start and where they end.
important: Make the tags (<line> signs) identical, expect the number.


<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:

<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:

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:


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:

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:

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! :)

impiwimpi
04-22-2009, 07:58 PM
A little version checker part?

Floor66
04-22-2009, 10:52 PM
The <line#> or whatever in .html is good, but maybe better to use XML? Then you can _really_ make custom tags :p

marpis
04-23-2009, 12:05 AM
ehh :D you can make how custom tags you want with html

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

Floor66
04-23-2009, 12:06 AM
Yeah but they aren't like real HTML tags ;P

marpis
04-23-2009, 01:04 AM
lol we arent using real html here :D no need to.
We create our own language!!! zomgz!! ok, no more dialogue here.

Floor66
04-23-2009, 01:09 AM
yaah! SCARTML! ^^

ShowerThoughts
04-23-2009, 01:19 AM
You're just reading the HTML file like a normal .txt file and look between the tags.
No, SCARTML :( sorry.

Floor66
04-23-2009, 01:20 AM
I know, but it sounds kwl ^^

Cazax
04-23-2009, 06:27 AM
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.

marpis
04-23-2009, 12:39 PM
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

?!

ian.
04-23-2009, 12:46 PM
It would have to be 'hello'+#13+'world' I believe.

marpis
04-23-2009, 07:36 PM
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

Da 0wner
04-23-2009, 08:06 PM
program New;
begin
writeln('Hello' #13 'World.');
end.

And to get news etc.


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...

marpis
04-23-2009, 08:38 PM
did you even try
writeln('hello'#13'world');
??

it still prints on one line.

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

Da 0wner
04-23-2009, 08:49 PM
What SCAR version are you using...mine works fine on 3.20 dude.

marpis
04-23-2009, 09:12 PM
doesnt work on 3.15 -> i don't recommend using it.

Da 0wner
04-23-2009, 09:31 PM
You should always use the latest version. 3.20 is stable. That may have been one of the bug fixes..

senrath
04-23-2009, 09:36 PM
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.

Da 0wner
04-23-2009, 09:39 PM
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.

marpis
04-24-2009, 10:33 PM
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.

Da 0wner
04-25-2009, 09:13 AM
Well that is something with your computer then marpis.