Need a little help with scores

Get help using Construct 2

Post » Sat Nov 12, 2011 12:12 am

Hi there guys!
I could really use some help, hope one of you has got a minute :)

(I'm a designer, but total non-programmer making a fun game for my personal website)

What I've been struggling to do for the past few hours is add up everyone's scores in a flatfile using PHP. I just can't get the hang of it.

I wanna make a scores file starting at 0, and everytime someone plays my game and gets, say, 3000 points, I want to add that to the number already in the file. Then retrieve the sum and show it in the game.

Something like "1000000 points have been scored until now".

I just can't get the hang of it. Arrrgh so frustrating I can't do a simple addition because I know absolutely no PHP. Pretty please help me?

Excuse my English. I'm from Russia .
B
1
G
1
Posts: 2
Reputation: 529

Post » Sat Nov 12, 2011 1:29 am

<?php

$file = "c:\users\user\scorefile.dat";
$score = $_GET['score'];
$total = file_get_contents($file);
$total += $score;
file_put_contents($file, $total);

?>
B
3
G
1
Posts: 3
Reputation: 508

Post » Sat Nov 12, 2011 1:30 am

have to call page from your game somehow like this

http://www.mysite.com/score.php?score=5000

but currently full of security holes e.g. anyone can post a score not just your game. May have to have game supply a secret key along with score
B
3
G
1
Posts: 3
Reputation: 508

Post » Sat Nov 12, 2011 1:36 am

Thank you so very very much! It's all right, i'm sure my visitors aren't so interested in cheating at my game :)
B
1
G
1
Posts: 2
Reputation: 529


Return to How do I....?

Who is online

Users browsing this forum: ETgirl79, Zebbi and 22 guests