I had this idea for a quick and simple online score board. I'm interested in any opinions about it. Maybe it's of use to someone. You need a website that you can ftp. The board downloads using http, and uploads with ftp.
The idea was to put everything on the client side, except a text file - meaning that the updating is done by the program, not online. There's no need for php or even html.
On my site, a text file uploads in less than a second and downloads almost instantly. That's fast enough for other things too, like an in game message board.
Nothing fancy here:
`simple message board
`uses a website to download and upload a text file
`uses mboard.txt to store high scores on a web site
`download by http, upload by ftp
set window size 640,480
sync on : sync rate 0
backdrop on
color backdrop rgb(0,0,0)
set text size 20
set text font "verdana"
`website information
link$ = "http://www.yoururl.com/mboard.txt"
server$="ftp.yourserver.com"
username$="yourusername"
password$="yourpassword"
`players information
player$ = "fred"
playerscore = 668
`dimension and load array
dim mb$(12,2)
dim score(12)
`**************************
`to start, use something like this to create mboard.txt and then upload it
remstart
mb$(1,1) = "23"
mb$(2,1) = "56"
mb$(3,1) = "67"
mb$(4,1) = "78"
mb$(5,1) = "34"
mb$(6,1) = "90"
mb$(7,1) = "123"
mb$(8,1) = "78"
mb$(9,1) = "54"
mb$(10,1) = "72"
mb$(11,1) = "114"
mb$(12,1) = "167"
mb$(1,2) = "bill"
mb$(2,2) = "harry"
mb$(3,2) = "dude"
mb$(4,2) = "up"
mb$(5,2) = "metwo"
mb$(6,2) = "sally"
mb$(7,2) = "arg"
mb$(8,2) = "homer"
mb$(9,2) = "sid"
mb$(10,2) = "mary"
mb$(11,2) = "ed"
mb$(12,2) = "whois"
save array "mboard.txt",mb$(12,2)
remend
`**********************************
`http download from the website, mboard.txt
`gosub down
download(link$,"mboard.txt")
load array "mboard.txt",mb$(12,2)
`check playerscore against score list and update
gosub check
`**************************loop
do
text 20, 0, err$
`draw the scoreboard
ink rgb(200,200,200),0
for t = 1 to 12
text 20,t*20,mb$(t,1)
text 100,t*20,mb$(t,2)
NEXT t
sync
LOOP
`score checking and updating
check:
`if connection failed return
if err$ = "failed to connect" then return
`check player score against scoreboard
for t = 1 to 12
score(t) = val(mb$(t,1))
if playerscore > score(t)
opt = 1
endif
next t
`if player score is among top 12 then update
if opt = 1
opt = 0
small = 12
for t = 1 to 11
if score(t) < score(t+1) and score(t)< score(small) then small = t
NEXT t
`replace the smallest with the player score
score(small) = playerscore
mb$(small,2) = player$
mb$(small,1) = str$(playerscore)
`upload mboard.txt via ftp
save array "mboard.txt",mb$(12,2)
ftp connect server$,username$,password$
if get ftp failure()= 0
if get ftp status() = 1
ftp put file "mboard.txt"
err$ = "connected"
else
err$ = "failed to connect"
endif
endif
ftp disconnect
endif
return
`http download function
function download(there$,here$)
if file exist(here$) then delete file here$
load dll "urlmon",1
load dll "wininet",2
failed_delete_cache = call dll(2,"DeleteUrlCacheEntryA", there$)
failed = call dll(1,"URLDownloadToFileA",0,there$,here$,0,0)
delete dll 2
delete dll 1
if failed = 0
if file exist("mboard.txt") = 1
load array "mboard.txt",mb$(24)
err$ = "connected"
else
err$ = "failed to connect"
endif
else
err$ = "failed to connect"
endif
endfunction err$