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